1. Transplantation environment
Host: VMWare--Fedora 9
Development board: Mini2440--64MB Nand, Kernel:2.6.30.4
Compiler: arm-linux-gcc-4.3.2.tgz
u-boot:u-boot-2009.08.tar.bz2
2. Transplantation steps
Features of this transplant include:
Support Nand Flash reading and writing
Support booting from Nor/Nand Flash
Support CS8900 or DM9000 network card
Support Yaffs file system
Support USB download (not yet implemented)
1. Understand the main directory structure and startup process of u-boot, as shown below.
The stage1 code of u-boot is usually placed in the cpu/xxxx/start.S file, which is written in assembly language;
The stage2 code of u-boot is usually placed in the lib_xxxx/board.c file, which is written in C language.
The flow chart of each part is as follows:
2. Create your own development board project and test the compilation.
At present, u-boot directly supports many CPUs. You can check some subdirectories of the board directory. For example, the board/samsung/ directory supports some Samsung ARM processors, including smdk2400, smdk2410 and smdk6400, but not 2440, so we Build your own development board project right here.
1) Since the resources of 2440 and 2410 are similar, the main frequency and peripherals are slightly different, so we established our own development board project under board/samsung/ and named it my2440
#tar -jxvf u-boot-2009.08.tar.bz2 //Unzip the source code
#cd u-boot-2009.08/board/samsung/ //Enter the directory
#mkdir my2440 //Create the my2440 folder
2) Since the resources of 2440 and 2410 are similar, we use the code of the 2410 project as a template and modify it later.
#cp -rf smdk2410/* my2440/ //Copy all codes under 2410 to 2440
#cd my2440 //Enter the my2440 directory
#mv smdk2410.c my2440.c //Rename smdk2410.c under my2440 to my2440.c
#cd ../../../ //Return to the u-boot root directory
#cp include/configs/smdk2410.h include/configs/my2440.h //Create the 2440 header file
#gedit board/samsung/my2440/ Makefile //Modify the compilation items of Makefile under my2440, as follows:
COBJS := my2440.o flash.o //Because we renamed smdk2410.c to my2440.c under my2440
3) Modify the Makefile file in the u-boot and directory. Find the place where smdk2410_config is found, and create the compilation options of my2440_config according to the format of smdk2410_config, and also specify the cross compiler.
#gedit Makefile
CROSS_COMPILE ?= arm-linux- //Specify the cross compiler as arm-linux-gcc
smdk2410_config: unconfig //2410 compilation option format
@$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 samsung s3c24x0
my2440_config: unconfig //2440 compilation option format
@$(MKCONFIG) $(@:_config=) arm arm920t my2440 samsung s3c24x0
*Description: arm: CPU architecture (ARCH)
arm920t: CPU type
my2440: The directory corresponding to the creation of a new development board project in the board directory
samsung: The superior directory of the new development board project directory. If you create a new development board project directory directly under the board, this will be NULL.
s3c24x0: CPU model
*Note: The second line of the compilation option format must be started with the Tab key, otherwise compilation errors will occur.
4) Test and compile the newly created my2440 development board project
#make my2440_config //If Configuring for my2440 board... appears, it means the setting is correct
#make //After compilation, the u-boot.bin file will appear in the root directory, then the first step of u-boot transplantation is completed.
So far, u-boot has no use for its own my2440 development board. The above transplantation only builds a framework for my2440 development board u-boot. To realize its functions, it must be based on the specific resources of the my2440 development board. to modify the u-boot source code.
3. Analyze or modify and add the u-boot source code according to the steps of the u-boot startup flow chart to make it suitable for the my2440 development board (Note: Modified or added places are indicated in red).
1) Analysis of the stage1 entry point of my2440 development board u-boot.
Generally in embedded system software development, after all source code files are compiled, the linker reads a link allocation file, which defines the entry point of the program, allocation of code segments, data segments, etc. Then the link file of our my2440 development board u-boot is cpu/arm920t/u-boot.lds. Part of the code to open this file is as follows:
Knowing that the entry point of the program is _start, then we open the first program cpu/arm920t/start.S to be run by my2440 development board u-boot (that is, the stage1 part of u-boot), and find the location of _start as follows:
From this assembly code, you can see that the program jumps to start_code and starts execution. Then the code found at start_code is as follows:
/*
* the actual start code
*/
start_code:
/*
* set the cpu to SVC32 mode
*/
mrs r0,cpsr
bic r0,r0,#0x1f
orr r0,r0,#0xd3
msr cpsr,r0
bl colored_LED_init //here The two lines are to initialize the LED on the AT91RM9200DK development board
bl red_LED_on
It can be seen from this that start_code is the real beginning of u-boot startup code. The above is the process of stage1 entry of u-boot.
2) Hardware device initialization in stage 1 of my2440 development board u-boot.
Because there are two lines in the u-boot startup code that are the LED initial codes of AT91RM9200DK, but the LED resources on our my2440 are inconsistent with those of the development board, so we need to delete or block the code there, plus the LED driver code of my2440 (Note: Adding the my2440 LED function is only used to indicate the running status of u-boot, which brings convenience to debugging. You can put this code anywhere you want to debug). The code is as follows:
/*bl colored_LED_init //These two lines are the LED initialization of the AT91RM9200DK development board, comment out
bl red_LED_on*/
#if defined(CONFIG_S3C2440) //Difference from other development boards
//According to the mini2440 schematic, it can be seen that the LEDs are controlled by PB5, 6, 7, and 8 ports of S3C2440. The following is the PB port register base address (check the DataSheet of 2440)
#define GPBCON 0x56000010
#define GPBDAT 0x56000014
#define GPBUP 0x56000018
//The following operations on the register refer to the DataSheet of S3C2440
ldr r0, =GPBUP
ldr r1, =0x7FF //That is: binary 11111111111, turn off the PB port pull-up
str r1, [r0]
ldr r0, =GPBCON //Configure PB5, 6, 7, and 8 are output ports, corresponding to bits 10-17 of the PBCON register
ldr r1, =0x154FD //That is: binary 010101010011111101
str r1, [r0]
ldr r0, =GPBDAT
ldr r1, =0x1C0 //That is: binary 111000000, PB5 is set to low level, 6, 7, and 8 are set to high level
str r1, [r0]
#endif
//This code causes LED1 on the development board to light up after u-boot is started, but LED2, LED3, and LED4 do not light up.
Add the CONFIG_S3C2440 macro in the include/configs/my2440.h header file
#gedit cpu/arm920t/s3c24x0/speed.c //Modify the function to obtain the clock frequency according to the set frequency division coefficient FCLK:HCLK:PCLK = 1:4:8
staTIc ulong get_PLLCLK(int pllreg)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
ulong r, m, p, s;
if (pllreg == MPLL)
r = clk_power->MPLLCON;
else if (pllreg == UPLL)
r = clk_power->UPLLCON;
else
hang();
m = ((r & 0xFF000) >> 12) + 8;
p = ((r & 0x003F0) >> 4) + 2;
s = r & 0x3;
#if defined(CONFIG_S3C2440)
if(pllreg == MPLL)
{ //参考S3C2440芯片手册上的公式:PLL=(2 * m * Fin)/(p * 2s)
return((CONFIG_SYS_CLK_FREQ * m * 2) / (p << s));
}
#endif
return((CONFIG_SYS_CLK_FREQ * m) / (p << s));
}
/* return HCLK frequency */
ulong get_HCLK(void)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
#if defined(CONFIG_S3C2440)
return(get_FCLK()/4);
#endif
return((clk_power->CLKDIVN & 0x2) ? get_FCLK()/2 : get_FCLK());
}
alright! After the modification is completed, we recompile u-boot, and then download it to RAM to run the test. As a result, the terminal outputs information and a shell-like command line appears, which indicates that the transplantation of this part is completed. The schematic diagram is as follows:
#gedit include/configs/my2440.h
#define CONFIG_ARM920T 1 /* This is an ARM920T Core */
#define CONFIG_S3C2410 1 /* in a SAMSUNG S3C2410 SoC */
#define CONFIG_SMDK2410 1 /* on a SAMSUNG SMDK2410 Board */
#define CONFIG_S3C2440 1 /* in a SAMSUNG S3C2440 SoC */
Now compile u-boot and a u-boot.bin file will be generated in the root directory. Then we use the original supervivi of mini2440 to download u-boot.bin to RAM and run the test (note: when we use supervivi to download, we have already initialized the CPU and RAM, so we need to block the CPU in u-boot , RAM initialization), as follows:
/*#ifndef CONFIG_SKIP_LOWLEVEL_INIT //Shield u-boot's initialization of CPU and RAM in the start.S file
bl cpu_init_crit
#endif*/
#make my2440_config
#make
After downloading and running, you can see that the first LED light on the development board is on, and the other three are off. The test results meet the above requirements. The terminal running results are as follows:
#gedit cpu/arm920t/start.S
.globl _start
_start: b start_code //Jump the execution of the program to start_code
#gedit cpu/arm920t/u-boot.lds
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm) //Define the target platform of the generated file to be arm
ENTRY(_start) //Define the entry point of the program to be _start
SEC TI ONS
{
//Some other code segments, data segments, etc. are allocated
. = 0x00000000;
. = ALIGN(4);
.text :
{
cpu/arm920t/start.o (.text)
*(.text)
}
..... ............................................. }
Previous article:Taking s3c2440 as an example to explain the startup process of the arm chip
Next article:A brief discussion on how to learn and get started with ARM embedded systems
Recommended ReadingLatest update time:2024-11-23 02:41
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- What is a Level 2 or Level 3 charger?
- dsp28335 gpio summary
- IAR download error
- Philips will enter the car navigation market in September this year
- Advantages and disadvantages of FPC soft board surface treatment process
- IMX6ULL development board apt-get software download tool
- 2019 National TI Sponsored Board Video Tutorials
- DIY Wooden Computer Case
- Principle and application of TOPSwitch single-chip switching power supply
- Switching Power Supply Reference Book, "Switching Power Converters: Principles, Simulation, and Design of Switching Power Supplies"