January 31, 2021

EBAZ4205 Bitcoin miner board - Building U-Boot

I want to study the U-Boot sources. I have learned in the past that a very effective way to do this is as follows: I am working from the u-boot-xlnx sources cloned from the Xilinx Github site. The first trick is picking a target board (i.e. a defconfig file in the configs directory) to use for the build. I want one that uses the Zynq-7000 chip, in particular the XC7Z010 that I have.

The first candidate that catches my eye is the "Miami Zynq Lite" from Topic systems. This board has 512M of DDR memory (twice what I have) and uses NOR flash (my board uses NAND). My board has ethernet and this one does not. By no means an ideal match, but the Zynq chip is correct.

Another candidate is "bitmain_antminer_s9_defconfig", this specifies

CONFIG_ARCH_ZYNQ=y
CONFIG_FPGA_ZYNQPL=y
CONFIG_NAND_ZYNQ=y
CONFIG_ZYNQ_GEM=y
CONFIG_ZYNQ_SERIAL=y
So here we have NAND and the ethernet, so this looks like a better match. The ethernet is gigabit (mine only has a 100 Mbit PHY) and can have up to 1G of ram.

I did some searching looking for source for the zedboard U-boot and curiously one recommendation is to build U-boot for the zc702. Note however that the current zedboard uses an AC7Z020-CLG484 chip, not the XC7Z010-CLG400 that I have. The Zybo and MicroZed use the ZC7Z010-1CLG400C chip and would be better choices. There is a config file that lists these, "xilinx_zynq_virt_defconfig"

CONFIG_OF_LIST="zynq-zc702 zynq-zc706 zynq-zc770-xm010 zynq-zc770-xm011 zynq-zc770-xm011-x16 zynq-zc770-xm012 zynq-zc770-xm013
  zynq-cc108 zynq-microzed zynq-minized zynq-picozed zynq-zed zynq-zturn zynq-zybo zynq-zybo-z7 zynq-dlc20-rev1.0"
This is an interesting scheme I have never seen before. It would seem that this allows a bunch of common boards that are differentiated by their device tree files.

The Microzed has my xc7Z010 chip along with a network (10/100/1000), 1G of DRAM, 128M of QSPI flash, and a $200 price tab.
The Zybo is another $200 board, this time from Digilent. The Zybo Z7-10 has my XC7Z010 chip, 1G of DRAM, gigabit ethernet, and 16M of QSPI flash.

None of these are a better match that the antminer S9, so I will build U-Boot for that.

Let's do the build!

We need to set the CROSS_COMPILE variable.
I just hack this line into the Makefile near the top:
# tjt -- added 1-31-2021
CROSS_COMPILE = arm-none-eabi-
make bitmain_antminer_s9_defconfig
make V=1 >build.log
The build blows up with:
/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc';
  scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:106: scripts/dtc/dtc] Error 1
make[1]: *** [scripts/Makefile.build:432: scripts/dtc] Error 2
make: *** [Makefile:555: scripts] Error 2
This is some kind of problem in script/dtc that perhaps I can sidestep for my purposes right now.
I go into scripts and comment out this line in the Makefile:
# tjt comments this out for now.
#subdir-$(CONFIG_DTC)   += dtc
And we try again and get this error:
In file included from tools/aisimage.c:9:
include/image.h:1101:12: fatal error: openssl/evp.h: No such file or directory
 1101 | #  include 
      |            ^~~~~~~~~~~~~~~
compilation terminated.
This looks like a missing dependency. I would need the libssl-dev package on some systems. I try openssl-devel on Fedora. Indeed, dnf install openssl-devel does the trick. Now it is busy for a while and ends with:
/bin/sh: ./scripts/dtc/dtc: No such file or directory
make[2]: *** [scripts/Makefile.lib:312: arch/arm/dts/bitmain-antminer-s9.dtb] Error 127
make[1]: *** [dts/Makefile:38: arch-dtbs] Error 2
make: *** [Makefile:1091: dts/dt.dtb] Error 2
This is no doubt due to my commenting out the dtc business when I encountered the first error. However, when I look in the source tree, I see what I want, namely object files scattered around here and there. In particular, in the "drivers/fpga" directory, I find:
cd drivers/fpga
ls -l *.o
-rw-rw-r-- 1 tom tom 75612 Jan 31 14:52 built-in.o
-rw-rw-r-- 1 tom tom 23616 Jan 31 14:52 fpga.o
-rw-rw-r-- 1 tom tom 21524 Jan 31 14:52 xilinx.o
-rw-rw-r-- 1 tom tom 34156 Jan 31 14:52 zynqpl.o
Which means I can restrict my attention to 3 files rather than puzzling over which of the 19 C source files in that directory are relevant. A mere 1000 lines of source code.

But what about this yyloc multiple definition error?

Based on a tip in a search, I add extern to line 1348 in dtc-parser.tab.c
 extern YYLTYPE yyloc;

This does not fix it, I now get even more errors:

/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc';
  scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
/usr/bin/ld: scripts/dtc/dtc-parser.tab.o: in function `yyparse':
dtc-parser.tab.c:(.text+0x5e3): undefined reference to `yyloc'
/usr/bin/ld: dtc-parser.tab.c:(.text+0x616): undefined reference to `yyloc'
/usr/bin/ld: dtc-parser.tab.c:(.text+0x61d): undefined reference to `yyloc'
/usr/bin/ld: dtc-parser.tab.c:(.text+0x625): undefined reference to `yyloc'
/usr/bin/ld: dtc-parser.tab.c:(.text+0x62c): undefined reference to `yyloc'
/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:dtc-parser.tab.c:(.text+0x6be): more undefined references to `yyloc' follow
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:106: scripts/dtc/dtc] Error 1
make[1]: *** [scripts/Makefile.build:432: scripts/dtc] Error 2
This has something to do with a gcc setting -fno-common. The old setting used to allow multiple declarations of a common variable and viewed them as the same thing. Apparently the latest U-boot sources are fixed:
if the code you're referring to is U-Boot a fix went upstream and is in 2020.04

This isn't worth my time to sort out at this point ...


Feedback? Questions? Drop me a line!

Tom's Computer Info / [email protected]