Skip to content

Instantly share code, notes, and snippets.

@nemtsov

nemtsov/Makefile Secret

Last active May 30, 2023 05:19
Show Gist options
  • Save nemtsov/513ed7e110b6299e8cf64355e4ac40e8 to your computer and use it in GitHub Desktop.
Save nemtsov/513ed7e110b6299e8cf64355e4ac40e8 to your computer and use it in GitHub Desktop.
STMLINK Minimal Repro
all: minimal.s
arm-none-eabi-gcc -mcpu=cortex-m0plus -T ./STM32L010F4.ld -nostdlib minimal.s -o minimal.elf
arm-none-eabi-objcopy -O ihex minimal.elf minimal.hex
st-flash --reset --format ihex write minimal.hex
.global vtable
.global reset_handler
.type vtable, %object
vtable:
.word _estack
.word reset_handler
.size vtable, .-vtable
.type reset_handler, %function
reset_handler:
MOV r0, #1
MOV r0, #2
MOV r0, #3
MOV r0, #4
MOV r0, #5
MOV r0, #6
MOV r0, #7
MOV r0, #8
MOV r0, #9
MOV r0, #10
MOV r0, #11
MOV r0, #12
MOV r0, #13
MOV r0, #14
MOV r0, #15
MOV r0, #16
MOV r0, #17
MOV r0, #18
MOV r0, #19
MOV r0, #20
MOV r0, #21
MOV r0, #22
MOV r0, #23
MOV r0, #24
MOV r0, #25
MOV r0, #26
MOV r0, #27
main_loop:
@ UNCOMMENT THE LINE BELOW TO GET THE ERROR
@ MOV r0, #28
@ UNCOMMENT THE LINE ABOVE TO GET THE ERROR
B main_loop
.size reset_handler, .-reset_handler
$ make
arm-none-eabi-gcc -mcpu=cortex-m0plus -T ./STM32L010F4.ld -nostdlib minimal.s -o minimal.elf
arm-none-eabi-objcopy -O ihex minimal.elf minimal.hex
st-flash --reset --format ihex write minimal.hex
st-flash 1.7.0
2023-05-30T01:18:43 INFO common.c: L011: 8 KiB SRAM, 16 KiB flash in at least 128 byte pages.
2023-05-30T01:18:43 INFO common.c: Attempting to write 66 (0x42) bytes to stm32 address: 134217728 (0x8000000)
2023-05-30T01:18:43 INFO common.c: Flash page at addr: 0x08000000 erased
2023-05-30T01:18:43 INFO common.c: Finished erasing 1 pages of 128 (0x80) bytes
2023-05-30T01:18:43 INFO common.c: Starting Flash write for L0
2023-05-30T01:18:43 INFO common.c: Starting Half page flash write for STM32L core id
2023-05-30T01:18:43 INFO flash_loader.c: Successfully loaded flash loader in sram
2023-05-30T01:18:43 INFO flash_loader.c: Clear DFSR
2023-05-30T01:18:43 ERROR flash_loader.c: Flash loader run error
2023-05-30T01:18:43 WARN flash_loader.c: Loader state: R2 0x0 R15 0x0
2023-05-30T01:18:43 WARN flash_loader.c: MCU state: DHCSR 0x1080009 DFSR 0x0 CFSR 0x0 HFSR 0x0
2023-05-30T01:18:43 WARN common.c: l1_stlink_flash_loader_run(0x8000000) failed! == -1
2023-05-30T01:18:43 WARN common.c:
write_half_pages failed == -1
_estack = ORIGIN(RAM) + LENGTH(RAM);
MEMORY
{
FLASH ( rx ) : ORIGIN = 0x08000000, LENGTH = 16K
RAM ( rxw ) : ORIGIN = 0x20000000, LENGTH = 2K
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment