u-boot transplant summary (IV) u-boot-2010.09 framework analysis

Publisher:ArtisticSoulLatest update time:2024-07-24 Source: elecfansKeywords:u-boot Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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

SDRAM

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.


Keywords:u-boot Reference address:u-boot transplant summary (IV) u-boot-2010.09 framework analysis

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

U-boot-2014.04 ported to MINI2440 (10) Porting nand flash to save environment variables and add partitions
1. Save environment variables to nand flash Step 1: Modify mini2440.h Since we execute the saveenv command and then save the environment variables, the u-boot commands are all implemented under common. Cut in and execute gerp "saveenv" –nr ./*.c, and find the following results: There are a lot of things here, op
[Microcontroller]
U-boot-2014.04 ported to MINI2440 (10) Porting nand flash to save environment variables and add partitions
TQ2440 Study Notes—— 29. Porting U-Boot [U-Boot compilation and linking process]
U-Boot compilation and linking process After configuration, execute "make all" to compile. From the Makefile, you can understand which files U-Boot uses, which file is executed first, and the memory occupied by the executable file. First determine which files are used. The following shows the ARM-related part of t
[Microcontroller]
TQ2440 Study Notes—— 29. Porting U-Boot [U-Boot compilation and linking process]
u-boot-2011.03 porting on mini2440/micro2440 supports yaffs download
6.1 include/conskfigs/micro2440.h Add #define CONFIG_CMD_NAND_YAFFS 【illustrate】 When I was reading cmd_nand.c, I found that u-boot-2011.03 already supports yaffs writing. I only need to add the above definition, but the actual writing error occurred. After reading the source code again, I fou
[Microcontroller]
uboot-2011.12 ported to S3C2440 (Part 1) - Simple modification to enable u-boot to compile
The cross-compilation environment is a cross-compilation toolchain made by Fedora14 and Friendly Arm 1. Modify boards.cfg and add a red line         smdk2400 arm arm920t - samsung s3c24x0         smdk2410 arm arm920t - samsung s3c24x0         smdk2440 arm arm920t - samsung s3c24x0 2. Under $(SOURCEDIR)/u-boot-20
[Microcontroller]
Design of embedded U-BOOT gigabit network function based on S3C2440A
U-BOOT supports network functions. When downloading operating system kernels and large file systems, it is faster and more convenient than other boot loaders that do not support the network. At present, U-BOOT only supports 10M/100M network functions. With the development of science and technology, gigabit network f
[Microcontroller]
Design of embedded U-BOOT gigabit network function based on S3C2440A
OK6410 default u-boot startup parameters
Default startup parameters: bootargs=root=/dev/mtdblock2 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200 bootcmd=nand read 0xc0008000 0x200000 0x500000;bootm 0xc0008000 baudrate=115200 ethaddr=00:40:5c:26:0a:5b netmask=255.255.255.0 bootdelay=5 ipaddr=192.168.48.100 serverip=192.168.48.103 gatewayip=192.168.48.
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号