1.gboot.lds
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS {
. = 0x30008000; //Start address
. = ALIGN(4); //4-byte alignment
.text : //Code segment
{
start.o (.text) //Start execution with .o
*(.text)
}
. = ALIGN(4);
.data : //Data segment
{
*(.data)
}
. = ALIGN(4);
bss_start = .; //Define variables
.bss : //Uninitialized segment
{
*(.bss)
}
bss_end = .;
}
2.start.S
.text
.global _start//define global variable
_start: //code starts executing
//The following is the exception vector table code
b reset//Reset
ldr pc, _undifined_instruction
ldr pc, _software_interrupt
ldr pc, _prefetch_abort
ldr pc, _data_abort
ldr pc, _not_used
ldr pc, _irq
ldr pc, _fiq
//Define the corresponding variables for jump
_undifined_instruction: .word undifined_instruction
_software_interrupt: .word software_interrupt
_prefetch_abort: .word prefetch_abort
_data_abort: .word data_abort
_not_used: .word not_used
_irq: .word irq
_fiq: .word reset
//The function implemented after the jump
undifined_instruction:
nop
software_interrupt:
nop
prefetch_abort:
nop
data_abort:
nop
not_used:
nop
irq:
nop
fiq:
nop
//reset
reset:
bl set_svc
bl disable_watchdog
bl disable_interrupt
bl disable_mmu
//set svc mode
set_svc:
mrs r0, cpsr
bic r0, r0,#0x1f
orr r0, r0,#0xd3
msr cpsr, r0
mov pc, lr
//disable watchdog
#define pWTCON 0x53000000
disable_watchdog:
ldr r0, =pWTCON
mov r1, #0x0
str r1, [r0]
mov pc, lr
//disable interrupt
disable_interrupt:
mvn r1, #0x0
ldr r0, =0x4a000008
str r1, [r0]
mov pc, lr
//disable mmu
disable_mmu:
mcr p15,0,r0,c7,c7,0
mrc p15,0,r0,c1,c0,0
bic r0, r0, #0x00000007
mcr p15,0,r0,c1,c0,0
mov pc, lr
//Makefile3.Makefile
all: start.o
arm-linux-ld -Tgboot.lds -o gboot.elf $^
arm-linux-objcopy -O binary gboot.elf gboot.bin
%.o : %.S
arm-linux-gcc -g -c $^
%.o : %.c
arm-linux-gcc -g -c $^
.PHONY: clean
clean:
rm *.o *.elf *.bin
/******************************** Stay hungry, Stay foolish. @Rocky ********************************/
Previous article:Assembly to light up the LED lamp (2440)
Next article:ARM-Assembly Instruction Set (Summary)
Recommended ReadingLatest update time:2024-11-15 17:44
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
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- 6ull mini board size
- Problems with STM32F103C8T6 standby mode
- TE Award Live: I will predict the future - Registration for the latest application of sensors in the Internet of Things has started~
- Microchip live broadcast today|Using PKCS #11 and security devices to develop Linux system security IoT edge devices to the cloud...
- Silicon Labs Development Kit Review + Development Board Arrives
- filter
- Looking for a company that can make SIC simulation models
- The volume control IC PT2259 has background noise, how to solve it?
- Learn about enhanced eCall car design in one article
- How to overcome the load-pull measurement challenges of 5G mmWave? (Part 2)