jamesmintram
Posts: 31
Joined: Mon Jan 15, 2018 12:14 am

Idea: Using Supervisor mode for Bootloader

Fri Sep 28, 2018 11:06 am

Something I have been thinking about recently. I have seen a few bootloaders out there that let you load an image over UART (for example) - and that is great for iteration.

However you have to power cycle your device, now this could be me being ultra lazy.. but I was thinking it would be nice if I had a boot loader than ran at EL2. It could then be provide a "Wait for new kernel" function that could be called from EL1 (via a trap)

This call would be done when the kernel panics or when you initiate it manually. The bootloader would reset all the relevant state, and then run the "Receive kernel" function as if it had just been power cycled.

I suppose one advantage (over lazyness and saving a couple of seconds each time) is you can run a suite of tests, one after the other without manual intervention - but each test would run as if the system was freshly booted.

Anyway, it was just some idle thoughts and I was curious if other people have done this? or even think it is a good idea?

LizardLad_1
Posts: 126
Joined: Sat Jan 13, 2018 12:29 am

Re: Idea: Using Supervisor mode for Bootloader

Fri Sep 28, 2018 11:06 pm

I like your thinking but I lack the knowledge to judge its positives and negatives however from this viewpoint it looks like a good idea. I would have thought that this had already been implemented somewhere, if it hasn't there is probably a reason for that.

LdB
Posts: 872
Joined: Wed Dec 07, 2016 2:29 pm

Re: Idea: Using Supervisor mode for Bootloader

Sat Sep 29, 2018 2:03 am

There are a number of other than Pi ARM boards that do it but they often have flash to hold the new kernel.
I know one in particular it's nothing as complicated as your suggestion they just have a special command you can send
via UART or Telnet and the moment it sees the command it swings to a mode to ask for password and then it simply
takes the new kernel.

LeMury
Posts: 33
Joined: Mon Jun 11, 2018 3:06 pm

Re: Idea: Using Supervisor mode for Bootloader

Sat Sep 29, 2018 2:22 pm

Unless I don't understand the question/suggestion, here's what I do for development cycle.

Power on, Pi boots and loads my serial loader which awaits new kernel.
kernel loads and executes.
Then if the kernel panics it reboots itself via the PM watchdog.
Or, I manually send some serial command to the Pi to force the above PM reboot.

Personally I like the reboot/reset as it puts the pi in a known state.

bzt
Posts: 178
Joined: Sat Oct 14, 2017 9:57 pm

Re: Idea: Using Supervisor mode for Bootloader

Sun Sep 30, 2018 9:42 am

jamesmintram wrote:I was thinking it would be nice if I had a boot loader than ran at EL2. It could then be provide a "Wait for new kernel" function that could be called from EL1 (via a trap)
I have a bootloader tutorial which does exactly that. The only difference is, it executes the kernel at EL2, but it's easy to replace the "ret" with a code for example from here using x2=0x80000. Then all you need to do is to add an EL2 handler which calls the main() function again.

Or maybe even simpler and more bullet-proof solution, you could also reset your board from an EL2 exception handler with this simple code. That also resets the devices, reloads the bootloader which will "Wait for a new kernel" in it's main() again.

Cheers,
bzt

Return to “Bare metal, Assembly language”