2023-05-22 12:04 AM
I'm a newbie to STM32 programming, but have 25+ years in desktop development.
I've created a PCB with a STM32F042F6 mcu (based on a working design). I added pins for a SWD port and I have an LED connected to PortB1.
I've used STM32CudeIDE to create a simple program to blink the LED every 500mSec.
I've connected using the black_magic probe and can get the LED to blink in debug mode
Startup code for the debug configuration is
set mem inaccessible-by-default off
target extended-remote /dev/ttyACM0
monitor tpwr enable
shell sleep 5
monitor swdp_scan
attach 1
Anyway this bit works.
My question is, how do I get this to work in the release mode. If I power cycle the target board the program does not restart automatically.
I also connected via GDB (without the STM32 IDE) and while I can connect and load the elf file, after "run" the GDB console remains unresponsive to further commands.
2023-05-22 12:05 AM
The forum would not let me add a link, the design is based on https://github.com/omzlo/canzero-hardware
2023-05-22 12:08 AM
The output from GDB (outside of STM32CudeIDE) is
(gdb) file ~/STM32CubeIDE/workspace_1.12.1/BlinkLED_STM32F042/Debug/BlinkLED_STM32F042.elf
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from ~/STM32CubeIDE/workspace_1.12.1/BlinkLED_STM32F042/Debug/BlinkLED_STM32F042.elf...
(gdb) load
Loading section .isr_vector, size 0xc0 lma 0x8000000
Loading section .text, size 0x1384 lma 0x80000c0
Loading section .rodata, size 0x30 lma 0x8001444
Loading section .init_array, size 0x4 lma 0x8001474
Loading section .fini_array, size 0x4 lma 0x8001478
Loading section .data, size 0xc lma 0x800147c
Start address 0x080003f4, load size 5256
Transfer rate: 14 KB/sec, 477 bytes/write.
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/david/STM32CubeIDE/workspace_1.12.1/BlinkLED_STM32F042/Debug/BlinkLED_STM32F042.elf
And the code that I added in main.c was
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
// flash the led every second
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_1);
HAL_Delay (500); /* Insert delay 500 ms */
}
/* USER CODE END 3 */