1. This porting is based on FL2440. The basic hardware of the board is:
CPU |
Model: S3C2440, based on ARM920T, instruction set ARMV4, clock frequency 400MHz |
H57V2562GTR-75C 2 pieces * 32MB = 64MB, mounted on nGCS6 (0x3000 0000) |
|
NANDFLASH |
Model: K9F2G08U0B Size: 256MB |
Network Adapter (Network Card) |
DM9000AEP 10/100M adaptive, mounted on nGCS4 (0x2000 0000) |
LED |
5 LEDs (LED0~3) I/O port indicator lights, LED5 power indicator light, LED9 core board 3.3V indicator light LED0~LED3 are connected to GPB6, GPB6, GPB8, GPB10 respectively |
BEEP (Buzzer) |
Connect to GPB0/TOUT0 |
(II) The overall framework of U-Boot:
arch |
cpu processor related code, each cpu contains related code and processor system related initialization files. U-Boot starts to execute the first file start.S, which mainly does the earliest system initialization, code redirection and system stack setting, laying the foundation for the second stage C program. The board.c file is where almost all the second stage code entry functions and related initialization functions of U-Boot are stored. |
board |
All the development board related files that have been supported include SDRAM initialization code, Flash underlying driver, and board-level initialization files. The config.mk file defines TEXT_BASE, which is also the real address of the code in memory, which is very important. |
drivers |
Contains drivers for almost all peripheral chips, including network card, USB, serial port, LCD, Nand Flash, etc. |
common |
Common code that is independent of the processor architecture, U-Boot command parsing code, /common/command.c, all command upper-level codes cmd_*.c, Uboot environment variable processing code env_*.c, etc. are all located in this directory |
Disk, fs, net |
Supports important CPU-independent subsystems; Disk drive partition processing code, file systems: FAT, JFFS2, EXT2, etc.; Network protocols: NFS, TFTP, RARP, DHCP, etc.; |
include |
Header files, including the register definitions of each CPU, file system, network, etc.; the files in the configs subdirectory are configuration header files related to the target board |
doc |
U-Boot documentation, which may be useful when modifying configuration files |
api |
APIs and examples for extending applications, third-party functions |
nand_spl owner_ipl post |
Some special architectures require startup code and power-on self-test program code |
Makefile config.mk rules.mk |
The main Makefile and rule files that control the entire compilation process |
tools |
Compile S-Record or U-Boot image and other related tools, and make the kernel image file tool mkimage source code for bootm boot is here |
boards.cfg |
Add board configuration, for example, if the board is ly440, you need to make ly2440_config to read the file configuration during the compilation stage |
COPYING README MAINTAINERS CREDITS |
Some introductory documents, copyright notices |
The files marked in red are more important and are the main files to be modified.
(III) This time, u-boot-2010.09 is modified based on the FL2440 board, and the second stage initialization function analysis
1. Testing
Add board configuration in the boards.cfg file
Makefile adds the cross compiler buildroot-2011.11
Test compilation, make ly2440_config read the configuration file
Since Samsung's smdk2410 is very similar to s3c2440, we use smdk2410 as a model to improve the efficiency of code modification
[zhouguangfeng@centos6 u-boot-2010.09]$ cd board
[zhouguangfeng@centos6 board] $mkdir -p lingyun/ly2
[zhouguangfeng@centos6 board]$ cp samsung/smdk2410/* lingyun/ly2440
[zhouguangfeng@centos6 board]$ ls lingyun/ly2440
config.mk flash.c lowlevel_init.S Makefile smdk2410.c
[zhouguangfeng@centos6 board] $mv Lingyuan/ly2440/smdk2410.c Lingyuan/ly2440/ly2440.c
[zhouguangfeng@centos6 board]$ ls lingyun/ly2440
config.mk flash.c lowlevel_init.S ly2440.c Makefile
[zhouguangfeng@centos6 board]$
The specific changes are not detailed.
2. U-Boot starts, and the first execution is Start.S. There is a summary in the u-boot transplant summary (I) start.S analysis (click link). Here are some functions about the second stage of board initialization: U-Boot uses an array init_sequence to store function pointers of initialization functions that must be executed for most development boards. There are many compilation options in the init_sequence array. After removing the compilation options, the init_sequence array is as follows:
typedef int(init_fnc_t) (void); //declare a function type, return value int, parameter void
init_fnc_t*init_sequence[] = {
board_init, /*Development board related configuration --board/lingyun/ly2440/ly2440.c */
timer_init, /*Clock initialization--arch/arm/cpu/arm920t/s3c24x0/timer.c*/
env_init, /*Initialize environment variables--common/env_flash.c or common/env_nand.c*/
init_baudrate, /*Initialize baud rate -- arch/arm/lib/board.c */
serial_init, /*Serial port initialization--drivers/serial/serial_s3c24x0.c*/
console_init_f, /* Control communication station initialization phase 1 -- common/console.c */
display_banner, /*Print U-Boot version, compilation time -- arch/arm/lib/board.c */
dram_init, /*Configure available RAM--board/lingyun/ly2440/ly2440.c */
display_dram_config, /* Display RAM size -- arch/arm/lib/board.c*/
NULL,
};
The board_init function is defined in board/lingyun/ly2440/ly2440.c. This function sets the values of MPLLCOM, UPLLCON, and some GPIO registers, as well as the U-Boot machine code and kernel startup parameter addresses:
#if defined(CONFIG_S3C2410)
/* arch number of SMDK2410-Board */
gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
#endif
#if defined(CONFIG_S3C2440)
/* arch number of S3C2440-Board ,MINI2440 machine code*/
gd->bd->bi_arch_number = MACH_TYPE_MINI2440 ;
#endif
/* Kernel startup parameter address */
gd->bd->bi_boot_params=0x30000100;
FL2440 uses two 32MB SDRAMs to form a 64MB memory, connected to BANK6 of the memory controller, with an address space of 0x3000 0000~0x3400 0000. In include/configs/ly2440.h, PHYS_SDRAM_1 and PHYS_SDRAM_1_SIZE are defined as 0x30000000 and 0x04000000 (64M) respectively.
The dram_init function is defined in board/lingyun/ly2440/ly2440.c as follows:
int dram_init (void)
{
gd->bd->bi_dram[0].start= PHYS_SDRAM_1;
gd->bd->bi_dram[0].size= PHYS_SDRAM_1_SIZE;
return 0;
}
After analyzing the above data structure, let's analyze the start_armboot function:
voidstart_armboot (void)
{
init_fnc_t**init_fnc_ptr;
char *s;
… …
/* Calculate the address of the global data structure gd, defined in include/asm/global_data.h */
gd =(gd_t*)(_armboot_start - CONFIG_SYS_MALLOC_LEN - sizeof(gd_t));
… …
memset((void*)gd, 0, sizeof (gd_t));
gd->bd= (bd_t*)((char*)gd - sizeof(bd_t)); /*bd structure is defined in arch/arm/include/asm/u-boot.h, saves information about the board*/
memset(gd->bd, 0, sizeof (bd_t));
gd->flags|= GD_FLG_RELOC;
monitor_flash_len= _bss_start - _armboot_start;
/* Call the initialization functions in the init_sequence array one by one */
for(init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
if((*init_fnc_ptr)() != 0) {
hang();
}
}
/*armboot_start is initialized in arch/arm/cpu/arm920t/start.S as _start in the u-boot.lds linker script */
mem_malloc_init(_armboot_start - CONFIG_SYS_MALLOC_LEN,
CONFIG_SYS_MALLOC_LEN);
/* NAND Flash initialization */
#ifdefined(CONFIG_CMD_NAND)
puts("NAND: ");
nand_init(); /* go init the NAND */
#endif
… …
/*Configure environment variables, relocate */
env_relocate();
… …
/* Get the IP address from the environment variable */
gd->bd->bi_ip_addr= getenv_IPaddr ("ipaddr");
stdio_init(); /* get the devices list going. */
jumptable_init();
… …
console_init_r(); /* fully init console as a device */
… …
/* enableexceptions */
enable_interrupts();
#ifdefCONFIG_USB_DEVICE
usb_init_slave();
#endif
/* Initialize from environment*/
if ((s =getenv ("loadaddr")) != NULL) {
load_addr= simple_strtoul (s, NULL, 16);
}
#ifdefined(CONFIG_CMD_NET)
if ((s =getenv ("bootfile")) != NULL) {
copy_filename(BootFile, s, sizeof (BootFile));
}
#endif
… …
/*Network card initialization */
#ifdefined(CONFIG_CMD_NET)
#ifdefined(CONFIG_NET_MULTI)
puts("Net: ");
#endif
eth_initialize(gd->bd);
#if defined(CONFIG_RESET_PHY_R)
debug ("Reset Ethernet PHYn");
reset_phy();
#endif
#endif
/*main_loop() can return to retry autoboot, if so just run it again. */
for (;;){
main_loop();
}
/*NOTREACHED - no way out of command loop except booting */
}
The main_loop function is defined in common/main.c. In general, when entering the main_loop function, the CONFIG_BOOTDELAY defined in include/configs/ly2440.h is exceeded.
time without pressing ESC, U-Boot will load the system kernel.
Previous article:S3C2440_LCD Controller
Next article:Kernel transplantation and file system creation (2): Linux kernel minimum system and initramfs file system
Recommended ReadingLatest update time:2024-11-23 08:37
- 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
- Let's talk about the calculation method of RCD
- Which option is the best?
- MSP430F5529 generates PWM waves with CCS
- TI C66x DSP QM queue reserve method
- GD32E231Cx builds its own project OK, share it with everyone
- How to deal with audio noise
- Wireless MIDI Control
- Terasic C5P FPGA development board and Intel Up2 Squared Grove development kit released
- I don't understand part of the charging circuit. Please explain it to me.
- As an RF engineer, do you really know how to use "dB"?