nijhawank
Posts: 23
Joined: Sat Aug 04, 2012 8:26 am

dual boot understanding

Sat Aug 04, 2012 8:57 am

hello friends:

I have been reading a bit about boot process on raspberry pi and dual booing. This is my understanding of this, please confirm if I'm correct...

1. On initial powering of the raspberrypi, the GPU reads and executes bootcode.bin, which then loads loader.bin which inturn loads start.elf.

2. Now, my understanding is that start.elf is responsible for partitioning RAM between GPU and CPU and loads the kernel image.

I've been thinking about booting into different distributions which have different RAM splitting requirements without removing the SD card as I intend to have the board in a closure.

So my questions are:
1. Would it be technically possible in future to have loader.bin providing us an option to choose between different start.elf(s) at boot time?

2. If not above, is it technically possible (in future) to have a single start.elf providing us to choose between different RAM splitting options?

It is one thing that it's restricted due to broadcom providing limited / restricted stuff and another thing if it's just not technically possible. Can anybody confirm on this?

After a lot of searching I came across two projects:
1. berryboot - but I guess it simply provides switching to different distributions but loads the same berryboot kernel always so my thinking is that it won't serve my purpose to use it to dual boot between raspbmc (which probably require 128/128 memory split) and a raspbian configured as NAS with more memory available to CPU than GPU.

2. u-boot - I'm simply not able to understand what exactly it is. Can somebody explain please.
Is it really a low level boot loader, executing at the level of loader.bin/start.elf, letting us choose between different kernels (unlike berryboot).
If yes, can somebody explain how it does that.
If not, then what exactly it does.

Thanks in advance.

- Kamal

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: dual boot understanding

Sat Aug 04, 2012 10:04 am

Hi,

all is not possible. The Ram Config has to be compiled, so no boot switching.
UBoot is a native bootloader yes, but not for raspberry pi. it loads after teh start.elf, as everybody else.

to make things short:
on a pc you cant "switch" between bioses. see the start.elf as the bios of the raspberry pi. after bios everything is possible, but before, nope.

So you can build with uboot a dual boot linux, but no dualboot with diff. ramsplitting.

hermanhermitage
Posts: 65
Joined: Sat Jul 07, 2012 11:21 pm
Location: Zero Page

Re: dual boot understanding

Sat Aug 04, 2012 11:13 am

nijhawank wrote:hello friends:

So my questions are:
1. Would it be technically possible in future to have loader.bin providing us an option to choose between different start.elf(s) at boot time?

2. If not above, is it technically possible (in future) to have a single start.elf providing us to choose between different RAM splitting options?

It is one thing that it's restricted due to broadcom providing limited / restricted stuff and another thing if it's just not technically possible. Can anybody confirm on this?
Its technically possible - it depends how you want to select between them. I think the easiest solution is actually a double boot. You want a mini kernel (arm) that offers the choice, checks if the correct start.elf was loaded and if its correct continues to boot the desired ARM OS, otherwise it swaps the correct start.elf into place, makes a note of the choice of OS on the SD card and reboots the pi which then detects the previous note, deletes the note and starts the desired arm kernel.

Writing a custom loader.bin that presents a choice (USB keyboard? and menu on screen) would be a major exercise but technically possible. Currently I think only Broadcom has the know how.

Max

Re: dual boot understanding

Sat Aug 04, 2012 12:59 pm

nijhawank wrote: After a lot of searching I came across two projects:
1. berryboot - but I guess it simply provides switching to different distributions but loads the same berryboot kernel always so my thinking is that it won't serve my purpose to use it to dual boot between raspbmc (which probably require 128/128 memory split) and a raspbian configured as NAS with more memory available to CPU than GPU.
Berryboot handles different memory splits fine.
Just name your SquashFS image my-operating-system.img128 if it prefers the 128 MB memsplit, .img192 for 192 MB, .img224 for 224 MB or .img for no preference.

Image
After the image is added you can also simply change the memory split in the properties.


