za3k
Posts: 3
Joined: Wed Dec 11, 2019 7:54 am

Raspberry Pi 4 ROM bootloader

Wed Dec 11, 2019 7:57 am

Is a dump/source of the Raspberry Pi 4 bootloader available (the ROM, not the EEPROM)? Thanks in advance, I know this is really a developer question but I figured this board was the best fit.

If you do dump this, please make sure to note exactly which model you have.

dickon
Posts: 642
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: Raspberry Pi 4 ROM bootloader

Wed Dec 11, 2019 11:42 am

I very much doubt it. It's VC, not ARM, so probably isn't even possible to get at.

Why on earth do you want it?

hippy
Posts: 6532
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Raspberry Pi 4 ROM bootloader

Wed Dec 11, 2019 12:13 pm

You would probably have to write some VC4/VC6 bare metal code to read the ROM bootloader then disassemble it. I doubt anyone would publish such dumps or disassembly as it would be covered by copyright and licensing and doing so would probably have adverse consequences.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24662
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry Pi 4 ROM bootloader

Wed Dec 11, 2019 12:29 pm

za3k wrote:
Wed Dec 11, 2019 7:57 am
Is a dump/source of the Raspberry Pi 4 bootloader available (the ROM, not the EEPROM)? Thanks in advance, I know this is really a developer question but I figured this board was the best fit.

If you do dump this, please make sure to note exactly which model you have.
No, not available. And as others have said, why on earth would you need it?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

hippy
Posts: 6532
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Raspberry Pi 4 ROM bootloader

Wed Dec 11, 2019 1:27 pm

dickon wrote:
Wed Dec 11, 2019 11:42 am
Why on earth do you want it?
Does it matter ? Maybe the OP has some genuine need or want, or maybe not, but isn't 'idle curiosity' or simply desiring it good enough ?

One of the great things about the Open Source movement as I see it is the push to make everything open and available to those who don't need it but are merely curious, to overturn the 'you don't need it, you cant have it' tendency towards secrecy.

Gaining a greater understanding of how the Pi works from initial power-up, what code does what and how, may not be of immense value but does satisfy a quest for knowledge.

More practically, having the ROM bootloader, bootcode.bin and Eeprom loader code is useful for people who want to know more about VideoCore programming, are developing tools related to that.

It is handy to have a large corpus of binary code covering various use cases to understand the VideoCore instruction set and improve tools which deal with that. It can also reveals the tricks of the trade used when programming for VideoCore, can reveal things which were previously hidden.

Is the ROM bootloader useful in that ? One can't say until one has it.

Does the OP, or anyone need, the ROM bootloader code ? Probably not, but it doesn't mean they can't be curious about it, want to have it, or want to see how it does its stuff.

dickon
Posts: 642
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: Raspberry Pi 4 ROM bootloader

Wed Dec 11, 2019 1:40 pm

