Porting u-boot1.1.6 to mini2440 document

Publisher:RadiantJourneyLatest update time:2022-06-20 Source: eefocusKeywords:u-boot1  6 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

 u-boot transplantation:

Transplantation is a complicated process, and there are too many things involved. Initially, you should focus on mastering ideas and methods, being able to compile, and implementing simple functions. In practice, you should slowly accumulate experience and become familiar with the process.


Compile U-Boot on the PC, generate Bin files, connect the development board to the PC through the serial port and USB port, download the generated Bin files to the RAM on the development board through the USB port, run directly from the RAM, and check whether the serial port outputs information as required. Be familiar with the process and basic settings of u-boot transplantation, and conduct in-depth research on the transplantation of flash, network card, USB, etc. in combination with kernel transplantation later


Transplantation content: LED, serial port, clock and basic hardware initialization, etc.


Transplantation process:

1. Establish a cross-compilation environment

Copy and unzip arm-linux-gcc-3.4.1.tgz,

# tar xvzf arm-linux-gcc-3.4.1.tgz –C / 

Create a working directory 

#mkdir /home/u-boot1.1.6

Run the command to change the path

#gedit /root/.bashrc

Edit the last line of the /root/.bashrc file

export PATH=$PATH:/usr/local/arm/3.4.1/bin

Restart Linux and test whether the compilation environment is established

#arm-linux-gcc –v


2. Create your own development board type in u-boot and test the compilation

1. Find a folder in the U-Boot source code Board that is similar to the target development board configuration, enter the board directory, copy smdk2410 and name it mini2440, enter the mini2440 directory, change smdk2410.c to mini2440.c, and make corresponding changes in Makefile.

2. Go to the include/configs directory, copy smdk2410.h and name it mini2440.h.

3. Open the Makefile file in the U-Boot root directory, search for smdk2410, locate smdk2410_config:unconfig, and add two lines below according to the format:

mini2440_config:unconfig

@$(MKCONFIG) $(@:_config=) arm arm920t mini2440 NULL s3c24x0

The meaning of each item is as follows:

arm: CPU architecture (ARCH)

arm920t: CPU type (CPU), which corresponds to the cpu/arm920t subdirectory.

mini2440: The model of the development board (BOARD), corresponding to the board/mini2440 directory.

Null: Developer/or distributor (vender), directly in the board directory here is NULL

s3c24x0: System on a chip (SOC).

4. Enter the mini2440 directory and modify the Makefie file

COBJS := smdk2410.o flash.o is

COBJS := mini2440.o flash.o

5. Test compilation

[root@localhost u-boot-1.1.6]# make mini2440_config

Configuring for mini2440 board...

[root@localhost u-boot-1.1.6]# make

The test is passed and the first step is completed


3. Modify the u-boot file to match mini2440

3.1 Modify /cpu/arm920t/start.S

(1) At the official start of the boot code, add an LED driver to enable it to display the u-boot process

#define GPBCON 0x56000010

#define GPBDAT 0x56000014

#define GPBUP 0x56000018

 

ldr r0, =GPBUP

ldr r1, =0x7FF

str r1, [r0]

 

ldr r0, =GPBCON

ldr r1, =0x154FF

str r1, [r0]

 

ldr r0, =GPBDAT

ldr r1, =0x000 /*Turn on all four LEDs*/

str r1, [r0]

In the above lines of code, the register address of the PB port is defined respectively, the pull-up of the PB port is turned off, and the PB5, 6, 7, and 8 ports are set as output ports (corresponding to the 4 LEDs on the mini2440 development board). PB5, PB6, 7, and 8 are set to low level, and the corresponding LED is on.

(2) Disable the RAM initialization function of u-boot

Generally, Bootloader has the following two functions: it initializes RAM at power-on; and then copies itself to RAM to run, thus increasing the running speed. We can see the above two points from the two macros below start_code in the start.S file:

#ifndef CONFIG_SKIP_LOWLEVEL_INIT

#ifndef CONFIG_SKIP_RELOCATE_UBOOT

We directly download the U-Boot.bin file to the memory through the current Bootloader and run it. The RAM initialization has been done by Supervivi. We don't need to initialize it again here, and if we do, the test will fail. Therefore, we must turn off the LOWLEVEL_INIT function. You can comment out bl cpu_init_crit here, or add a macro definition in include/configs/mini2440.h:

#define CONFIG_SKIP_LOWLEVEL_INIT 1

(3) Modify the register address

#if defined(CONFIG_S3C2400)

#define pWTCON 0x15300000

