I am programming a standard STM32F407 board under Linux. And I'm looking for a way to visualize the variables on a graph in an OpenSTM32 environment.
How do I visualize the variables in OpenSTM32. Is it like in Open STM Studio?
I am programming a standard STM32F407 board under Linux. And I'm looking for a way to visualize the variables on a graph in an OpenSTM32 environment.
How do I visualize the variables in OpenSTM32. Is it like in Open STM Studio?
I was working on the same thing. Here how I did it (not the GUI part).
You can use OpenOCD and gdb to debug/view variables.
Start an OpenOCD server:
sudo openocd -f /usr/local/share/openocd/scripts/board/st_nucleo_f4.cfg -c "init"
I assume you are working with a STM32F4DISCOVERY (STM32F407VG), so you should use stm32f4discovery.cfg
config file.
Now start gdb in another terminal:
sudo gdb
Provide your object file (.elf/.axf) to gdb which contains debug info, symbols and etc. If you are using Keil uVision (MDK-ARM), you can find the .axf file under myProject/MDK-ARM/myProject/
folder. If you are using GNU Arm Embedded Toolchain, you should compile your program as a debug program, so compiler generates an .elf file under ../Build/
folder.
In gdb console:
file ~/myProject/Build/myProgram.axf
Now you can monitor your variables by name with gdb since you provided the object file.
Connect to OpenOCD server from gdb:
target remote localhost:3333
You can now see your variables from gdb with p myVar1
, the type of the variable with ptype myVar1
and the address of the variable with info address myVar1
commands:
p myVar1
Here is a simple script which prints the desired variables every 1 second.
You can run the script with gdb --batch --command=script.gdb
:
shell sudo openocd -f /usr/local/share/openocd/scripts/board/st_nucleo_f4.cfg -c "init" &> /dev/null &
file b/BUILD/NUCLEO_F446RE/GCC_ARM/b.elf
target remote localhost:3333
#monitor reset run
display myVar1
display myVar2
while(1)
display
shell sleep 1s
Code on STM32:
uint32_t myVar1 = 0;
uint32_t myVar2 = 0;
int main(void){
while(1){
myVar1 +=1;
myVar2 +=2;
}
}