Open silvanshade opened 5 months ago
For what it's worth, if you have a look at the github actions workflow, there are artifacts generated by those steps. If you download e.g. sophgo-bootloader-single-sg2042-master (https://github.com/sophgo/bootloader-riscv/actions/runs/8414100858) you will find an .img therein. If you mount that, there is an actual fip.bin
file contained. Maybe that is what you are looking for, if yes, then the steps in the workflow tell you, how it's been created. If you have already figured that out, I'm sorry, I am very new to this risc-v businees and just try to get my own Pioneer board running...
Yeah, I've looked at that.
In fact, I created from scratch a Nix flake for building the BSP and bootloader which follows the similar procedure, and copies the fip.bin
at this step here.
Unfortunately I just have to take the fip.bin
as the binary blob from this repository because, even if you dig into the build scripts here, there's no mention of how it's generated.
Looking at efforts to run NixOS on the MilkV Duo show something similar, where they have to package the fip.bin
as a prebuilt artifact here.
Anyway, still hoping the sources for this can be provided although I'm not sure how likely that is to happen.
@xingxg2022 : Can you guys please provide the source code to build the riscv fip.bin
binary from this commit: https://github.com/sophgo/bootloader-riscv/commit/3f750677e0249ff549ad3fe20bbc800998503539
I found some related code in this tree https://github.com/sophgo/bootloader-arm64/tree/master/trusted-firmware-a/drivers/sophgo but I'm not sure if it is 100% compatible.
If you can provide the true source, I may buy a board and help write a port for milkv/pioneer for coreboot.
(It would be a pity if the community was unable to create alternative bootloaders that gave extra flexibility, eg booting from SATA disk from a pure SPI flash image due to missing multi-processor, pcie, or RAM bringup details)
@silvanshade I was able to compile a (possibly old) version of fip.bin for mango
using the following repo and commands:
git clone https://github.com/sophgo/bootloader-arm64
CHIP=mango CROSS_COMPILE_64=aarch64-linux-gnu- source bootloader-arm64/scripts/envsetup.sh
CHIP=mango build_fip
But I get an error near the end: undefined reference to 'invalidate_icache_all'
So I copied a different board's implementation in trusted-firmware-a/plat/sophgo/mango/plat_helpers.S
:
.globl invalidate_icache_all
...
func invalidate_icache_all
ic ialluis
isb sy
ret
endfunc invalidate_icache_all
This compiled a fip.bin but I don't have hardware to test yet.
@zamaudio I was also eventually able to compile the fip.bin
with a similar approach.
The problem that remains is that the board will not boot the fip.bin
unless the build procedure uses the correct certificates (the boot fails with an error about certificate mismatch), which I assume nobody has access to except for the vendor. This may be why there hasn't been a response to requests for information about fip.bin
.
There may be a way to turn off certificate validation with a jumper or commands issued to the ARM mcu over serial or something like that but I haven't put much effort into investigating that. This would also of course defeat the purpose of the trusted firmware bootflow, but alas it doesn't help the user that wants to build everything themselves anyway.
@silvanshade @zamaudio
I am trying to do something similar to silvanshade with a custom bootloader and needed to generate the fip.bin
file as well. I have found what looks to be the script responsible for generating it, as well as related scripts for signing. I'm not able to test it yet but the magic number matches and hopefully this is what you're looking for.
I also found potentially relevant documentation on the secure boot process they use
Also found here: https://github.com/sophgo/fiptool You may also be able to build the whole bootloader yourself; I'm not sure with this: https://github.com/sophgo/bootloader-riscv/blob/master/scripts/envsetup.sh Sophgo has made more pre-built images for Pioneer boards: https://github.com/sophgo/sophgo-doc/blob/main/SG2042/HowTo/FAQ.rst
Is the source code available for generating the
firmware/fip.bin
?I am trying to put together a custom bootloader and would like to be able to reproduce this file from source if possible.
I also created an issue asking for more information about
fip.bin
in the sophgo-doc repository:https://github.com/sophgo/sophgo-doc/issues/69
The closest thing I have been able to find regarding the
fip.bin
is from thecv18xx
documentation:I notice that there is a
u-boot
repository with ansg2042-dev
branch:https://github.com/sophgo/u-boot/tree/sg2042-dev
But I'm not sure if this is where the
firmware/fip.bin
in this repository is being generated from.Any information would be appreciated.