sifive / freedom-u540-c000-bootloader

Freedom U540-C000 Bootloader Code
Other
85 stars 38 forks source link

Bootrom challenge #7

Open scintill opened 6 years ago

scintill commented 6 years ago

Using this toolchain: https://github.com/riscv/riscv-gnu-toolchain/commit/c7fb15341e615e1a1e2fca094ad149bfb7ece16b

SHA256 f9353bab5e826e937783c9ace7411375af9733c454d3d5f9f365509f2f7a4cdb. make bootrom.bin verifies the shasum.


The toolchain given by @tmagik does seem to be close. The relaxation and general compilation is good, but there are a few differences in optimization and codegen. My goal was to make a few small patches that are easy to audit. I've almost succeeded with C tweaks and patching asm, but unfortunately ux00boot_load_gpt_partition() comes out wildly different so I've just embedded asm. (I'm bummed to not have a better solution, but at ~20 hours it's starting to not be fun, and I have other responsibilities...)

ux00boot_ordered.c is made so I can re-order the code to match the image, without actually moving text in a way that would be hard to understand and audit.

Thanks to @SirCmpwn for the dts file, @esmil for misc things like some disassembly and segment alignment, and @tmagik for the pointer to a similar toolchain.


Edit: https://github.com/riscv/riscv-gcc/commit/07b59d44c18d75fd5a5171fae7514bb12e3290a7 looks related to the code I see in the shipped image, but using its parent commit or it, I can't seem to get a gcc that compiles the switch() like the ROM does.