Uboot usage
uboot console, countdown
command: debug, operate some hardware
setenv printenv saveenv
nand erase
nand write
tftp 20008000 zImage
help: What commands can uboot provide?
setenv == set == sete == seten
Environment variables: provide parameters for the command
serverip: the tftp command provides the address of the tftp server
ipaddr: the tftp command provides the address of the tftp client (development board)
Two environment variables
uboot: download the kernel and start the kernel
bootcmd: what should uboot do automatically after the countdown ends
set bootcmd tftp 20008000 zImage ; bootm 20008000
set serverip 192.168.7.2
set ipaddr 192.168.7.6
set ethaddr 00:22:23:24:25:ee
When the countdown ends, uboot will execute the content in bootcmd:
tftp 20008000 zImage ; bootm 20008000
Download the zImage file (/tftpboot/) from the tftp server (serverip) to 20008000 in the memory of the development board (ipaddr)
set bootcmd tftp 20008000 zImage ; bootm 20008000
bootargs: responsible for telling the kernel where the file system is (uboot passes it to the kernel, which is used by the kernel)
set bootargs init=/linuxrc console=ttySAC0,115200 root=/dev/nfs nfsroot=192.168.7.2:/opt/filesystem ip=192.168.7.6
root=xxxx: Where is the root file system directory?
/dev/nfs: The root file system directory is at the remote end of the network
nfsroot=xxxx: Which file path of which machine is the root file system directory?
nfsroot=192.168.7.2:/opt/filesystem
ip=192.168.7.6: When the system logs in, a static ip is assigned.
If root=/dev/nfs
root=/dev/nfs + nfsroot=xxxx +ip=xx
If root=/dev/mtdblock2 (will be discussed when the file system is created)
root=/dev/mtdblock2 + rootfstype=cramfs
console=ttySAC0,115200: During kernel startup, where should the debugging information be output? printk
init=/linuxrc : Specify the executable code file of the first init process
/opt/filesystem==> host: /etc/exports
sudo vim /etc/exports
/opt/filesystem *(subtree_check,rw,no_root_squash,async)
/opt/fs100/rootfs *(subtree_check,rw,no_root_squash,async)
Start the kernel: go/bootm
Official uboot
zImage
: go
set bootcmd tftp 20008000 zImage ; go 20008000
uImage
: bootm(download address, cannot be 20008000)
set bootcmd tftp 20800000 uImage ; bootm 20800000
selection of download address:
go==> can be any address
bootm==> 20008000+zImage size or above==>20800000
Comprehensive usage:
set bootcmd tftp 20800000 zImage ; go 20800000
set bootcmd tftp 20800000 uImage ; bootm 20800000
uboot1.3.4:
zImage/uImage ==>bootm
set bootcmd tftp 20800000 uImage ; bootm 20800000
uboot connection script
Path: cpu/arm_cortexa8/u-boot.lds
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start) // Entry function
SECTIONS
{
. = 0x00000000; // Current starting position 0x0
. = ALIGN(4);
.text(target file) :
{
cpu/arm_cortexa8/start.o (.text) // First file's .text
*(.text)
}
. = ALIGN(4); // Current position four-byte alignment
.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
. = ALIGN(4);
.data : { *(.data) }
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .; // Use __u_boot_cmd_start to record the current position. The code will use the global
.u_boot_cmd: { *(.u_boot_cmd) } // Segment data
__u_boot_cmd_end = .; // End position
. = ALIGN(4);
__bss_start = .;
.bss: { *(.bss) }
_end = .;
}
Connection base address:
-Ttext 0x34800000==>board/samsung/smdkc100/config.mk
TEXT_BASE = 0x34800000
1, TEXT_BASE specifies the starting position of the uboot connection
2, specifies the location of the uboot relocation (can be changed to 0x2ff00000)
Detailed description of uboot configuration
make smdkc100_config
vim Makefile
unconfig:
@rm -f $(obj)include/config.h $(obj)include/config.mk
$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp
$(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep
MKCONFIG := $(SRCTREE)/mkconfig == ./mkconfig Shell script (executable program)
smdkc100_config: unconfig
@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 smdkc100 samsung s5pc1xx
./mkconfig smdkc100 arm arm_cortexa8 smdkc100 samsung s5pc1xx
Execute a script: 6 parameters are passed (control source code compilation)
arm: architecture ==> lib_arm
smdkc100: include/configs/smdkc100.h // Configuration of all macros of the development board
arm_cortexa8: arm name ==> cpu/arm_cortexa8
smdkc100 samsung: development board name ==> board/samsung/smdkc100
s5pc1xx: cpu ==> cpu/arm_cortexa8/s5pc1xx
$(@:_config=): $@:_config= ==>smdkc100_config:_config= // _config is replaced with empty, remove
$(@:_config=xxx) ===>smdkc100xxx
uboot first stage startup process
1, build exception vector table:
_start: b reset
ldr pc, _undefined_instruction
ldr pc, _software_interrupt
ldr pc, _prefetch_abort
ldr pc, _data_abort
ldr pc, _not_used
ldr pc, _irq
ldr pc, _fiq
2,
reset:
/*
* set the cpu to SVC32 mode, disable F, I
*/
mrs r0, cpsr
bic r0, r0, #0x1f
orr r0, r0, #0xd3
msr cpsr,r0
bl cpu_init_crit
|
/*
* Invalidate L1 I/D
*/
mov r0, #0 @ set up for MCR
mcr p15, 0, r0, c8, c7, 0 @ invalidate TLBs
mcr p15, 0, r0, / * Disable MMU stuff and caches */ mrc p15, 0, r0, c1, c0, 0
bic r0, r0, #0x00002000 @ clear bits 13 (--V-) bic r0, r0, #0x00000007 @ clear bits 2:0 (-CAM) orr r0, r0, #0x00000002 @ set bit 1 (--A-) Align orr r0, r0, #0x00000800 @ set bit 12 (Z---) BTB mcr p15, 0, r0, c1, c0, 0 bl lowlevel_init //lowlevel_init.S (boardsamsungsmdkc100):lowlevel_init: | /* Disable Watchdog */ ldr r0, =S5PC100_WATCHDOG_BASE @0xEA200000 orr r0, r0, #0x0 str r5, [r0] /* setting SRAM */ ldr r0, =S5PC100_SROMC_BASE ldr r1, =0x9 str r1, [r0] /* S5PC100 has 3 groups of interrupt sources */ ldr r0, =S5PC100_VIC0_BASE @0xE4000000 ldr r1, =S5PC100_VIC1_BASE @0xE4000000 ldr r2, =S5PC100_VIC2_BASE @0xE4000000 /* Disable all interrupts (VIC0, VIC1 and VIC2) */ mvn r3, #0x0 str r3, [r0, #0x14] @INTENCLEAR str r3, [r1, #0x14] @INTENCLEAR str r3, [r2, #0x14] @INTENCLEAR /* Set all interrupts as IRQ */ str r5, [r0, #0xc] @INTSELECT str r5, [r1, #0xc] @INTSELECT str r5, [r2, #0xc] @INTSELECT /* Pending Interrupt Clear */ str r5, [r0, #0xf00] @INTADDRESS str r5, [r1, #0xf00] @INTADDRESS str r5, [r2, #0xf00] @INTADDRESS bl uart_asm_init // Just set the gpio function, the baud rate is set in the second stage #if 1 // The changed part /* init system clock */ bl system_clock_init // Basically no big problem bl mem_ctrl_asm_init //mem_setup.S boardsamsungSmdkc100 // Memory initialization is more complicated, the original manufacturer will provide (1.3.4) // Ask FAE // This part of the code has problems running 1, mem_ctrl_asm_init
2, mem_setup.S needs to be compiled <=== boardsamsungSmdkc100Makefile
3, memory initialization code should be in the first 16k (disassembled)
modify cpu/arm_cotexa8/u-boot.lds
/* Set up the stack */
stack_setup: ldr
r0, _TEXT_BASE @ upper 128 KiB: relocated uboot
sub r0, r0, #CONFIG_SYS_MALLOC_LEN @ malloc area
sub r0, r0, #CONFIG_SYS_GBL_DATA_SIZE @ bdinfo
#ifdef CONFIG_USE_IRQ
sub r0, r0, #(CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ)
#endif
sub sp, r0, #12 @ leave 3 words for abort-stack
and sp, sp, #~7 @ 8 byte alinged for (ldr/str)d
Self-copy of uboot code:
/* nand src offset : 0x0*/
mov r0, #0x0
/* ddr dst addr : 0x2ff00000*/
ldr r1,=0x2ff00000
/*size*/
ldr r2, =0x40000
bl copy2ddr
ddr address (relocation target address): should be the same as the base address of the uboot link
board/samsung/smdkc100/config.mk
TEXT_BASE=xxxx
Clear bss end
/* Clear BSS (if any). Is below tx (watch load addr - need space) */
clear_bss:
ldr r0, _bss_start @ find start of bss segment
ldr r1, _bss_end @ stop here
mov r2, #0x00000000 @ clear value
clbss_l:
str r2, [r0] @ clear BSS location
cmp r0, r1 @ are we at the end yet
add r0, r0, #4 @ increment clear index pointer
bne clbss_l @ keep clearing till at end
Jump to C stage
ldr pc, _start_armboot @ jump to C code
_start_armboot: .word start_armboot
_start_armboot: .word start_armboot
//start_armboot's value is determined during compilation: 0x2ff00000+offset==> 0x2ff00980
arm: basically all instructions are position-independent (the instructions can be executed anywhere).
Some codes are position-dependent: ldr pc, _start_armboot (pc jumps to the target address _start_armboot (0x2ff00980), which is related to a specific location)
The ldr instruction itself is position-independent, and the entire ldr pc, _start_armboot ==> becomes a position-dependent instruction
Link address: The linker sorts all the instructions. There must be a base address: base address + offset of the instruction.
Run address: The address where the instruction is actually loaded. When running, the address where the instruction is stored.
Physical address: Related to the hardware. The addresses in the data sheet are all physical addresses. The values set by the hardware engineer for the device.
Virtual address: Generally related to MMU.
Ideas:
1. Support a boot mode nand boot
a. Initialize the clock and memory
1. mem_setup.S is compiled
b. Complete the implementation of self-copy
nand_ops.c (read operation)
nand(0x0) --> ddr(TEXT_BASE)
board/samsung/smdkc100/config.mk
c. The first stage code must all be in the first 16k
u-boot.lds
d. Familiar with the first stage boot process code
Previous article:arm series knowledge framework
Next article:[Embedded] arm-linux-gcc/ld/objcopy/objdump parameter overview
Recommended ReadingLatest update time:2024-11-15 05:08
- 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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Similarities and differences between totem pole output and complementary push-pull output
- TMS320C6000 chip structure diagram and basic characteristics
- TI releases the latest industrial electronics reference design!
- MSP430FR6972 serial port baud rate setting code
- 【XMC4800 Relax EtherCAT Kit Review】+ FreeRTOS real-time system usage
- 【Silicon Labs BG22-EK4108A Bluetooth Development Evaluation】+ Development Environment Construction
- Do you know how to save power in RTOS applications?
- The problem of lower yield strength
- What you should know about the switching characteristics of Mosfet
- Understanding wireless communication technology