Presentation is loading. Please wait.

Presentation is loading. Please wait.

Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University.

Similar presentations


Presentation on theme: "Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University."— Presentation transcript:

1 Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University

2 SILICON VALLEY UNIVERSITY CONFIDENTIAL 2 Spring 2014 Section 10 Bootloader What is a Bootloader?  Responsible for loading an Operating System Kernel.  Responsible for loading Kernel infrastructure ( i.e. File System ). RAM-based File System to mount the root File System.  Start Kernel execution (init Process, System Daemons). Linux Server Bootloader  System Firmware ( BIOS ) Configuration of hardware devices. Program System Memory Controllers. Initialize Processor Caches. Enables Hardware Devices. Network Boot Infrastructure. Interrupt Routing details.  Load Kernel / Load File System / Start Kernel Embedded Linux Bootloader  Performs System Firmware tasks through Bootloader.  Load Kernel / Load File System / Start Kernel

3 SILICON VALLEY UNIVERSITY CONFIDENTIAL 3 Spring 2014 Section 10 Bootloader  Linux In Desktop PC – Power Up BIOS in host (X86 system)  Program core system components (RAM Controllers, CPU State / Registers), APIC Tables (Interrupt Routing), Flush Processor Cache.  POST (Power-On-Self-Test). BIOS access the hard drive Master Boot Record. In MBR is GRUB, Linux bootloader in Linux distributions.  Load Kernel Image, Load File System, Starts Kernel. GRUB provides choice to boot one of multiple OS (i.e. Linux or Windows).  /boot/grub/grub.conf contains GRUB configuration file with menu selection (i.e. which OS) and disk partition containing Linux Kernel and the root file system. GRUB loads Linux Kernel from /boot directory ( contains Linux Kernel(s), Kernel System Map(s), initrd (initial Ramdisk with drivers), Kernel config file(s) from Kernel build ).  Initrd is temporary root file system with executables (i.e. insmod) and drivers to mount the root file system on disk. After mounting, initrd is unmounted and memory freed.  NOTE: In embedded Linux systems, initrd is the final root file system. Linux Kernel starts init process. Init process is the root/parent process of all other process executing on Linux. Init process runs script, /etc/rc.d/rc.sysinit. Init process runs script, /etc/inittab, to execute scripts to start processes based on the runlevel.

4 SILICON VALLEY UNIVERSITY CONFIDENTIAL 4 Spring 2014 Section 10 Bootloader  Linux In Desktop PC – Power Up

5 SILICON VALLEY UNIVERSITY CONFIDENTIAL 5 Spring 2014 Section 10 Bootloader  Embedded Linux Boot Process – Bootloader First stage bootloader located in small ROM (2K or 4K Bytes). ROM bootloader loads second stage bootloader (i.e. Redboot) from fixed address from flash to RAM. ROM bootloader must have flash driver.  NAND Flash –large, less cost, cannot execute-in-place.  NOR Flash – smaller, execute-in-place (i.e. Second Stage Bootloader execute from NOR). Second stage bootloader will initializes CPU, MMU, on-chip devices, configures memory map.  POST ( Power-On-Self-Test ). Load the Linux Kernel and RAMDisk from flash to RAM:  Automatically decompress the Linux Kernel and RAMDisk.  Manually interrupt bootloader ( ) and use tftp to load Linux Kernel from server.  After Linux Kernel starts running, bootloader is no longer in RAM. Bootloader configuration (i.e. IP address, host system (server) IP address) saved in high address space in flash. Only for development and testing. Bootloader configured with the starting address space in flash where Linux is located and where RAMDisk is located. Bootloader executes a jump to the Kernel code to configure the microprocessor registers and start_kernel() function. Bootloader architecture specific. Bootloader has memory map for the flash and for loading Kernel and RAMDisk and will be different for another microcontroller.

6 SILICON VALLEY UNIVERSITY CONFIDENTIAL 6 Pro Linux Embedded Systems, Gene Sally Spring 2014 Section 10 Bootloader 

7 SILICON VALLEY UNIVERSITY CONFIDENTIAL 7 Spring 2014 Section 10 Bootloader  Embedded Linux: Execution Context  1 st Stage ROM Bootloader Assembly Code. Loads 2 nd Stage Bootloader into RAM.  2 nd Stage RAM Bootloader Lack of Execution Context: No Resources No RAM stack structure for C calling conventions.  Higher-level language, “C”, cannot run. Creates the Execution Context  Initialize RAM timings in the memory controller circuitry.  C Code can be used: Allow Bootloader to be written in C Code, instead of Assembly Language. Flush the processor caches. Program up the CPU registers with default values. Determine hardware installed within system and supply to Linux Kernel in architectual-dependent software tables. Built Independent from Linux Kernel.

