2020-12-14 02:34 AM
I am using a self compiled arm-none-eabi gcc 10.2 toolchain and I am trying to write a minimal program to switch on a GPIO LED (putting that output to 0 because is cathode connected) on pin PA1. I have the following resulting binary:
Disassembly of section .text:
08000000 <_Z8_startupv>:
// RCC_AHB1ENR |= 1;
8000000: 4b07 ldr r3, [pc, #28] ; (8000020 <_Z8_startupv+0x20>)
8000002: 681b ldr r3, [r3, #0]
8000004: 4a06 ldr r2, [pc, #24] ; (8000020 <_Z8_startupv+0x20>)
8000006: f043 0301 orr.w r3, r3, #1
800000a: 6013 str r3, [r2, #0]
// GPIOA_MODER |= 0x00000004;
800000c: 4b05 ldr r3, [pc, #20] ; (8000024 <_Z8_startupv+0x24>)
800000e: 681b ldr r3, [r3, #0]
8000010: 4a04 ldr r2, [pc, #16] ; (8000024 <_Z8_startupv+0x24>)
8000012: f043 0304 orr.w r3, r3, #4
8000016: 6013 str r3, [r2, #0]
// GPIOA_ODR = 0;
8000018: 4b03 ldr r3, [pc, #12] ; (8000028 <_Z8_startupv+0x28>)
800001a: 2200 movs r2, #0
800001c: 601a str r2, [r3, #0]
// while (true) ;
800001e: e7fe b.n 800001e <_Z8_startupv+0x1e>
// here the constants...
8000020: 40023830 // RCC_AHB1ENR address
8000024: 40020000 // GPIOA_MODER address
8000028: 40020014 // GPIOA_ODR address
I have sent the code to ths MCU using both dfu-tool and official STM32CubeProgrammer but the led does not switch on. I have checked using STM32CubeProgrammer that the binary I send is perfectly stored at 0x08000000 (the boot address when BOOT0 pin is low).
I am not configuring the PLLs for use the external board clock but I think that it is not necesary for a proff of concept like this, correct?
What am I doing wrong?
2020-12-14 04:54 AM
It does not execute code from 0x08000000.
You need a minimal vector table pointing to initial SP and PC.
You will need to enable GPIOA clock.
2020-12-14 05:45 AM
Thanks for the answer.
When I was developing with STM32F103 I put the vector table because at 0x00000000 because there are FLASH there, but in STM32H750 at 0x00000000 there are RAM.
Also, reading the Option Bytes with STM32CubeProgrammer I get these values:
So I think that it is correct to put my code at 0x08000000. About the GPIO clock enable, I am enabling it with the "RCC_AHB1ENR |= 1". When I switch on the board with BOOT0 pin at 3.3v y can connect the booloader with DFU using STM32CubeProgrammer but when I switch on the board with BOOT0 pin to 0v nothing occurs.
I am also a bit confused because, in the reference manual of STM32H750 y get this:
So I don't know why my chip have these options bytes (may be a second hand chip), but the fact is that the value I read of BOOT_ADD1 using STM32CubeProgrammer is 0x1FF00000 and that is a reserved area! :| and the other fact is that that BOOT_ADD1 runs ok because I am connectin using STM32CubeProgrammer using DFU!
Any explanation?
2020-12-14 10:29 AM
>>So I think that it is correct to put my code at 0x08000000. About the GPIO clock enable, I am enabling it with the "RCC_AHB1ENR |= 1". When I switch on the board with BOOT0 pin at 3.3v y can connect the booloader with DFU using STM32CubeProgrammer but when I switch on the board with BOOT0 pin to 0v nothing occurs.
You want to place your image at 0x08000000, the first things there are NOT CODE, but vectors (addresses to something else..)
ie
.word 0x20002000 // Some RAM for Stack
.word 0x08000009 // First Instruction, THUMB
// 0x08000008
// RCC_AHB1ENR |= 1;
ldr r3, =0x40023830
ldr r2, [r3, #0]
orr.w r2, r2, #1
str r3, [r3, #0]
The H750 is not an F750 or F740 device