STANDARD WINDOWS IDE FOR STM32

User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

STANDARD WINDOWS IDE FOR STM32

Post by EV_Builder »

I would like to ask to include into all github repo's the default STM32CubeIDE configurations to build and debug the code with the supported ST-LINK.

The V5 Charger software can be imported easily.

is this doable?
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
arturk
Posts: 146
Joined: Wed Oct 02, 2019 3:58 am
Location: United States, MD
Has thanked: 1 time
Been thanked: 2 times

Re: STANDARD WINDOWS IDE FOR STM32

Post by arturk »

EV_Builder I think this is great idea. As much as I would love to see it for exiting projects I suspect it will probably not happen. I am not expert in STM32 development but I spent some time reviewing templates used for OpenInverter development including ZombieVerter and I think it would be very difficult at best to port them into STM32CubeIDE.

I am also running Windows and I like to get involved STM32 development. Being able to debug code is one the key features for me.
I have taken slightly different approach and decided to setup Windows based development environment which would allow to build projects like ZombieVerter and debug them as they are.

I have successfully setup and tested environment with Visual Studio Code as editor with intellisensing capability and debugger using appropriate plugins additional components like OpenOCD. Projects can be open without modifications and build using Make for Windows. In order to allow debugging very small update is needed in the Makefile. Debugger allows you to setup breakpoints anywhere in the code, step through and view all register values and periferals for any SMT32 chip thanks to SVD files.

It took some effort to figure out all the puzzles but in the end it is not very difficult.
If you or others are interested I can put together guide explaining how to set it up.
1998 Jaguar XJR, GS450h drivetrain, 48kWh/96s BMW battery
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: STANDARD WINDOWS IDE FOR STM32

Post by johu »

Sounds good. I could add the necessary project file to github, provided it's not tons of files. Then there is more freedom of choice in dev tools.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
davefiddes
Posts: 211
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 14 times
Been thanked: 35 times

Re: STANDARD WINDOWS IDE FOR STM32

Post by davefiddes »

Damien merged my Visual Studio Code project files for the Stm32_vcu project last week. They set up build tasks, launch tasks to allow debugging and C/C++ extension configuration to allow Intellisense. I use VS Code on Linux but they should work unmodified on Windows. It would be useful to get a write up of how you set things up on Windows. I'd be happy to test them on a Windows box and reconcile any differences with my Linux config. IMHO VS Code is a nice IDE and much lighter weight than the Eclipse based IDEs like STM32 Cube that want to take over everything.
User avatar
arturk
Posts: 146
Joined: Wed Oct 02, 2019 3:58 am
Location: United States, MD
Has thanked: 1 time
Been thanked: 2 times

Re: STANDARD WINDOWS IDE FOR STM32

Post by arturk »

johu wrote: Tue Jun 22, 2021 8:08 am Sounds good. I could add the necessary project file to github, provided it's not tons of files. Then there is more freedom of choice in dev tools.
Johannes, there is not to many file at all. Let us work out some kinks and once we have solid solution you will be able to incorporate it in your projects.

Dave, I an glad you were able to get it to work on Linux, I found your VS Code configuration in "ACDC_LIM" branch, I wish I knew about it earlier ;)

I tried it on Windows and run into few small issues, let's try to address them so we can come up with cross-platform solution. Unfortunately I do not have have Linux machine and I am not able to test my updates on Linux.

In "c_cpp_properties.json" currently hardcoded "compilerPath" will not work on all systems specially Windows, I propose to use Environment Variable for the Toolchain bin folder (in my case "C:/Program Files (x86)/gcc-arm-none-eabi-10-2020-q4-major/bin"). Hopefully it can be replicated on Linux. Please see my comments in modified file below.
Param "intelliSenseMode": "linux-gcc-arm" did not work for me, will "gcc-arm" work on Linux?

Code: Select all

{
    "configurations": [
        {
            "name": "Linux", //no big deal but shouldn't this reflect project name? Like "STM32-VCU"
            "includePath": [
                "${workspaceFolder}/include",
                "${workspaceFolder}/libopeninv/include",
                "${workspaceFolder}/libopencm3/include"
            ],
            "defines": [
                "STM32F1"
            ],
            "compilerPath": "${env:ARMGCC_DIR}/arm-none-eabi-gcc", //"/usr/lib64/ccache/arm-none-eabi-gcc" use env variable to specify compiler path, hopefully this will work on Linux as well 
            "cStandard": "c11",
            "intelliSenseMode": "gcc-arm", //"linux-gcc-arm" is not acceptable value on Windows, hopefully this will work on Linux as well
            "cppStandard": "c++17",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}
I am not familiar with your configuration for Debug ("launch.json"). I am getting weird error (screenshot attached). For some reason path is being messed up by removing slash characters.
Am I missing some component? Do I need to do something before hitting F5?

I am using "Cortex-Debug" plugin for VS Code and OpenOCD.
Here is my config file:

Code: Select all

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Cortex Debug",
            "cwd": "${workspaceRoot}",
            "executable": "./build/F105RB.elf",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "openocd",
            "device": "STM32F105xC",
            "configFiles": [
                "interface/stlink.cfg",
                "target/stm32f1x.cfg"
            ],
            "svdFile": "./STM32F107.svd"
        }
    ]
}
SVD file can be downloaded from ST website, I am attaching latest one for STM32F1* family.

I can test it further on Windows if you have any suggestions. I can create guide but it is probably better to wait until we have solid solution worked out.
Attachments
en.stm32f1_svd.zip
(298.34 KiB) Downloaded 101 times
DebugError.png
DebugError.png (7.83 KiB) Viewed 5287 times
1998 Jaguar XJR, GS450h drivetrain, 48kWh/96s BMW battery
davefiddes
Posts: 211
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 14 times
Been thanked: 35 times

Re: STANDARD WINDOWS IDE FOR STM32

Post by davefiddes »

My launch config expects an openocd process to be running. I found it easier to keep an eye on openocd. Using Cortex Debug is probably a much better way to go. Apologies for the hard coded paths, I'll need to do a bit more digging and see if we can't come up with a neater cross-platform config. I have Linux and Windows PCs to test with.
User avatar
arturk
Posts: 146
Joined: Wed Oct 02, 2019 3:58 am
Location: United States, MD
Has thanked: 1 time
Been thanked: 2 times

Re: STANDARD WINDOWS IDE FOR STM32

Post by arturk »

I have tried to start OpenOCD before initiating Debug session:

Code: Select all

Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : DEPRECATED target event trace-config
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 1000 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.197404
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on 3333
Info : Listening on port 3333 for gdb connections
and I still got the same popup error. I am lost on this one.

As far as environment variables I run another test removing compiler path and leaving just the name of executable. Since I have Toolchain bin directory in PATH Variable it worked just fine. If we can do it the same way on Linux it would simplify configuration process.

Code: Select all

{
    "configurations": [
        {
            ...
            "compilerPath": "arm-none-eabi-gcc",
            ...
        }
    ],
    "version": 4
}
Not much progress but just wanted to share.

It would be great if you could try to test Cortex Debug plugin configuration in Linux. Perhaps this method will work on both platforms.
1998 Jaguar XJR, GS450h drivetrain, 48kWh/96s BMW battery
User avatar
zilion
Posts: 58
Joined: Tue Feb 02, 2021 7:50 am
Location: Poland

Re: STANDARD WINDOWS IDE FOR STM32

Post by zilion »

You could look at "Cortex Builder" plugin.
It was tested only on Win10, but it may run on Linux.
I smell lithium in the air. It's not lithium, it's glycolium.
User avatar
zilion
Posts: 58
Joined: Tue Feb 02, 2021 7:50 am
Location: Poland

Re: STANDARD WINDOWS IDE FOR STM32

Post by zilion »