hippy wrote:
Wed Dec 11, 2019 1:27 pm
dickon wrote:
Wed Dec 11, 2019 11:42 am
Why on earth do you want it?
Does it matter ?
No, not at all. It was a genuine question. Boot ROMs are such a niche thing to worry about I'm surprised anyone's interested in it. Once they've done their initial bootstrapping, they're irrelevant, and, being ROMs, there isn't anything practical you can do with them past that. They aren't running code on a booted system, so attempting to exploit them is nonsense, their functionality is usually extremely limited (the Marvell Armada series chips can't even setup RAM, for instance), and as all they do is some very low-level setup of a bare minimum needed to bootstrap phase two, they aren't particularly exciting (other than to other engineers working on similar chips writing boot ROMs, I suppose).

I honestly can't see why anyone would possibly want it.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24662
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry Pi 4 ROM bootloader

Wed Dec 11, 2019 1:55 pm

hippy wrote:
Wed Dec 11, 2019 1:27 pm
dickon wrote:
Wed Dec 11, 2019 11:42 am
Why on earth do you want it?
Does it matter ? Maybe the OP has some genuine need or want, or maybe not, but isn't 'idle curiosity' or simply desiring it good enough ?

One of the great things about the Open Source movement as I see it is the push to make everything open and available to those who don't need it but are merely curious, to overturn the 'you don't need it, you cant have it' tendency towards secrecy.

Gaining a greater understanding of how the Pi works from initial power-up, what code does what and how, may not be of immense value but does satisfy a quest for knowledge.

More practically, having the ROM bootloader, bootcode.bin and Eeprom loader code is useful for people who want to know more about VideoCore programming, are developing tools related to that.

It is handy to have a large corpus of binary code covering various use cases to understand the VideoCore instruction set and improve tools which deal with that. It can also reveals the tricks of the trade used when programming for VideoCore, can reveal things which were previously hidden.

Is the ROM bootloader useful in that ? One can't say until one has it.

Does the OP, or anyone need, the ROM bootloader code ? Probably not, but it doesn't mean they can't be curious about it, want to have it, or want to see how it does its stuff.
Videocore is closed, including the boot ROM and including the instruction set. End of. Don't even bother asking why. It's just "The way it is".

There are loads of OS example bootloaders out there if you want to know how they work. But there no need to know how the VC one works, at all.

Curiosity is fine. However, if the OP has a specific task they wish to accomplish, then knowing what that task is would make it easier to provide alternatives given that this particular stuff is not available.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

W. H. Heydt
Posts: 11273
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Raspberry Pi 4 ROM bootloader

Wed Dec 11, 2019 11:06 pm

Having once written a bootstrap-and-load-an-object-deck program (then hand assembled it and keypunched the two binary cards) for an IBM S/360, I can understand the curiosity. (And the keypunching part of that was by far the worst part of the entire process.)

hippy
Posts: 6532
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 1:17 am

My main interest in VideoCore is in turning a Pi 4B into a quite powerful, self-contained, standalone Arduino-style board. Bootloader, program loader, and user program all held in Boot Eeprom; no SD Card, no USB or network booting required.

User avatar
Gavinmc42
Posts: 4231
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 1:56 am

OP is First time poster.
It is like going into KFC for the first time and asking what are your 11 secret herbs and spices?
My main interest in VideoCore is in turning a Pi 4B into a quite powerful, self-contained, standalone Arduino-style board. Bootloader, program loader, and user program all held in Boot Eeprom; no SD Card, no USB or network booting required.
That would be cool, even better if something like a Basic interpreted can fit into it.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

W. H. Heydt
Posts: 11273
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 5:23 am

Gavinmc42 wrote:
Thu Dec 12, 2019 1:56 am
OP is First time poster.
It is like going into KFC for the first time and asking what are your 11 secret herbs and spices?
My main interest in VideoCore is in turning a Pi 4B into a quite powerful, self-contained, standalone Arduino-style board. Bootloader, program loader, and user program all held in Boot Eeprom; no SD Card, no USB or network booting required.
That would be cool, even better if something like a Basic interpreted can fit into it.
Well... The EEPROM is 512KB... Considering the original IBM PC maxed out at 640KB and the early ones only started with 16KB, a BASIC interpreter *ought* to fit...

W. H. Heydt
Posts: 11273
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 5:26 am

Gavinmc42 wrote:
Thu Dec 12, 2019 1:56 am
OP is First time poster.
It is like going into KFC for the first time and asking what are your 11 secret herbs and spices?
My main interest in VideoCore is in turning a Pi 4B into a quite powerful, self-contained, standalone Arduino-style board. Bootloader, program loader, and user program all held in Boot Eeprom; no SD Card, no USB or network booting required.
That would be cool, even better if something like a Basic interpreted can fit into it.
This all argues that he hasn't looked at the Pi very closely and *really* doesn't know what he's talking about. Not only would he have to figure out how to do enough VC6 programming, but he'd have to work out how to flash the EEPROM as well. Then there is the problem of convincing the ARM CPUs to load and run anything from the EEPROM. He'd probably be better off finding components to build his own (non-Pi) system from the ground up.

A practical alternative would probably be to use a CM3+ with as much flash storage as he thinks he needs...either on board, or on the carrier.

User avatar
Gavinmc42
Posts: 4231
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 6:59 am

Is the OP asking us to reverse engineer the boot code?
And Dump it?

Most of this has been reverse E for the VC4 Pi's, Kristina's bootloader etc.
And the reason why it was halted, which pretty much still applies.
https://github.com/christinaa/rpi-open- ... /issues/37

Nice idea but lots of work.
Still it's a 512KB EEPROM.
Someday, someone might do it.
Not today ;)
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