#define INTMSK 0x14400008 /* Interupt-Controller base addresses */

#define CLKDIVN 0x14800014 /* clock divisor register */

#else

#define pWTCON 0x53000000

#define INTMSK 0x4A000008 /* Interupt-Controller base addresses */

#define INTSUBMSK 0x4A00001C

#define CLKDIVN 0x4C000014 /* clock divisor register */

#endif

(4) Modify the interruption part

#if defined(CONFIG_S3C2410)

    ldr r1,=0x7ff /*According to the 2410 chip manual, INTSUBMSK has 11 bits available, and vivi is also 0x7ff. U-Boot has not changed it. */  

ldr r0,=INTSUBMS

str r1,[r0]

#endif

#if defined(CONFIG_S3C2440)

    ldr r1,=0x7fff /*According to the 2440 chip manual, INTSUBMSK has 15 bits available*/

    ldr r0,=INTSUBMSK

    str r1,[r0]

#endif

(5) Modify the clock

#define MPLLCON 0x4C000004

#define UPLLCON 0x4C000008

 

ldr r0, =UPLLCON

ldr r1, =0x38022

str r1, [r0]

 

ldr r0, =MPLLCON

ldr r1, =0x7F021

str r1, [r0]

 

ldr r0, =CLKDIVN

mov r1, #5

str r1, [r0]

The first section of the code defines the relevant registers. CLKDIVN has been defined before. The second section sets the USB clock frequency to 48MHz. The third section sets the system's main frequency to 405MHz. The fourth section sets the frequency division factor to allocate the main frequency to the system bus for use by other slow devices.

Open board//mini2440/mini2440.c and modify M_MDIV,

Here, we mainly modify the macro definition to make it consistent with the parameters set in the register in the assembly file.

#define M_MDIV 0x7f                        


#define M_PDIV 0x2


#define M_SDIV 0x1

//ldr r0, =MPLLCON

//ldr r1, =0x7F021 (the above value is designed from here)

(6) Modify the serial port

Modify the frequency calculation function in cpu/arm920t/s3c24x0/speed.c. The calculation of FCLK in 2440 is somewhat different from that in 2410, which is twice the original calculation value of 2410. In addition, it is known that the frequency division parameters set previously are FCLK:HCLK:PCLK=1:4:8, so HCKL is directly set to 1/4 of FCLK. The code is modified as follows:

ulong get_FCLK(void)

{

               ......

               p = ((r & 0x003F0) >> 4) + 2;

               s = r & 0x3;

 

              

    if (pllreg == MPLL)

               r = clk_power->MPLLCON;

               return((CONFIG_SYS_CLK_FREQ * m*2) / (p << s));

    else if (pllreg == UPLL)

               r = clk_power->UPLLCON;

               return ((CONFIG_SYS_CLK_FREQ * m) / (p << s));

    else

               hang();   

}

 

ulong get_HCLK(void)

{

    S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();

 

    return((clk_power->CLKDIVN & 0x2) ? get_FCLK()/4 : get_FCLK());

}

(7) Add "CONFIG_S3C2440" to the file so that the original s3c2410 code can be compiled in.

Some drivers in U-Boot have different configuration methods and parameters according to different processor models, so they are distinguished by defining CONFIG_XXXXX. Since the register addresses and parameter settings of S3C2410 and S3C2440 are basically the same, you only need to add CONFIG_S3C2440 where CONFIG_S3C2410 is defined, and the same applies to CONFIG_MINI2440; if the processors are very different, you need to write the corresponding driver code according to the functional needs of the specific location.

 

In the u-boot root directory, use the command to find the file with "CONFIG_S3C2410" and then add || defined(CONFIG_S3C2440) at the end.

[root@localhost u-boot-1.1.6]# grep 'CONFIG_S3C2410' * -R

Then modify it in turn

pay attention:

Line 181 of /cpu/arm920t/s3c24x0/interrupts.c file, add the red part

#elif defined(CONFIG_SBC2410X) ||

      defined(CONFIG_SMDK2410) ||

      defined(CONFIG_VCMA9)||defined(CONFIG_mini2440)


4: After the modification is completed, compile

[root@localhost u-boot-1.1.6]# make

Compile and generate uboot.bin, now run

The basic process of Uboot is already familiar to you, and you can then perform related transplantation such as flash and network card as needed.  


Keywords:u-boot1  6 Reference address:Porting u-boot1.1.6 to mini2440 document

Previous article:Install u-boot on mini2440
Next article:uboot-2009.03 successfully ported to mini2440

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号