Booting uClinux on SmartFusion2 in 0.5 Seconds |
 Fast-booting Linux on SmartFusion2 This application note demonstrates how Linux (uClinux) boots up on SmartFusion2 from power-up to the interactive shell in about 0.5 seconds. The hardware platform is Microsemi's SF2-DEV-KIT board. The Cortex-M3 is configured to run at 166 MHz. PCLK0 is set to a 1/2 of the main clock (83 MHz), allowing to run SPI_0 and access the SPI Flash at up to 41.5 MHz. The on-chip cache is enabled by software for DDR3. The Linux configuration used in this demo targets a typical "data harvesting" device. Support for SPI Flash, Flash partitioning and JFFS2 are all enabled in the kernel. As soon as Linux comes up to the shell, a data harvesting application (or any number of such applications) can be started from the /etc/rc start-up script, collecting data from various sensors and logging collected data into the on-board SPI Flash. It takes uClinux only 0.5 seconds from power-up / reset to the point where data harvesting can commence. Linux Bootstrap Sequence The Linux bootstrap can be described by the following sequence:
Installing the Demo The procedure described here explains how to install the bootable Linux image (fastboot.uImage) to the target. Here is how you can build and install the bootable Linux image from the project sources (fastboot.tgz), having installed them on top of the Emcraft Systems SmartFusion2 uClinux distribution. Note: The Linux image and the sample project have been built and validated in context of the Emcraft Systems Release 1.11.0. If you are using a different release, some porting changes may be needed. Understanding the Demo Here is a detailed description of the demo. The first message printed by U-Boot after power-up/reset is as follows: U-Boot 2010.03-linux-cortexm-1.10.0 (May 17 2013 - 16:09:15) U-Boot proceeds with initialization of the target and reports various characteristics of the hardware platform: CPU : SmartFusion®2 SoC (Cortex-M3 Hard IP) U-Boot then waits for the number of seconds defined by the bootdelay environment variable before proceeding to execute a bootup sequence defined by the bootcmd variable. If the user presses any key while in the bootdelay loop, U-Boot interrupts the boot-up sequence and enters the interactive command monitor. Initially we set bootdelay to 3. Hit any key to stop autoboot: 0 Now, this is the point when the bootdelay loop has expired and the bootcmd commands sequence is being executed. On SmartFusion2, the first action bootcmd performs is loading a bootable Linux image from the SPI Flash to the DDR3: 8192 KiB AT25DF641 at 0:0 is now current device Then a bootm command is called upon the image loaded into DDR. What this command does is, parse the image header, figure out the image type and size, optionally verify the checksum and pass control to the kernel entry point: ## Booting kernel from Legacy Image at a0007fc0 ... This is where U-Boot is done and the Linux kernel starts running: Starting kernel ... The following are the first messages printed by the kernel: Linux version 2.6.33-arm1 (psl @ocean.emcraft.com) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-189) ) #12 Mon May 20 18:32:43 +0400 2013 Note the kernel input arguments passed by U-Boot to the kernel. This is defined by bootargs in U-Boot: Kernel command line: m2s_platform=sf2-dev-kit console=ttyS1,115200 panic=10 The kernel proceeds to set the memory up. We have 256 MB of DDR3 to run Linux from: Memory: 256MB = 256MB total Then the kernel runs the so-called "calibration loop" in order to calculate loops-in-jiffies also referred to as lpj. The lpj value is used by the kernel to implement various delays. Note that as part of the calibration loop, the kernel also calculates the BogoMIPS value, which is a Linux approximation of the MIPS (Million Instructions Per Second) metric: Calibrating delay loop... 155.23 BogoMIPS (lpj=776192) The UART device driver and the serial console are initialized: Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled The SPI device driver is started and the SPI Flash is partitioned onto 3 separate logical partitions. Each partition can be accesses as a separate logical device by user-space code: m25p80 spi0.0: at25df641 (8192 Kbytes) The initramfs root filesystem is mounted and init, which is the first user-space process, is launched: init started: BusyBox v1.17.0 (2012-12-14 10:29:39 +0400) init proceeds to execute a start-up command-line sequence defined by the /etc/rc script. In our application, we have /etc/rc contain a single command (echo "Data harvesting can commence"), which results in the output below: Data harvesting can commence And finally, init starts the interactive command shell: / # Configuring for Fast-Boot To achieve the ~0.5 seconds boot times, you will need to specifically configure U-Boot. Note that each of the configuration steps described below is optional, in the sense that if you don't perform a certain optimization step, the demo will still boot on the target, although slightly slower than it would otherwise. From the U-Boot prompt, do the following:
SF2-DEV-KIT> set verify no SF2-DEV-KIT> set bootargs m2s_platform=sf2-dev-kit console=ttyS1,115200 panic=10 lpj=776192 SF2-DEV-KIT> set bootargs m2s_platform=sf2-dev-kit console=ttyS1,115200 panic=10 lpj=776192 quiet=quiet SF2-DEV-KIT> set bootdelay 0 SF2-DEV-KIT> saveenv 8192 KiB AT25DF641 at 0:0 is now current device Restoring Default Configuration Please step through the following procedure to restore the default configuration:
U-Boot 2010.03-linux-cortexm-1.10.0 (May 17 2013 - 16:09:15) SF2-DEV-KIT> print bootargs |