Upon making a selection in the boot menu, it checks what the current memory split is (by looking at /proc/meminfo memtotal).
If the current memsplit is not what the image prefers it will:
  • write the name of the operating system the user selected to a temporary file /data/runonce
  • renames the current start.elf file back to its original name (e.g. arm128_start.elf)
  • rename the desired start.elf file to start.elf.
  • sync & reboot
  • after reboot it will read /data/runonce to see which operating system the user wanted to boot, remove that file, and boot the OS the user selected straight away.

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: dual boot understanding

Sat Aug 04, 2012 4:06 pm

Max wrote:
nijhawank wrote: After a lot of searching I came across two projects:
1. berryboot - but I guess it simply provides switching to different distributions but loads the same berryboot kernel always so my thinking is that it won't serve my purpose to use it to dual boot between raspbmc (which probably require 128/128 memory split) and a raspbian configured as NAS with more memory available to CPU than GPU.
Berryboot handles different memory splits fine.
Just name your SquashFS image my-operating-system.img128 if it prefers the 128 MB memsplit, .img192 for 192 MB, .img224 for 224 MB or .img for no preference.

Image
After the image is added you can also simply change the memory split in the properties.


Upon making a selection in the boot menu, it checks what the current memory split is (by looking at /proc/meminfo memtotal).
If the current memsplit is not what the image prefers it will:
  • write the name of the operating system the user selected to a temporary file /data/runonce
  • renames the current start.elf file back to its original name (e.g. arm128_start.elf)
  • rename the desired start.elf file to start.elf.
  • sync & reboot
  • after reboot it will read /data/runonce to see which operating system the user wanted to boot, remove that file, and boot the OS the user selected straight away.
But this is not what nijhawank wanted. he wants a bootup directly in a menu, not booting linux and doing this on a file rename thing and reset.

nijhawank
Posts: 23
Joined: Sat Aug 04, 2012 8:26 am

Re: dual boot understanding

Sat Aug 04, 2012 4:42 pm

Max wrote:
nijhawank wrote: After a lot of searching I came across two projects:
1. berryboot - but I guess it simply provides switching to different distributions but loads the same berryboot kernel always so my thinking is that it won't serve my purpose to use it to dual boot between raspbmc (which probably require 128/128 memory split) and a raspbian configured as NAS with more memory available to CPU than GPU.
Berryboot handles different memory splits fine.
Just name your SquashFS image my-operating-system.img128 if it prefers the 128 MB memsplit, .img192 for 192 MB, .img224 for 224 MB or .img for no preference.

Image
After the image is added you can also simply change the memory split in the properties.


Upon making a selection in the boot menu, it checks what the current memory split is (by looking at /proc/meminfo memtotal).
If the current memsplit is not what the image prefers it will:
  • write the name of the operating system the user selected to a temporary file /data/runonce
  • renames the current start.elf file back to its original name (e.g. arm128_start.elf)
  • rename the desired start.elf file to start.elf.
  • sync & reboot
  • after reboot it will read /data/runonce to see which operating system the user wanted to boot, remove that file, and boot the OS the user selected straight away.
Thanks for the explanation.
So that meets one of my requirement to have the correct memory splitting but what about the kernel, I guess it always loads the berryboot kernel and if the selected distribution has a differently compiled kernel, some of the distribution feature may not work.
I guess it should be possible for berryboot to do a similar kernel image file renaming, so after the reboot raspberrypi reboots into distribution kernel rather than berryboot one. But I didn't see that option in berryboot. Am I correct, or I missed anything?

Also, from my reading, berryboot uses splashfs for the root filesystem, so the OS that it loads will always be read-only. I would need all the write support in the distribution. Again, am I correct or there is something else?

Thanks again.

nijhawank
Posts: 23
Joined: Sat Aug 04, 2012 8:26 am

Re: dual boot understanding

Sat Aug 04, 2012 4:47 pm

Cycl0ne wrote:
Max wrote:
nijhawank wrote: But this is not what nijhawank wanted. he wants a bootup directly in a menu, not booting linux and doing this on a file rename thing and reset.
It doesn't matter if there is a little trick of rebooting and file renaming involved in the process if we are able to achieve what we want to do.

