24
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

Linux-without-a-bootloader

Embed Size (px)

DESCRIPTION

Done as part of OMAP Tutorial Hourhttp://omapedia.org/wiki/Tutorial_Hour_Topics#Aug_25th_at_8:30_am_CST_.28Central_Standard_Time.29

Citation preview

Page 1: Linux-without-a-bootloader

Linux without a boot loader – the OMAP way!

OR

Why I stopped being scared of X-loader and started using Linux

Nishanth Menon25 August 2010

Page 2: Linux-without-a-bootloader

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 /

Page 3: Linux-without-a-bootloader

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 /

Page 4: Linux-without-a-bootloader

Agenda 2/2

What next? Using Linux as a bootloader

Problems with the Approach

Summary

Terminology

References

4 /

Page 5: Linux-without-a-bootloader

Concepts of OMAP boot load process

ROM Code

X-loader U-Boot Kernel

KernelU-Boot“XIP”

I/O device(Nand/MMC)

Memory mappeddevice(NOR)

2nd U-Boot Kernel Peripheral (USB/UART)

NORNOR

SRAMSRAM

SDRAMSDRAM

ROMROM

Scope of this presentation

5 /

Page 6: Linux-without-a-bootloader

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 /

Page 7: Linux-without-a-bootloader

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 /

Page 8: Linux-without-a-bootloader

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 /

Page 9: Linux-without-a-bootloader

Do I REALLY need x-loader?

There are alternatives: Barebox? my_own_stupid_bootloader.s Linux? But it is 3 megs big!! Soln: Load it to SDRAM directly

NOPsuedocode:Switch cpsr to svcDisable watchdogEnable uartCopy image from x to sdramGive control to image

9 /

Page 10: Linux-without-a-bootloader

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 SDRAMRef: http://www.arm.linux.org.uk/developer/booting.php

10 /

Page 11: Linux-without-a-bootloader

Linux image without bootloader

bzImage

Sty

BootHeader

zImage

piggy

Disable watchdogConfigure one uartSetup r0 = 0r1 = mach IDr2 = ATAG address

Disable watchdogConfigure one uartSetup r0 = 0r1 = mach IDr2 = ATAG address

Configuration Header

Load address, sizegpsigngpsign

taggertagger

make bzImagemake bzImage

11 /

Page 12: Linux-without-a-bootloader

How does tagger work?

taggertagger

bzImagebzImageConfig file

-tags- machid

Config file-tags- machid

bzImage

ATAG

Sty

Marker:MACHID

Marker:Size

Sty template

12 /

Page 13: Linux-without-a-bootloader

zImage

piggy

Sty in the works

ATAG

Sty

DisableWDT

Cache, intdisable

SetupUART

Setup Uart mux

Relocate atag toFirst 16k memory

Uncompressed kernel

1 – the setup

2 – hand over to piggy

3- uncompress the real image

4- give control to kernel

13 /

Page 14: Linux-without-a-bootloader

GP Sign – Boot Header

gpsigngpsign

imageimageConfig file

- clock config- ddr config

Config file- clock config- ddr config

Clockconfiguration

DDRconfiguration

GPMC CS0configuration

MMCconfiguration

ConfigurationHeader

Load addressSize of image

image

14 /

Page 15: Linux-without-a-bootloader

How does this GP image boot?

Clockconfiguration

DDRconfiguration

GPMC CS0configuration

MMCconfiguration

ConfigurationHeader

Load addressSize of image

image

OMAPRomCode

SDRAMSDRAM

DPLLs1 Configures clocks

2Figures out where to load

3 -Loads image

4 – gives control

OMAP

There is more that happens in HS/EMU device..15 /

Page 16: Linux-without-a-bootloader

Demo

16 /

Page 17: Linux-without-a-bootloader

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 /

Page 18: Linux-without-a-bootloader

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 /

Page 19: Linux-without-a-bootloader

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 /

Page 20: Linux-without-a-bootloader

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 /

Page 21: Linux-without-a-bootloader

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 /

Page 22: Linux-without-a-bootloader

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 /

Page 23: Linux-without-a-bootloader

References ARM linux kernel boot requirements:

http://www.arm.linux.org.uk/developer/booting.php

ELC2010 work (SFO) Greg Ungerer: Linux without a bootloaderhttp://elinux.org/images/7/7b/LinuxWithoutABootLoader.pdf Magnus Damm: Linux as a bootloaderhttp://elinux.org/images/2/2f/ELC-2010-Damm-Kexec.pdf Grant Likely: Device tree supporthttp://elinux.org/images/b/b6/ARM_Device_Tree_Status_Report.pdf

Ghorai Sukumar: eMMC boothttp://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 /

Page 24: Linux-without-a-bootloader

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 /