250 likes | 386 Views
The success's road. Bootloaders. www.farsight.com.cn. What is bootloader?. Bootloader It is just the component that boots a device and launches the main software Monitor
E N D
The success's road Bootloaders www.farsight.com.cn
What is bootloader? • Bootloader • It is just the component that boots a device and launches the main software • Monitor • In addition to booting capabilities, it provides a command-line interface that can be used for debugging, reading/writing memory, flash reprogramming, configuring, etc. • Usually we can refer to both types of software as "bootloaders“ • Note: Linux bootloader is a part of zImage which can decompress kernel image and start up.
Bootloaders for Linux • Setting up bootloader is a task common to allLinux systems • It is a special task for embedded Linux systems • Completely different bootloaders • PPC and x86 have well known and establishedbootloaders • Other architectures have few or no standardbootloaders • Relied on bootloaders provided by HW manufacture • Open Source or Commercial bootloaders
x86 Bootloaders • There are 2 main bootloaders used for x86: LILO and GRUB • LILO: http://brun.dyndns.org/pub/linux/lilo/ • GRUB: http://www.gnu.org/software/grub/ • The Makefiles of LILO and GRUB are not built to allow cross-compilation. An x86-based host is most required • Other bootloaders: Rolo, EtherBoot, LinuxBIOS • Less known bootloaders • Using under certain circumstances
ARM Bootloaders • U-Boot is becoming the standard ARM bootloader • Armboot merged into ppcboot and become u-boot • Support arm720, arm920, arm926, sa1100, xscale • http://armboot.sourceforge.net/ • Blob • blob was introduced as the bootloader for the LART hardware project • blob has been ported to many other ARM-based systems • http://www.lart.tudelft.nl/lartware/blob • Redboot can support
PowerPC Bootloaders • U-boot is a main bootloader for PowerPC • Ppcboot is the former of u-boot • Can support tens of PowerPC boards. • Support PPC 4xx, 5xx, 8xx, 82xx, 7xx, 74xx… • OpenBIOS • The free software of IEEE 1275-1994 compatible firmware • Support some IBM PPC405 boards. • Redboot can support
MIPS Bootloaders • YAMON • A standard bootloader for MIPS-based embedded Linux systems • A free software of MIPS company • Support most of MIPS systems • PMON • may be useful as an initial codebase • need to port it to your target before using it • U-boot and Redboot can support
Others • SuperH • sh-boot is the main bootloader for SH-based embedded Linux systems • Redhat can support • M68K • Redhat can support • No standard bootloader
Commercial bootloaders • Board manufacturer can provide • Source code for development board • Binary for OEM board • Usually it is confidential to customers. • You can get support and documentation.
Booting from Network • Setting up a target for network boot is ideal during the early stages of development • The simplest way to boot your target from the network is to use : • BOOTP/DHCP /etc/dhcpd.conf # /etc/init.d/dhcpd start • TFTP /etc/xinetd.d/tftp # /etc/init.d/xinetd restart • NFS /etc/exports # /etc/init.d/nfs start
Booting from disk devices • Disk devices • IDE hard disks • SCSI disks • Compact Flash • Disk On Chip • USB storage • They are in common use on most X86 systems • Vmlinuz is placed in /boot • Boot with lilo or grub • Patch is needed for DOC
Booting from Flash Memory • NOR Flash • Random access Flash memory • Bootloader is located at bottom or top end of the FLASH. • NAND Flash • Not random access flash memory • Bootloader can copy itself and zImage into ram and run. • Usually bootloader is very little. • MTD device drivers can support NOR and NAND flash.
RedBoot • RedBoot was originally for booting eCos,which now is licensed through GPL • RedBoot is a open-sourcebootloader that supports all architectures • It is fairly well documented • http://sources.redhat.com/redboot/ • We don’t talk about Redboot in detail here.
U-boot Overview • Wolfgang Denk, DENX Software Engineering • Free Software, GNU General Public License • Start from PPCboot project, create ARMBoot Project, then create U-boot Project. • http://sourceforge.net/projects/u-boot • http://lists.sourceforge.net/lists/listinfo/u-boot-users/ • http://www.denx.de/re/DPLG.html
U-boot Overview • U-Boot can be installed in a boot ROM and used to initialize and test the hardware or to download and run application code. • U-Boot aims at becoming the standard bootloader • The richest, most flexible, and most activelydeveloped open-source bootloader • Supports 100 different PPC-based boards, more thana dozen ARM-based boards, a handful of x86-based boards, and more… • Capable of booting a kernel through TFTP, from an IDE or SCSI disk, and from a DOC
U-boot README • The README file included with the package, for example, covers the use of U-Boot extensively. • Among other things, it discusses the package's source code layout, the available build options, U-Boot's command set, and the typical environment variables used in U-Boot. • In the following, I will cover the essential aspects of U-Boot and provide practical examples of its use
Source Code Analysis • Platform dependence • board, cpu, lib_ppc, lib_arm, include… • Platform independence • common, net, fs, drivers… • Tools and Documentation • tools, doc
Booting with U-Boot • U-Boot is properly installed on your target and connected through a serial line. • Boot message can output to serial terminal emulator. • Use help command to understand more u-boot commands =>help =>help cp • U-Boot is strict in its argument parsing. It expects most values to be provided in hexadecimal form • U-Boot accepts any unique subset of characters that starts a command name
Using Environment Variables • To view the current values of the environment variables =>printenv • Configure common variables, their meaning are discussed in README. =>setenv ipaddr 192.168.1.100 =>setenv serverip 192.168.1.1 =>setenv kernel_addr 40000 • Add new variable =>setenv nfscmd “bootm \$(kernel_addr) ” =>printenv nfscmd nfscmd=bootm $(kernel_addr) • Delete variables =>setenv nfscmd • Save variables, remember to check all variables =>saveenv
Creating Boot Scripts • boot scripts are actually environment variables containing a set of U-Boot command sequences • For example: nfscmd • Run boot scripts by using a combination of the run command and the ; (semicolon) operator =>run nfscmd • Set bootcmd to autoboot =>setenv bootcmd “run nfscmd” Or set bootcmd to contain the entire boot script instead of using run nfscmd
Booting Commands • Download images with “tftp” and go =>tftp 30008000 zImage =>go 30008000 • Booting u-boot image • =>bootm 00040000 • Booting Using BOOTP =>bootp • Booting from ramdisk, the ramdisk.img address should be given =>bootm 00040000 00200000 • Booting from Compact Flash =>ide =>diskboot =>disk
Updating U-Boot • U-boot can be used to update itself because it runs from RAM • Download the U-Boot image into RAM =>tftp 30100000 u-boot.bin Or using serial port =>loadb 30100000 • Unprotect the flash region where U-Boot is located and erase it =>protect off 0000000 0003FFFF =>erase 0000000 0003FFFF • Copy the new bootloader to its final destination =>cp.b 30100000 00000000 <filesize>
Porting U-boot • U-boot can support PowerPC, ARM, XSCALE and x86 Processors. More and more boards are supported now. • Porting is very easy if you have a board which is very similar with a supported board. • Make sure if the processor and I/O devices of your board is supported by u-boot . You should be aware of your hardware platform before porting u-boot. • Add board specific files, configure and build it.
成功之路 www.farsight.com.cn谢谢!