So from Max explanation's berryboot is able to handle the memory split fine. Now, if it let me to boot into the distribution specific kernel rather than it's own, it'd be good. Distribution kernel might be compiled with special options which berryboot kernel might not have. So that's my second requirement.

nijhawank
Posts: 23
Joined: Sat Aug 04, 2012 8:26 am

Re: dual boot understanding

Sat Aug 04, 2012 4:51 pm

hermanhermitage wrote:
nijhawank wrote:hello friends:

So my questions are:
1. Would it be technically possible in future to have loader.bin providing us an option to choose between different start.elf(s) at boot time?

2. If not above, is it technically possible (in future) to have a single start.elf providing us to choose between different RAM splitting options?

It is one thing that it's restricted due to broadcom providing limited / restricted stuff and another thing if it's just not technically possible. Can anybody confirm on this?
Its technically possible - it depends how you want to select between them. I think the easiest solution is actually a double boot. You want a mini kernel (arm) that offers the choice, checks if the correct start.elf was loaded and if its correct continues to boot the desired ARM OS, otherwise it swaps the correct start.elf into place, makes a note of the choice of OS on the SD card and reboots the pi which then detects the previous note, deletes the note and starts the desired arm kernel.

Writing a custom loader.bin that presents a choice (USB keyboard? and menu on screen) would be a major exercise but technically possible. Currently I think only Broadcom has the know how.
Hello. Thanks for replying. I see berryboot does exactly what you said above.
I found some of your threads online like https://github.com/hermanhermitage/videocoreiv This is good information.
I hope Broadcom opens this up some day.

nijhawank
Posts: 23
Joined: Sat Aug 04, 2012 8:26 am

Re: dual boot understanding

Sat Aug 04, 2012 5:12 pm

Cycl0ne wrote:Hi,

all is not possible. The Ram Config has to be compiled, so no boot switching.
UBoot is a native bootloader yes, but not for raspberry pi. it loads after teh start.elf, as everybody else.
so uboot is a native bootloader for platforms other than raspberry pi. then what advantages uboot has over berryboot?

Also, I see uboot has some bare minimal drivers for usb, network etc. and something to do with net booting.
Cycl0ne wrote:to make things short:
on a pc you cant "switch" between bioses. see the start.elf as the bios of the raspberry pi. after bios everything is possible, but before, nope.

So you can build with uboot a dual boot linux, but no dualboot with diff. ramsplitting.
I didnt find proper documentation on uboot, can you point me to any.

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: dual boot understanding

Sat Aug 04, 2012 5:16 pm

http://www.denx.de/wiki/U-Boot/

denx is the company behind u-boot.

if you think in a pc world, U-Boot = Grub Bootloader.
Other systems as x86 normaly dont have a bios and then you "burn" U-Boot into a ROM for bootup. Nearly the same as EFI for Macs.

nijhawank
Posts: 23
Joined: Sat Aug 04, 2012 8:26 am

Re: dual boot understanding

Sat Aug 04, 2012 6:15 pm

Cycl0ne wrote:http://www.denx.de/wiki/U-Boot/

denx is the company behind u-boot.

if you think in a pc world, U-Boot = Grub Bootloader.
Other systems as x86 normaly dont have a bios and then you "burn" U-Boot into a ROM for bootup. Nearly the same as EFI for Macs.
There's no raspberry pi specific documentation, what's supported, what's not.

Max

Re: dual boot understanding

Sat Aug 04, 2012 6:25 pm

nijhawank wrote: So that meets one of my requirement to have the correct memory splitting but what about the kernel, I guess it always loads the berryboot kernel and if the selected distribution has a differently compiled kernel, some of the distribution feature may not work.
Additional kernels are not supported at the moment.
But there are only very few features that really need a seperate kernel instead of just compiling an extra module.
Using distribution provided kernels and things like overclock settings are a risk, because if they turn out to be not working correctly it also prevents you from booting other operating systems given that berryboot depends on the kernel.
Also, from my reading, berryboot uses splashfs for the root filesystem, so the OS that it loads will always be read-only. I would need all the write support in the distribution. Again, am I correct or there is something else?
Berryboot uses aufs to provide a writeable file system.
On disk there is the original Squashfs image, e.g. /images/operatingsystem.img and there is a /data/operatingsystem folder where any files you modify are stored.
These two are merged together and will look as one to the operating system. Can use the system as normal.

