sifive / freedom

Source files for SiFive's Freedom platforms
Apache License 2.0
1.11k stars 286 forks source link

mcs failes to build (target romgen) #172

Closed AntonHermann closed 3 years ago

AntonHermann commented 3 years ago

Hey :) I can't get the .mcs file to build, in particular the make target romgen failes with this error:

make -C /home/anton/uni/bachelor/repos/freedom/bootrom/xip romgen
make[1]: Entering directory '/home/anton/uni/bachelor/repos/freedom/bootrom/xip'
dtc -I dts -O dtb -o /home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitConfig.dtb /home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitConfig.dts
/bin/riscv64-unknown-elf-gcc -march=rv32imac -mabi=ilp32 -O2 -std=gnu11 -Wall -I. -nostartfiles -fno-common -g -DXIP_TARGET_ADDR=0x20400000 -DDEVICE_TREE='"/home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitConfig.dtb"' -static -nostdlib -o /home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/xip.elf xip.S
/bin/riscv64-unknown-elf-objcopy -O binary /home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/xip.elf /home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/xip.bin
od -t x4 -An -w4 -v /home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/xip.bin > /home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/xip.hex
/home/anton/uni/bachelor/repos/freedom/rocket-chip/scripts/vlsi_rom_gen /home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitConfig.rom.conf /home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/xip.hex > /home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/rom.v
Traceback (most recent call last):
  File "/home/anton/uni/bachelor/repos/freedom/rocket-chip/scripts/vlsi_rom_gen", line 90, in iterate_by_n
    batch += (next(it),)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/anton/uni/bachelor/repos/freedom/rocket-chip/scripts/vlsi_rom_gen", line 138, in <module>
    main()
  File "/home/anton/uni/bachelor/repos/freedom/rocket-chip/scripts/vlsi_rom_gen", line 134, in main
    **parse_line(line))
  File "/home/anton/uni/bachelor/repos/freedom/rocket-chip/scripts/vlsi_rom_gen", line 113, in parse_line
    kwargs = {key: try_cast_int(val)
  File "/home/anton/uni/bachelor/repos/freedom/rocket-chip/scripts/vlsi_rom_gen", line 113, in <dictcomp>
    kwargs = {key: try_cast_int(val)
RuntimeError: generator raised StopIteration
make[1]: *** [Makefile:38: /home/anton/uni/bachelor/repos/freedom/builds/e300artydevkit/rom.v] Error 1

My tool versions:

Python 3.9.1
DTC 1.6.0
Vivado v2020.2 (64-bit)
openjdk 11.0.10 2021-01-19
  OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
  OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)
riscv64-unknown-elf-gcc (Arch User Repository) 9.2.0

I'll continue digging around in rocket-chip and try to understand what happens there.

Thanks in advance,\ Anton

AntonHermann commented 3 years ago

For some reason, the iterate_by_n-function in _rocket-chip/scripts/vlsi_romgen raised an error where it should have returned:

diff --git a/scripts/vlsi_rom_gen b/scripts/vlsi_rom_gen
index 3e97070db..c0185d1d2 100755
--- a/scripts/vlsi_rom_gen
+++ b/scripts/vlsi_rom_gen
@@ -94,7 +94,7 @@ def iterate_by_n(it, n):
                         'Iterable length not evenly divisible by {}'.format(n)
                     )
                 else:
-                    raise
+                    return
         yield batch

With this change, the romgen target builds as expected.

I'm honestly wondering what went wrong with my build, I can't be the first one to have such a trivial problem :confused: