Opportunities, challenges, and power of media and information
Linux-without-a-bootloader
1. Linux without a boot loader – the
OMAP way!
OR
Why I stopped being scared of X-
loader and started using Linux
Nishanth Menon
25 August 2010
2. Introduction
Why do we need a bootloader?
Too many bootloaders, yet, not one that works
for me..
Heresy: What if Linux is used as a bootloader?
A single s/w package- Reduce maintenance.
New features – easier to borrow from Linux
It'd be kinda fun
Builds on ELC2010 SFO Greg Ungerer, Magnus
Damm 's work
2/
3. Agenda 1/2
Concepts of OMAP GP device boot load process
Why x-loader?
Content of a Linux image without bootloader
The tools
Tagger
Gpsign
Demo
3/
4. Agenda 2/2
What next? Using Linux as a bootloader
Problems with the Approach
Summary
Terminology
References
4/
5. Concepts of OMAP boot load process
X-loader U-Boot Kernel
I/O device
(Nand/MMC)
U-Boot Kernel
ROM Code “XIP” Memory mapped
device(NOR)
ROM
ROM
Peripheral
2nd U-Boot Kernel
(USB/UART)
SDRAM NOR SRAM
SDRAM NOR SRAM Scope of this presentation
5/
6. Why X-loader?
SRAM is tiny: 64K(OMAP3 GP), 32K(OMAP4)
“Traditional Bootloaders” are bloated!– e.g.
U-boot: beagleboard build is 196K!!
Barebox: first beagleboard version of
barebox was 36k, it is around 40+k now!
There is never going to be a solution as long as
we need to keep adding new features!
6/
7. What I love about X-loader
“shared code” with TI u-boot
Does the stuff (well.. mostly)
Simple code (usually!)
TINY.. well.. mostly so, until we started adding
FAT, MMC, USB...
TI mostly has some variant for every OMAP
7/
8. What I hate about X-loader
It does way more than what it needs to do the job
- “load and execute u-boot”
There is NO mainline x-loader code
Toooo many variants of x-loader.. There is a
broken up community of x-loader – each centered
around some silicon variant
I am gonna stop now..
8/
9. Do I REALLY need x-loader?
NO
There are alternatives: Psuedocode:
Switch cpsr to svc
Disable watchdog
Barebox? Enable uart
Copy image from x to sdram
my_own_stupid_bootloader.s Give control to image
Linux? But it is 3 megs big!!
Soln: Load it to SDRAM directly
9/
10. Basic things for Linux to boot on
OMAP?
Basic h/w configuration:
Make the SDRAM ready – clocks
configured
Very basic mux – we expect the kernel to
take care of it's own needs..
One serial port configured
Setup ATAGs as required for any Linux port of
ARM to boot
Load the kernel up in SDRAM
Ref: http://www.arm.linux.org.uk/developer/booting.php
10 /
11. Linux image without bootloader
Load address, size
gpsign
gpsign
Boot Configuration Header
Header
Disable watchdog
Disable watchdog
Configure one uart
Configure one uart
Sty Setup
Setup tagger
tagger
r0 ==00
r0
r1 ==mach ID
r1 mach ID
r2 ==ATAG address
r2 ATAG address
bzImage
piggy
make bzImage
make bzImage
zImage
11 /
13. Sty in the works
1 – the
setup Disable
WDT
Sty
Cache, int
disable
ATAG
2 – hand Setup
over to UART
piggy
piggy Setup
Uart mux
4- give 3-
control to zImage
uncompres
kernel Relocate atag to
s the real
First 16k memory
image
Uncompressed kernel
13 /
15. How does this GP image boot?
Load address OMAP
Size of image
2 OMAP
Figures out RomCode
Clock
where to
configuration
load
DDR
configuration
1 3- DPLLs
Configures Loads
GPMC CS0 clocks image
configuration 4 – gives
control
MMC
configuration
Configuration
Header SDRAM
SDRAM
image
There is more that happens in HS/EMU device..
15 /
17. Next steps 1/2: optimize
Choose a sane kernel configuration for the
environment you'd like to work on
If your board has ethernet, enable ethernet, use
nfs as rootfs
If you board has usb, you may want to try out
usbnet
Reduce statically built kernel drivers and have
only the kernel modules you need (if you dont
care for multimedia in your bootloader, why
have dspbridge, audio drivers enabled?)
17 /
18. Next steps 2/2: power features
Write your own custom shell scripts if your “users”
are interested in “u-boot like” environment, -e.g.
setenv/saveenv pair could be:
setenv() { x=$1;shift;export $x="$*";}
saveenv() { export>/etc/exported_vars;}
and the /etc/profile file uses that file..
Use kexec! With kexec you get bootm equivalent.
You can wrap kexec inside a bootm as well.
Remember you now have the power to do what you
can imagine without thinking how to port it..
18 /
19. Ok, so what's the catch? (1/2)
Deployment issues
Single bootimage requirement for multiple
board variants and (clocks sdrc, machid are
all coded in),
Training new users and re-training old users?
NAND technology and badblocks → with large
uImage, any bad block can make the image no
longer usable.. but we can debate that at a later
date ;)
19 /
20. Ok, so what's the catch? (2/2)
“MLO file” MMC with FAT partition on
OMAP3 has limitations of 128k sized image(so
not kernel or u-boot at least :(), but it will
become usable with OMAP4 -are there options?
Probably (see references)
So now we need to maintain and test kernel in
two defconfig configurations? - yeah maybe..
20 /
21. Summary
Linux without a bootloader provides a lot of
flexibilities
There are limitations as well – wont solve everyone's
problems.
Could be suited in a single platform environment
Not really hardcore tested solution beyond “lab
environment”
21 /
22. Terminology
XIP – Execute in Place
U-Boot – Das U-Boot – the Universal Boot
loader
X-loader – TI variant of U-Boot. A stripped
down version
Barebox – Somewhere between Linux and U-
boot – can also be used as a boot loader
Busybox – a filesystem with tiny versions of
standard unix utils
OMAP-Uboot-utils – a bunch of utilities to do
the grunt workof this presentation
22 /
23. References
ARM linux kernel boot requirements:
http://www.arm.linux.org.uk/developer/booting.php
ELC2010 work (SFO)
Greg Ungerer: Linux without a bootloader
http://elinux.org/images/7/7b/LinuxWithoutABootLoader.pdf
Magnus Damm: Linux as a bootloader
http://elinux.org/images/2/2f/ELC-2010-Damm-Kexec.pdf
Grant Likely: Device tree support
http://elinux.org/images/b/b6/ARM_Device_Tree_Status_Report.pdf
Ghorai Sukumar: eMMC boot
http://omapedia.org/wiki/E-MMC_boot#You_can_boot_omap3630_without_x-loader
Kexec: http://www.ibm.com/developerworks/linux/library/l-kexec.html
Omap u-boot utils: http://code.google.com/p/omap-u-boot-utils/
23 /
24. Backup
Reference code:
http://github.com/nmenon/uomapfs
branch: ldemo
You get kexec, linux-omap omap-uboot-fs and a
bunch of reference configuration files for
SDP3630 which can be easily customized and
improved for development platforms.
24 /