Intrigued by this topic I started to experiment myself with VSC IDE, but I'm bumped over compiling under WIN10.
How did you guys managed to compile arm code if there is no "make" under powershell?
I'm managed to install with chocolatey some gnu-make version, but it throws `LoopFillZerobss' error.
I smell lithium in the air. It's not lithium, it's glycolium.
User avatar
zilion
Posts: 58
Joined: Tue Feb 02, 2021 7:50 am
Location: Poland

Re: STANDARD WINDOWS IDE FOR STM32

Post by zilion »

Found this while looking for another ;)


I smell lithium in the air. It's not lithium, it's glycolium.
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: STANDARD WINDOWS IDE FOR STM32

Post by jon volk »

zilion wrote: Tue Jun 29, 2021 6:40 pm Intrigued by this topic I started to experiment myself with VSC IDE, but I'm bumped over compiling under WIN10.
How did you guys managed to compile arm code if there is no "make" under powershell?
By running it all on Ubuntu within Virtualbox :D
Formerly 92 E30 BMW Cabrio with Tesla power
User avatar
arturk
Posts: 146
Joined: Wed Oct 02, 2019 3:58 am
Location: United States, MD
Has thanked: 1 time
Been thanked: 2 times

Re: STANDARD WINDOWS IDE FOR STM32

Post by arturk »

zilion wrote: Tue Jun 29, 2021 9:03 pm Found this while looking for another ;)
This is great guide, It is essentially how I setup my environment. I like to be able to develop under Windows, all works very well.
1998 Jaguar XJR, GS450h drivetrain, 48kWh/96s BMW battery
User avatar
zilion
Posts: 58
Joined: Tue Feb 02, 2021 7:50 am
Location: Poland

Re: STANDARD WINDOWS IDE FOR STM32

Post by zilion »

jon volk wrote: Wed Jun 30, 2021 1:28 am By running it all on Ubuntu within Virtualbox :D
Well, I have bare metal with linux, so no problem there.
The real challenge is to setup all of this under windows 8-)

And by running virtual linux just to have compiler it's some kind of overkill, or the ultimate windows solution XD
I smell lithium in the air. It's not lithium, it's glycolium.
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: STANDARD WINDOWS IDE FOR STM32

Post by EV_Builder »

Woww I lost track of this thread but seems it catched some fire!
Nice work guys gonna check the link from zillion hopefully I can then ditch my efforts to get it running unther ST32CubeIDE. Which somehow tries to build everything it can find instead of what is 'linked' through the project main.c file ....
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: STANDARD WINDOWS IDE FOR STM32

Post by EV_Builder »

arturk wrote: Tue Jun 22, 2021 6:08 am If you or others are interested I can put together guide explaining how to set it up.
XXX; I count three yesses! :)
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: STANDARD WINDOWS IDE FOR STM32

Post by EV_Builder »

jon volk wrote: Wed Jun 30, 2021 1:28 am
zilion wrote: Tue Jun 29, 2021 6:40 pm Intrigued by this topic I started to experiment myself with VSC IDE, but I'm bumped over compiling under WIN10.
How did you guys managed to compile arm code if there is no "make" under powershell?
By running it all on Ubuntu within Virtualbox :D
I think we should go this way if we want all an easy live... in the makefile there are linux commands used not available on windows.
test and printf to name 2.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
arturk
Posts: 146
Joined: Wed Oct 02, 2019 3:58 am
Location: United States, MD
Has thanked: 1 time
Been thanked: 2 times

Re: STANDARD WINDOWS IDE FOR STM32

Post by arturk »

EV_Builder wrote: Sun Jul 11, 2021 5:41 pm I think we should go this way if we want all an easy live...
I am happy with Windows, sure sometimes things are little more difficult being in minority. VM is an option for sure but I like to work in native OS specially dealing with external hardware connected to VM. Sure there is virtual USB, serial but it can be tricky sometimes.
I researched options I reported earlier in this thread. Setting up fully featured IDE with debug capability for our projects in native Windows is perfectly doable and not difficult.

