%_config::unconfig
@$(MKCONFIG) -A $(@:_config=)
The weird thing is that there is this little bit below:
################################################ ######################
## ARM1176 Systems
####################### ################################################
smdk6400_noUSB_config
smdk6400_config :unconfig
@mkdir -p $(obj)include $(obj)board/samsung/smdk6400
@mkdir -p $(obj)nand_spl/board/samsung/smdk6400
@echo "#define CONFIG_NAND_U_BOOT" > $(obj)include/config.h
@echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
@if [ - z "$(findstring smdk6400_noUSB_config,$@)" ]; then
echo "RAM_TEXT = 0x57e00000" >> $(obj)board/samsung/smdk6400/config.tmp;
else
echo "RAM_TEXT = 0xc7e00000" >> $(obj)board /samsung/smdk6400/config.tmp;
fi
@$(MKCONFIG) smdk6400 arm arm1176 smdk6400 samsung s3c64xx
@echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
I felt strange when I saw this. In the new version of uboot, the configuration of other boards all use the %_config target. Why does smdk6400 have a separate target? I looked at the nand_spl directory out of curiosity, and used make smdk6400_config and make to see the configuration and compilation process. At that time, I initially figured out what was going on:
There is a nand_boot.c in the nand_spl directory. From the file name, it seems to be related to booting from nand. Speaking of nand booting, I have to add a sentence: I studied the GNU ARM assembly series on a broken notebook with Ubuntu installed. Because it is a notebook, there is no parallel port or serial port. I can only use a USB to serial port. I can't afford advanced gadgets like jlink. Because it is a broken notebook, win doesn't run well, so I just run linux. So I dare not touch the nor flash in my board at all, and can only use nand flash. Therefore, I am quite familiar with the process of nand flash booting. Then why does s3c2440 boot from nand Flash booting must use the internal 4K sram. According to the datasheet, when booting from nand, you must set the OM[0:1] switch to map the internal 4K sram to 0x00000000, because arm boots from 0x00000000. Samsung's design is that in this case, the first 4K data in nand will be loaded into sram by hardware, so that nand can be booted with this 4K sram. Why is this 4K sram necessary to boot from nand? According to some predecessors and my own understanding, there are two main reasons: first, nand flash operation requires a controller, and when soc is booting, no instruction is executed in time, how to initialize the controller, if the controller is not initialized, how to get the instructions on nand flash; second, nand flash itself can only read pages, and cpu cannot get a 32-bit instruction from nand. In addition, nand flash is dumbfounded for jump instructions, and nand flash cannot be read randomly in this way.
I said I was going to insert a sentence, but I accidentally inserted a paragraph and started a new paragraph:
There are three files in nand_spl/board/samsung/smdk6400: config.mk, Makefile and u-boot.lds. By looking at these three files and the makefile in the uboot root directory, you can roughly understand how nand_spl is implemented:
In the makefile in the uboot root directory there is:
$(obj)u-boot-nand.bin:nand_spl $(obj)u-boot.bin
cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $( obj)u-boot-nand.bin
This is how to merge two bin files into one bin file!!!
To be honest, I had this idea when I was making my own bootloader. I didn't expect that when I transplanted uboot by myself, I found that the new uboot also adopted this method. I was a little proud, ^_^
More specifically, u-boot-spl.bin in the nand_spl directory does the following:
1. Set the CPU to svc mode
2. Turn off the door dog and interrupt
3. Initialize the system clock
4. Disable MMU and Cache
5. Initialize the sdram controller
6. Set sp and jump to the nand_boot function in nand_boot.c mentioned above. This function initializes the nand controller and loads the u-boot.bin image after 4K from nand to sdram, and then jumps to the beginning of the u-boot.bin image to continue the subsequent work
To implement this u-boot-spl-16k.bin, you can follow the steps below:
1. Add a new target in the makefile in the uboot root directory:
################################################ ####################
#TQ2440 by Baikal
########################## ###########################################
TQ2440_config: unconfig
@echo " #define CONFIG_NAND_U_BOOT" > $(obj)include/config.h
#echo "RAM_TEXT = 0x33000000" > $(obj)board/samsung/TQ2400/config.tmp;
@$(MKCONFIG) TQ2440 arm arm920t - samsung s3c24x0
@echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
2. Create a new folder TQ2440 under nand_spl/board/samsung, copy the three files under the smdk6400 directory and modify them slowly. The biggest modification is the change of makefile:
start.S uses arch/arm/cpu/arm920t/start.S
lowlevel_init.S uses board/samsung/smdk2410/lowlevel_init.S
nand_boot.c uses nand_spl/nand_boot.c
s3c2440_nand.c uses drivers/mtd/nand/s3c2440_nand.c
3. Porting the code of s3c2440_nand
4.Wrap some code in start.S with #ifdef CONFIG_NAND_SPL or #ifndef CONFIG_NAND_SPL according to the specific situation.
5. The final compilation and linking process is to link a u-boot-spl file, and strip the binary data file u-boot-spl.bin from the u-boot-spl file. In fact, this bin file is only about 1.2k, fill it to 4K size
If you have a certain understanding of bootloader and are familiar with compiling, linking, and makefile scripts, this alone is not a big task. Don't forget to be familiar with nand flash control.
Finally, let me talk about a problem that delayed me for a long time. I forgot to set sp when jumping nand_boot.c. Because I could only debug through LED, the phenomenon I saw made me mistakenly think that my nand flash driver was not adjusted correctly. Finally, I suddenly understood. At that time, I was also annoyed when looking at those LEDs...
just go on, stop being impatient
Previous article:GNU ARM Assembly--(Seventeen) Interpretation of u-boot's makefile and mkconfig
Next article:GNU ARM Assembly--(XIX) u-boot-nand-spl startup process analysis
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- Xunwei 3399 development board-PCIE 4G module test-test program
- Which of the two ways of making differential lines of equal length internally is better?
- Program for MSP430F5529 and MAX7456 character overlay module
- Arteli SC0034AT32F4xx_CAN filter usage
- X-NUCLEO-IKS01A3 Review——by dcexpert
- [RISC-V MCU CH32V103 Review] 4. Take a look at the temperature + your opinion on RISC-V
- itop4412 development board Qt serial port programming-interface layout
- Wireless communication signal propagation
- Master these skills to easily operate DC-DC circuits
- Antenna Design Solutions for Next Generation Mobile Devices