[info] How to compile the firmware

It's all about the code!
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

How to compile the firmware

Post by AndreyB »

Click here for info on pre-compiled binaries
Click here for info on how to compile rusEfi console

Cygwin required on Windows

Tl,DR: on unix or WSL? see setup_linux_environment.sh
Fanciest 2014 method see https://github.com/rusefi/rusefi/wiki/Custom-Firmware


The firmware code is written in mixture of C and C++ languages, in this post I will briefly list all the tools needed to compile or edit this code. There is another thread about the code itself.

Step #1: First you need to download current version of the code from our source code repository.

Step #2: Let's begin with just compiling code from command line. I am using Windows, but there is not much difference with other platforms.

#2.1: Install Arm port of GCC compiler: - that's gnu-toolchain

Validation: in cmd, type "arm-none-eabi-gcc -v" and you should see "...gcc version ... something" (Not version 4.7 as of 2021 - you are looking at an OLD post)

Image

#2.2: Install make. I use make which comes with Cygwin, in package menu select 'Devel' > 'make: The GNU version of the 'make' utility'.

UPDATE: see below why https://sourceforge.net/projects/gnuarmeclipse/files/Build%20Tools/ is needed

Image

Add "bin/" subfolder into system PATH. In case of default installation folder, it would be C:\cygwin\bin

Image

(alternatively you can use some path editor like http://rix0rrr.github.io/WindowsPathEditor/)

Validation: in cmd, type "make -version" and you should see "GNU Make ... for cygwin"

Image

With these two pieces of software, you should be able to compile the code by executing "make" command in the root folder of the source code location.

Image

Step #3: Now, if you also want to change the code & compile using the integrated development environment,
#3.0: GNU Arm toolchain
#3.1: Eclipse Downloads - scroll down a bit and select "Eclipse IDE for C/C++ Developers Eclipse IDE for C/C++ Developers"
#3.2: Eclipse GNU ARM plugin - http://gnuarmeclipse.sourceforge.net/updates

Here is a snapshot of my "Help->About Eclipse->Installation details dialog:
Image
The required ones are
Eclipse IDE for C/C++ Developers
GNU ARM C/C++ Cross Compiler
Optional for SVN integration are JavaHL and Sub* entries
Optional for debugging is C/C++ GDB Hardware Debugging

#3.3: Close that weird 'Welcome' windows
#3.4: Click "File->Import->Existing project into Workspace" and point to the folder containing the source code bundle - 'firmware'.
Here is how this should look like once you've imported the 'firmware' project:
Image

#3.5: Time for 'Project->Build All'
It might take couple of minutes, once it's done you should see
Image

Once you see this, you've got yourself your own version of rusefi.hex compiled within the IDE which you can now program into your brain board :) It's in the Debug folder.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Q&A on how to compile the code

Post by AndreyB »

Oh, by the way IAR Embedded Workbench for ARM is now supported, too. update: not any more :(
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Q&A on how to compile the code

Post by AndreyB »

GitHub is the primary repository these days - https://github.com/rusefi/rusefi/
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Q&A on how to compile the code

Post by AndreyB »

Just to make things easier I will also publish compiled versions at http://rusefi.com/build_server/
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
jedediah_frey
contributor
contributor
Posts: 51
Joined: Tue Nov 05, 2013 1:43 pm

Re: Q&A on how to compile the code

Post by jedediah_frey »

russian wrote:Just to make things easier I will also publish compiled versions at http://sourceforge.net/p/rusefi/code/HEAD/tree/trunk/firmware_binary/

The folder contains the .hex file along with the version.txt which tells how old this binary is - so far this would be done manually.
ChibiStudio is a MUCH easier way to get setup with this. You unzip it and it has openocd, make, and GCC all in the tools directory. For some reason minGW/Cygwin make takes a long time to get running. It takes 2-3 seconds to 'run' no clue why. It has 4.7 2013q2 but you can always get the latest version from https://launchpad.net/gcc-arm-embedded. Either way it's single file to expand and place at C:\

http://sourceforge.net/projects/chibios/files/ChibiStudio/

And of course delete this message once you do :)
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Q&A on how to compile the code

Post by AndreyB »

jedediah_frey wrote:ChibiStudio is a MUCH easier way to get setup with this.
Can you please check if rusEfi default eclipse projects opens and compiles with ChibiStudio? Technically I am using Sourcery GCC, not sure if this would make a difference.

If you could confirm this and start a separate thread for ChibiStudio that would help a lot.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
jedediah_frey
contributor
contributor
Posts: 51
Joined: Tue Nov 05, 2013 1:43 pm

Re: Q&A on how to compile the code

Post by jedediah_frey »

russian wrote:
jedediah_frey wrote:ChibiStudio is a MUCH easier way to get setup with this.
Can you please check if rusEfi default eclipse projects opens and compiles with ChibiStudio? Technically I am using Sourcery GCC, not sure if this would make a difference.

If you could confirm this and start a separate thread for ChibiStudio that would help a lot.
Works great doing GDB debugging was just as easy, (literally just copied some settings over) and I had a GDB/OpenOCD running.
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Q&A on how to compile the code

Post by AndreyB »

jedediah_frey wrote:Works great doing GDB debugging was just as easy, (literally just copied some settings over) and I had a GDB/OpenOCD running.
Any chance you can write a more detailed step by step pretty please? :)
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
jedediah_frey
contributor
contributor
Posts: 51
Joined: Tue Nov 05, 2013 1:43 pm

