In the previous post, we saw how to compile u-boot image from the mainline source, for our Orange Pi Zero 2 development board. If we want to boot u-boot on the board, one obvious way is to prepare a minimal SD card where the u-boot image goes. However, this approach does not scale well, because every time you re-compile u-boot, you need to plug out the SD card from the board, insert into the host machine, copy the new u-boot image and plug the SD card back to the development board. This takes a lot of time, and more than that, there are chances of damaging the board due to repeated SD card insertions/removals.
In this post, we are going to learn about a new boot method supported by almost all AllWinner SOCs called FEL boot mode, or USB boot mode. In this mode, the Orange Pi Zero 2 development board presents itself as a USB OTG device on the development machine. Once the device is in USB mode, you can point it to boot the u-boot image (or any binary, in fact), from the development host machine directly.
Step 1 : Plug Orange Pi Zero 2 as a USB OTG device
The first step is to get the Orange Pi Zero 2 board detected as a USB OTG device on the host development machine. There are various ways to get this done and you can read about them here. However, the easiest way is by having no valid bootable image. If the ROM code does not find a valid bootable image, it falls back to the FEL mode.
This means if you have got a brand new Orange Pi board (that basically has empty SPI flash), just remove any SD card or a USB device, and plug this using a type C USB cable to the host development machine. Even remove the debug serial cable, because there is a known issue on some of these Allwinner boards, where the current leaks from the UART, powering the board.
If all goes well, you should be able to see the board as a USB OTG device.
naveen@workstation:~$ lsusb
Bus 004 Device 005: ID 8564:4100 Transcend Information, Inc. USB3.0 Hub
Bus 004 Device 002: ID 8564:4000 Transcend Information, Inc. microSD/SD/CF UHS-II Card Reader [RDF8, RDF9]
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 006: ID 1f3a:efe8 Allwinner Technology sunxi SoC OTG connector in FEL/flashing mode
Bus 003 Device 004: ID 046d:c52f Logitech, Inc. Unifying Receiver
Bus 003 Device 003: ID 8564:4100 Transcend Information, Inc. USB2.0 Hub
Bus 003 Device 002: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 8087:0a2a Intel Corp. Bluetooth wireless interface
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
naveen@workstation:~$
Step 2 : Get the tools
Once the board is detected as a USB OTG device, you can plug your serial debug cable as well. Now, you would need a tool called sunxi-fel
to load the images onto the board. You can get this tool compiled easily from the sunxi-tools GitHub repo.
naveen@workstation:~/orangepi$ git clone https://github.com/linux-sunxi/sunxi-tools.git
Cloning into 'sunxi-tools'...
remote: Enumerating objects: 2268, done.
remote: Counting objects: 100% (227/227), done.
remote: Compressing objects: 100% (110/110), done.
remote: Total 2268 (delta 118), reused 158 (delta 114), pack-reused 2041
Receiving objects: 100% (2268/2268), 844.26 KiB | 711.00 KiB/s, done.
Resolving deltas: 100% (1368/1368), done.
naveen@workstation:~/orangepi$
Install the dependencies and build the tools.
naveen@workstation:~/orangepi$cd sunxi-tools
naveen@workstation:~/orangepi/sunxi-tools$ sudo apt install libusb-1.0-0-dev libz-dev libfdt-dev -y
naveen@workstation:~/orangepi/sunxi-tools$ make tools -j24
cc -std=c99 -Wall -Wextra -Wno-unused-result -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE -D_DEFAULT_SOURCE -Iinclude/ `pkg-config --cflags libusb-1.0` `pkg-config --cflags zlib` -o sunxi-fel \
fel.c fit_image.c progress.c soc_info.c fel_lib.c fel-spiflash.c `pkg-config --libs libusb-1.0` `pkg-config --libs zlib` -lfdt
naveen@workstation:~/orangepi/sunxi-tools$
Checking the sunxi-fel
tool. The below output is seen only if the development board is detected successfully as a USB OTG device.
naveen@workstation:~/orangepi/sunxi-tools$ sudo ./sunxi-fel ver
[sudo] password for naveen:
AWUSBFEX soc=00001823(H616) 00000001 ver=0001 44 08 scratchpad=00007e00 00000000 00000000
naveen@workstation:~/orangepi/sunxi-tools$
Step 3 : Boot the u-boot image
Use the sunxi-fel
tool to load the u-boot image.
naveen@workstation:~/orangepi/sunxi-tools$ sudo ./sunxi-fel uboot ~/.repos/src/arm64/u-boot/u-boot-sunxi-with-spl.bin
naveen@workstation:~/orangepi/sunxi-tools$
In a different terminal window, that is connected to the debug serial cable via minicom.
naveen@workstation:~/orangepi/sunxi-tools$ sudo minicom
[sudo] password for naveen:
Welcome to minicom 2.8
OPTIONS: I18n
Port /dev/ttyUSB0, 12:53:19
Press CTRL-A Z for help on special keys
U-Boot SPL 2023.10-rc4-00039-g252592214f (Sep 19 2023 - 17:56:00 +0530)
DRAM: 1024 MiB
Trying to boot from FEL
NOTICE: BL31: v2.9(debug):v2.9.0-726-gcc933e1d1
NOTICE: BL31: Built : 17:47:45, Sep 19 2023
NOTICE: BL31: Detected Allwinner H616 SoC (1823)
NOTICE: BL31: Found U-Boot DTB at 0x4a0b2c30, model: OrangePi Zero2
INFO: ARM GICv2 driver initialized
INFO: Configuring SPC Controller
INFO: PMIC: Probing AXP305 on RSB
INFO: PMIC: aldo1 voltage: 3.300V
INFO: PMIC: aldo2 voltage: 3.300V
INFO: PMIC: aldo3 voltage: 3.300V
INFO: PMIC: bldo1 voltage: 1.800V
INFO: PMIC: dcdcd voltage: 1.500V
INFO: PMIC: dcdce voltage: 3.300V
INFO: BL31: Platform setup done
INFO: BL31: Initializing runtime services
INFO: BL31: cortex_a53: CPU workaround for erratum 855873 was applied
INFO: BL31: cortex_a53: CPU workaround for erratum 1530924 was applied
INFO: PSCI: Suspend is unavailable
INFO: BL31: Preparing for EL3 exit to normal world
INFO: Entry point address = 0x4a000000
INFO: SPSR = 0x3c9
INFO: Changed devicetree.
U-Boot 2023.10-rc4-00039-g252592214f (Sep 19 2023 - 17:56:00 +0530) Allwinner Ty
CPU: Allwinner H616 (SUN50I)
Model: OrangePi Zero2
DRAM: 1 GiB
Core: 52 devices, 21 uclasses, devicetree: separate
WDT: Not starting watchdog@30090a0
MMC: mmc@4020000: 0
Loading Environment from FAT... MMC: no card present
** Bad device specification mmc 0 **
In: serial@5000000
Out: serial@5000000
Err: serial@5000000
Allwinner mUSB OTG (Peripheral)
Net: eth0: ethernet@5020000using musb-hdrc, OUT ep1out IN ep1in STATUS ep2in
MAC de:ad:be:ef:00:01
HOST MAC de:ad:be:ef:00:00
RNDIS ready
, eth1: usb_ether
starting USB...
Bus usb@5200000: USB EHCI 1.00
Bus usb@5200400: USB OHCI 1.0
scanning bus usb@5200000 for devices... 1 USB Device(s) found
scanning bus usb@5200400 for devices... 1 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot: 0
=>
References
Categories: bootloaders , operating-system Tags: #u-boot , #arm , #operating-system , #boot , #linux , #microprocessors