Booting uClinux on SmartFusion2 in 0.5 Seconds |
Fast-booting Linux on SmartFusion2 Watch this video to see how Linux (uClinux) boots up on SmartFusion2 from power-up to the interactive shell in about 0.5 seconds. The hardware platform is Emcraft Systems' SmartFusion2 system-on-module (SOM) plugged into the SOM-BSB-EXT baseboard. Both Cortex-M3 and LPDDR are 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 LPDDR. The Linux configuration used in this demo targets a typical "data harvesting" device. Support for the SPI controller, 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-module SPI Flash. As can be seen from the above video, it takes uClinux only 0.5 seconds from power-up / reset to the point where data harvesting can commence.
The Linux boostrap 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.
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 LPDDR: 16384 KiB S25FL128S_64K 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 (vlad @ocean.emcraft.com) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-189) ) #79 Thu Dec 27 11:32:17 +0400 2012 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=m2s-som console=ttyS0,115200 panic=10 The kernel proceeds to set the memory up. We have 64 MB of LPDDR to run Linux from: Memory: 64MB = 64MB 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... 154.82 BogoMIPS (lpj=774144) 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: s25fl129p1 (16384 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: / #
To achieve the ~0.5 seconds boot times shown in the above video, 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:
M2S-SOM> set verify no M2S-SOM> set bootargs m2s_platform=m2s-som console=ttyS0,115200 panic=10 lpj=774144 M2S-SOM> saveenv U-Boot 2010.03-00001-gc9f691b (Dec 26 2012 - 14:06:31)
Please step through the following procedure to restore the default configuration:
M2S-SOM> print bootargs |