Thanks a lot @maxgerhardt.
I tried your clock patch, without any success. I was anticipating this result as my Nucleo board is brand new.
Here is my platformio.ini:
[env:nucleo_l476rg]
platform = ststm32
board = nucleo_l476rg
framework = arduino
monitor_speed = 115200
and main.cpp:
#include "Arduino.h"
void setup()
{
Serial.begin(115200);
Serial.println("Hello World!");
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
Serial.println("Hello again!");
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}
It seems the program hangs up at startup in the interrupt default handler. With the debugger, I can trace it back to startup_stm32l476xx.s
line 117 where I can see this comment:
This is the code that gets called when the processor receives an
unexpected interrupt. This simply enters an infinite loop, preserving
the system state for examination by a debugger.
Here is the call stack:
WWDG_IRQHandler@0x080041a8 (c:\Users\S\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32L4xx\Source\Templates\gcc\startup_stm32l476xx.s:117)
<signal handler called>@0xfffffff9 (Unknown Source:0)
??@0x00000000 (Unknown Source:0)
And here is the full debug log:
Processing nucleo_l476rg (platform: ststm32; board: nucleo_l476rg; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_l476rg.html
PLATFORM: ST STM32 (14.0.0) > ST Nucleo L476RG
HARDWARE: STM32L476RGT6 80MHz, 128KB RAM, 1MB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
- framework-arduinoststm32 4.20000.210603 (2.0.0)
- framework-cmsis 2.50700.210515 (5.7.0)
- toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 10 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Checking size .pio\build\nucleo_l476rg\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 0.7% (used 956 bytes from 131072 bytes)
Flash: [ ] 2.0% (used 20716 bytes from 1048576 bytes)
========================= [SUCCESS] Took 3.64 seconds =========================
Reading symbols from C:\Users\S\Travail\Projets en cours\LaserPacer\Tech\EmbeddedApp\TestPlatformIO3\.pio\build\nucleo_l476rg\firmware.elf...
undefinedC:\Users\S\.platformio\packages\toolchain-gccarmnoneeabi\bin\arm-none-eabi-gdb.exe: warning: Couldn't determine a path for the index cache directory.
PlatformIO Unified Debugger -> http://bit.ly/pio-debug
PlatformIO: debug_tool = stlink
PlatformIO: Initializing remote target...
xPack OpenOCD, x86_64 Open On-Chip Debugger 0.11.0-00155-ge392e485e (2021-03-15-16:44)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 500 kHz
Info : STLINK V2J37M27 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.247613
Info : stm32l4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32l4x.cpu on pipe
Info : accepting 'gdb' connection from pipe
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x61000003 pc: 0x080041a8 msp: 0x2001ffd0
Info : device idcode = 0x10076415 (STM32L47/L48xx - Rev 4 : 0x1007)
Info : flash size = 1024kbytes
Info : flash mode : dual-bank
WWDG_IRQHandler () at C:\Users\S\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32L4xx\Source\Templates\gcc\startup_stm32l476xx.s:117
117 b Infinite_Loop
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08004158 msp: 0x20020000
Loading section .isr_vector, size 0x188 lma 0x8000000
Loading section .text, size 0x4774 lma 0x8000188
Loading section .rodata, size 0x8e4 lma 0x80048fc
Loading section .ARM, size 0x8 lma 0x80051e0
Loading section .init_array, size 0x10 lma 0x80051e8
Loading section .fini_array, size 0x8 lma 0x80051f8
Loading section .data, size 0x94 lma 0x8005200
Info : Padding image section 0 at 0x08005294 with 4 bytes (bank write end alignment)
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08004158 msp: 0x20020000
Start address 0x8004158, load size 21140
Transfer rate: 12 KB/sec, 2642 bytes/write.
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
Unable to match requested speed 500 kHz, using 480 kHz
Unable to match requested speed 500 kHz, using 480 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08004158 msp: 0x20020000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08004158 msp: 0x20020000
Temporary breakpoint 1 at 0x8004136: file C:\Users\S\.platformio\packages\framework-arduinoststm32\cores\arduino\main.cpp, line 50.
PlatformIO: Initialization completed
PlatformIO: Resume the execution to `debug_init_break = tbreak main`
PlatformIO: More configuration options -> http://bit.ly/pio-debug
Note: automatically using hardware breakpoints for read-only addresses.
Any clue?