Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4505

Advanced users • Does the Pi 2 B bootloader read a specific set of bytes like MBR or does it read the files regardless of bit location?

$
0
0
Does the Raspberry Pi 2 Model B primary bootloader look for bootcode.bin and start.elf within a specific range of bits/bytes, like the master boot record, or does it read the SD card and find the two files regardless of physical location?

So I understand that the Pi 2 B's bootloader is pretty locked down in the GPU, but I am curious about how it goes about this. I understand there are multiple bootloaders, with the first being in the GPU's ROM.

I understand the process to set up an SD card, and that it needs a FAT32 partition to boot from.
I have a bit of a project where I'm making an SD card that can be booted on a PC and also on my old Pi.

Based on my understanding, the bootloader looks for the first FAT32 partition and finds the different startup files (bootcode.bin and start.elf).

If it scans for the files rather than looking at a specific set of bits (MBR booting does the latter, looking at the first 512 bits of a hard drive for the primary bootloader code), then if I have my SD card partitioned, theoretically I should be able to have that partition existing anywhere on the hard drive.

If it looks for data at a specific bit, or straight up reads the MBR, then doing this may not be an option.

However, I remember with old NOOBS setup, you would just extract the files into a properly formatted SD card and it works. I don't think this method is reliable enough that it would place the data bit-for-bit where it belongs -- that is why when preparing a Live CD (for Linux in general) you must flash a USB device (or burn cd/dvd) with an ISO, because the ISO is (basically) a photograph of a disc and therefore the imager program places all data bit-for-bit exactly where it needs to go.

But I remember NOOBS just worked. So something tells me that the built in bootloader is smart enough to just find the bootcode.bin and start.elf files anywhere on that FAT32 partition.

If this is true, this will make my project a gazillion times easier. The reason why it matters if the bootloader's physical location on the storage media is essential is because of my partitioning setup on the SD card. Of course the MBR is going to be taken up by the OS for PC, but since the first stage bootloader on the Pi is embedded into ROM then I think I should be able to accomplish what I've described just fine. Also if you were curious, the partition for the Pi is a 32gb FAT32 partition that my PC's host environment recognizes as "sda4", making it the 4th primary partition and therefore on the end of the storage medium and nowhere near the first 512 bytes.

Working out of town currently and away from my Pi, so I can't test this until Wednesday. I will post the results once I try this.

Statistics: Posted by sylphyk — Tue Mar 26, 2024 3:50 am — Replies 0 — Views 12



Viewing all articles
Browse latest Browse all 4505

Trending Articles