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
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
- 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
- 【Topmicro Intelligent Display Module】Part 2: Power on and experience the demo
- Guangdong companies are looking for electronic engineers/structural engineers/acoustic engineers
- 【Distributed Temperature and Humidity Acquisition System】Work Submission
- Analog Modulation Attached (PPT)
- Can the output voltage of an LDO be equal to the input voltage?
- [EVK-NINA-B400 Evaluation Kit] Unboxing
- Oscilloscope usage tips you don't know
- Two questions about F7
- After importing the 2812 project example, it prompts that it does not match and cannot be run
- MSP430F149 Program - RS485