One additional advantage of keeping the original image and modfied files seperate is that it is easier to have more than one instance of the operating system, without it costing twice the disk space.
If you want a fresh Debian installation in addition to a version you modified, just select the os in berryboot and press "clone". It will use the same original image for both.

nijhawank
Posts: 23
Joined: Sat Aug 04, 2012 8:26 am

Re: dual boot understanding

Sat Aug 04, 2012 6:45 pm

Max wrote:
nijhawank wrote: So that meets one of my requirement to have the correct memory splitting but what about the kernel, I guess it always loads the berryboot kernel and if the selected distribution has a differently compiled kernel, some of the distribution feature may not work.
Additional kernels are not supported at the moment.
But there are only very few features that really need a seperate kernel instead of just compiling an extra module.
Using distribution provided kernels and things like overclock settings are a risk, because if they turn out to be not working correctly it also prevents you from booting other operating systems given that berryboot depends on the kernel.
Also, from my reading, berryboot uses splashfs for the root filesystem, so the OS that it loads will always be read-only. I would need all the write support in the distribution. Again, am I correct or there is something else?
Berryboot uses aufs to provide a writeable file system.
On disk there is the original Squashfs image, e.g. /images/operatingsystem.img and there is a /data/operatingsystem folder where any files you modify are stored.
These two are merged together and will look as one to the operating system. Can use the system as normal.

One additional advantage of keeping the original image and modfied files seperate is that it is easier to have more than one instance of the operating system, without it costing twice the disk space.
If you want a fresh Debian installation in addition to a version you modified, just select the os in berryboot and press "clone". It will use the same original image for both.
This is good. Thanks, it seems berryboot is the answer for me.

Are you the developer of berryboot? Can you tell, if berryboot is compiled with ARM hard float support?

Thanks for all the information friends. This is truly amazing and I really appreciate all you taking the time of your busy lifes and helping the community.

Max

Re: dual boot understanding

Sat Aug 04, 2012 6:59 pm

Are you the developer of berryboot? Can you tell, if berryboot is compiled with ARM hard float support?
Yes and yes.
Kernel and boot menu are compiled with a toolchain that defaults to hardfp (not that there is much to gain by that, given it doesn't really use floats, but doesn't hurt either).

nijhawank
Posts: 23
Joined: Sat Aug 04, 2012 8:26 am

Re: dual boot understanding

Sat Aug 04, 2012 7:21 pm

Max wrote:
Are you the developer of berryboot? Can you tell, if berryboot is compiled with ARM hard float support?
Yes and yes.
Kernel and boot menu are compiled with a toolchain that defaults to hardfp (not that there is much to gain by that, given it doesn't really use floats, but doesn't hurt either).
Thanks very much for your help and creating this nice software.

I can understand why loading a different kernel might not be possible. Is this because once the distribution specific kernel is loaded, there is no way to restore berryboot kernel on next reboot without the support from the loaded distribution?

On other note, do you think berryboot kernel is ok for running raspbmc and a generic linux distribution to act as a network file server etc.

Max

Re: dual boot understanding

Sat Aug 04, 2012 7:51 pm

nijhawank wrote: I can understand why loading a different kernel might not be possible. Is this because once the distribution specific kernel is loaded, there is no way to restore berryboot kernel on next reboot without the support from the loaded distribution?
Not in any automated way.
(can fix it by putting the card in another computer, and specifying a different kernel in config.txt manually. But is not something I can expect an average user to do. Need to have something foolproof)
On other note, do you think berryboot kernel is ok for running raspbmc and a generic linux distribution to act as a network file server etc.
it comes with openelec by default, which is similar to raspbmc.
Raspbmc should also work, if you convert it to squashfs format, but haven't tested it.

