Bootload Design
Bootload Design
Bootload Design
By
Sumanth Vidyadhara
(Technical Architect, Wipro Technologies) [email protected] And
Arun Patil
(Project Lead, Wipro Technologies) [email protected]
Page 2 of 13
Overview:
A good boot loader is an essential component of any embedded system and any design deficiencies can lead to a system that is slow on b and performance. This tutorial oot would cover the best practices in boot loader design. First section is a summary of the basic assumptions about the reader used throughout this paper. Definitions contain a description of terms used in the context of this paper. Boot process gives an overview of boot procedure in embedded system. Initial Startup explains the behavior of CPU after power on reset, the issues faced during startup and some suggested solutions to those issues. Boot Loader Feature requirement, explains the features or enhancements that can be added to make boot loader more efficient.
Assumptions:
The main assumption for this paper is that the reader has a good understanding of embedded systems. A good knowledge of hardware platform and processor architecture is also necessary. This paper is to provide the reader with a good starting point in designing an effective boot loader for various target platforms. The design alternatives presented in this paper is just the tip of the iceberg and there are other ways as well for an effective design.
Page 3 of 13
Definitions:
Boot Device: This typically is a Flash device which holds the Firmware image. Ex: Compact flash, NAND flash. Boot Window: After reset CPU jumps to the reset vector. The reset vector is usually mapped to a boot device. The CPU fetches and executes code from this boot device. This initial execution environment is termed as the boot window. JTAG: Joint Test Action Group, JTAG also allows the internal components of the device (the CPU, for example ) to be scanned. This means you can use JTAG to debug embedded devices by allowing access to any part of the device that is accessible via the CPU, and still test at full speed. This has since become a standard emulation debug method used by silicon vendors. JTAG can also provide system level debug capability. Having extra pins on a device provides additional system integration capabilities for benchmarking, profiling, and system level breakpoints. MIU: Memory Interface unit is an interface between the CPU and the memory. This controls the data transfer to and from the memory. PLL: Phase locked loop, an electronic circuit that controls an oscillator so that it maintains a constant phase angle (i.e., lock) on the frequency of an input, or reference, signal. A PLL ensures that a communication signal is locked on a specific frequency and can also be used to generate, modulate and demodulate a signal and divide a frequency. UART: Universal asynchronous receiver transmitter handles the asynchronous serial communication.
Page 4 of 13
Boot Process:
Power on Reset
Jump to reset vector
Boot Media
Copy image to RAM
RAM
Execute from RAM
After reset the CPU fetches instructions from the reset vector, the reset vector is the default location a CPU will go to find the first instruction it will execute after a reset. That is to say, the reset vector is an address where the CPU should always begin as soon as it is able to execute instructions . Reset vector is usually mapped to the first sector in a boot device. The reset vector code does minimal hardware initialization and copies the rest of the firmware image to RAM. Once copied, CPU executes instruction from RAM. The boot loader code then initializes ASICs hardware modules and processors cache. The boot loader then loads OS image at OS base address and hands over the control of execution to Operating System.
Page 5 of 13
Initial startup:
After power on reset the CPU fetches and executes instructions from reset vector. The execution of first few instructions in the reset vector during power on reset usually involves, Setup PLLs for the ASIC Initialize MIU of ASIC Copy image to RAM.
Page 6 of 13
Suggestions:
A few suggestion or design proposals that can be followed to overcome the issues during the initial boot: Keep the code that executes from flash to a minimum. Setup C environment in the initial boot code. This makes the code easier to understand and portable. To setup C environment the stack pointer needs to be initialized to a contiguous memory area. As MIU is not initialized at power on reset, the stack pointer can be set to processor secondary RAM. If processors RAM is not available, stack pointer register can be setup using processors data cache or contiguous unused memory space in the ASIC. Usually the available space to setup stack either using data cache or processor RAM is less, care should be taken not to exceed the stack size One way to cross check this is to disassemble the compiled initial boot code and check if stack pointer overgrows the size. If there is any repetitive loop during initial execution, every fetch and execution of the same instruction to the flash is time consuming. To improve boot performance we can enable the instruction cache, traverse the initial boot code once so that the code gets into instruction cache. Any instruction fetch after this goes to instruction cache.
Page 7 of 13
Page 8 of 13
Network Boot:
To fetch a firmware/OS image over the network, all you need is DHCP server and a TFTP server. It does this via standard Internet protocols. When the appliance is powered on, the boot loader makes a DHCP request. The DHCP server, recognizing the appliance as a network-booting client, returns instructions on the location of a TFTP server and the name of the file that it should download from the server. The advantage of having a network boot is you can quickly download a new development run-time firmware image to your target device.
Page 9 of 13
Decompression support:
To reduce the size of firmware in flash the image can be compressed. The boot loader would have to support decompression. The boot loader decompresses the firmware code in flash and copies it to RAM. The advantage of having a compressed image would be that the size of flash required to store firmware image would be small. This would have a huge cost saving. Note: The compression/decompression algorithm used by boot loader needs to be a lossless one.
Page 10 of 13
Page 11 of 13
Page 12 of 13
References
Das U-Boot Universal boot loader The GNU GRUB Boot Loader
http://sourceforge.net/projects/u- boot
http://www.linuxgazette.com/issue64/kohli.html
Page 13 of 13