Building linux for custom U500

Hi All,

I have a custom U500 build, without PCIe. It has only DDR3 memory (4 GBytes) and UART for now.
I already have a mechanism to load the DDR3 with the linux file system.

I would like to boot linux on this and access it using uart, later on move to Ethernet.
To begin, i looked into freedom-u500-sdk, built the standard linux as given by the makefile.
Can anyone point me to a document or reference to enable U500 to boot directly from DDR3.

Thanks,
Anup.

If you started from our design, then the processor is booting from the ROM at 0x1000. You need to change the program that is stored in that ROM. Currently, the ROM grabs the first 16MB from the SD card, puts it to 0x80000000 and then jumps to it. You would want to just replace that program with one that just jumps immediately to 0x80000000. If you do this, you will need to make sure you hold the processor in reset while you fill the DDR and then release it once you’re done.

So, I just took a peek in the freedom git repository. You will see in the bootrom directory the image that gets baked into the ROM. Try:
riscv64-unknown-elf-objdump -m riscv -b binary --adjust-vma=0x1000 -D bootrom/u500vc707devkit.img
… you’ll see there the bootloader I described. When you create your replacement file, keep in mind that address 0x100C-0x100F must be kept unused so that the pointer to the config string can go there.

Thanks Wesley for the quick response.
I will look for these changes in my build and make the changes.

Will get back once i am able to proceed.

I went through the assembly code, but could not understand much of it.
As suggested by you, i can just replace the existing code to make a jump to address 0x80000000

1000 - to 100F - dont touch
1010: jump to 0x80000000 ( lui and shift to get the address into a register)
is that all, or am i missing anything ?

after this, how do i generate the u500vc707devkit.img file with this new code ?

Thanks,
Anup.

Yes, that is all you need to do. The .img file is just a raw binary file containing the exact contents of the ROM. You can generate it however you want, such as attempting to reassemble the disassembly with your modifications, or even using a hex editor to replace the raw bytes in the existing u500vc707devkit.img with the bytes that correspond to your desired instructions.

Alternatively, you can compile your own bootloader from scratch. The source code for the E300’s boot ROM is located at https://github.com/sifive/freedom/blob/f4375c22662f82b1b4f94e88b1aba6998b1f34ba/bootrom/xip/xip.S, which simply jumps to the address provided by the XIP_TARGET_ADDR preprocessor variable. For example, to generate a version that jumps to 0x80000000:

$ riscv64-unknown-elf-gcc -nostartfiles -DXIP_TARGET_ADDR=0x80000000 -o xip.o xip.S -Wl,--section-start=.text=0x1000
$ riscv64-unknown-elf-objcopy -O binary xip.o bootrom.img

Hello Terpstra, I tried your command and get a .S. However, there exists many lines like 0x1b160701 left untouched. Is there anything I missed? I really want to see the source codes of the u500vc707devkit.img so that I can transplant the freedom project to other platform like vc709 with no SD slot.

Almost everything in that image has to do with booting from an SD card. In the past we also put a “config string” in there, but that is being replaced as we speak. I don’t think it makes sense to disassemble this for you right now. Shortly we. will have a much better boot sequence for linux.