August 30, 2018

Nanopi Fire3 -- The linux U-Boot setup

I spent a lot of time trying to figure this out and have decided that it simply isn't worth my while and that my time is better spent elsewhere. And it is easy to get U-Boot started without all of what I describe here.

I can replicate the Linux U-Boot setup as follows:

	dd if=bl1-mmcboot.bin of=/dev/sdf bs=512 seek=1 conv=fdatasync
        dd if=fip-loader.img  of=/dev/sdf bs=512 seek=129 conv=fdatasync
        dd if=fip-secure.img  of=/dev/sdf bs=512 seek=769 conv=fdatasync
        dd if=fip-nonsecure.img of=/dev/sdf bs=512 seek=3841 conv=fdatasync
fip-nonsecure is the U-boot image, wrapped up as a FIP gizmo. There is no telling for sure what fip-loader and fip-secure are. These things (fip-loader and fip-secure) are pretty big:
-rw-rw-r-- 1 tom  tom       21552 Aug 10 14:08 bl1-mmcboot.bin
-rw-rw-r-- 1 tom  tom      279040 Aug 10 14:08 fip-loader.img
-rw-rw-r-- 1 tom  tom      257136 Aug 10 14:08 fip-secure.img
-rw-rw-r-- 1 tom  tom      501648 Aug 26 22:14 fip-nonsecure.img
A look at the linux SD card shows:
[tom@trona ~]$ fdisk /dev/sdf
Disk /dev/sdf: 7.4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sdf1         8192   139263   131072   64M 83 Linux
/dev/sdf2       139264 15523839 153845
So there is an area of 8192 blocks (64M) left that all of this rubbish can get crammed into. U-Boot is something over 1000 blocks, and it gets deposited after 3841 blocks, so all of that uses 4841 blocks (round it up to 5000), leaving something like 3000 for elbow room (the U-Boot env variables get dumped there someplace).

The U-Boot environment

This starts at block 5889 and is 16 blocks in size. See include/configs/s5p6818_nanopi3.h where the relevant CONFIG variables are defined.

Fetch it via:

dd if=/dev/sdf of=zzz skip=5889 count=16

Lessons Learned

It is not clear what all this complexity buys us, me, or anyone. I do not have sources or explanation of what all of this is or does. I am happy to use this as a black box to get linux running. For my own use, I want to run U-Boot and have it tftpboot my own binaries, and I don't need all of this to do that.


Have any comments? Questions? Drop me a line!

Tom's electronics pages / [email protected]