I found the solution after some time.
Orange pi 5B and other boards based on some Rockchip CPU have a booting issue.
When the eMMC is flashed with ubuntu (or other OS such as armbian as I believe), then if a blank SD is inserted, the board will not boot.
Investigation of the problem through serial debug cable show that the bootloader select SD as the first boot device,
and try to boot from it. Since there is no valid image, the system will panic and just halt. On x86 systems, the bootloader will
fallback to the next boot device.
The problem is related to the module "config_distro_bootcmd.h" in the u-boot section which contains boot steps.
The system tries to boot from the SD without checking whether it has a valid imag or not.
A quick and solid solution is to patch this moudle and rebuilt the u-boot. The following steps are used to solve the problem:
1. On the development Linux PC, such as virtual machine, with updated ubuntu, create a directory on the home/user folder
- mkdir $HOME/orangepi
- cd orangepi
- git clone https://github.com/orangepi-xunlong/orangepi-build.git -b next
- cd orangepi-build
2. Run build script to install the required files:
then select u-boot only and select board type (ornage pi 5B in my case)
Note: build.sh will install the required cross compile toolchain and source files when it runs first time.
3. To enable code editing without comparing with the git, edit the following file :
sudo nano userpatches/config-default.conf
set:
4. Edit the following file using gedit or any other editor with root permission
$HOME/orangepi/orangepi-build/u-boot/v2017.09-rk3588/include/config_distro_bootcmd.h
Change line 81 from: "if mmc dev 0; then " \
to: "if mmc dev 0 && rkimgtest mmc 0; then " \
This will force the bootloader to check if there exist a valid image on the SD or not.
I know this solution may be insuitable for other brands, but, of course, it can be applied for all Rockchip boards.
Developers of other boards may implement their checking moudle.
5. repeat building process:
- sudo ./build.sh BOARD=orangepi5b BRANCH=legacy BUILD_OPT=u-boot KERNEL_CONFIGURE=no
6. Copy the generated deb package from output directory: orangepi-build/output/debs/u-boot to the home directory of the target board.
7. Install generated linux-u-boot-legacy-orangepi5b_1.0.8_arm64.deb package to the target board
Important: Remove the SD from the board,
power cycle ornage pi 5B and login using terminal emulator, then issue:
- sudo apt purge -y linux-u-boot-orangepi5b-legacy
- sudo dpkg -i linux-u-boot-legacy-orangepi5b_1.0.8_arm64.deb
- sudo nand-sata-install
When asked select : 5 Install/Update the bootloader on SD/eMMC
it will update the u-boot section on the eMMC.
Note: orange pi 5B has no SPI flash. u-boot is stored in eMMC or SD.