xlar54
Posts: 47
Joined: Tue Aug 20, 2013 5:08 am

Kernel switcher... kernel?

Sun Jul 14, 2019 6:41 pm

Hey guys, I have raspbian installed, and I also have another kernel project Im toying with. Im wondering if there is a kernel that can load up and swap the two. So for instance, if I put all the raspbian files in a directory called "raspbian" and my kernel and files in a directory called "myos". On the root would be a kernel that gives a menu option for which one to boot, and then boots it. Is this out there somewhere? Noobs multiboot wont do something like this and wants instead to (I believe) repartition the entire card. Its not necessary for such a small kernel like my own.

Thanks

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

Re: Kernel switcher... kernel?

Mon Jul 15, 2019 1:34 am

You are after a boot loader/manager they just install themselves in the master boot record and control things from there.. there are a truckload of them

Wiki has a small list of what will be a very large list
https://en.wikipedia.org/wiki/Compariso ... ot_loaders

The more modern way is UEFI
https://www.happyassassin.net/2014/01/2 ... work-then/

ghans
Posts: 7862
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Kernel switcher... kernel?

Mon Jul 15, 2019 5:03 am

The Raspberry Pi does not support UEFI out-of-the-box. What people (or companies like Microsoft and SuSE) have been doing is to replace the file kernel.img with an
(U)EFI implementation (either TianoCore or uboot + EFI emulation patches).

It seems to work well enough. Obviously, this adds another step to the boot process,
making it four or five stages long (e.g. SuSE boots GRUB2 from uboot, which in turn finally boots Linux proper)

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

pik33
Posts: 135
Joined: Thu Sep 10, 2015 4:26 pm

Re: Kernel switcher... kernel?

Mon Jul 15, 2019 5:55 am

The simplest technique to use is:

- make a directory
- put your kernels there
- write a kernel which:
- lists a kernels in the directory
- allows to select one
- copies the selected kernel over itself
- restarts the pi

config.txt and cmdline.txt may be treated this way too.

I did this kind of kernel using Ultibo.

The problem is: the kernel you run has to restore the multiboot kernel again.
I solved this using a shell script/desktop icon in Raspbian, so the script restore my "microdos" as I called it
Also, bare metal programs I write use a couple of lines to restore the multiboot kernel

I also use this method to develop using Ultibo. The Ultibo GUI is installed in Raspbian. So I start Raspbian and IDE, write what I need, then use a shell script to boot to my program. Then the program restores the Raspbian kernel and after the reboot I can continue dveloping: I even made the IDE to autostart so after the reboot I have it open.

IDE->write->compile->reboot with a scrpt to my experimental kernel->find a bug-> reboot->raspbian->IDE-> repeat :)

The lines which restores the raspbian kernels have to be at the very start of the debugged program to have the Raspbian ready when the program hangs up :) due to a bug in it.

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

Re: Kernel switcher... kernel?

Mon Jul 15, 2019 8:33 am

Hi,

The magic keyword you need to google for is "raspberrypi dual boot".

There are boot managers written for the RPi, and they do exactly as @pik33 described (except the overwrite part, which is unnecessary with chain loading). My personal favourite is jncronin's multiboot compatible rpi-boot.
Many people seems to like BerryBoot too.

Cheers,
bzt

Return to “Bare metal, Assembly language”