Friendly Arm's latest mini2440 study notes - u-boot 1.1.6 transplantation (I)

Publisher:自由探索Latest update time:2020-05-18 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Starting from this article, I will record the problems encountered by the blogger during the u-boot 1.1.6 porting process. This article will cover two issues:


1. Add development board in u-boot


2. u-boot first stage startup code


1. Add development board in u-boot

1.1. Makefile changes

1.1.1. Add disassembly file output

Line 239 in the Makefile file, the source file is:


ALL = $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND)


change to:


ALL = $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(obj)u-boot.dis $(U_BOOT_NAND)


1.1.2. Adding a development board

Line 1879 of the Makefile file adds the mini2440 development board configuration as follows according to the form of smdk2410:


mini2440_config:unconfig

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


1.1.3. Deleting disassembled files during automatic cleanup

Makefile file 2293 lines, source file is:


rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)


change into:

rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(obj)u-boot.dis $(ALL)

1.2. Add header files

Add the mini2440.h file in the include/configs/ directory. You can directly copy a copy of the smdk2410.h file.


1.3. Add core version files

Add the mini2440 directory under the board/directory. You can directly copy the smdk2410 folder.


1.4. Summary

Since then, the mini2440 development board has been added to u-boot 1.1.6. You can directly execute the following command to generate the u-boot.bin file


make mini2440_config


make

But this u-boot.bin file cannot be started, and the relevant code needs to be modified for transplantation.




2. U-boot first stage startup code transplantation

The SOC of mini2440 is S3C2440, and its CPU is an ARM920t core, so the first stage startup code of u-boot is the cpu/arm920t/start.S file.


2.1. Disable watchdog and interrupt service

The watchdog of S3C2440 is the same as that of S3C2410, so make the following changes in the start.S file:


124 lines of source code:

#elif defined(CONFIG_S3C2410)

#define pWTCON 0x53000000

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

#define INTSUBMSK 0x4A00001C

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


change to:

#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)

#define pWTCON 0x53000000 /* watchdog register address */

#define INTMSK 0x4A000008 /* interrupt mask register address */

# define INTSUBMSK 0x4A00001C /* interrupt sub-mask register address */

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


131 lines of source code:

#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)

ldr r0, =pWTCON

mov r1, #0x0

str r1, [r0]


change to:

#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)

    ldr r0, =pWTCON

    mov r1, #0x0

    str r1, [r0]

142 lines of source code:

# if defined(CONFIG_S3C2410)

ldr r1, =0x3ff

ldr r0, =INTSUBMSK

str r1, [r0]


Then add some code, it becomes:

# if defined(CONFIG_S3C2410)

ldr r1, =0x3ff

ldr r0, =INTSUBMSK

str r1, [r0]

#elif defined(CONFIG_S3C2440)

ldr r1, =0x7FFF

ldr r0, =INTSUBMSK

str r1, [r0]


2.2. Setting MPLL and UPLL

In the source code, find:


/* FCLK:HCLK:PCLK = 1:2:4 */

/* default FCLK is 120 MHz ! */

ldr r0, =CLKDIVN

mov r1, #3

str r1, [r0]


change to:

#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)

/* FCLK:HCLK:PCLK = 1:2:4 */

/* default FCLK is 120 MHz ! */

ldr r0, =CLKDIVN

mov r1, #3

str r1, [r0]

#elif defined(CONFIG_S3C2440)

#define MPLLCON 0x4C000004

#define UPLLCON 0x4C000008

ldr r0, =CLKDIVN

ldr r1, =0x5 /* FCLK:HCLK:PCLK = 1:4:8 */

str r1, [r0]

ldr r0, =MPLLCON

ldr r1, =0x5C011 /* MPLL=400MHz */

str r1, [r0]

ldr r0, =UPLLCON

ldr r1, =0x38022 /* UPLL=48MHz */

str r1, [r0]

/* configure S3C2440 to asynchronous bus mode */

mrc p15, 0, r1, c1, c0, 0

orr r1, r1, #0xc0000000

mcr p15, 0, r1, c1, c0, 0

#endif


2.3. Add NAND boot code

The default in u-boot's smdk2410 code is NOR boot, so you need to add NAND boot code yourself.


Find the NOR startup code in the source file:


#ifndef CONFIG_SKIP_RELOCATE_UBOOT

relocate: /* relocate U-Boot to RAM */

adr r0, _start /* r0 <- current position of code */

ldr r1, _TEXT_BASE /* test if we run from flash or RAM */

cmp r0, r1 /* don't reloc during debug */

beq stack_setup

 

ldr r2, _armboot_start

ldr r3, _bss_start

sub r2, r3, r2 /* r2 <- size of armboot */

add r2, r0, r2 /* r2 <- source end address */

 

copy_loop:

ldmia r0!, {r3-r10} /* copy from source address [r0] */

stmia r1!, {r3-r10} /* copy to target address [r1] */

cmp r0, r2 /* until source end addreee [r2] */

ble copy_loop

#endif /* CONFIG_SKIP_RELOCATE_UBOOT */


change to:

#ifndef CONFIG_SKIP_RELOCATE_UBOOT

