August 8, 2018

The Nanopi Fire3 - Reconfiguring U-Boot

For the record, this exercise failed -- because the U-Boot I have on the SD card booting linux was built without networking. What I had hoped to do here is to change a few environment variables in the way I have done in the past for OrangePi boards and get U-Boot to tftpboot my test code. But this is going to require more work. At the very least rebuilding U-Boot.

To do the bare metal stuff I want to do (and eventually do a diskless boot of my Kyu operating system) I need to fiddle with U-Boot. I have an SD card that is booting linux, so with a serial console hooked up, it is a simple matter (if you are quick) to type anything on the keyboard and have U-Boot drop to a command line. Interestingly the U-Boot prompt is "nanopi3#". U-Boot fiddling is all about changing environment variables, which are like so:

baudrate=115200
board_rev=05
bootargs=console=ttySAC0,115200n8 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait init=/sbin/init loglevel=7 printk.time=1 consoleblank=0 lcd=HDMI720P60 bootdev=2
bootcmd=run mmcboot
bootdelay=1
bootpart=1
dtb_addr=0x49000000
dtb_name=s5p6818-nanopi3-rev05.dtb
dtb_reserve=if test -n "$dtb_addr"; then fdt addr $dtb_addr; fi
ethaddr=d2:a5:61:c9:2e:e4
fb_addr=0x46000000
fdt_high=0xffffffffffffffff
fdtcontroladdr=7daa2df0
firstboot=0
initrd_addr=0x48000000
initrd_high=0xffffffffffffffff
initrd_name=ramdisk.img
initrd_size=0x600000
kernel=Image
load_dtb=ext4load mmc ${rootdev}:${bootpart} ${dtb_addr} ${dtb_name}; run dtb_reserve
load_initrd=ext4load mmc ${rootdev}:${bootpart} ${initrd_addr} ${initrd_name}; setenv initrd_size 0x${filesize}
load_kernel=ext4load mmc ${rootdev}:${bootpart} ${loadaddr} ${kernel}
loadaddr=0x40080000
mmcboot=run load_kernel; run load_initrd; run load_dtb; booti ${loadaddr} ${initrd_addr}:${initrd_size} ${dtb_addr}
rootdev=1
rootpart=2
splashfile=logo.bmp
splashimage=0x47000000
splashpos=m,m

Environment size: 1113/16380 bytes
Page 15-5 on the user manual shows that DDR ram lives in a 2G region starting at 0x40000000 (of course we only have 1G), so ram is at 0x40000000 - 0x7fffffff. So something like this ought to do (exactly the same as for the Orange Pi):
setenv bootaddr 0x40000000
setenv boot_kyu "echo Booting Kyu via dhcp ; dhcp ${bootaddr}; go ${bootaddr}"
setenv bootcmd "run boot_kyu"
saveenv
Doing this and then typing reset gives me the following error. It looks like this U-boot was built without the dhcp command, which is unfortunate. I type on the keyboard to get to the U-Boot prompt, and type help as advised. It looks like there are no network related commands at all. Maybe nobody even wrote a network driver for U-Boot for this chip. That would create a lot of work for me.
Unknown command 'dhcp' - try 'help'

nanopi3# help
?       - alias for 'help'
base    - print or set address offset
bdinfo  - print Board Info structure
bmp     - manipulate BMP image data
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootelf - Boot from an ELF image in memory
booti   - boot arm64 Linux Image image from memory
bootm   - boot application image from memory
bootvx  - Boot vxWorks from an ELF image
clrlogo - fill the boot logo area with black
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
dm      - Driver model low level access
echo    - echo args to console
editenv - edit environment variable
env     - environment handling commands
exit    - exit script
ext4_img_write- Compressed ext4 image write.

ext4load- load binary file from a Ext4 filesystem
ext4ls  - list files in a directory (default /)
ext4size- determine a file's size
ext4write- create a file in the root directory
false   - do nothing, unsuccessfully
fastboot- use USB Fastboot protocol
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fatsize - determine a file's size
fatwrite- write file into a dos filesystem
fdisk   - mmc list or create ms-dos partition tables (MAX TABLE 7)
fdt     - flattened device tree utility commands
go      - start application at address 'addr'
gpio    - query and control gpio pins
gpt     - GUID Partition Table
help    - print command description/usage
i2c     - I2C sub-system
iminfo  - print header information for application image
imxtract- extract a part of a multi-image
itest   - return true/false on integer compare
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loadx   - load binary file over serial line (xmodem mode)
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
md      - memory display
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mtest   - simple RAM read/write test
mw      - memory write (fill)
nm      - memory modify (constant address)
pmic    -  operations
printenv- print environment variables
regulator- uclass operations
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
saveenv - save environment variables to persistent storage
sd_recovery- Image Update from SD Card

setenv  - set environment variables
showvar - print local hushshell variables
sleep   - delay execution for some time
source  - run script from memory
test    - minimal test like /bin/sh
true    - do nothing, successfully
udown   - Download USB
usb     - USB sub-system
usbboot - boot from USB device
version - print monitor, compiler and linker version

nanopi3# version

U-Boot 2016.01-00025-gb5566ab172 (May 09 2018 - 13:52:47 +0800)
aarch64-linux-gcc (ctng-1.23.0-150g-FA) 6.4.0
GNU ld (ctng-1.23.0-150g-FA) 2.28


Have any comments? Questions? Drop me a line!

Tom's electronics pages / tom@mmto.org