June 25, 2024

Zynq - SD card booting, bootgen, BOOT.BIN

I had a sudden insight into all of this while cooking breakfast this morning.

Up to this point, it had seemed to me that booting from SD cards was a unique and special case. The card has a FAT filesystem on the first partition. There must be a file named BOOT.BIN in that partition. All this seemed like a world unto itself.

What I realized was that BOOT.BIN holds exactly the structure I have worked out for the NAND device. This means that the code in the FSBL can look for all of the same pointers and datastructrues, they are just contained within that file. It is the job of the SD card driver to hide this and unify things so that the FSBL neither knows nor cares.

I have no idea why Xilinx decided to do things in this way. It ought to have been possible to have just written the blocks on the SD card in the same way as it would be done for NAND or qSPI devices. Having the FAT filsystem as a layer between the hardware and the boot loader seems like a lot of needless code if nothing else. But it is what it is and it certainly works.

Bootgen

This is a rather immense piece of software written in C++. By my count it is 73,000 lines of code at least. I have yet to look at it, but it is what sets up all these datastructures I have been figuring out. There is a big and comprehensive manual about it -- as per the usual superb Xilinx documentation practices. As much as I dislike C++, I am sure it would be worth my time to take a look at all of this. The output from running it is BOOT.BIN. Based on the discussion just above, this could be placed as a file in a FAT partition on an SD card, or it could be written directly on hardware via something like "dd if=BOOT.BIN of=/dev/nand".
Feedback? Questions? Drop me a line!

Tom's Computer Info / [email protected]