Where does the rpi4 store the firmware necessary to read from the sd card where this software is (presumably) stored?
[1] https://github.com/isometimes/rpi4-osdev/blob/master/part1-b...
Where does the rpi4 store the firmware necessary to read from the sd card where this software is (presumably) stored?
[1] https://github.com/isometimes/rpi4-osdev/blob/master/part1-b...
Getting into C (or Rust) assuming the presence of some kind of system firmware (BIOS, UEFI, u-boot, coreboot, etc.) isn't too difficult in the grand scheme of things.
Not to toot my own horn much, but here's an example I did of getting into Rust on a 386EX SBC i had hanging around. I actually yanked out the BIOS chip and this replaces it. Please forgive any poor Rust practices, this was written in a hurry.
https://github.com/teknoman117/ts-3100-images/tree/master/ru...
I discovered a mind-melting bug where replacing the RTC clock chip / battery-backed RAM can erase the BIOS. This SBC uses the same flash chip for both user storage and the BIOS. The partition between the user area and the bios is stored in the CMOS ram, so if there is any junk in it, the BIOS might misidentify the flash boundaries and erase itself...
So, I wrote this to recover the boards. Bonus points were that I only had an 8 KiB EEPROM hanging around so it had to fit in 8K initially.
https://github.com/isometimes/rpi4-osdev/tree/master/part2-b...
https://raspberrypi.stackexchange.com/questions/10489/how-do...
You don't handle the CPU from the reset vector like you would in a microcontroller or system firmware environment. There is an entire loader stack that finds a boot device to read a kernel image from that exists under you.
That's not to take away from this series at all, it's just the parent comment was asking about how it was so easy to get into a kernel image written in C on an SD card without any apparent SD card or FS logic.
The main chip of the RPi4 has a small amount of code in a built-in ROM which runs on boot. In the normal boot flow, that code loads the bootloader from the EEPROM chip, but it can also read a recovery image from the SD card. See https://www.raspberrypi.com/documentation/computers/raspberr... for details (or https://www.raspberrypi.com/documentation/computers/raspberr... for how it was on the older RPi devices).
The hard part is the linker-script to get this working right :-) https://github.com/isometimes/rpi4-osdev/blob/master/part1-b...
Doesn't necessarily have to involve assembly!
There are a bunch of other headers in that file, but the "start_of_setup:" label is what's invoked by the bootloader, and "calll main" transitions to C. So 32 lines of code, by my count.