NitsM
Posts: 7
Joined: Mon Sep 16, 2019 2:51 pm

Switch two kernel image in raspberry pi using UBoot

Mon Sep 16, 2019 3:26 pm

I am trying to boot backup kernel image if first kernel fail to boot but unable to identify any environment variable related to boot failure. Is there any way to achieve this using Uboot or any other Boot loader.

User avatar
DougieLawson
Posts: 36571
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Switch two kernel image in raspberry pi using UBoot

Mon Sep 16, 2019 3:50 pm

You're more likely to get an answer by posting your question to the u-boot mailing list.

https://www.denx.de/wiki/U-Boot has the details and archive for that mailing list.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

fruitoftheloom
Posts: 21081
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Switch two kernel image in raspberry pi using UBoot

Mon Sep 16, 2019 3:52 pm

Removed as OP posted in x86 Debian Section, which is totally wrong, reported.
Last edited by fruitoftheloom on Tue Sep 17, 2019 2:00 pm, edited 1 time in total.
Retired disgracefully.....
This at present is my daily "computer" https://www.asus.com/us/Chrome-Devices/Chromebit-CS10/

NitsM
Posts: 7
Joined: Mon Sep 16, 2019 2:51 pm

Re: Switch two kernel image in raspberry pi using UBoot

Tue Sep 17, 2019 12:00 pm

Is there any possibility to get two different kernels using NOOBs. Can we use NOOBs and Uboot together.
I just want to know is there any way to use 2 different kernel image one for initial boot and other for backup.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12411
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Switch two kernel image in raspberry pi using UBoot

Tue Sep 17, 2019 12:26 pm

Are you talking about a raspberry PI, or about a PC you want to run the PI desktop on?

If the latter, then NOOBS doesn't run on PC's
if the former, then I again have to move this thread to the correct place.

please give us enough information, you are not making sense now!

P.S. PI's at the moment don't support UBOOT.

User avatar
procount
Posts: 1849
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: Switch two kernel image in raspberry pi using UBoot

Tue Sep 17, 2019 1:06 pm

Assuming your are talking about running this on a RPi (and not an x86 PC running Debian with a Raspberry Pi Desktop), then I guess you could get NOOBS or PINN to do it with a manually configured SD card.

You could install Raspbian with NOOBS / PINN along with a Data Partition (If using PINN, you can use Matt Huisman's site to customise the size of the data partition. If not, you would have to create your own data partition to be the same size as the Raspbian BOOT partition).

Copy your Raspbian Boot partition over to this data partition, so that it becomes your backup boot partition. Make any modifications necessary to change the kernel to a new version. Don't forget to copy any lib/modules over to the Raspbian rootfs.

Then modify /settings/installed_os.json to indicate to NOOBS/PINN that 2 identical OSes are installed using 2 different boot partitions, but sharing the same rootfs.

You should now be presented with a choice of booting the same OS but using 2 different kernels on 2 different boot partitions.

The only problem with this technique is that each time you switch from one boot partition to the other, you will need to modify /etc/fstab to mount the correct boot partition. You could probably do this with a startup script.

So yes it is possible, if a bit clunky.
(NOTE: The above is only a strategy and not a step by step tutorial on how to do it. Further acquaintance with how NOOBS/PINN works would be needed, but it's all available in the relevant documentation).
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

NitsM
Posts: 7
Joined: Mon Sep 16, 2019 2:51 pm

Re: Switch two kernel image in raspberry pi using UBoot

Tue Sep 17, 2019 1:42 pm

Hi All,

Thanks all for prompt replies. for more clarity let me add one thing here that i am trying to achieve it on raspberry-pi 3 A+ board not on desktop pc.

query 1:- I need some direction to achieve fallback condition like if default kernel fails to boot then how we can switch backup kernel.
query 2:- Is there any need to unlock raspberry pi to flash boot loader into it ? if yes then how we can achieve it .

User avatar
procount
Posts: 1849
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: Switch two kernel image in raspberry pi using UBoot

Tue Sep 17, 2019 3:17 pm

I'm just wondering why you are singling out the kernel for fallback reasons?
Do you think this is more vulnerable than any other part of the software, like the root file system?
Or are you experimenting by installing different custom kernels that may fail?
Do you need an "on-system" recovery system as opposed to removing the SD card and fixing it on another Linux machine should the kernel fail?
What would you do if the kernel booted fine, but the rootfs failed / corrupted?
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

epoch1970
Posts: 3875
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Switch two kernel image in raspberry pi using UBoot

Tue Sep 17, 2019 3:51 pm

As dougieLawson said. Have a look at Uboot’s docs and mailing list, google
“uboot bootcount”.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

NitsM
Posts: 7
Joined: Mon Sep 16, 2019 2:51 pm

Re: Switch two kernel image in raspberry pi using UBoot

Wed Sep 18, 2019 1:39 pm

I found bootcount (U-Boot)is useful for booting and switching to second kernel but how can we achieve this using PINN and Uboot together.Anyone have idea about that please suggest.

User avatar
procount
Posts: 1849
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: Switch two kernel image in raspberry pi using UBoot

Wed Sep 18, 2019 1:49 pm

I don't see any point running UBoot with PINN.
I try to remove uboot from any OS that I convert for PINN as it just complicates the installation (especially with partition references in boot scripts in compressed files :roll: )
Or are you thinking of installing multiple OSes that each have redundant swithable kernels?
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

NitsM
Posts: 7
Joined: Mon Sep 16, 2019 2:51 pm

Re: Switch two kernel image in raspberry pi using UBoot

Wed Sep 18, 2019 2:20 pm

I want two kernels, one is for running and second one for backup image. If first one fail to boot ( corrupted by any reason) so the backup image start to booting.one more query I have how to check boot failure conditions in raspberry-Pi.

Return to “Advanced users”