8 SILICON VALLEY UNIVERSITY CONFIDENTIAL 8 Spring 2014 Section 10 Bootloader  Embedded Bootloaders First task is porting Bootloader to controller board. Diagnostic routines, system configuration options.  LILO (LInux LOader) Commercial Linux Distributions. Desktop PC (Intel x86) Architecture. lilo.conf: Used by lilo Configuration Utility when lilo image created. boot = /dev/hda timeout=50 default=linux image=/boot/myLinux-2.6.11.1 label=linux initrd=/boot/myInitrd-2.6.11.1.img read-only append="root=LABEL=/“ other=/dev/hda1 optional label=that_other_os MBR in first hard drive /dev/hda. Primary boot image. Initial RAMDisk. Linux command line passed to Linux Kernel. Dual boot, second boot image.

9 SILICON VALLEY UNIVERSITY CONFIDENTIAL 9 Spring 2014 Section 10 Bootloader  GRUB (Grand Unified Bootloader) Commercial Linux Distribution. Enhanced features not found in Lilo.  Understand File Systems and Kernel Image Formats. Read and Modify its configuration at boot time. Network boot. Kernel command line interface at boot time. default=0 timeout=3 splashimage=(hd0,1)/grub/splash.xpm.gz title Fedora Core 2 (2.6.9) root (hd0,1) kernel /bzImage-2.6.9 ro root=LABEL=/ rhgb proto=imps quiet initrd /initrd-2.6.9.img title Fedora Core (2.6.5-1.358) root (hd0,1) kernel /vmlinuz-2.6.5-1.358 ro root=LABEL=/ rhgb quiet title That Other OS rootnoverify (hd0,0) chainloader +1 Root Filesystem where all files are located. First partition of first drive. Kernel image with the Kernel command line. Initial RAMDisk.

10 SILICON VALLEY UNIVERSITY CONFIDENTIAL 10 Spring 2014 Section 10 Bootloader  Coreboot (LinuxBIOS) Used in x86 system without PC BIOS. Performs the function of PC BIOS (initial system bringup, interrupt-routing assignment, device initialization). Coreboot typically loads a Linux kernel, but it can load any other stand-alone ELF executable. Written for speed and reliability for boot process.  Boots Linux in seconds.  Yamon MIPs ROM Monitor.  Bootstrap program in ROM that initializes the hardware and boots the board Operating System during power on.

11 SILICON VALLEY UNIVERSITY CONFIDENTIAL 11 Spring 2014 Section 10 Bootloader  RedBoot Red Hat Embedded Debug and Bootstrap firmware. Open source application that uses the eCos real-time operating system Hardware Abstraction Layer to provide bootstrap firmware for embedded Linux systems.  eCos (embedded configurable operating system).  One process with multiple threads.  Customizable to precise application requirements of run-time performance and hardware needs.  Memory size in the tens to hundreds of kilobytes, or with real- time requirements.  Used on hardware with too little RAM to support embedded Linux (currently needs a minimum of about 2 MB of RAM, not including application and services). Provides an interactive command line interface to allow management of the Flash images, image download, RedBoot configuration, etc., accessible via serial or Ethernet. Boot scripts can be stored in Flash allowing loading of images from Flash or a TFTP server.

12 SILICON VALLEY UNIVERSITY CONFIDENTIAL 12 Spring 2014 Section 10 Bootloader  U-Boot Most actively developed open source embedded bootloader. Supports ARM, x86, Motorola 68K, MIPS, PowerPC, etc. TFTP Kernel over network connection, USB, and Flash. Supports filesystems: Cramfs (Linux), ext2 (Linux), FAT (Microsoft), JFF2 (Linux). U-boot and Linux Kernel retrieved to local storage (RAM).

