January 18, 2025

Antminer S9 board - SD card FSBL style booting "bare metal"

The ultimate goal in all this is to be able to build U-boot from source, put it onto an SD card, and boot it up. Why is that not simple and obvious?

Having tried what I thought would be simple ways to do this, and having none of them work, I have decided to start from scratch and build all the tools to do this. First I need the simplest possible executable, and I decide on something that will send endless messages via the uart. This will require doing all necessary initialization since the bootrom won't hand me an initialized uart. Next I will need a tool to write a bootable image onto the SD card.

It turns out that SD card booting is quite different from NAND booting. A FAT filesystem is expected on the SD card, and it must contain the file BOOT.BIN. This file must contain a Zynq bootrom header right at the start, followed by the image to be booted.

I wrote much of the code to generate the bootrom header in Python when I was working up a tool to send images to the "secret" uart boot mode. This means that I can use that as a starting point, along with information in the TRM to write the C program I need. Yes, I could make simple modifications to the Python program and use it, but for whatever reason I am going to go the route of writing the C program.

But I do press the "secret" boot program into use to test my minimal executable. It turns out this is time well spent as I do uncover one error. This ultimately works, so I turn my attention to finishing up the C program and generating BOOT.BIN. I finish that, find an SD card that already has a FAT filesystem on it, copy BOOT.BIN onto that and give it a try. It doesn't work. Nothing happens. Now what?

Time for JTAG

I dig out my Segger clone and discover the cable is damaged. So the chore is to remake the cable in a more robust form. It turned out that I didn't need JTAG at all to sort this out. I had a stupid mistake in my utility that builds the BOOT.BIN image. Once I fixed that, it booted and ran my code just fine, which was sort of a surprise.
Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org