EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: dusan on December 07, 2024, 08:28:38 am

Title: STM32G030 in Arduino IDE on linux using ST-LINK v2 - How to read variable value?
Post by: dusan on December 07, 2024, 08:28:38 am
I'm using Arduino IDE on linux with STM32G030 programmed via ST-LINK v2, here is working blinking example (everything works fine, the led is blinking):

Code: [Select]
void setup() {
  pinMode(PB11, OUTPUT);
}

int n = 0;

void loop() {
  n++;
  digitalWrite(PB11, n % 3 == 0 ? HIGH : LOW);
  delay(100);
}

I would like the read the value of "n". I don't want to use UART as I'm trying to find out if I can ommit UART and use just ST-LINK for debugging. How to do it using ST-LINK v2? How to read variable value?

I'm not sure if it helps but here is what arduino prints during compilation:

Code: [Select]
Sketch uses 13688 bytes (20%) of program storage space. Maximum is 65536 bytes.
Global variables use 900 bytes (10%) of dynamic memory, leaving 7292 bytes for local variables. Maximum is 8192 bytes.
      -------------------------------------------------------------------
                        STM32CubeProgrammer v2.11.0                 
      -------------------------------------------------------------------

ST-LINK SN  : 39002100050000343251524E
ST-LINK FW  : V2J29S7
Board       : --
Voltage     : 3.23V
SWD freq    : 4000 KHz
Connect mode: Under Reset
Reset mode  : Hardware reset
Device ID   : 0x466
Revision ID : Rev 1.1
Device name : STM32G03x/STM32G04x
Flash size  : 64 KBytes
Device type : MCU
Device CPU  : Cortex-M0+
BL Version  : --

Memory Programming ...
Opening and parsing file: example1.ino.bin
  File          : example1.ino.bin
  Size          : 13.57 KB
  Address       : 0x08000000


Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 6]
Download in Progress:

File download complete
Time elapsed during download operation: 00:00:00.464

RUNNING Program ...
  Address:      : 0x8000000
Application is running, Please Hold on...
Start operation achieved successfully

Title: Re: STM32G030 in Arduino IDE on linux using ST-LINK v2 - How to read variable value?
Post by: tooki on December 07, 2024, 12:57:20 pm
What you want to do is debugging, but Arduino IDE supports debugging only with a very, very short list of boards using SAMD microcontrollers: https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-debugger/

So your STM32G030 is not supported for debugging in Arduino IDE.

EDIT: it seems debugging is supported as of a few months ago. See link in DavidAlfa’s reply.

The STM32G030 is not officially supported in the PlatformIO IDE (with which I have successfully debugged other STM32’s), but it has been done by others: https://github.com/platformio/platform-ststm32/pull/622

The only environments that I know for sure will support debugging your chip right away are the Cube IDE and Keil. But you’d lose Arduino code compatibility. (See edit note above.)
Title: Re: STM32G030 in Arduino IDE on linux using ST-LINK v2 - How to read variable value?
Post by: dusan on December 07, 2024, 01:42:15 pm
Can I somehow get the information via command line?
Title: Re: STM32G030 in Arduino IDE on linux using ST-LINK v2 - How to read variable value?
Post by: DavidAlfa on December 07, 2024, 01:57:50 pm
Maybe this:
https://github.com/stm32duino/Arduino_Core_STM32/wiki/How-to-debug
Title: Re: STM32G030 in Arduino IDE on linux using ST-LINK v2 - How to read variable value?
Post by: tooki on December 07, 2024, 02:24:58 pm
Maybe this:
https://github.com/stm32duino/Arduino_Core_STM32/wiki/How-to-debug
Oh cool, it seems the STM32 board support now includes debugging. Per the page’s edit history, just since July.