hippy
Posts: 6532
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 9:00 am

W. H. Heydt wrote:
Thu Dec 12, 2019 5:26 am
This all argues that he hasn't looked at the Pi very closely and *really* doesn't know what he's talking about. Not only would he have to figure out how to do enough VC6 programming, but he'd have to work out how to flash the EEPROM as well. Then there is the problem of convincing the ARM CPUs to load and run anything from the EEPROM.
We don't know what the OP's interest in the ROM bootloadeer is or what their plans may be.

Flashing the Boot Eeprom is perhaps the easiest part. The ROM bootloader already includes a means to initially program the Boot Eeprom from a file on SD Card when it's there and it's booted. The flashrom utility will program it from userland and the chip itself is well documented. Once programmed it should be able to flash itself.

There's not necessarily any need to start up the ARM cores but it is feasible. It depends on what one wants to create, who one is targeting. There's not necessarily any need to support all of what a Pi is capable of. That capabilities 'go to waste' isn't necessarily a concern for some target audiences.

dickon
Posts: 642
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 9:08 am

W. H. Heydt wrote:
Thu Dec 12, 2019 5:26 am
Then there is the problem of convincing the ARM CPUs to load and run anything from the EEPROM.
That's the easy bit: the GPU would simply copy the ARM image to RAM, and point the ARM at it (ie, release the reset hold, most likely).

User avatar
Gavinmc42
Posts: 4231
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 10:17 am

It would be nice to know if the ROM bootloader has an EEPROM size limit?
Could bigger ones be used?
We know a smaller one could be used, perhaps on rev 1.2?
Different types?

The Pi4 is OTG able?
Is that from the ROM or EEPROM code?
My guess is EEPROM, but what was the ROM code size?
Would it need 32KB? to just copy EEPROM code?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24662
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 10:57 am

We want to reduce the size of the EEPROM, not increase it. (BOM reasons).
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

hippy
Posts: 6532
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 11:22 am

Gavinmc42 wrote:
Thu Dec 12, 2019 10:17 am
It would be nice to know if the ROM bootloader has an EEPROM size limit?
Could bigger ones be used?
Such questions are why it would be nice to have the ROM bootloader source to provide definitive answers but that's not going to happen.

I don't have my notes to hand but paraphrased; the pre-4B chips copies bootcode.bin into cache RAM of limited size then executed that. That then opens up more RAM which later stages of bootloading can use. There seems no reason that it couldn't be the same using Boot Eeprom.

So potentially unlimited size of Eeprom, but there would need to be a match between what the SoC puts out and what the Eeprom expects for addressing which could constrain that. The W25X40 has a 24-bit address, which the SoC presumably puts out, so would seem able to access up to 16MB Eeproms.
Gavinmc42 wrote:
Thu Dec 12, 2019 10:17 am
The Pi4 is OTG able?
Is that from the ROM or EEPROM code?
My guess would be, same as pre-4B; supported by the ROM bootloader or even deeper than that; manufacturer's ROM rather than customer customisable ROM.

User avatar
thagrol
Posts: 2116
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 4:22 pm

Gavinmc42 wrote:
Thu Dec 12, 2019 10:17 am
The Pi4 is OTG able?
iIf you mean bootable over USB like the zero/zeroW, I guess the answer is maybe

The SoC's USB 2 port is routed out to the USB C connector and can function in "device mode". Whether or not it appears as a boradcom boot device when connected to a host without an SD card inserted I don't know. Guess that depends on the ROM bootloader built into the SoC and/or the boot loader in the EEPROM.

I'd try it but unplugging ym 4B woudl break my LAN.
Attempts to contact me outside of thes forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24662
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 4:27 pm

Just to be really clear, the two bootloaders - the one baked in to the chip, and the second stage bootcode.bin are both closed, contain proprietary information, and will not be released as source.

Also, it would be inadvisable to use the EEPROM for anything else than what it is currently used for as there is no guarantee it will remain as it is, either in future OR current models. So if you do use it for something, that 'something' may stop working at any time.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