EV_Builder wrote: Sun Jul 11, 2021 5:41 pm ... in the makefile there are linux commands used not available on windows.
test and printf to name 2.
This is not exactly true, all of these command are available in Git package for Windows.

Earlier I was thinking about creating guide but then Zilion posted lint to excellent video by Embedded Geek, it covers subject in very comprehensive way, anything else would be just duplicating it.
1998 Jaguar XJR, GS450h drivetrain, 48kWh/96s BMW battery
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: STANDARD WINDOWS IDE FOR STM32

Post by EV_Builder »

mhhh ok can you post your json files then?
and where do we find that GIT package?

p.s. i followed movie 1 and 2. 3 is pending now...
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
arturk
Posts: 146
Joined: Wed Oct 02, 2019 3:58 am
Location: United States, MD
Has thanked: 1 time
Been thanked: 2 times

Re: STANDARD WINDOWS IDE FOR STM32

Post by arturk »

Here is Git package I am using:
https://git-scm.com/download/win

Files for ZombieVerter project attached.
Attachments
launch.json
(721 Bytes) Downloaded 115 times
c_cpp_properties.json
(904 Bytes) Downloaded 105 times
1998 Jaguar XJR, GS450h drivetrain, 48kWh/96s BMW battery
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: STANDARD WINDOWS IDE FOR STM32

Post by EV_Builder »

arturk wrote: Sun Jul 11, 2021 9:35 pm Here is Git package I am using:
https://git-scm.com/download/win

Files for ZombieVerter project attached.
did you modify the makefile itself?
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
SciroccoEV
Posts: 369
Joined: Thu Oct 10, 2019 1:50 pm
Location: Luton UK
Been thanked: 15 times

Re: STANDARD WINDOWS IDE FOR STM32

Post by SciroccoEV »

I used the Platform IO plugin for Visual Studio Code to generate some test code for an STM32 dev board. I found it easy to use and it worked directly with an STM-Link, but it would not generate binary or hex files as standard output so that I could upload via the Wifi interface. I tried to follow examples of how to add these as output filles, but the files I was supposed to edit, did not match up with those I was seeing in the IDE.
User avatar
arturk
Posts: 146
Joined: Wed Oct 02, 2019 3:58 am
Location: United States, MD
Has thanked: 1 time
Been thanked: 2 times

Re: STANDARD WINDOWS IDE FOR STM32

Post by arturk »

EV_Builder wrote: Mon Jul 12, 2021 8:34 pm
did you modify the makefile itself?
Not much to changed but you need to be aware of few aspects.
First of all, for debugging you need .elf file, in Makefile from Johannes based projects it is disguised, basically it is generated but with no extension. This is why in launch.json file I have:

Code: Select all

"executable": "./stm32_vcu"
instead "./stm32_vcu.elf". Keeping that in mind you do not have to change Makefile but account for that in VSC configuration files.
Also to allow debugging additional information has to be included in .elf files. This information is generated by adding additional compiler flag "-g". In my attached Makefile for ZombieVerter project (I had to add .txt) look at lines 33 and 36. This is really the only change I found necessary in the Makefile.

Make a note of SVD file which is very handy for debugging:

Code: Select all

"svdFile": "./STM32F107.svd"
Those can be downloaded directly from ST website. I have attached zip for F1 family.
Attachments
en.stm32f1_svd.zip
(298.34 KiB) Downloaded 85 times
Makefile.txt
(4.3 KiB) Downloaded 109 times
1998 Jaguar XJR, GS450h drivetrain, 48kWh/96s BMW battery
User avatar
zilion
Posts: 58
Joined: Tue Feb 02, 2021 7:50 am
Location: Poland

Re: STANDARD WINDOWS IDE FOR STM32

Post by zilion »

While I was on a short vacation I see that here something happened :)

Here I put some short tutorial on arming Win10 and VSC to do some STM. (lol, lots of acronyms)

First you install chocolatey -it's a kinda packet installer project for windows.
Run powershell (as admin) and paste (from chocolatey homepage):

Code: Select all

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Then some packets. Put in powershell:

Code: Select all

choco install vscode -y
choco install openocd -y
choco install gcc-arm-embedded -y
choco make -y
choco install git -y
List all installed packets:

Code: Select all

choco list --local-only
add to system path:

Code: Select all

C:\Program Files\Git\bin
C:\Program Files\Git\usr\bin
Under VSC install "Cortex Builder" and "Cortex Debuger"
In Crotex Builder Settings -> Debug set your hardware for debug, and under General paste:
For GCC path

Code: Select all

C:\ProgramData\chocolatey\lib\gcc-arm-embedded\tools\gcc-arm-none-eabi-10-2020-q4-major\bin\arm-none-eabi-gcc-10.2.1.exe
For OpenOCD path

Code: Select all

C:\ProgramData\chocolatey\lib\openocd\tools\OpenOCD-20190828-0.10.0\share\openocd\scripts
I was on the line with Semyon Ivanov, creator of "Cortex Builder" to point him some issues with buttons under Windows.
But it seams that he is not into this extension at the moment. At least not for Linux testing...
It's a good addition to VSC because it configures STM environment in a simple way. It's bad because buttons for flashing, erasing and etc are now invoked by powershell -so it's windows specific.

If anyone wants to deal with this subject, here is a path to file:

Code: Select all

%USERPROFILE%\.vscode\extensions\semyon-ivanov.cortex-builder-1.0.5\out
Buttons are in terminalCommands.js

Anyway, I added some lines to Makefile to invoke them manually from console:

Code: Select all


OCD_SCRIPTS = 	C:/ProgramData/chocolatey/lib/openocd/tools/OpenOCD-20190828-0.10.0/share/openocd/scripts
OCD_INTERFACE = $(OCD_SCRIPTS)/interface/stlink.cfg
OCD_TARGET = 	$(OCD_SCRIPTS)/target/stm32f1x.cfg

#-----------------------------------------------------------------------------------------
#	Actions
#-----------------------------------------------------------------------------------------
all: $(OUTPUT_PATH)/$(TARGET).elf $(OUTPUT_PATH)/$(TARGET).hex $(OUTPUT_PATH)/$(TARGET).bin
	@echo.
	@echo "Build Completed."
	@echo.

flash: all
	openocd -f $(OCD_INTERFACE) -f $(OCD_TARGET) -c "program $(OUTPUT_PATH)/$(TARGET).hex verify reset exit"
	@echo.
	@echo "Write Completed."
	@echo.

erase:
	openocd -f $(OCD_INTERFACE) -f $(OCD_TARGET) -c "init; reset halt; flash erase_sector 0 0 1; exit"
	@echo.
	@echo "Erase Completed."
	@echo.

reset:
	openocd -f $(OCD_INTERFACE) -f $(OCD_TARGET) -c "init; reset; exit"
	@echo.
	@echo "Reset Completed."
	@echo.

clean:
	rm -r $(OUTPUT_PATH)/*
	rm -r $(BUILD_PATH)/*
	@echo.
	@echo "Clean Completed." 
	@echo.
#-----------------------------------------------------------------------------------------
#	End of Actions
#-----------------------------------------------------------------------------------------
All of this is for an empty project.
There is some work to be done to adopt an exiting project, like stm32-sine.
I smell lithium in the air. It's not lithium, it's glycolium.
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: STANDARD WINDOWS IDE FOR STM32

Post by EV_Builder »

I'm still on windows 7 will it work on that?
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: STANDARD WINDOWS IDE FOR STM32

Post by EV_Builder »

ok in order to try to get this stuff building in vscode my next issue is that libopencm3 doesn't build it errors out because i don't have python.
i thought including de .h and pointing to the source would be enough?
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
Post Reply