September 14, 2018

The Nanopi Fire3 - the bl1 boot loader

You could toss U-Boot out the window and just use this, especially if you don't intend to run linux. The big advantage of U-Boot that I worked so hard to leverage is network booting.

Friendly ARM provides a binary bl1 loader, but no source code or documentation and although it works in their complex scheme to boot linux, I never was able to make use of it, so out the window it goes. I found a version of bl1 for the NanoPi M3 with full source code. I cloned it from the git repository and typed "make" and it built without errors. I have used it ever since.

This "bl1" loader essentially replaces the U-Boot "SPL" that is used on some systems. When the Fire3 starts up, reset runs boot code in rom inside the S5P6818. This code will boot from MMC (i.e. an SD card) if it finds one it likes. Failing that it will try to boot from USB. In general, I put bl1 onto an SD card so the on chip loader will find it. I have found it useful to USB load versions of bl1 when making and testing modifications.

You may be asking, "why not just use the on-chip loader". The reason why is that the on-chip loader does not know anything about off chip SDRAM. If you are willing to work only with the 64K of on-chip SRAM, the on chip loader is indeed all you need. The bl1 loader initializes off chip SDRAM while running in the on chip SRAM.

The bl1 loader itself has a 512 byte header with an NSIH signature. A word in this header tells bl1 whether to boot from USB or from SD card. I have built and used both versions. These days I use the SD card version along with U-Boot also on the SD card. When I was experimenting with U-Boot, I found the USB version much more convenient that yanking SD cards in and out of sockets.

Using bl1 in USB mode is almost as nice as network booting. You do have to build your software, then hit the reset button, then run a command to download your new code. I suppose if you combined the build and download, you could reduce this to two steps. Reset the board, then have a command to rebuild and download the new code in one step.

But I prefer having U-boot to do a network boot. With this, I rebuild software (which also deposits the binary into the tftpboot directory), then hit the reset button and I am running the new code. In this scenario, bl1 is an invisible "middle man".


Have any comments? Questions? Drop me a line!

Tom's electronics pages / tom@mmto.org