Difference between revisions of "Compiling and Installing Firmware"

From Speeduino
Jump to: navigation, search
(Latest Stable Firmware)
Line 1: Line 1:
 
With the goal of maximum simplicity in mind, the process of compiling and installing the firmware is reasonably straightforward.
 
With the goal of maximum simplicity in mind, the process of compiling and installing the firmware is reasonably straightforward.
  
== Requirements ==
+
== Latest Stable Firmware ==
 +
* '''Date:''' November 29th 2018
 +
* '''Details:''' See https://speeduino.com/forum/viewtopic.php?f=13&t=2456
 +
 
 +
== Installation - Easy Method ==
 +
The simplest method of installing the Speeduino firmware onto a standard Arduino Mega 2560 is with the SpeedyLoader utility. SpeedyLoader takes care of downloading the firmware and installing it onto an Arduino without the need to manually compile any of the code yourself. You can choose the newest firmware that has been released, or select from one of the older ones if preferred. SpeedyLoader will also download the INI file for the firmware you choose so it can be loaded into your TunerStudio project.
 +
 
 +
* '''Windows:''' [https://github.com/noisymime/SpeedyLoader/releases/download/v1.1.0/SpeedyLoader.1.1.0-ia32.exe 32-bit] / [https://github.com/noisymime/SpeedyLoader/releases/download/v1.1.0/SpeedyLoader.1.1.0-x64.exe 64-bit]
 +
* '''Mac:''' [https://github.com/noisymime/SpeedyLoader/releases/download/v1.1.0/SpeedyLoader-1.1.0.dmg SpeedyLoader-1.1.0.dmg ]
 +
* '''Linux:''' [https://github.com/noisymime/SpeedyLoader/releases/download/v1.1.0/SpeedyLoader.1.1.0.AppImage SpeedyLoader.1.1.0.AppImage ] (Will need to be made executable after downloading)
 +
 
 +
Once the firmware is installed on the board, see [[Connecting to TunerStudio]] for more details on how to configure TunerStudio
 +
 
 +
== Manually Compiling ==
 +
If you want to compile the firmware yourself, or make any code changes, then the source of both the releases and the current development version is freely available. Note that manually compiling the firmware is '''NOT''' required to install Speeduino, the easiest (and recommended for most users) method is using SpeedyLoader as described above.
 +
 
 +
=== Requirements ===
 
* A Windows, Mac or linux PC
 
* A Windows, Mac or linux PC
 
* One of the following:
 
* One of the following:
Line 9: Line 25:
 
* A copy of [http://www.tunerstudio.com/index.php/downloads TunerStudio] to test that the firmware has uploaded successfully
 
* A copy of [http://www.tunerstudio.com/index.php/downloads TunerStudio] to test that the firmware has uploaded successfully
  
== Downloading the firmware ==
+
=== Downloading the firmware ===
 
There are two methods for obtaining the Speeduino firmware:
 
There are two methods for obtaining the Speeduino firmware:
# Regular, stable code drops are produced, typically on the last day of each month. Details of the latest code drop are below
+
# Regular, stable code drops are produced and made as releases on Github. These can be found at: https://github.com/noisymime/speeduino/releases
 
# If you want the latest and greatest (And occasionally flakiest) code, the git repository can be cloned and updated. See https://github.com/noisymime/speeduino
 
# If you want the latest and greatest (And occasionally flakiest) code, the git repository can be cloned and updated. See https://github.com/noisymime/speeduino
  
=== Latest Stable Firmware ===
+
==== Older firmware releases ====
* '''Date:''' November 29th 2018
 
* '''Details:''' See https://speeduino.com/forum/viewtopic.php?f=13&t=2456
 
* '''Download:''' https://speeduino.com/wiki/images/d/d7/Speeduino-Oct18.zip
 
* '''Notes:'''
 
** '''Remember to always reload the latest ini file into your TunerStudio project when you load new firmware''' (See below for details)
 
** '''Tuner Studio version 3.0.2 or newer is required from July 2016 onwards!'''
 
** There is a known bug with these newer versions of the Arduino IDE when running on Windows XP. See this post for a workaround: http://speeduino.com/forum/viewtopic.php?f=13&t=555&p=7664&hilit=xp#p7665
 
 
 
=== Older firmware releases ===
 
 
If required, older firmware releases and details can be found at [[Firmware History]]
 
If required, older firmware releases and details can be found at [[Firmware History]]
  
== Compiling the firmware ==
+
=== Compiling the firmware ===
 
* Start the IDE, select ''File > Open'', navigate to the location you downloaded Speeduino to and open the '''speeduino.ino''' file.
 
* Start the IDE, select ''File > Open'', navigate to the location you downloaded Speeduino to and open the '''speeduino.ino''' file.
 
* Set the board type: ''Tools > Board > Arduino Mega 2560'' or Mega ADK (This is the only board currently supported)
 
* Set the board type: ''Tools > Board > Arduino Mega 2560'' or Mega ADK (This is the only board currently supported)
Line 35: Line 42:
 
<center><embedvideo service="youtube">AX9URou4JTs</embedvideo></center>
 
<center><embedvideo service="youtube">AX9URou4JTs</embedvideo></center>
  
=== Optional (But recommended) ===
+
==== Optional (But recommended) ====
 
There is an option available for changing the compiler optimization level, which can improve . By default, the IDE uses the -Os compile option, which focuses on producing small binaries. As the size of the Speeduino code is not an issue but speed is a consideration, changing this to -O3 produces better results (Approximately 20% faster, with a 40% larger sketch size)
 
There is an option available for changing the compiler optimization level, which can improve . By default, the IDE uses the -Os compile option, which focuses on producing small binaries. As the size of the Speeduino code is not an issue but speed is a consideration, changing this to -O3 produces better results (Approximately 20% faster, with a 40% larger sketch size)
 
To do this, you need to edit the platform.txt file:
 
To do this, you need to edit the platform.txt file:
Line 51: Line 58:
 
'''Note:''' This is NOT required if using PlatformIO, the above optimisation is applied automatically there
 
'''Note:''' This is NOT required if using PlatformIO, the above optimisation is applied automatically there
  
== Installing ==
+
=== Installing ===
 
Once you've successfully compiled the firmware, installation on the board is trivial.
 
Once you've successfully compiled the firmware, installation on the board is trivial.
 
* Plug in your Mega 2560 to a free USB port
 
* Plug in your Mega 2560 to a free USB port
Line 80: Line 87:
 
<img src="http://i.imgur.com/iBRSq5t.png" />
 
<img src="http://i.imgur.com/iBRSq5t.png" />
  
== Verifying Firmware ==
+
=== Verifying Firmware ===
 
The firmware is now loaded onto your board and you are now able to move onto [[Connecting to TunerStudio]].
 
The firmware is now loaded onto your board and you are now able to move onto [[Connecting to TunerStudio]].
  
Line 92: Line 99:
  
  
You can also enter "?" for a list of queries from your Mega:
+
You can also enter "?" for a list of queries from your Mega.
<pre>
 
=== Command Help ===
 
 
 
All commands are single character and are concatenated with their parameters
 
without spaces. Some parameters are binary and cannot be entered through this
 
prompt by conventional means.
 
Syntax:  <command>+<parameter1>+<parameter2>+<parameterN>
 
 
 
=== List of Commands ===
 
 
 
A - Displays 31 bytes of currentStatus values in binary (live data)
 
B - Burn current map and configPage values to eeprom
 
C - Test COM port.  Used by Tunerstudio to see whether an ECU is on a given serial
 
    port. Returns a binary number.
 
L - Displays map page (aka table) or configPage values.  Use P to change page (not
 
    every page is a map)
 
N - Print new line.
 
P - Set current page.  Syntax:  P+<pageNumber>
 
R - Same as A command
 
S - Display signature number
 
Q - Same as S command
 
V - Display map or configPage values in binary
 
W - Set one byte in map or configPage.  Expects binary parameters.
 
    Syntax:  W+<offset>+<newbyte>
 
t - Set calibration values.  Expects binary parameters.  Table index is either 0,
 
    1, or 2.  Syntax:  t+<tble_idx>+<newValue1>+<newValue2>+<newValueN>
 
Z - Display calibration values
 
T - Displays 256 tooth log entries in binary
 
r - Displays 256 tooth log entries
 
? - Displays this help page
 
</pre>
 
 
 
You can now test your new Speeduino code by starting TunerStudio and attempting to connect. See [[Connecting to TunerStudio]] for more details
 
  
== Troubleshooting ==
+
=== Troubleshooting ===
=== Incorrect Arduino board selected ===
+
==== Incorrect Arduino board selected ====
 
If you see the following (or similar) errors when trying to compile the firmware and the solutions:
 
If you see the following (or similar) errors when trying to compile the firmware and the solutions:
 
<pre>
 
<pre>
Line 137: Line 111:
 
You may have the wrong kind of Arduino board selected. Set the board type by selecting ''Tools > Board > Arduino Mega 2560'' or Mega ADK
 
You may have the wrong kind of Arduino board selected. Set the board type by selecting ''Tools > Board > Arduino Mega 2560'' or Mega ADK
  
=== Entire Speeduino project is not opened ===  
+
==== Entire Speeduino project is not opened ====
 
The following can occur if you have only opened the speeduino.ino file rather than the whole project.
 
The following can occur if you have only opened the speeduino.ino file rather than the whole project.
  

Revision as of 03:49, 12 February 2019

With the goal of maximum simplicity in mind, the process of compiling and installing the firmware is reasonably straightforward.

Latest Stable Firmware

Installation - Easy Method

The simplest method of installing the Speeduino firmware onto a standard Arduino Mega 2560 is with the SpeedyLoader utility. SpeedyLoader takes care of downloading the firmware and installing it onto an Arduino without the need to manually compile any of the code yourself. You can choose the newest firmware that has been released, or select from one of the older ones if preferred. SpeedyLoader will also download the INI file for the firmware you choose so it can be loaded into your TunerStudio project.

Once the firmware is installed on the board, see Connecting to TunerStudio for more details on how to configure TunerStudio

Manually Compiling

If you want to compile the firmware yourself, or make any code changes, then the source of both the releases and the current development version is freely available. Note that manually compiling the firmware is NOT required to install Speeduino, the easiest (and recommended for most users) method is using SpeedyLoader as described above.

Requirements

Downloading the firmware

There are two methods for obtaining the Speeduino firmware:

  1. Regular, stable code drops are produced and made as releases on Github. These can be found at: https://github.com/noisymime/speeduino/releases
  2. If you want the latest and greatest (And occasionally flakiest) code, the git repository can be cloned and updated. See https://github.com/noisymime/speeduino

Older firmware releases

If required, older firmware releases and details can be found at Firmware History

Compiling the firmware

  • Start the IDE, select File > Open, navigate to the location you downloaded Speeduino to and open the speeduino.ino file.
  • Set the board type: Tools > Board > Arduino Mega 2560 or Mega ADK (This is the only board currently supported)
  • Click the Verify icon in the top left corner (Looks like a tick)

At this point you should have a compiled firmware! If you experienced a problem during the compile, see the Troubleshooting section below.

This video walks through the whole process of installing the firmware on your Arduino from scratch:

Optional (But recommended)

There is an option available for changing the compiler optimization level, which can improve . By default, the IDE uses the -Os compile option, which focuses on producing small binaries. As the size of the Speeduino code is not an issue but speed is a consideration, changing this to -O3 produces better results (Approximately 20% faster, with a 40% larger sketch size) To do this, you need to edit the platform.txt file:

  • Make sure the Arduino IDE isn't running
  • Open the platform.txt file which is in the following locations:
    • On Windows: c:\Program Files\Arduino\hardware\arduino\avr
    • On Mac: /Applications/Arduino/Contents/Resources/Java/hardware/arduino/avr/
    • On Linux:
  • On the following 3 entries, change the Os to be O3:
    • compiler.c.flags
    • compiler.c.elf.flags
    • compiler.cpp.flags
  • Save the file and restart the Arduino IDE

Note: This is NOT required if using PlatformIO, the above optimisation is applied automatically there

Installing

Once you've successfully compiled the firmware, installation on the board is trivial.

  • Plug in your Mega 2560 to a free USB port
  • If you're running an older version of Windows and this is the first time you've used an Arduino, you may need to install drivers for the Arduino serial chip (USB-UART or "USB adapter chip").

Most official boards and many non-official versions use the ATMega16U2 or 8U2, whereas many of the Mega2560 clone boards utilize the CH340G IC. Both types work well. The serial chips can generally be identified by appearance:

ATMega16U (square IC) - drivers included in Windows, MacOS and Linux:

or

WCH CH340G (Rectangular IC) - uses "CH341" drivers from WCH for Windows:

WCH-original CH340/CH341 drivers for other systems (Mac, Linux, Android, etc) may be found here.


  • In Arduino IDE; select the Mega2560: Tools > Board
  • Select your system's serial port to upload: Tools > Serial Port
  • Hit the Upload button from the top left corner (Looks like an arrow point to the right)

Assuming all goes well, you should see the IDE message that avrdude is done, similar to this:

Verifying Firmware

The firmware is now loaded onto your board and you are now able to move onto Connecting to TunerStudio.

Optionally, you may perform a verification of the firmware by using the Arduino IDE's Serial Monitor. This can be started by selecting 'Serial Monitor' from the Tools menu.

In the window that appears, enter a capital "S" (no quotes) and press Enter. The Mega should respond with the year and month of the code version installed (xxxx.xx):

Speeduino 2017.03

NOTE: Ensure the baud rate is set to 115200


You can also enter "?" for a list of queries from your Mega.

Troubleshooting

Incorrect Arduino board selected

If you see the following (or similar) errors when trying to compile the firmware and the solutions:

scheduler.ino:317:7: error: ‘OCR4A’ was not declared in this scope
scheduler.ino:323:8: error: ‘TIMSK5’ was not declared in this scope 
scheduler.ino:323:25: error: ‘OCIE4A’ was not declared in this scope 

You may have the wrong kind of Arduino board selected. Set the board type by selecting Tools > Board > Arduino Mega 2560 or Mega ADK

Entire Speeduino project is not opened

The following can occur if you have only opened the speeduino.ino file rather than the whole project.

speeduino.ino:27:21: fatal error: globals.h: No such file or directory

Make sure all the files are contained within the same directory, then select File->Open and find the speeduino.ino file. If you have opened the project correctly, you should have multiple tabs along the top: