TQ210 study notes - uboot code migration

Publisher:幸福约定123Latest update time:2020-12-21 Source: eefocusKeywords:TQ210  uboot Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Learning materials: TQ210 development board + Guoqian teaching video

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Code migration: refers to the process of moving the remaining boot code to the memory during the boot process (for 210, when the bootloader code is larger than 96KB, BL2 must be moved to the memory, because the 210 boot process stipulates that BL2 cannot be larger than 80KB)


This article is about moving from SRAM to memory, not moving from nand flash to memory. The reasons are as follows:

(1) If you want to move from nand flash to memory, you must first initialize nand flash. This part has not been learned yet, so it is temporarily impossible to move from nand flash to memory.

(2) Only when the bootloader is larger than a certain value, BL1 will move BL2 from nandflash to memory. The uboot we are writing now is much smaller than 4kb, so it is not necessary to move it from nandflash to memory for the time being and can run directly in SRAM. The reason for moving from SRAM to memory is just to learn how to move. A more standardized method should be to move from nandflash to memory.

How to migrate code?

Find out the starting point, end point, and how to move


1. 210 moving starting point:

The SRAM of 210 is IRAM, and the starting address is 0xd0020000. As shown below


It is the IRAM address. Why is it this? Because when 210 starts, the program (BL0) in IROM will automatically copy BL1 to BL1, that is, to the 96KB IRAM. IRAM is equivalent to the steppingstone in 2440 and 6410, but 210 does not have this term. See the figure below.




2. Moving destination:

1. The role of the link address in the connector script file. The following two roles are introduced

(1) In C language programming, if a function is called midway, such as calling the reset() function, the PC pointer will be assigned the link address of reset. This is an absolute jump.

(2) During assembly, if the pseudo instruction ldr is used to jump to the reset function ldr pc, =reset, the PC will also be assigned the link address of reset. This is an absolute jump.

2. About relative jump and absolute jump.

(1) Relative jump b jump is a relative jump

After the jump, PC = current PC value + the difference between the jump label and the current PC in the relative address table (that is, the difference in the link address, this part of the description may be wrong, anyway, this is the meaning) as shown below (uboot code)



Start is the program entry point. The address set in the linker script is 0x20000000. The first statement is b reset, which jumps to reset execution. The entire program is compiled and linked to generate an elf format file. Use arm-linux-objdump to disassemble it. When you look at the disassembled file, you can see that the address of the first statement (that is, bl reset) is 0x20000000


 

The address of the reset label (that is, the jump destination) is 0x2000005c, as shown below



If a relative jump is executed (the b instruction is a relative jump), after executing this instruction, PC = current PC + (0x2000005c-0x20000000). After the chip is powered on, the PC value must be 0, so the current PC is 0. Therefore, after executing this statement, PC = 0 + (0x2000005c-0x20000000).

(2) Absolute jump

The two examples in 1 above are absolute jumps. After the absolute jump is executed, the PC pointer value will become the link address. That is, if a reset is executed through an absolute jump, after the jump instruction is executed, PC = 0x2000005c (jumped to the memory)

The link start address determines the location of the first line of code in the program in memory, that is, the starting address of the program in memory. When moving, refer to the link start address and move the code to the corresponding location in memory.

The link start address is the end point of the code migration. The video tutorial says this, but I don't quite understand it. I will think about this part later. If you know, please introduce it to me, or give me a link to watch it myself. The code migration program is posted below.


@Topic 9 Code Migration

copy_to_ram:

ldr r0, =0xd0020000 @Move starting point

ldr r1, =0x20000000 @Move end point

add r3, r0, #(1024*4) @r3=starting point + amount of data copied (4KB)

copy_loop:

ldr r2, [r0], #4 @Start reading data. Since it is 32 bits at a time, the address should be moved back 4 bytes after reading.

str r2, [r1], #4 @Copy the read data to the memory, also copy 32 bits at a time, and move the memory address back 4 bytes after copying

cmp r0, r3 @Judge whether 4KB data has been moved

bne copy_loop

mov pc, lr @Back to the calling point


Keywords:TQ210  uboot Reference address:TQ210 study notes - uboot code migration

Previous article:S5PV210 address addressing capability mapping
Next article:Understanding the process of loading u-boot on S5PV210

Recommended ReadingLatest update time:2024-11-23 16:47

OK6410 development board uboot burning
After the uboot porting was completed, I thought it would be quickly burned onto the board and Linux would be installed. However, it took three days to finally succeed in burning uboot. During this process, I encountered many problems, which I will summarize here. First of all, Feiling's OK6410 development board does
[Microcontroller]
TQ210 - Light up the LED
1. Introduction to S5PV210 GPIO Hardware 1.1. GPIO       GPIO stands for General-Purpose IO ports. In embedded systems, there are often a large number of external devices/circuits with relatively simple structures. Some of these devices/circuits require the CPU to provide control means, while others need to be used
[Microcontroller]
TQ210 - Light up the LED
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号