I have an embedded device with a SPI connected flash. Basically this means the device boots its bootloader and Linux kernel from a small flash part.

As the device boots, but before the root filesystem is mounted and switch_root is called - I'd like to optionally boot a second, different, kernel

Is such a thing possible? My goal in this is to have a very minimal bootloader and stock kernel in flash - but then to put a newer/larger kernel on a hard disk.

My bootloader is very limited, where I cannot read the newer kernel from the hard disk.

in short

a) CPU comes out of reset, reads its bootloader from flash
b) bootloader boots, inits basic hardware, loads Linux kernel from flash
c) kernel boots, inits more hardware, and reads a second kernel from a hard disk
d) I'd like to switch to the second kernel at this point

my goal in this process is to provide a mechanism where the kernel in flash can get old with time, but updated kernels can be supplied via the hard disk. If my bootloader were more advanced, I'd go that route - however it's not able to initialize the hardware necessary (the disk controller), nor does it have modern filesystem support

...an option I've pondered is if it'd be possible to put the second kernel into physical memory, mark a known address as having this second kernel, then reset. The boot loader could then detect the known address and verify the integrity of the second kernel, choosing it instead of one coming from Flash

any tips would be appreciated!


You don't have to do anything too complicated. Just call kexec to boot into the new kernel. It couldn't get simpler...unless your old kernel was somehow compiled without kexec support.

  • this is great, thanks for the tip! I'll check it out – stuck Jan 7 '13 at 2:34

Take a look at UBOOT, this has worked for me in the past.

You can use this even to read filesystems but, should allow you to switch between multiple images. This way you always overwrite the image you are not currently using and reconfigure uboot to launch the upgrade on reset.

  • I'm actually using UBOOT, but it's struggling to init some newer USB hard drives (ones that dont have 512 byte sectors, I think) – stuck Jan 7 '13 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.