Modify and compile a program
- muehlpower
- Posts: 750
- Joined: Fri Oct 11, 2019 10:51 am
- Location: Germany Fürstenfeldbruck
- Has thanked: 17 times
- Been thanked: 168 times
Modify and compile a program
Maybe I'm the only one here who doesn't get it, but how do I modify a program and compile it? I installed the toolchain and downloaded the latest zip file from git. Now I have a new folder in Programs (x86) and a zip file with lots of subfolders. How do I modify the program and how do I get a bin or hex file that I can then transfer?
- manny
- Posts: 164
- Joined: Sun Jan 23, 2022 4:15 pm
- Location: Netherlands
- Has thanked: 38 times
- Been thanked: 125 times
Re: Modify and compile a program
You can modify the code with you favorite text editor.
The files are in the src folder
On windows I use WSL linux command line for windows to compile the firmware. With the Make command.
The files are in the src folder
On windows I use WSL linux command line for windows to compile the firmware. With the Make command.
[DRIVING] Citroen Saxo electrique
- Volvo ERAD motor, XC90 inverter/DCDC (custom OI board)
- PSA battery (50kWh)
- Foccci and MG ZS charger 6.6kW
- Zombie VCU
- muehlpower
- Posts: 750
- Joined: Fri Oct 11, 2019 10:51 am
- Location: Germany Fürstenfeldbruck
- Has thanked: 17 times
- Been thanked: 168 times
Re: Modify and compile a program
Which editor is suitable? Normally, I start the Arduino IDE, type in the program, and then press upload. I can view the relevant program section with the Windows editor and also change it, but without checking the syntax.
What is “WSL Linux command line for Windows”? I can type “cmd” in the bottom left corner of my Windows screen, and then something that looks like DOS appears.
- tom91
- Posts: 2753
- Joined: Fri Mar 01, 2019 9:15 pm
- Location: Bristol
- Has thanked: 264 times
- Been thanked: 717 times
Re: Modify and compile a program
Uhmm thanks for the clarity on what you are on about. Please be more specific.
You can search the forum for threads on compling. search.php?st=0&sk=t&sd=d&sr=posts&keywords=compile
viewtopic.php?p=76553&hilit=compile#p76553
- muehlpower
- Posts: 750
- Joined: Fri Oct 11, 2019 10:51 am
- Location: Germany Fürstenfeldbruck
- Has thanked: 17 times
- Been thanked: 168 times
Re: Modify and compile a program
Johu recommends in another thread: “Install the latest version of stm32-sine, which you can find on Git, i.e., compile it yourself. It fixes various CAN issues compared to 5.35.R.” 5.35.R is the latest version I can download as a binary file.
On Git, it says to install “arm-none-eabi toolchain.” I did that. I also downloaded “stm32-sine-master.zip.”
The question now is how do I use the toolchain to create the “stm32_sine.bin” file from the “stm32-sine-master.zip” and what can I use to make additional changes to the source code?
On Git, it says to install “arm-none-eabi toolchain.” I did that. I also downloaded “stm32-sine-master.zip.”
The question now is how do I use the toolchain to create the “stm32_sine.bin” file from the “stm32-sine-master.zip” and what can I use to make additional changes to the source code?
- tom91
- Posts: 2753
- Joined: Fri Mar 01, 2019 9:15 pm
- Location: Bristol
- Has thanked: 264 times
- Been thanked: 717 times
Re: Modify and compile a program
Depends on your preference.
I use Docker and this https://github.com/crasbe/ZombieBuild can be adapted to work for any OI software repo.
For writing code I use Code Blocks.
I use Docker and this https://github.com/crasbe/ZombieBuild can be adapted to work for any OI software repo.
For writing code I use Code Blocks.
- muehlpower
- Posts: 750
- Joined: Fri Oct 11, 2019 10:51 am
- Location: Germany Fürstenfeldbruck
- Has thanked: 17 times
- Been thanked: 168 times
Re: Modify and compile a program
I have now installed Code Blocks. It looks good. It found a GNU when it started, which I think is good. Then I opened stm32_sine.cpp and clicked on “build.” I got this error message: "C:\compile test\stm32-sine-5.35.R\src\stm32_sine. cpp|22|fatal error: libopencm3/stm32/usart.h: No such file or directory|||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|"
Johu writes on Git: “The only external dependency is libopencm3, which I forked.”
What does that mean and how should I proceed?
Johu writes on Git: “The only external dependency is libopencm3, which I forked.”
What does that mean and how should I proceed?
- manny
- Posts: 164
- Joined: Sun Jan 23, 2022 4:15 pm
- Location: Netherlands
- Has thanked: 38 times
- Been thanked: 125 times
Re: Modify and compile a program
If you want the latest software. You can download it from github. You need to be logged in to github. got to https://github.com/jsphuebner/stm32-sine/actionsmuehlpower wrote: ↑Sat Oct 25, 2025 12:36 pm Johu recommends in another thread: “Install the latest version of stm32-sine, which you can find on Git, i.e., compile it yourself. It fixes various CAN issues compared to 5.35.R.” 5.35.R is the latest version I can download as a binary file.
And select the the latest commit of the branche you want. Scroll down to Artifacts and select the FOC or SINE file.
Visual Studio Code is a good option
muehlpower wrote: ↑Sat Oct 25, 2025 11:10 am What is “WSL Linux command line for Windows”? I can type “cmd” in the bottom left corner of my Windows screen, and then something that looks like DOS appears.
WSL is similar to cmd but its linux on windows.
[DRIVING] Citroen Saxo electrique
- Volvo ERAD motor, XC90 inverter/DCDC (custom OI board)
- PSA battery (50kWh)
- Foccci and MG ZS charger 6.6kW
- Zombie VCU
- tom91
- Posts: 2753
- Joined: Fri Mar 01, 2019 9:15 pm
- Location: Bristol
- Has thanked: 264 times
- Been thanked: 717 times
Re: Modify and compile a program
On windows I would strongly recommend using ZombieBuild and docker to compile. Code Blocks is not used to compile.tom91 wrote: ↑Sat Oct 25, 2025 12:58 pm I use Docker and this https://github.com/crasbe/ZombieBuild can be adapted to work for any OI software repo.
- muehlpower
- Posts: 750
- Joined: Fri Oct 11, 2019 10:51 am
- Location: Germany Fürstenfeldbruck
- Has thanked: 17 times
- Been thanked: 168 times
- manny
- Posts: 164
- Joined: Sun Jan 23, 2022 4:15 pm
- Location: Netherlands
- Has thanked: 38 times
- Been thanked: 125 times
Re: Modify and compile a program
Sorry did not see that they are expired. Maybe johu can redo the copile or change the expire settings?
[DRIVING] Citroen Saxo electrique
- Volvo ERAD motor, XC90 inverter/DCDC (custom OI board)
- PSA battery (50kWh)
- Foccci and MG ZS charger 6.6kW
- Zombie VCU
- muehlpower
- Posts: 750
- Joined: Fri Oct 11, 2019 10:51 am
- Location: Germany Fürstenfeldbruck
- Has thanked: 17 times
- Been thanked: 168 times
Re: Modify and compile a program
I think I now have Debian Linux, WSL2, Code Blocks, the arm-none-eabi toolchain, Docker and Windows Terminal installed. And I have downloaded the ZombieBuild-main.zip, stm32-sine-master.zip and libopencm3-5ba1bb5f8b0287a0ccec9def20f3a6185c3a2a8e files.
How do I turn all of this into a bin or hex file that I can then load onto my LDU board using ST-Link?
How do I turn all of this into a bin or hex file that I can then load onto my LDU board using ST-Link?
- manny
- Posts: 164
- Joined: Sun Jan 23, 2022 4:15 pm
- Location: Netherlands
- Has thanked: 38 times
- Been thanked: 125 times
Re: Modify and compile a program
In the command line go to the Stm32-sine directory and execute the commands on the guthub.
https://github.com/jsphuebner/stm32-sin ... #compiling
Good luck
https://github.com/jsphuebner/stm32-sin ... #compiling
Good luck
[DRIVING] Citroen Saxo electrique
- Volvo ERAD motor, XC90 inverter/DCDC (custom OI board)
- PSA battery (50kWh)
- Foccci and MG ZS charger 6.6kW
- Zombie VCU
- uhi22
- Posts: 1143
- Joined: Mon Mar 14, 2022 3:20 pm
- Location: Ingolstadt/Germany
- Has thanked: 231 times
- Been thanked: 638 times
Re: Modify and compile a program
Another way, which was straight forward (for me):
- I forked the repository to my github account. https://github.com/uhi22/stm32-sine
- Have git installed on my windows 10 machine.
- Open a git bash
- clone the repository to my machine: git clone https://github.com/uhi22/stm32-sine
- change into the new directory: cd stm32-sine
- using a text editor (I prefer Notepad++), change in the file param_prj.h the VERSION number
- back in the git bash, check the differences (git status) (git diff), stage them (git add .), commit them (git commit -m "changed version") and finally push them to the github server (git push)
- On github, the continuous integration is enabled, which means, that github itself will build every change directly, and provide the binary files (bin and hex) in the "actions" tab: https://github.com/uhi22/stm32-sine/actions
Pro:
- No need to install the tool chain for building.
- The changes and the binaries are accessable by everybody for "community testing"
Contra:
- Needs a github account
- Pushing un-tested software to github is a bad habbit. So only recommended for very small changes.
Alternatively made a local build. On windows 10. Precondition: git installed.
- Have git installed on my windows 10 machine.
- Open a git bash
- clone the repository to my machine: git clone https://github.com/jsphuebner/stm32-sine
- change into the new directory: cd stm32-sine
- using a text editor (I prefer Notepad++), change in the file param_prj.h the VERSION number or whatever else
- back in the bit bash, follow the compile commands described here: https://github.com/jsphuebner/stm32-sine#compiling with the difference, that on my windows the "make" does not work, instead I have to use mingw32-make.
- mingw32-make get-deps
-> this takes two minutes to compile a lot of library stuff
- mingw32-make
-> compiles and links the project:
OBJCOPY stm32_sine.bin
OBJCOPY stm32_sine.hex
text data bss dec hex filename
50988 4596 928 56512 dcc0 stm32_sine
- I forked the repository to my github account. https://github.com/uhi22/stm32-sine
- Have git installed on my windows 10 machine.
- Open a git bash
- clone the repository to my machine: git clone https://github.com/uhi22/stm32-sine
- change into the new directory: cd stm32-sine
- using a text editor (I prefer Notepad++), change in the file param_prj.h the VERSION number
- back in the git bash, check the differences (git status) (git diff), stage them (git add .), commit them (git commit -m "changed version") and finally push them to the github server (git push)
- On github, the continuous integration is enabled, which means, that github itself will build every change directly, and provide the binary files (bin and hex) in the "actions" tab: https://github.com/uhi22/stm32-sine/actions
Pro:
- No need to install the tool chain for building.
- The changes and the binaries are accessable by everybody for "community testing"
Contra:
- Needs a github account
- Pushing un-tested software to github is a bad habbit. So only recommended for very small changes.
Alternatively made a local build. On windows 10. Precondition: git installed.
- Have git installed on my windows 10 machine.
- Open a git bash
- clone the repository to my machine: git clone https://github.com/jsphuebner/stm32-sine
- change into the new directory: cd stm32-sine
- using a text editor (I prefer Notepad++), change in the file param_prj.h the VERSION number or whatever else
- back in the bit bash, follow the compile commands described here: https://github.com/jsphuebner/stm32-sine#compiling with the difference, that on my windows the "make" does not work, instead I have to use mingw32-make.
- mingw32-make get-deps
-> this takes two minutes to compile a lot of library stuff
- mingw32-make
-> compiles and links the project:
OBJCOPY stm32_sine.bin
OBJCOPY stm32_sine.hex
text data bss dec hex filename
50988 4596 928 56512 dcc0 stm32_sine
Github: http://github.com/uhi22 --- Patreon: https://www.patreon.com/uhi22
- uhi22
- Posts: 1143
- Joined: Mon Mar 14, 2022 3:20 pm
- Location: Ingolstadt/Germany
- Has thanked: 231 times
- Been thanked: 638 times
Re: Modify and compile a program
- 1. Find out how to open a command line ("shell").muehlpower wrote: ↑Sat Oct 25, 2025 7:36 pm I think I now have Debian Linux, WSL2, Code Blocks, the arm-none-eabi toolchain, Docker and Windows Terminal installed. And I have downloaded the ZombieBuild-main.zip, stm32-sine-master.zip and libopencm3-5ba1bb5f8b0287a0ccec9def20f3a6185c3a2a8e files.
How do I turn all of this into a bin or hex file that I can then load onto my LDU board using ST-Link?
- 2. In the shell navigate into your stm32-sine directory (that you have extracted from zip, or got using the git clone command). Something like cd ~/downloads/stm32-sine
- 3. make get-deps
- 4. make
I'm not sure whether it works to put the stm32-sine-master.zip and the libopencm3...zip together somehow. I prefer getting the data from github not using the zip, but using the command "git clone".
Github: http://github.com/uhi22 --- Patreon: https://www.patreon.com/uhi22
- johu
- Site Admin
- Posts: 6968
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 454 times
- Been thanked: 1771 times
- Contact:
Re: Modify and compile a program
I think it may not work with downloaded zip as the git submodule command will likely fail.
So use clone instead
So use clone instead
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
-
davefiddes
- Posts: 375
- Joined: Mon Jan 18, 2021 12:39 pm
- Location: Edinburgh, Scotland, UK
- Has thanked: 149 times
- Been thanked: 195 times
Re: Modify and compile a program
Yep. The GitHub releases source tarballs don't build because they are missing the submodules. I have added code to create working standalone source tarballs for the stm32-sine M3_DU project: https://github.com/davefiddes/stm32-sin ... 55C2-L73C1
If you just want binaries of a up to date stm32-sine then the release I put together here: https://github.com/davefiddes/stm32-sin ... DU_v5.39.0 might be of interest. It has the most recent CAN fixes and has been tested on the M3_DU. No testing on other boards but it *should* be OK.
If you just want binaries of a up to date stm32-sine then the release I put together here: https://github.com/davefiddes/stm32-sin ... DU_v5.39.0 might be of interest. It has the most recent CAN fixes and has been tested on the M3_DU. No testing on other boards but it *should* be OK.
- muehlpower
- Posts: 750
- Joined: Fri Oct 11, 2019 10:51 am
- Location: Germany Fürstenfeldbruck
- Has thanked: 17 times
- Been thanked: 168 times
Re: Modify and compile a program
Ubuntu is installed, make and git are running. “make get-deps” produces an error message.
-
davefiddes
- Posts: 375
- Joined: Mon Jan 18, 2021 12:39 pm
- Location: Edinburgh, Scotland, UK
- Has thanked: 149 times
- Been thanked: 195 times
Re: Modify and compile a program
make get-deps will not work on the unzipped source. You need to "git clone https://github.com/jsphuebner/stm32-sine.git"
- muehlpower
- Posts: 750
- Joined: Fri Oct 11, 2019 10:51 am
- Location: Germany Fürstenfeldbruck
- Has thanked: 17 times
- Been thanked: 168 times
Re: Modify and compile a program
I have now created a local copy using git clone, and the result looks exactly like the unzipped version of the downloaded master zip file. Is there a difference?
-
davefiddes
- Posts: 375
- Joined: Mon Jan 18, 2021 12:39 pm
- Location: Edinburgh, Scotland, UK
- Has thanked: 149 times
- Been thanked: 195 times
Re: Modify and compile a program
The "git clone" will have created a special ".git" folder which is not present in the zip file. You should be able to run "make get-deps" now which will fetch and build libopencm3 and libopeninv which the project needs.
- muehlpower
- Posts: 750
- Joined: Fri Oct 11, 2019 10:51 am
- Location: Germany Fürstenfeldbruck
- Has thanked: 17 times
- Been thanked: 168 times
Re: Modify and compile a program
You're absolutely right, I didn't see that. “make get-deps” worked, and so did “make.” So the newly created hex and bin files should be the ones I can load onto my board? I've only changed the version number for now and will test whether it's correct after loading.
What does the warning mean?
-
davefiddes
- Posts: 375
- Joined: Mon Jan 18, 2021 12:39 pm
- Location: Edinburgh, Scotland, UK
- Has thanked: 149 times
- Been thanked: 195 times
Re: Modify and compile a program
Yep. You can take the bin file and upload it via the web interface or CAN as you would with an official release. The stm32_sin file (without an extension) is what you need for debugging.
The warning can be safely ignored. It's a compiler bug(ish) cause by some slightly convoluted code in libopeninv. Newer compilers like gcc 15.1 don't complain.
The warning can be safely ignored. It's a compiler bug(ish) cause by some slightly convoluted code in libopeninv. Newer compilers like gcc 15.1 don't complain.