Multiprotocol firmware is compiled using the Arduino IDE. The guide below will walk you through all the steps to compile and upload your customized firmware.
These instructions are for the Atmega328p version of the Multiprotocol module. If you are compling for the STM32 version please go to the dedicated STM32 page.
- Tools Required
- Preparation
- Configure the firmware
- Compiling and uploading the firmware
- Troubleshooting
3.3V USBasp Programmer | 10-pin to 6-pin Adapter | 6-pin header |
---|---|---|
(example aliexpress link) | (example ebay link) | (example Digi-Key link) |
Important: The USBasp must be 3.3V. Using a 5V USBasp (most blue PCB type) will fry the RF modules as they are not 5V tolerant.
Tip: You can cut or remove the VCC line on your USBasp 6-pin adapter or ribbon cable and power the module from the radio when flashing to ensure that it receives the correct voltage.
The 6-pin header needs to be soldered onto the board as indicated by the red rectangle:
Banggood 4-in-1 Module | DIY Multiprotocol Module | Arduino Pro Mini Module |
---|---|---|
- Download and install the Arduino IDE. The currently supported Arduino version is 1.8.5, available for Windows and Mac OSX
- It is recommended to upgrade Java to the latest version
- Either
- Download the zip file with the Multiprotocol module source code from here and unzip and copy the source code folder Multiprotocol to a location of your choosing, or
- Clone the project using Git or Github Desktop, then
- Double-click the Multiprotocol.ino file in the Multiprotocol folder to open the project in the Arduino IDE
Important note for Windows users: You must download or unzip the Multiprotocol source in a folder which has no spaces in the path. If you have spaces in your username do not use a sub-folder of your user directory. This is due to a bug in the Arduino IDE, caused by an issue in Go.
- Follow these instructions to install the Multi 4-in-1 AVR Board in the Arduino IDE
- Under Tools -> Board select 'Multi 4-in-1 (Atmega328p, 3.3V, 16MHz)
- Under Tools -> Programmer select USBasp
All customization is done by editing the _Config.h
file in the Multiprotocol Arduino project.
In the Arduino IDE, click on the down arrow on the far right of the tab bar to show a list of project files (see the red circle on the screenshot below). Scroll down and select the _Config.h file.
The file has different sections which are explained in details. The best is to go through them one by one carefully and apply the configuration which matches your needs.
Most of the default settings should get you started quickly. But on modules with ATMega microcontrollers, the memory required for all the protocols exceeds the available 32KB of flash memory. You therefore need to select which protocols you wish to use in order to fit them into the available memory.
To fill in the "PROTOCOLS TO INCLUDE" section, it would be good to review all the available protocols on the Protocol Details page and identify which one you would like to add on your module.
To check that the program will compile correctly and fit in the Atmega click Sketch -> Verify/Compile, or press Ctrl+R.
If you see something like the following, your firmware is still too big and you need to deselect additional protocols:
Sketch uses 42032 bytes (128%) of program storage space. Maximum is 32768 bytes.
Global variables use 1180 bytes (57%) of dynamic memory, leaving 868 bytes for local variables. Maximum is 2048 bytes.
Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
Error compiling for board Multi 4-in-1 (Atmega328p, 3.3V, 16MHz).
If there is another error carefully read it, go to the line number indicated and correct your typo.
If there are no errors and you see output like this:
Sketch uses 31874 bytes (97%) of program storage space. Maximum is 32768 bytes.
Global variables use 1083 bytes (52%) of dynamic memory, leaving 965 bytes for local variables. Maximum is 2048 bytes.
You can proceed to the next step.
If you have already burned the bootloader, and are simply recompiling firmware to re-flash using your TX, you can skip straight to Flash from TX.
- Before you connect the programmer make sure that you have selected the 3.3V mode and not 5V. The RF Modules are not 5V tolerant and you will break them with 5V. On most programmers this is done by moving a jumper.
- Please re-read item 1. above before going on, it's important.
- If your module has a rotary switch, set it to the 0 position. The upload will not work if the switch is in any other position.
- Connect the 6-pin programming connector to the 6-pin ASP IVR connector on the DIY Multiprotocol board. Be sure to match the ground pin of the programmer connector to the ground pin on the board.
The images below indicate the pin layout and the location of the ground pin on the board:
Banggood 4-in-1 Module | DIY Multiprotocol Module | Arduino Pro Mini Module |
---|---|---|
You are now ready to plug in the USB programmer to the computer. If you are looking for a good working USBasp Windows driver, use this one.
The bootloader only needs to be burned once, unless you decide to switch from one option to the other (or it is accidentally erased). If you have already burned the bootloader / set the fuses you can skip this step.
There are two bootloader options:
- 'No bootloader' maximises flash space for protocols
- 'Flash from TX' installs a small (512 byte) bootloader which allows flashing the module firmware using from a radio running ersky9x
Note: 'Burning the bootloader' is necessary even if the 'No bootloader' option is selected, as it sets the fuses on the AVR module. This only needs to be once (unless you decide to change your bootloader choice later)
- Under Tools -> Bootloader select a bootloader
- Click on Tools -> Burn Bootloader
You are now ready to upload the firmware to the multiprotocol module. There are two methods for uploading the firmware:
- Flash from TX - uses the bootloader mode of radios running ersky9x or OpenTX to upload the firmware. The radio needs to run the latest bootloader with the Flash Multi app.
- Upload using Arduino IDE uses the Arduino IDE and the USBasp programmer to upload the firmware
- The MPM module must have the 'Flash from TX' bootloader installed
- In the Arduino IDE click Sketch -> Export compiled Binary, or press Ctrl+Alt+S
- Locate the file named multi-avr-x.x.x.x.hex in the Multiprotocol source folder (x.x.x.x is the multi version)
- Follow the instructions here to upload the firmware using your radio
- Once the previous step is completed your module is ready to be used
Note: If you have burned the 'Upload from TX' bootloader and you then upload firmware to your module using Upload Using Programmer, you will erase the bootloader. That's just the way the Arduino IDE works - avrdude will erase the entire flash memory prior to writing the new code, including the bootloader, and the upload will not put it back. If this happens you can burn it again.
- In the Arduino IDE click Sketch -> Upload Using Programmer, or press Ctrl+Shift+U.
If the output indicates that the firmware has been uploaded successfully - give yourself a pat on the back. Well done, you have successfully programmed your DIY Multiprotocol module. You can already go to the final step Setting up your Transmitter and begin to fly!!!!
If you get an error that indicates "warning : Can not Set sck period . usbasp please check for firmware update ." just ignore it, everything is fine. Don't be tempted to 'upgrade' your USBasp firmware to try to get rid of this message - if you do, you will find that the USBasp is no longer able to flash your multiprotocol module.
If you get an error that indicates a valid microcontroller was not found there is something wrong with:
- your connections,
- your programmer, or
- your board