trejan
Posts: 1106
Joined: Tue Jul 02, 2019 2:28 pm

Re: Raspberry Pi 4 ROM bootloader

Thu Dec 12, 2019 4:28 pm

Gavinmc42 wrote:
Thu Dec 12, 2019 10:17 am
The Pi4 is OTG able?
Yes
Gavinmc42 wrote:
Thu Dec 12, 2019 10:17 am
Is that from the ROM or EEPROM code?
The others were from the SoC boot ROM so I expect this is as well since the same USB controller is involved.

User avatar
Gavinmc42
Posts: 4231
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspberry Pi 4 ROM bootloader

Fri Dec 13, 2019 1:03 am

So if you do use it for something, that 'something' may stop working at any time.
The others were from the SoC boot ROM so I expect this is as well since the same USB controller is involved.
So if you brick the EEPROM there might be away to unbrick from OTG or JTAG?
In circuit EEPROM programmer?

I understand the smaller EEPROM BOM desire, dealt with enough Purchasing Officers in my time as FAE.
Just understand we like to tinker and putting a bigger EEPROM on is nearly irresistible :D
The W25X40 has a 24-bit address, which the SoC presumably puts out, so would seem able to access up to 16MB Eeproms.
Thansk had not bothered checking the datasheet yet for max size.
While the desire is there, lack of knowledge to do anything yet and probably for years.

Still, what size was the ROM bootloader again?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

trejan
Posts: 1106
Joined: Tue Jul 02, 2019 2:28 pm

Re: Raspberry Pi 4 ROM bootloader

Fri Dec 13, 2019 1:09 am

Gavinmc42 wrote:
Fri Dec 13, 2019 1:03 am
So if you brick the EEPROM there might be away to unbrick from OTG or JTAG?
You can fix it using the SD card. The SoC boot ROM will always load recovery.bin if it finds it on the SD card so you can reflash the bootcode EEPROM.

Via OTG should be possible as you can make it boot Linux and then directly reflash it using flashrom. Directly using rpiboot with recovery.bin is probably not possible as it wants to read the the new firmware from the SD card so you might as well use the official method.

Doubtful about JTAG as the accessible JTAG interface on the GPIO header is for the ARM cores but if the bootcode EEPROM is corrupt or blank then your ARM cores aren't going to be running. The VC JTAG interface is on the bottom on that unpopulated connector but has no public documentation.
Gavinmc42 wrote:
Fri Dec 13, 2019 1:03 am
Still, what size was the ROM bootloader again?
The SoC boot ROM was 32KB for the BCM2835/6/7. Don't know for the BCM2838 in the Pi 4. I expect it is the same though.

W. H. Heydt
Posts: 11273
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Raspberry Pi 4 ROM bootloader

Fri Dec 13, 2019 1:27 am

trejan wrote:
Fri Dec 13, 2019 1:09 am
Don't know for the BCM2838 in the Pi 4. I expect it is the same though.
BCM2711. Likely the same as, for instance, the USB 2.0 interface is the same.

trejan
Posts: 1106
Joined: Tue Jul 02, 2019 2:28 pm

Re: Raspberry Pi 4 ROM bootloader

Fri Dec 13, 2019 1:47 am

W. H. Heydt wrote:
Fri Dec 13, 2019 1:27 am
trejan wrote:
Fri Dec 13, 2019 1:09 am
Don't know for the BCM2838 in the Pi 4. I expect it is the same though.
BCM2711. Likely the same as, for instance, the USB 2.0 interface is the same.
Yeah. You're right. I was looking at the DT which calls it a BCM2838 but the laser etched part number on the SoC and the documentation both say BCM2711.

It looks like somebody changed their mind during development and altered the naming scheme. It used to be that the BCM27xx name was the family and the BCM28xx name is a specific implementation in a chip. They've only ever had one implementation of each of them though until the Pi 4 SoC. The Pi 4 SoC is called by the family name BCM2711 this time whilst the Pi 4 DT still refers to it by the implementation name BCM2838. The other implementation is called the BCM7211 and meant for set-top box devices and is probably why the Pi 4 SoC is BCM2711...

Return to “Advanced users”