A Design Method of Linux Bootloader Based on S3C2440

Xianfan Xu, Kun Zhang, Lei Xu, Qiang LiProceedings of the 2nd International Conference on Computer Science and Electronics Engineering (ICCSEE 2013) 2013 · DOI

Abstract

The bootloader is a critical component in embedded system development. Traditional Linux bootloaders often suffer from large code sizes and slow boot speeds due to their universal nature. This paper presents a streamlined, two-stage bootloader designed specifically for the S3C2440 processor. By initializing only the hardware necessary for the Linux kernel and leveraging the S3C2440’s unique dual-boot characteristics, the authors achieved a fast-booting solution with a footprint under 3KB. Experimental results confirm high efficiency and successful dual-boot support for both NOR and NAND flash.

Introduction

In embedded Linux systems, the bootloader is the first software to execute upon power-on. Its primary role is to initialize hardware and load the operating system kernel. While universal bootloaders like U-Boot are widely used, their "one-size-fits-all" design often results in bloated codebases and unnecessary initialization delays. For specialized applications using the Samsung S3C2440 processor, a more optimized approach is required to minimize boot time and complexity.

Methodology: The Staged Booting Approach

The proposed design utilizes a two-stage process to balance execution efficiency with ease of development.

Stage 1: Hardware Initialization (Assembly)

The first stage is written in assembly to ensure maximum speed and direct hardware control. It performs the "bare metal" essentials: disabling the watchdog timer, configuring CPU clocks to 400MHz, enabling the instruction cache, and initializing the SDRAM and stack pointer.

Flowchart of the first stage bootloader initialization process.

Stage 2: Kernel Loading (C Language)

Once the basic environment is established, the bootloader transitions to C code. This stage detects the boot source (NOR vs. NAND), sets the kernel startup parameters (tags), and copies the Linux kernel into SDRAM. A key optimization here is the "minimalist initialization" philosophy: peripherals like network cards or LCDs are ignored, as the Linux kernel will re-initialize them later anyway.

Key Insights and Ideas

Leveraging the "Steppingstone"

A standout feature of the S3C2440 is its internal 4KB SRAM buffer, known as "Steppingstone." During a NAND boot, the hardware automatically copies the first 4KB of NAND flash into this buffer. By keeping the entire bootloader under 3KB, the authors allowed the system to run entirely from internal SRAM initially, bypassing the need for complex NAND-to-RAM copying logic in the very first cycles of execution.

The S3C2440 NAND Flash boot mechanism utilizing the 'Steppingstone' buffer.

Dual-Boot Detection

The bootloader distinguishes between NOR and NAND flash through a simple memory write test. It attempts to write to address 0x0000 0000. A successful write indicates the system is running in the internal SRAM (NAND boot), whereas a failure indicates the read-only NOR flash is mapped to that address.

Results and Verification

The design was tested on an S3C2440A platform with 256MB of NAND flash. The final bootloader size was remarkably small—less than 3KB. Functional verification via serial logs confirmed that the bootloader correctly initialized the UART and successfully handed off control to Linux kernel 2.6.22.6.

Conclusion

By focusing strictly on the requirements of the Linux kernel and exploiting specific hardware features like the Steppingstone, this design provides a high-performance alternative to bulky universal bootloaders. While it lacks the broad feature set of U-Boot, its speed and small footprint make it ideal for production-ready embedded devices. Future work could involve precise millisecond-level benchmarking to quantify the speed advantage over standard solutions.

Summary updated

Abstract

Bootloader is an important part in the developing stage of embedded system.Most embedded Linux Bootloaders are developed based on development and application, which have the disadvantages of large code capacity and low booting speed.In this paper, by only operating necessary equipments closely related to booting Linux kernel and combining with dual-boot characteristic of S3C2440 and the staged booting method, a new fast booting Bootloader is designed, which can support dual-boot of NOR Flash and NAND Flash.The practical test results show that the Bootloader prompted in this paper has the advantages of low code capacity, fast booting speed and high implementation efficiency.
BibTeX
@inproceedings{xu2013design,
  author = {Xianfan Xu and Kun Zhang and Lei Xu and Qiang Li},
  title = {{A Design Method of Linux Bootloader Based on S3C2440}},
  booktitle = {Proceedings of the 2nd International Conference on Computer Science and Electronics Engineering (ICCSEE 2013)},
  year = {2013},
  doi = {10.2991/iccsee.2013.66},
}
Figure