1 Introduction
At present, embedded processors based on ARM core have become the mainstream in the embedded system market. With the widespread application of ARM technology, the establishment of embedded operating systems for ARM architecture has become a hot topic in current research. S3C2410 is a 16/32-bit embedded processor developed by SAMSUNG based on the ARM920T processor core. It has a running frequency of more than 200M and has rich on-chip resources such as MMU and cache. It is currently the chip with the largest shipment volume based on the ARM920T core. There are also many embedded operating systems, such as Tor2nado's VxWork, Microsoft's Windows CE, etc. However, a large number of developers choose Linux because its source code is open and can be easily modified and transplanted to their own target platform system for use. And it has been proven that the effect is satisfactory. The combination of the two will surely create a new world in the world of embedded systems.
2 Linux operating system porting
2.1 Meaning of transplantation
In order to make standard Linux run on ARM embedded processors, it is necessary to go through the process of porting. The so-called porting is to make a set of software run normally on a selected hardware platform, that is, to make appropriate modifications to the platform dependent parts. The arch subdirectory of the kernel source code includes all the core codes related to the platform architecture. Each of its subdirectories represents a supported architecture. arm is the subdirectory about the processor architecture we selected. Our porting work is mainly concentrated in this directory.
2.2 Specific implementation of porting
If we have built a complete cross-compilation platform, the porting work can begin (taking the most widely used linux-2.4 as an example, put it under /usr/src/linux-2.4.18).
/Makefile
A project often contains many files, which are placed in multiple directories according to certain rules. Makefile is used to specify compilation rules, such as which files need to be compiled and which files should be compiled first. What needs to be done here is:
Specify the target platform ARCH := $(shell uname -m | sed -es/i.86/i386/ -es/sun4u/sparc64/ -es/arm.*/arm/ -es/sa110/arm/)
Set to ARCH := arm
Specify the cross compiler CROSS_COMPILE =
Set CROSS_COMPILE = arm-linux-
/arch/arm/Makefile
The boot code is generated through this file. Since the 2.4 kernel does not support S3C2410, add the following code by yourself
ifeq ((CONFIG_ARCH_ S3C2410),y)
TEXTADDR = xxx
MACHINE = s3c2410
Endif
TEXTADDR is the virtual starting address of the kernel[6] and also the final running address of the kernel. It is usually set to PAGE_OFFSET + 0x8000 and must be combined with the actual situation[2].
/arch/arm/config.in
config.in is the configuration file that determines what we see in the configuration menu. Add the $CONFIG_ARCH_S3C2410 suboption [5] by yourself.
if [ "$CONFIG_ARCH_S3C2410" = "y" ]; then
comment'Archimedes/A5000 Implementations'
dep_bool 'SMDK (MERI TECH BOARD) '
CONFIG _S3C2410_SMDK//
$CONFIG_ARCH_S3C2410
//other
be
在if [ "$CONFIG_FOOTBRIDGE_HOST" = "y" -o \
……
"$CONFIG_ARCH_SA1100" = "y" ]; then
define_bool CONFIG_ISA y
else
define_bool CONFIG_ISA n
be
Add "$CONFIG_ARCH_s3c2410" = "y"-o\ in the same way.
/arch/arm/boot/Makefile
ZTEXTADDR is the location of image.rom before decompression, and ZRELADDR is the location where the kernel is decompressed and finally executed. The mapping relationship between ZRELADDR and TEXTADDR is as follows: __virt_to_phys(TEXTADDR) == ZRELADDR[6].
ifeq ((CONFIG_ARCH_s3c2410),y)
ZTEXTADDR = xxx
ZRELADDR = xxx
Endif
/arch/arm/boot/compressed/ Makefile
Add ifeq ("$(CONFIG_ARCH_S3C2410),y) in the same way
OBJS +=head-s3c2410.o
endif
/arch/arm/boot/compressed/head-s3c2410.s
Here you need to add the kernel decompression pre-processor initialization file head-s3c2410.s, sample code:
.section ".start", "ax"
__S3C2410_start:
bic r2, pc, #0x1f @ Clear pc related bits and put them in r2
add r3, r2, #0x4000
1: ldr r0, [r2], #32
teq r2, r3
bne 1b
mcr p15, 0, r0, c7, c10, 4 @ Write back to Write Buffer
mcr p15, 0, r0, c7, c7, 0 @ 刷新 I & D caches
#if 0
@ Disable MMU, caches
……
#endif
move r0, #0x00200000
1: subs r0, r0, #1
bne 1b
/arch/arm/kernel/ Makefile
Add $(CONFIG_ARCH_2400) $(CONFIG_ARCH_2410) \ to the same
no-irq-arch :=$(CONFIG_ARCH_INTEGRATOR) $(CONFIG_ARCH_CLPS711X) \
……
$(CONFIG_ARCH_AT91RM9200
And add obj-$(CONFIG_MIZI) += ecard.o
obj-$(CONFIG_ARCH_APM) +=apm2.o
/arch/arm/kernel/entry-armv.S
This file mainly defines the interrupt processing part during CPU initialization [6]. Please refer to the processor manual and set it according to the processor usage requirements.
/arch/arm/kernel/debug-armv.S
This file is used for the most basic serial port debugging functions [6], including debugging serial port address initialization, sending, waiting, busy status definition, etc. This file can be used to print out relevant information during the startup process.
/arch/arm/kernel/setup.c
In this file, several variables need to be set according to the board used [5]. nr_banks specifies the number of memory blocks, bank specifies the range of each memory block, PAGE_OFFSET is the memory start address, and MEM_SIZE is the memory size. PAGE_OFFSET and MEM_SIZE should be defined in /include/asm-arm/arch-s3c2410.
/arch/arm/mm/mm-armv.c
This file is used for hardware-related memory management, such as initializing memory page tables, memory mapping, etc.
Change init_maps->bufferable = 0; to init_maps->bufferable = 1;
/arch/arm/mach-s3c2410
Create the corresponding directory and write irq.c, mm.c, time.c, arch.c, and Makefile according to the processor usage requirements, respectively implementing the initialization of the interrupt controller, the virtual-real mapping relationship of the address, clock interrupt and real-time clock processing, and the setting of Ramdisk usage parameters.
/include/asm-arm/arch-s3c2410
The header files used are defined in this directory.
At this point, the transplantation work is basically completed. By performing the following compilation process, we can obtain the image file we need [4].
make dep; make clean; make zImage
3. Composition of the complete system
In order for Linux to really run, it also requires the support of the root file system. The commonly used method is Ramdisk. Ramdisk is a driver mechanism that creates and mounts a file system by simulating the computer's memory (RAM) as a device. It should generally include the following directory contents: /dev (device file directory); /proc (proc file system directory); /etc (system configuration file directory); /sbin (system program directory); /bin (basic application directory); /lib (shared function library directory); /mnt (directory for mounting other disk nodes); /usr (directory for additional applications)[3].
In addition, a complete embedded system also needs boot code, such as vivi, u_boot, etc. Bootloader also needs to be ported and compiled, which is not described in detail here. After the above three parts are prepared and the FLASH is divided into intervals[1], the FLASH burning tool can be used to burn the Bootloader, kernel and root file system into the FLASH in sequence. Then the system can be started.
The system starts to execute the Bootloader from address 0. After the Bootloader completes the related hardware initialization work, it copies the compressed kernel image from the FLASH to the SDRAM and passes the address parameter of the root file system to the kernel [1]. After the kernel is copied to the SDRAM, it is decompressed and started. During the kernel startup process, the root file system is searched according to the address parameter passed by the Bootloader and loaded into the embedded system. In this way, the entire Linux is booted and started and enters the normal working state.
4 Conclusion
The author's innovation: The commonly used 2.4 version of Linux does not include support for S3C2410, which brings inconvenience to the development of embedded systems based on it. Based on the understanding of the common problems in the transplantation process and the author's accumulated experience and lessons, this article analyzes in detail the main technologies of how to transplant Linux2.4 to the embedded system of the ARM platform, so that the system can well support the target platform, and the transplanted Linux retains the original stable working characteristics. Emphasizing its principles and operability in the transplantation process is very important for deepening the understanding of the Linux kernel and developing embedded systems, and has reference significance for the development of other embedded systems.
References
[1] Liu Jingjing, Design of boot program for embedded system based on ARM-Linux[J], Microcomputer Information, 2006, 2-2: 123-125
[2] Li Ming, ARM Linux porting process and analysis, Electronic Design Applications [J], 2003, 7: 55-57
[3] Xu Hong et al., Operating System Experiment Guide [M], Beijing: Tsinghua University Press, 2002, 5
[4] Zhang Jie, Cao Weihua, Wu Min, Shi Weiqiang, Linux transplantation based on S3C2410 [J], Microcomputer Development, 2005 (15), 6: 142-144
[5] Sun Tianze, Yuan Wenju, Zhang Haifeng, Embedded Design and Linux Driver Development Guide [M], Beijing: Electronic Industry Press, 2005, 9
[6]Wookey and Tak-Shing,Porting the Linux Kernel to a New ARM Platform,SOLUTIONS JOURNAL,2002,4:52-57
Previous article:s3c2410 startup code analysis
Next article:Linux-2.6.32.2 kernel transplantation on mini2440 (XVII) --- transplantation of PWM control buzzer
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Summarize the commonly used communication interfaces of microcontrollers
- Considerations for using PMOS tube as power switch
- "Circuit Garden" by artist Kelly Heaton
- Newbie help, the light flashes five times, the buzzer sounds once, now it flashes and sounds
- An 80W power amplifier for LS band, equalizer adjustment
- Protel99 generates a network table where some components have no connections
- Common problems in debugging the TMS320C3x series?
- Regarding GaN devices, these issues should be paid attention to!
- 【GD32E231_DIY】-02: Development environment construction and creating a new project
- TI C64X DSP interrupt vector table configuration (hardware interrupt)