commit fb5ea9c3ec1fc0321d945b925aa712ee2d39d53a Author: hasslesstech Date: Wed Feb 5 00:06:56 2025 +0200 working code v1 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..322ca2b --- /dev/null +++ b/Makefile @@ -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 diff --git a/ldscript.ld b/ldscript.ld new file mode 100644 index 0000000..222b46d --- /dev/null +++ b/ldscript.ld @@ -0,0 +1,7 @@ +MEMORY +{ + FLASH ( rx ) : ORIGIN = 0x08000000, LENGTH = 1M + RAM ( rwx ) : ORIGIN = 0x20000000, LENGTH = 128K +} + +__stack_start = ORIGIN(RAM) + LENGTH(RAM); diff --git a/start.S b/start.S new file mode 100644 index 0000000..f6794f5 --- /dev/null +++ b/start.S @@ -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__