Building an Embedded Linux System Based on S3C2410
2026-04-06 06:41:38··#1
Currently, ARM microcore-based embedded processors have become the mainstream in embedded systems. With the widespread application of ARM technology, establishing embedded operating systems for the ARM architecture has become a hot research topic. Many embedded operating systems have emerged, such as VxWorks, Windows CE, PalmOS, and Linux. Among these, Linux is favored by developers for its open-source code and free use. This paper selects the S3C2410 microprocessor, which is based on the 32-bit ARM920T core. Based on this processor, a Linux embedded operating system is constructed and ported to a system based on the 32-bit ARM920T core. Application development is then carried out on this basis. 1 Development Environment Introduction 1.1 Hardware Platform Based on S3C2410 ARM920T The hardware platform of this system is provided by Shenzhen Xuanji Company. The core component of the hardware is the Samsung S3C2410 ARM920T chip. The peripherals also include: 64M NAND FLASH and RAM peripheral storage chips; serial port, network port and USB peripheral interfaces; CSTN LCD and touch screen peripheral display devices; UDA1341TS peripheral audio devices. The S3C2410 processor and peripheral devices together constitute the ARM920T-based development board. 1.2 Embedded Linux Software System The embedded Linux software system consists of the following four parts: the bootloader vivi; the Linux 2.6.14 kernel; the YAFFS2 file system; and user programs. Their executable images are stored sequentially on the system storage device, as shown in Figure 1. Unlike the typical embedded system layout, this system adds a boot parameter area between the bootloader and the kernel image, where system boot parameters are stored. The bootloader determines the boot mode, boot wait time, etc., by calling these parameters. The addition of these boot parameters enhances the system's flexibility. This system uses a 64M NAND FLASH storage device, the layout of which is shown in Table 1. 2 Embedded Linux System Design and Implementation 2.1 Bootloader vivi 2.1.1 Basic Functions of vivi The system uses vivi as its bootloader. Vivi is a bootloader written by MIZI Research in South Korea for its SMDK2410 development board. Vivi is the first program to run after the CPU is powered on. Its basic function is to initialize hardware devices and establish a memory space mapping, thus preparing for calling the embedded Linux kernel. Vivi consists of two parts: one part is CPU architecture-dependent code that uses assembly language to initialize the hardware environment and prepare for the execution of the second part of the code; the other part uses C language to implement the memory space mapping, read the Linux memory image and root file system image from FLASH into RAM space, set the boot parameters, and finally call the kernel. 2.1.2 Bootloadcrvivi Porting Download the vivi source code from www.mizi.com and decompress it. Port it according to the following steps. This system uses ARM-GCC-2.95.2 to compile vivi. (1) Specify CROSS-COM-PILE, Linux-INCLUDE-DIR, and ARM-GCC-LIBS in the /vivi/Makefile file, as shown in the following reference paths: Linux_INCLUDE_DIR=/opt/host/armv41/include/; CROSS_COMPILE=/opt/host/armv41/bin/armv41-Unknown-Linux-; ARM-GCC-LIBS=/opt/host/armv41/lib/gcc-lib/armv41-unknown-Linux/2.95.2; (2) Modify the partition contents of mtd-partition-t default-mtd-partitions[] in the /vivi/arch/s3c2410/smdk.C file as shown in Table 1; (3) Add the /vivi/lib/loadyaffs.C file to burn the yaffs2 image file; modify /vivi/lib/Config_cmd. In, add the following line: bool'load yaffs to flash command'CONFIG-LOAD-YAFFS, so that the loadyaffs command can be used as an option; (4) Execute make distclean: clean up the vivi compilation environment; execute make menuconfig to trim vivi, select according to the actual situation, note that "[*]load yaffs to flash command" should be selected because the YAFFS2 file system is used here, and vivi needs to support YAFFS2 image download; execute make to generate the required file vivi; (5) Use JTAG to burn the image to the zero address of the target board NAND FLASH to realize the loading of the boot program. 2.2 Porting of Linux 2.6.14 kernel 2.2.1 Selection of kernel The Linux kernel version updates very quickly, but the release of Linux kernel version is not synchronized with the development of Linux's support for embedded processors. Therefore, it is necessary to select a suitable kernel for a specific processor architecture and add corresponding patches according to its hardware functional components. Based on the architecture and peripheral hardware characteristics of $3C2410, the system uses the Linux 2.6.14 kernel and the compiler used is ARM-Linux-GCC version 3.4.1. Since the system uses the YAFFS2 file system, it is necessary to download the yaffs2.tar.gz file from the Internet, decompress it and execute the command "./patch.ker.sh/Linux2.6.14" to patch the Linux kernel to support the YAFFS2 file system. 2.2.2 Kernel Modification (1) Modify the cross-compilation items in the Makefile in the kernel source code: ARM=arm; CROSS-COMPILE=/usr/local/arm/3.4.1/bin/arm-Linux-; (2) In the arch/arm/mach-s3c2410/devs.C file: ① Add header file definition: #include #include #inelude ② Add the static struct mtd-partition partition-info[] function to create partition table information. The partition content is shown in Table 1. ③ Add Nand Flash partition: struet s3c24 1 O-nand-set nandset一{nr_partitions:5,partitions:partition-info,}. ④ Create Nand Flash chip support struct s3c24 10-platform-nand superlpplatform={tacls:0,twrph0:30,twrphl:0,sets:&. nandset,nr-sets:1,}. ⑤ Add Nand Flash chip support in the Nand Flash driver: Add . dev一{. platforM一data一&super-lpplatform} in s3C-device-nand. (3) Add &s3c-device-nand to the initdata section of arch/arm/machs3c2410/machsmdk2410.C to initialize NAND FLASH information during kernel startup. (4) To enable the kernel to support devfs and automatically mount /dev as a devfs filesystem before running /sbin/init at startup, modify fs/Kconfig. And add the following statement under menu "Pseudo filessystems": config DEVFS_FSbool "/dev file system support (OBOLETE) default yconfig DEVFS-MOUNTbool "Automatically mount at boot" default ydepends on DEVFS FS 2.2.3 Kernel compilation and loading (1) Execute make mrproper: Clean up the compilation environment before compiling the kernel. (2) Execute make menuconfig: Configuring the kernel is a tailored process. It is a very complex process. Configuring a kernel that suits your own needs may require multiple repetitions of configuration operations. The following is a brief introduction to some configurations based on this system: Boot options -> Default kernel command st ring Noinitrd root = /dev/mtdblock3 init = /Linuxrc console -> ttySAC0.1 15200 Explanation: mtdblock3 represents the 4th partition of NAND FASH, which is the root partition of this system; Floating point emulation -> [*]NwFPE math emulation # Select NWFPE floating-point emulation in the kernel File systems -> <> Second extended fs support # Remove support for ext2 Pseudo filesystems -> [*] /proc file system support [*] Virtual memory file system support (former shm fs) [*] /dev file system support (OBSOLETE) [*] Automatically mount at boot (NEW) Here you will see the results of the previous modification to fs/Kconfig, devfs is now supported. Miscellaneous filesystems -> # Select YAFFS2 root file system <*> YAFFS2 file system support —————— 51 2 byte /page devices [*] Lets Yaffs do its own ECC [*] Use the same ecc byte order as Steven Hill's nand-ecc. C -> 2048 byte (or larger) /page devices [*] Autoselect yaffs2 format [*] Disable lazy loading (1 0) Reserved blocks for checkpointing [*]Turn off wide tnodes []Force chunk erase check []Cache short names in RAM Network File Systems——-〉 <*〉NFS file system support (3)Execute make bzlmage, and after successful compilation, the required file zImage will be generated under arch/arm/boot/. (4)At the vivi prompt, enter the command "load flash kernel x" to download the kernel image to the KERNEL partition of NAND FLASH via serial port. 2.3 File System Linux uses a file system to organize files and devices in the system, providing a unified interface for devices and user programs. It supports multiple file systems such as CRAMFS, JFFS2, and RAMDISK. This system uses the read-write YAFFS2 root file system. 2.3.1 Introduction to YAFFS2 File System YAFFS2 is an upgraded version of YAFFS (Yet Another FLASH File System), which can better support NAND FLASH. It is an embedded file system designed specifically for FLASH, similar to JFFS. Compared with JFFS, it has reduced some functions, so it is faster and occupies less memory. NAND Most FLASH systems adopt the MTD+YAFFS model. Through the YAFFS file system, data in the FLASH can be manipulated like files on a hard drive. The data is still stored in the FLASH chip after the system is powered off. 2.3.2 Root File Creation (1) Create the root file system directory root. In the root directory, create subdirectories bin, sbin, dev, etc, proc, lib, and user; /bin: Stores most binary files such as init, busybox, shell, and file management utilities; /sbin: Stores commands usually needed during system startup; /dev: Contains all backup nodes used in the device; /etc: Contains all system configuration files; /proc: This is a special directory that must be set. After the system is running, it contains many contents. In some cases, system settings can be performed through it, and many tools can obtain information from here. When compiling the kernel, you must select the proc file system support; /lib: Contains all necessary libraries; /user: Stores user programs. (2) Compile busybox. busybox is a well-known open-source software. It integrates more than 100 of the most commonly used Linux commands in a very small application, hence the reputation of being the "Swiss Army knife of embedded Linux". First, download the busybox source code from the Internet. The system uses version 1.1.3; second, execute the nlakemenuconfig command. Configure the functions according to actual needs. The system compiles busybox as a static link; finally: execute Filakc a11 install to compile and install; the compiler is: ARM-Linux-GCC-3.4.1, and the installation path is the same as root as above. In this way, there will be a script Linuxrc in the root directory. The symbolic link command set provided by busybox pointing to busybox will be in the /bin and /sbin directories. (3) Write the startup script: Generally, the system will perform the corresponding initialization operations as required when it starts up. Write the command init=/Linuxrc. This Linuxrc is a symbolic link pointing to the /etc/init.d/rcS file. The rcS file lists the files to be executed by Linux initialization, such as the initialization process init, mounting the root system, mounting modular device drivers, etc. The role of rcS is equivalent to the autocxec.bat file in Windows. Since the content of rcS varies greatly for different applications, the content of rcS should be written according to actual needs. (4) Create a YAFFS2 image: Use the utility nlkyaffsinlage (mkvaffmage and the root directory are in the same path) to create a YAFFS2 image root.img. The command is: #. /inkyaffsimage root root.inlgroot.img is the required YAFFS2 file system; (5) Download the file system image: At the vivi prompt, execute "loadyaffs root x" and select root.inlg to download the file to NAND via serial port. In the root partition of FLASH, then copy or restart the development board to boot the Linux system. 3. Conclusion Through the construction of the ARNI embedded system platform and the analysis of the bootloader vivj's function, this paper elucidates the porting of the Linux kernel and explains the steps and methods for creating the YAFFS2 file system. The aim is to provide a holistic understanding of embedded system platform construction, thereby lowering the barrier to entry into the ARM embedded development application field and further advancing the process of embedded software and hardware development.