What it does is parsing the elf file to find where the variables are stored in memory.
Then it reads or writes the memory with SWIM protocol (STLINK protocol) I think.
I was even thinking about rebuilding this tool in web in a more user friendly way after seing this
I also tried the STM32CubeMonitor in the past, I think it’s the replacement for STM Studio, it has more features but I couldn’t get it to acquire data as fast as STM Studio.
Hey Candas1, I want to try this, but I don’t know how to set up current sense, not quite. I have some idea but am painfully aware of how things can get complicated.
Can you post the exact code you used? I can extract the critical elements and make some elemental code to monitor current with this board.
I want to monitor current to do stall detection. The best thing for me is to watch the combined current of all three phases. That way I can take a single measurement and see what the current draw is, no need to average out a bunch of measurements on a single phase.
I have been using STMViewer for some time now, I must say I like it.
You can add a variable, type the name of any global variable like motor.LPF_current_q.Tf, update the variable address, and it just works.
You can download STMViewer from here. Here are the installation instruction.
I believe it needs at least version 13.2 of GDB (issue).
I am compiling with platformio using -g -ggdb build flags, this ensures proper information are available in the .elf file.
I made a short video showing basic usage of the tool.
If you change your program, the memory addresses might change, so you need use the Update variable addresses button.
This should support different model of stlinks and should work on STM32 only.
But it works for me with a Chinese STlink V2.1 clone and GD32F103/GD32F130 chips also.
Yeah but after downloading it, like what’s the process? You compile with arduino, how does it know the memory address? Doesn’t it need to have info from the compiler somehow to know the address of a variable and it’s name? I don’t see how it can get that info.
Oh ok a video is awesome, sorry. Will check it out thanks! Looking in there and seeing the system working is extremely important but in arduino it’s quite hard.
Edit:hm, how do you get this mysterious .elf file? It’s the binary I take it?
Anton wrote how to trigger the platformio debug toolchain from Arduino-code
first add a build_opt.h file in your arduino sketch and add inside the line -g -ggdb
Just to clarify: this “build_opt.h” file doesn’t already exist somewhere in my arduinoIDE libraries?
I don’t have to edit it and add the -g -ggdb line, but have to create a new file? Is that correct?
I never figured out build options with arduino very well, but there was a file specific to each family of boards that contained a section where the build options were located. There are some instructions I think I left on the forum for modifying some of them in some ways, the build options were needed to get current sensing working with the b-g431b-esc1 board.
Why would you use platformio’s debugger from inside ArduinoIDE? That doesn’t make that much sense for most people, I think.
At that point it would be easier to just use PlatformIO, for code and debugging, and not have to deal with the idiosyncrasies of both IDEs at the same time?
For me it isn’t about debugging code, but watching variables without slowing down the loop.
Maybe find better PID values here and there…
I’ve started using sFOC for different MCUs supported by arduinoIDE, why would I switch to another platform?
Well, I believe the current version of ArduinoIDE include debugging support?
My point was not that anyone should change IDE… everyone should use whatever they like best. I was just suggesting that using and configuring 2 IDEs is a complicated way to work. But if it’s right for you, then its right for you