January 21, 2025

Antminer S9 board - U-boot - plan B environment variables

I experiment and try "saveenv", and get:
antminer> saveenv
Saving Environment to NAND... Failed (1)
This is not what we want, but why did it fail? This is on my board "A" and I get no response when I try to get it to boot from NAND, so there may be a NAND issue. Another board that is "bricked" (i.e. my board "C") will print several lines from the Xilinx FSBL then get into trouble trying to launch U-boot.

A look at the defconfig file shows:

CONFIG_ENV_IS_IN_NAND=y
I look at some other boards. On the "boneblack", I see the following, but I am pretty sure they mean the on-board emmc.
CONFIG_ENV_IS_IN_MMC=y
Another board is configured like so:
CONFIG_SPL_FS_FAT=y
CONFIG_CMD_FAT=y
CONFIG_ENV_SIZE=0x20000
CONFIG_CMD_ASKENV=y
CONFIG_ENV_IS_IN_FAT=y
CONFIG_ENV_FAT_INTERFACE="mmc"
CONFIG_ENV_FAT_DEVICE_AND_PART="1:1"
The file may be uboot.env. I do this:
## CONFIG_ENV_IS_IN_NAND=y -- comment out
CONFIG_SPL_FS_FAT=y		-- ok
CONFIG_CMD_FAT=y		-- ok
CONFIG_ENV_SIZE=0x20000 -- ok (the default)
CONFIG_CMD_ASKENV=y		-- make it so
CONFIG_ENV_IS_IN_FAT=y	-- make it so
CONFIG_ENV_FAT_INTERFACE="mmc"
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
I see the following which guides my settings above.
antminer> mmc part
Partition Map for MMC device 0  --   Partition Type: DOS
Part	Start Sector	Num Sectors	UUID		Type
  1	2048      	655360    	5ffdd01d-01	0b
I make these changes in .config, then "make clean ; make It asks me questions!! It wants me to verify the mmc and 0:1 then asks for the name of the FAT file as follows. Presumably hitting return accepts the name "uboot.env".
Environment in a NAND device (ENV_IS_IN_NAND) [N/y/?] (NEW) n
Name of the block device for the environment (ENV_FAT_INTERFACE) [mmc] mmc
Device and partition for where to store the environemt in FAT (ENV_FAT_DEVICE_AND_PART) [0:1] 0:1
Name of the FAT file to use for the environment (ENV_FAT_FILE) [uboot.env] (NEW)

It does not work. I put the SD card in, hit reset, cycle power. I get no output on the serial port. Who would have thought the build would be this fragile? Of course I really should be modifying a custom defconfig file, not hacking away at .config.

Every time I do a build, the contents of "spl" get nuked. Clearly it deletes this entire directory every time and regenerates it when I do a build. Probably the makeclean does it. This means if I want to add my own scripts or Makefiles, I should do it in the source root, not in spl.

So I will start over totally from distclean, and then slowly make some changes. What I am going to do is to copy bitmain_antminer_s9_defconfig to zztom_antminer_s9_defconfig and work from there.

make clean
make distclean
make zztom_antminer_s9_defconfig
make
This works, and I am now starting a practice of saving images in the directory /u1/Projects/Zynq/U-boot/images along with notes as to what they are.
Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org