13 SILICON VALLEY UNIVERSITY CONFIDENTIAL 13 Spring 2014 Section 10 Bootloader  Network File Server ( NFS ). Kernel can mount Root FileSystem from remote Network File System (NFS) Server. /etc/exports  Describes the directories that each host or set of hosts can access.  /data/root/virtex4 192.168.1.201(rw, no_root_squash)  /data/root/virtex4: Directory of the Root FileSystem (same structure as Linux “/” directory.  192.168.1.201: Remote system.  rw: Remote system has read and write privilege.  no_root_squash: Allows remote system to access directory with root privilege. /usr/sbin/exportfs –a  Maintain the current table of exported file systems for NFS.  List of all file systems named in /etc/exports. /sbin/service nfs restart  Restart the NFS daemons (portmap, lockd, mountd, rquotad, statd).  File containing exported file system are read by the mountd daemon.

14 SILICON VALLEY UNIVERSITY CONFIDENTIAL 14 Spring 2014 Section 10 Bootloader  Network File Server ( NFS ) Access Control Files control access to the NFS server.  Entry Format: daemon_list : client_list [ : shell_command ] /etc/hosts.deny  Access will be denied when a (daemon,client) pair matches an entry. /etc/hosts/allow  Access will be granted when a (daemon,client) pair matches an entry. Access Control Files Entries: portmap: ALL Converts TCP/IP port numbers to RPC program numbers. lockd: ALL A daemon that is not necessary with modern kernels. mountd: ALL Checks for access permission for the exported filesystem. rquotad: ALL An RPC server providing user quota information for remote users. statd: ALL Implements the Network Status Monitor (NSM) RPC protocol.

15 SILICON VALLEY UNIVERSITY CONFIDENTIAL 15 Spring 2014 Section 10 Bootloader  U-Boot Environment Variables  Similar to how environment variables are used in UNIX shells (i.e. bash), but used in U-Boot environment.  Saved in flash and copied to RAM when U-Boot starts. GTA01Bv4 # printenv bootargs= bootdelay=3 baudrate=115200 usbtty=cdc_acm bootargs_base=rootfstype=jffs2 root=/dev/mtdblock4 console=ttySAC0,115200 console=tty0 loglevel=8 stdin=serial stdout=serial stderr=serial dontask=y bootcmd=setenv bootargs ${bootargs_base} ${mtdparts}; bootm 0x30100000 menu_1=Set console to USB: setenv stdin usbtty; setenv stdout usbtty; se menu_2=Set console to serial: setenv stdin serial; setenv stdout serial; \ setenv stderr serial menu_3=Power off: neo1973 power-off... Environment size: 766/16380 bytes

16 SILICON VALLEY UNIVERSITY CONFIDENTIAL 16 Spring 2014 Section 10 Bootloader  U-boot Environment Variables for NFS. bootargs: Environment Variable automatically passed to Linux Kernel.  Display Boot Arguments used by the Kernel $ cat /proc/cmdline => setenv ipaddr 192.168.100.6 => setenv serverip 192.168.1.1 => setenv netmask 255.255.0.0 => setenv hostname canyonlands => setenv rootpath /opt/eldk-4.2/ppc_4xx => saveenv => setenv ipaddr 192.168.100.6 => setenv serverip 192.168.1.1 => setenv netmask 255.255.0.0 => setenv hostname canyonlands => setenv rootpath /opt/eldk-4.2/ppc_4xx => saveenv => setenv nfsargs 'root=/dev/nfs rw nfsroot=${serverip}:${rootpath}‘ => setenv bootargs ${nfsargs} ip=${ipaddr}:${serverip}:${serverip}:${netmask}:${hostname}::off Assigning variable “bootargs” without environment variables: => setenv bootargs root=/dev/nfs rw nfsroot=192.168.1.1:/opt/eldk-4.2/ppc_4xx ip=192.168.100.6:192.168.1.1:192.168.1.1:255.255.0.0:canyonlands::off

17 SILICON VALLEY UNIVERSITY CONFIDENTIAL 17 Spring 2014 Section 10 Bootloader  Redboot  Command Set Structured around the Bootstrap Environment.  Designed to be Simple to Use and Remember.  Class of Commands: Program Loading and Execution. Flash image and Configuration Management. Miscellaneous Commands.  RedBoot> COMMAND [-S]... [-s val]... Operand -s: A boolean switch. The behavior of the command will differ depending on the presence of the switch. -s val: A qualified value. The letter “s” introduces the value, qualifying its meaning. Multiple commands may be entered on a single line, separated by the semi- colon “;” character. => setenv ipaddr 192.168.100.6 => setenv serverip 192.168.1.1 => setenv netmask 255.255.0.0 => setenv hostname canyonlands => setenv rootpath /opt/eldk-4.2/ppc_4xx => saveenv

18 SILICON VALLEY UNIVERSITY CONFIDENTIAL 18 Spring 2014 Section 10 Bootloader  Redboot => setenv ipaddr 192.168.100.6 => setenv serverip 192.168.1.1 => setenv netmask 255.255.0.0 => setenv hostname canyonlands => setenv rootpath /opt/eldk-4.2/ppc_4xx => saveenv RedBoot> help Manage aliases kept in FLASH memory alias name [value] Set/Query the system console baud rate baudrate [-b ] Manage machine caches cache [ON | OFF] Display/switch console channel channel [-1| ] Display disk partitions disks Display (hex dump) a range of memory dump -b [-l ] [-s] Execute an image - with MMU off exec [-w timeout] [-b [-l ]] [-r [-s ]] [-c "kernel command line"] [ ] Manage flash images fis {cmds} Manage configuration kept in FLASH memory fconfig [-i] [-l] [-n] [-f] [-d] | [-d] nickname [value].... Execute code at a location go [-w ] [-c] [-n] [entry] Help about help? help [ ] Set/change IP addresses ip_address [-l [/ ]] [-h ] Load a file load [-r] [-v] [-d] [-c ] [-h ] [-m {TFTP | HTTP | {x|y}MODEM | disk}] [-b ] Network connectivity test ping [-v] [-n ] [-t ] [-i <IP_addr] -h Reset the system reset Display RedBoot version information version Display (hex dump) a range of memory x -b [-l ] [-s]

19 SILICON VALLEY UNIVERSITY CONFIDENTIAL 19 Spring 2014 Section 10 Bootloader  Redboot RedBoot> fconfig -l Run script at boot: true Boot script:.. fis load ramdisk.. fis load zImage.. exec -r 0x800000 -s 0x300000 Boot script timeout (1000ms resolution): 1 Use BOOTP for network configuration: false Gateway IP address: 0.0.0.0 Local IP address: 192.168.1.200 Local IP address mask: 0.0.0.0 Default server IP address: 0.0.0.0 DNS server IP address: 0.0.0.0 Set eth0 network hardware address [MAC]: true eth0 network hardware address [MAC]: 0x00:0x00:0x00:0x00:0x4C:0x33 GDB connection port: 9000 Force console for special debug messages: false Network debug at boot time: false RedBoot> => setenv ipaddr 192.168.100.6 => setenv serverip 192.168.1.1 => setenv netmask 255.255.0.0 => setenv hostname canyonlands => setenv rootpath /opt/eldk-4.2/ppc_4xx => saveenv

20 SILICON VALLEY UNIVERSITY CONFIDENTIAL 20 Spring 2014 Section 10 Bootloader  Redboot... Resetting. +Ethernet eth0: MAC address 00:00:00:00:4c:33 IP: 192.168.1.200/255.255.255.0, Gateway: 0.0.0.0 Default server: 0.0.0.0, DNS server IP: 0.0.0.0 RedBoot(tm) bootstrap and debug environment [ROMRAM] Non-certified release, version v2_0 - built 23:18:18, Jan 15 2006 Platform: Cirrus Logic EDB9302 Board (ARM920T) Rev A Copyright (C) 2000, 2001, 2002, Red Hat, Inc. RAM: 0x00000000-0x02000000, 0x00041e48-0x01fdd000 available FLASH: 0x60000000 - 0x60400000, 32 blocks of 0x00020000 bytes each. == Executing boot script in 1.000 seconds - enter ^C to abort RedBoot> fis load ramdisk RedBoot> fis load zImage RedBoot> exec -r 0x800000 -s 0x300000 Using base address 0x00080000 and length 0x0017b380 Uncompressing Linux............................................................. => setenv ipaddr 192.168.100.6 => setenv serverip 192.168.1.1 => setenv netmask 255.255.0.0 => setenv hostname canyonlands => setenv rootpath /opt/eldk-4.2/ppc_4xx => saveenv

21 SILICON VALLEY UNIVERSITY CONFIDENTIAL 21 Spring 2014 Section 10 Bootloader  Redboot  NFS Configuration. fis load zImage exec -c "ip=192.168.1.200:192.168.1.230:192.168.1.230:255.255.255.0::eth0:off ethaddr=00:00:00:00:4c:33 root=/dev/nfs rw nfsroot=192.168.1.230:/tftpboot/initrd noinitrd rootdelay=2" => setenv ipaddr 192.168.100.6 => setenv serverip 192.168.1.1 => setenv netmask 255.255.0.0 => setenv hostname canyonlands => setenv rootpath /opt/eldk-4.2/ppc_4xx => saveenv

22 SILICON VALLEY UNIVERSITY CONFIDENTIAL 22 Spring 2014 Section 10 Bootloader  Redboot  NFS Configuration.... eth0: generated random MAC address d2:21:b6:29:45:70. IP-Config: Complete: device=eth0, addr=192.168.1.200, mask=255.255.255.0, gw=192.168.1.230, host=192.168.1.200, domain=, nis-domain=(none), bootserver=192.168.1.230, rootserver=192.168.1.96, rootpath= Waiting 2sec before mounting root device... Looking up port of RPC 100003/2 on 192.168.1.96 Looking up port of RPC 100005/1 on 192.168.1.96 VFS: Mounted root (nfs filesystem). Freeing init memory: 112K init started: BusyBox v1.00 (2004.12.18-13:12+0000) multi-call binary Please press Enter to activate this console. BusyBox v1.00 (2004.12.18-13:12+0000) Built-in shell (ash) Enter 'help' for a list of built-in commands. ~ # => setenv ipaddr 192.168.100.6 => setenv serverip 192.168.1.1 => setenv netmask 255.255.0.0 => setenv hostname canyonlands => setenv rootpath /opt/eldk-4.2/ppc_4xx => saveenv


Download ppt "Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University."

Similar presentations


Ads by Google