Published on

Done as part of OMAP Tutorial Hour

Published in: News & Politics, Technology


  1. 1. Linux without a boot loader – theOMAP way!ORWhy I stopped being scared of X-loader and started using Linux Nishanth Menon 25 August 2010
  2. 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  Itd be kinda fun Builds on ELC2010 SFO Greg Ungerer, Magnus Damm s work 2/
  3. 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. 4. Agenda 2/2 What next? Using Linux as a bootloader Problems with the Approach Summary Terminology References 4/
  5. 5. Concepts of OMAP boot load process X-loader U-Boot Kernel I/O device (Nand/MMC) U-Boot KernelROM 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. 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. 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. 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. 9. Do I REALLY need x-loader? NOThere 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. 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 its own needs.. One serial port configured Setup ATAGs as required for any Linux port of ARM to boot Load the kernel up in SDRAMRef: 10 /
  11. 11. Linux image without bootloader Load address, size gpsign gpsign Boot Configuration HeaderHeader 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 addressbzImage piggy make bzImage make bzImage zImage 11 /
  12. 12. How does tagger work? Sty tagger tagger ATAG bzImage Sty template Config file Config filebzImage bzImage -tags -tags - -machid Marker: machid Size Marker: MACHID 12 /
  13. 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 mux4- give 3-control to zImage uncompreskernel Relocate atag to s the real First 16k memory image Uncompressed kernel 13 /
  14. 14. GP Sign – Boot Header Load address Size of image Clock configuration gpsign gpsign DDR configuration GPMC CS0 configuration Config file Config file MMCimage image - -clock config clock config configuration - -ddr config ddr config Configuration Header image 14 /
  15. 15. How does this GP image boot?Load address OMAPSize 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 configurationConfiguration Header SDRAM SDRAM image There is more that happens in HS/EMU device.. 15 /
  16. 16. Demo 16 /
  17. 17. Next steps 1/2: optimize Choose a sane kernel configuration for the environment youd 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. 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. 19. Ok, so whats 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. 20. Ok, so whats 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. 21. Summary Linux without a bootloader provides a lot of flexibilities There are limitations as well – wont solve everyones problems. Could be suited in a single platform environment Not really hardcore tested solution beyond “lab environment” 21 /
  22. 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. 23. References ARM linux kernel boot requirements: ELC2010 work (SFO)  Greg Ungerer: Linux without a bootloader  Magnus Damm: Linux as a bootloader  Grant Likely: Device tree support Ghorai Sukumar: eMMC boot Kexec: Omap u-boot utils: 23 /
  24. 24. Backup Reference code: 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 /