relocate: /* relocate U-Boot to RAM */

adr r0, _start /* r0 <- current position of code */

ldr r1, _TEXT_BASE /* test if we run from flash or RAM */

cmp r0, r1 /* don't reloc during debug */

beq stack_setup

#if defined(CONFIG_NOR_BOOT)

ldr r2, _armboot_start

ldr r3, _bss_start

sub r2, r3, r2 /* r2 <- size of armboot */

add r2, r0, r2 /* r2 <- source end address */

copy_loop:

ldmia r0!, {r3-r10} /* copy from source address [r0] */

stmia r1!, {r3-r10} /* copy to target address [r1] */

cmp r0, r2 /* until source end addreee [r2] */

ble copy_loop

#elif defined(CONFIG_NAND_BOOT)

ldr sp, =0x1000 /* setup stack to 4k temporarily to call the c function nand_read_ll*/

bl nand_init_ll /* initialize nand flash */

ldr r0, _TEXT_BASE /* destination for u-boot relocation */

ldr r1, =0x0 /* ​​source address in NAND */

ldr r2, =0x40000 /* length to read from NAND to SDRAM, 256K */

bl nand_read_ll /* call nand_read_ll to relocate u-boot */

#endif

#endif /* CONFIG_SKIP_RELOCATE_UBOOT */

2.4. Summary

So far, all the codes in start.S have been modified.


3. Description

The last part involves two functions, nand_init_ll and nand_read_ll. There are many C codes for these two functions used in NAND startup on the Internet, but the blogger reported errors after downloading them. Finally, I made up my mind and modified a version based on the NAND bare metal program of the great Wei Dongshan, and the effect was good.

Reference address:Friendly Arm's latest mini2440 study notes - u-boot 1.1.6 transplantation (I)

Previous article:Friendly Arm latest version mini2440 study notes - development board architecture and building development environment
Next article:arm9 mini2440 supervivi programming method

Recommended ReadingLatest update time:2024-11-23 15:45

atmega8 example: T1 timer CTC mode square wave output
/******************************************************************* * Function library description: ATMEGA8 T1 timer CTC mode square wave output * Version: v1.00         * Edited by: Pang Hui, Wuhu Lianda Freescale Studio                      * Modified on: August 8, 2011     *         * Description: OC1A
[Microcontroller]
Features and application advantages of Keithley’s 5-1/2 digit display model 6485 picoammeter
The 5-1/2-digit display model 6485 picoammeter incorporates Keithley's technical advantages in sensitive current measuring instruments and has improved measurement speed and durability. This economical instrument features 8 current ranges and a fast autoranging function that can measure currents from 20fA to 20mA at u
[Test Measurement]
u-boot transplantation (9)---Code modification---NAND
1. NAND principle      NAND has no address space, and the transmission of address and data relies on the LDATA string of data buses.       Without looking at random page programming, you can see that the pages from high to low are divided into 64 pages in total. Each page is composed of 2K + 64 bytes. The size of a
[Microcontroller]
u-boot transplantation (9)---Code modification---NAND
Xiaomi launches Xiaomi Civi 1S with new 4D ray tracing beauty technology, starting at 2,299 yuan
       On the afternoon of April 21, Xiaomi released the upgraded version of Xiaomi Civi, Xiaomi Civi 1S. This time, Xiaomi Civi 1S, based on the continuation of the first generation of natural beauty, has added 6 new beauty modes and male beauty adaptation functions, and is equipped with the Snapdragon 778G plus chip
[Mobile phone portable]
ARM NEON Programming Series 1 - Introduction
Preface This series of blog posts is used to introduce the NEON instruction optimization under ARM CPU. Blog post github address: github Related code github address: github NEON History The history of ARM processors can be found in . This article assumes that the reader has basic experience in programming under ARM
[Microcontroller]
Analysis and treatment of frequent liquid level alarms in high and low temperature water tanks of 18PA6B diesel engines
introduction The emergency diesel engine of a nuclear power plant uses the 18PA6B model assembled by Shaanxi Diesel Heavy Industry Group. The auxiliary system includes the fuel system, lubricating oil system, cooling water system, starting compressed air system, and intake and exhaust system. The cooling water
[Embedded]
Analysis and treatment of frequent liquid level alarms in high and low temperature water tanks of 18PA6B diesel engines
Aion LX is equipped with high-precision maps, which can predict 1km in advance and can automatically drive at high speeds?
Recently, GAC New Energy announced that Aion LX will be equipped with high-precision maps that can be delivered to achieve better autonomous driving. As a result, Aion LX becomes the first model to use the Chinese version of high-precision maps, with a positioning accuracy of 0.2m, and can predict the path ahead 1 km
[Automotive Electronics]
Aion LX is equipped with high-precision maps, which can predict 1km in advance and can automatically drive at high speeds?
MOS-FET final stage without negative feedback battery powered Class A 6 watt power amplifier
Power amplifier, referred to as "power amplifier". In many cases, the rated output power of the host is not enough to drive the entire audio system. At this time, a power amplifier must be installed between the host and the playback device to fill the required power gap. The power amplifier plays a pivotal role in "
[Analog Electronics]
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号