Re: Q&A on how to compile the code

Post by jedediah_frey »

russian wrote:
jedediah_frey wrote:Works great doing GDB debugging was just as easy, (literally just copied some settings over) and I had a GDB/OpenOCD running.
Any chance you can write a more detailed step by step pretty please? :)
Of course, I'll get to it after work today.
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: How to compile the code

Post by AndreyB »

Speaking of Eclipse, the two most important features are:

1) "Ctrl+mouse click" - go to declaration of whatever you've clicked on while holding 'Ctrl'
2) "Ctrl-Shift-G" - find usages of whatever your cursor is at
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
E4ODnut
Posts: 207
Joined: Mon Feb 10, 2014 11:52 pm
Location: Gibsons, BC, Canada

Re: How to compile the code

Post by E4ODnut »

I think I have the correct version of Eclipse installed. When I go to Help>About Eclipse, it returns:
Eclipse IDE for C/C++ Developers
Version: Kepler Service Release/
Build ID: 20130919-0819

I can't seem to load the rusEFI project that I downloaded from

http://rusefi.com/build_server/rusefi_firmware.zip

Suggestions?
Robert
1995 Ford E-150, 300 CID I6 E4OD, Custom MS1-Extra
1992 Winnebago Elante 33 RQ, Ford 460 CID V8, E4OD, Custom MS1-Extra
1992 Bayliner 3288, Twin Ford 351CID Windsor V8s, Custom MS1-Extra
1995 Dodge Ram 2500 4x4 488 CID V10 5 spd. MS3 (in progress)
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: How to compile the code

Post by AndreyB »

build server is the place where the binaries are uploaded by the... build server which builds and tests the binaries every time there is an official code change.

You want to import your 'firmware' folder which cobtains main.c and other source code files. The easy option is rusefi.rXXXX.zip from soueceforge files but the better option is a subfolder of the stuff you've checked out using the SVN client.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
E4ODnut
Posts: 207
Joined: Mon Feb 10, 2014 11:52 pm
Location: Gibsons, BC, Canada

Re: How to compile the code

Post by E4ODnut »

Sorry, you lost me. What's an SVN client? Remember, I'm just blindly following instructions here.

The Zip file I downloaded was unzipped under the folder "code". In that folder there were sub folders, "firmware", "Firmware Bineries", Hardware", "Java Consol" and a bunch of others. Was this the correct download?
Robert
1995 Ford E-150, 300 CID I6 E4OD, Custom MS1-Extra
1992 Winnebago Elante 33 RQ, Ford 460 CID V8, E4OD, Custom MS1-Extra
1992 Bayliner 3288, Twin Ford 351CID Windsor V8s, Custom MS1-Extra
1995 Dodge Ram 2500 4x4 488 CID V10 5 spd. MS3 (in progress)
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: How to compile the code

Post by AndreyB »

E4ODnut wrote:Sorry, you lost me. What's an SVN client? Remember, I'm just blindly following instructions here.

The Zip file I downloaded was unzipped under the folder "code". In that folder there were sub folders, "firmware", "Firmware Bineries", Hardware", "Java Consol" and a bunch of others. Was this the correct download?
TortoiseSVN as described here is our SVN client of choice. Wikipedia: SVN and Wikipedia: Version Control

I do not think we have a .zip file which contains 'hardware', do we?

Anyway. You should have a folder which would have main.c and rusefi.c and a bunch of other files in it. Point eclipse at this folder, I am expecting this folder to be called 'firmware'.

Remeber - you do not have to use Eclipse. You can use clean_build.bat which you should have next to the main.c.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
legath-t
contributor
contributor
Posts: 10
Joined: Mon Jun 23, 2014 6:48 pm
Location: Ryazan

Re: How to compile the code

Post by legath-t »

Hi
i think we need to migrate to linaro toolchain, because it is absolute opensource.
Code sourcery have some limitations.
ghaem313
Posts: 2
Joined: Mon Dec 15, 2014 8:56 pm

Re: How to compile the firmware

Post by ghaem313 »

I wonder if you've installed the right ARM plugin?
I have downloaded all off Required things from links that you put them on last page.
you can see the installed plugin and error in the attachment.
Attachments
eclipse err.png
eclipse err.png (237.75 KiB) Viewed 442064 times
ghaem313
Posts: 2
Joined: Mon Dec 15, 2014 8:56 pm

Re: How to compile the firmware

Post by ghaem313 »

i have removed all arm plugin and installed V 0.5.5 plugin that copied in dropins folder
but problem not resolved
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: How to compile the firmware

Post by AndreyB »