Generic distro should be ok, but suspect file server performance to be not too great compared to a normal NAS device with sata.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: dual boot understanding

Sat Aug 04, 2012 8:02 pm

nijhawank wrote:There's no raspberry pi specific documentation, what's supported, what's not.
A quick google for "uboot raspberry pi" brought me to this: http://kernelnomicon.org/?p=133
So, current state of affairs is raspberry-pi-uboot-20120621.tar.gz. It includes:

USB support
SD card support (FAT filesystem)
Support for built-in USB ethernet
Autoimport environment from uEnv.txt
Autorun of boot script (boot.scr)
And then http://kernelnomicon.org/?p=138
New build for Raspberry Pi. ChangeLog:

New firmware
Improved SD card performance
Added USB mass storage devices support
Added ext2 filesystem support (painfully slow with SD card, tolerable with USB memory stick)
Tarball: raspberry-pi-uboot-20120707.tar.gz
And so on. You should be able to use any of the "standard" U-boot commands to load and boot arbitrary kernels, in short.

Max

Re: dual boot understanding

Sat Aug 04, 2012 9:14 pm

tufty wrote: And so on. You should be able to use any of the "standard" U-boot commands to load and boot arbitrary kernels, in short.
But how do you issue the commands to boot the secondary operating system?
Does that requires a serial console cable hooked up to a second computer?
(your quote doesn't mention support for the Pi's framebuffer to display things on screen)

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: dual boot understanding

Sat Aug 04, 2012 9:49 pm

Max wrote:
tufty wrote: And so on. You should be able to use any of the "standard" U-boot commands to load and boot arbitrary kernels, in short.
But how do you issue the commands to boot the secondary operating system?
Does that requires a serial console cable hooked up to a second computer?
(your quote doesn't mention support for the Pi's framebuffer to display things on screen)

Yes, since the UBoot from gonzo ony supports:
USB Mass
USB Ethernet

No Videocore, no Keyboard, no mouse.

i tried his usb stack, plugging in a mouse or keyboard and it hangs.

there is no official u-boot for raspi. His goal is to boot NETBSD which needs a loader like U-Boot.

nijhawank
Posts: 23
Joined: Sat Aug 04, 2012 8:26 am

Re: dual boot understanding

Sun Aug 05, 2012 5:19 pm

Max wrote:
nijhawank wrote: I can understand why loading a different kernel might not be possible. Is this because once the distribution specific kernel is loaded, there is no way to restore berryboot kernel on next reboot without the support from the loaded distribution?
Not in any automated way.
(can fix it by putting the card in another computer, and specifying a different kernel in config.txt manually. But is not something I can expect an average user to do. Need to have something foolproof)
On other note, do you think berryboot kernel is ok for running raspbmc and a generic linux distribution to act as a network file server etc.
it comes with openelec by default, which is similar to raspbmc.
Raspbmc should also work, if you convert it to squashfs format, but haven't tested it.

Generic distro should be ok, but suspect file server performance to be not too great compared to a normal NAS device with sata.
Hi Max, I was reading about the android port for raspberry pi and was thinking the android kernel will be very different than other distrbutions like raspbian, openelec etc. So once it is released, we would need a way to boot into distribution specific kernel.
I think we can provide a way to boot distribution specific kernel but then the loaded distribution must restore the kernel to berryboot so that on next reboot berryboot takes control.
Most probably this option won't be automatic because this will require changing somewhere in the distribution init scripts.

Max

Re: dual boot understanding

Sun Aug 05, 2012 7:13 pm

nijhawank wrote: Hi Max, I was reading about the android port for raspberry pi and was thinking the android kernel will be very different than other distrbutions like raspbian, openelec etc. So once it is released, we would need a way to boot into distribution specific kernel.
Will have to see how well Android runs first, before deciding wheter it is worth adding.
It is unclear from the demo if any other application than gallery and youtube runs.
And whether or not any trick was used to get around the memory limitation (e.g. swapfile on usb hard disk).

Return to “Bare metal, Assembly language”