working code v1

This commit is contained in:
ІО-23 Шмуляр Олег 2025-02-05 00:06:56 +02:00
commit fb5ea9c3ec
3 changed files with 40 additions and 0 deletions

17
Makefile Normal file
View File

@ -0,0 +1,17 @@
CROSS_COMPILE = arm-none-eabi-
build: start.S
$(CROSS_COMPILE)gcc -x assembler-with-cpp -c -O0 -g3 -mcpu=cortex-m4 -mthumb -Wall -o start.o start.S
$(CROSS_COMPILE)gcc start.o -mcpu=cortex-m4 -mthumb -Wall --specs=nosys.specs -nostdlib -lgcc -T./ldscript.ld -o start.elf
$(CROSS_COMPILE)objcopy -O binary -F elf32-littlearm start.elf start.bin
qemu: build
qemu-system-gnuarmeclipse --verbose --verbose --board STM32F4-Discovery \
--mcu STM32F407VG -d unimp,guest_errors \
--semihosting-config enable=on,target=native -s -S \
--image start.bin
clean:
rm *.o
rm *.elf
rm *.bin

7
ldscript.ld Normal file
View File

@ -0,0 +1,7 @@
MEMORY
{
FLASH ( rx ) : ORIGIN = 0x08000000, LENGTH = 1M
RAM ( rwx ) : ORIGIN = 0x20000000, LENGTH = 128K
}
__stack_start = ORIGIN(RAM) + LENGTH(RAM);

16
start.S Normal file
View File

@ -0,0 +1,16 @@
.syntax unified
.cpu cortex-m4
.thumb
.global vtable
.global reset_handler
.type vtable, %object
vtable:
.word __stack_start
.word __hard_reset__+1
.size vtable, .-vtable
__hard_reset__:
ldr sp, =__stack_start
b __hard_reset__