ghaem313 wrote:i have removed all arm plugin and installed V 0.5.5 plugin that copied in dropins folder
but problem not resolved
At this point best I can offer would be installing http://www.teamviewer.com/ and getting in touch with me on Skype (my Skype ID is below)
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
Tambralinga
donator
donator
Posts: 174
Joined: Wed Jun 18, 2014 8:36 am
Location: Bangkok, Thailand

Re: How to compile the firmware

Post by Tambralinga »

Image

Image

I want to solve this problem.
Skype : shiva-p
+66 8 5357 5159
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: How to compile the firmware

Post by AndreyB »

Tambralinga wrote:I want to solve this problem.
Looks like you need to fix the linker script path
Image
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: How to compile the firmware

Post by AndreyB »

With the new plugin, finally setting up the debugger is relatively simple

1) download & uncompress https://svn.code.sf.net/p/rusefi/code/trunk/misc/install/openocd-0.8.0.7z add bin/ folder to path

2) install ARM Cross-compiling & OpenOCD debugging
Image

3) use https://svn.code.sf.net/p/rusefi/code/trunk/misc/openocd/run_openocd.bat to start openocd

4) create OpenOCD Debug configuration, un-check the "run OpenOCD locally"
Image
Image

5) run openocd with run_openocd.bat

it should work!
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: How to compile the firmware

Post by kb1gtt »

It's been a while sense I looked to download it, but last I recall, the file you wanted was semi hidden, such that you typically got the wrong file instead of the actual free edition. If you ignore what your eyes come to first for the download, do you notice another file linked somewhere else on the page?
Welcome to the friendlier side of internet crazy :)
ScubaSteve
Posts: 12
Joined: Fri Jul 10, 2015 2:22 am

Re: How to compile the firmware

Post by ScubaSteve »

kb1gtt wrote:It's been a while sense I looked to download it, but last I recall, the file you wanted was semi hidden, such that you typically got the wrong file instead of the actual free edition. If you ignore what your eyes come to first for the download, do you notice another file linked somewhere else on the page?
Well I dug deep and ended up here.
They literately made only the ARM edition a 30 day trial :\

I'm gonna look around and see if anyone has archived an installer for the old free edition.

Update 1: Think I found a working version!

Update 2: AOK! Just built the firmware
Download: https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q3-update
Update 3: Does not work with Eclipse, its not Codebase
Image
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: How to compile the firmware

Post by AndreyB »

Eclipse is not required to compile the code - there is also a Makefile, you can compile with make
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Rhinoman
contributor
contributor
Posts: 256
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK

Re: How to compile the firmware

Post by Rhinoman »

I'm trying to install the Eclipse IDSE following these instructions:

(edit by @: please do not use this link to install anything for rusEfi) http://stm32discovery.nano-age.co.uk/open-source-development-with-the-stm32-discovery/setting-up-eclipse-for-stm32-discovery-development

As usual with Eclipse nothing works, so who has a working set up and what versions of the different packages do you have? I have got past the Java 32/64-bit incompatibility but I can't update the software, I'm guessing its another Java/Eclipse incompatibility.
I have:
Eclipse IDE for C/C++ Developers
Version: Helios Service Release 1
Build id: 20100917-0705

Java Version 8 update 60
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: How to compile the firmware

Post by AndreyB »

I think part of the issue is that you are trying to use a version from 5 years ago. The article is referencing Eclipse and GCC probably from the times when the article was written, these older versions would not be compatible with the current version of the ARM Eclipse plugin I am using.
Rhinoman wrote:Build id: 20100917-0705

In order to get latest Eclipse CDT one would look at https://eclipse.org/cdt/downloads.php

On the other hand, you do not really need eclipse in order to compile - you only need current eclipse if you want to integrate all the tools. A bare bones installation just to compile would be some ARM gcc and some 'make' - I am using somewhat old Sourcery CodeBench Lite 2014.05-28 from http://go.mentor.com/31xl6 and current Cygwin make (I like on Windows)
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Rhinoman
contributor
contributor
Posts: 256
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK

Re: How to compile the firmware

Post by Rhinoman »

OK, thanks, I didn't realise that was an older version, I will install the latest version and try again.
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: How to compile the firmware

Post by AndreyB »

On Windows linker command has just exceeded 8Kb with the addition of a new file, https://mcuoneclipse.com/2015/03/29/solving-the-8192-character-command-line-limit-on-windows/ is now needed to work around this issue.

https://sourceforge.net/projects/gnuarmeclipse/files/Build%20Tools/
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
marko
Posts: 8
Joined: Sat Mar 25, 2017 5:20 pm

Re: How to compile the firmware

Post by marko »

Why do you use sourcery? Can you not get it to work with normal arm gcc? the one formally called launchpad. That's what I've always used for STM32 in the past. Looks like ARM is actually doing the development now.

https://developer.arm.com/open-source/gnu-toolchain/gnu-rm
User avatar
AndreyB
Site Admin
Posts: 14280
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: How to compile the firmware

Post by AndreyB »

Thank you CodeSourcery - we now use arm gcc See https://github.com/rusefi/rusefi/issues/376

I am not aware of any major differences, just keeping up with current version of everything,
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Post Reply