Update STM32 documentation for Boards Definition (#116)

Updating the compiling for STM32 documentation to take advantage of the boards definition.
This commit is contained in:
Ben Lye 2017-11-28 20:56:42 +00:00 committed by GitHub
parent cc83177542
commit 277402a25d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 282 additions and 110 deletions

View File

@ -1,32 +1,44 @@
# Arduino IDE board definition for Multi 4-in-1 transmitter module # Arduino IDE board definitions for Multi 4-in-1
At this point the only supported board/module is the Atmega328p-based module, the STM32-based module is not yet supported. Board definitions are available for both the Atmega328p and STM32F103C boards. The board definitions make it easier to compile and install the multiprotocol module firmware.
## Installing ## Installing
The board definition is installed using the Arduino IDE Boards Manager. The board definitions are installed using the Arduino IDE Boards Manager.
1. Open the Arduino IDE 1. Open the Arduino IDE
2. Go to File->Preferences (or Ctrl+Comma)
3. Locate the 'Aditional Boards Manager URLs' field and paste in this URL: https://raw.githubusercontent.com/pascallanger/DIY-Multiprotocol-TX-Module/master/BootLoaders/package_multi_4in1_board_index.json
4. Click OK to save the change
5. Click Tools->Board [Board Name]->Boards Manager
6. Scroll to the bottom of the list of boards and click on 'Multi 4-in-1 Boards' then click the Install button
7. Click Close to close the Boards Manager
## Selecting the board 2. Go to **File -> Preferences**, or press Ctrl+Comma
1. Click Tools->Board [Board Name]
2. Scroll down the list to 'Multi 4-in-1 Boards' and select 'Multi 4-in-1 (Atmega328p, 3.3V, 16MHz)'
## Choosing the bootloader 3. Locate the **Aditional Boards Manager URLs** field and paste in this URL: `https://raw.githubusercontent.com/pascallanger/DIY-Multiprotocol-TX-Module/master/BootLoaders/package_multi_4in1_board_index.json`
There are two bootloader options. The default 'No bootloader' won't install a bootloader, allowing the maximum space for protocols. The 'Flash from TX' option installs a small Optiboot bootloader which is compatible with Ersky9x and OpenTX option to flash firmware from the transmitter's maintenance menu.
1. Click Tools->Bootloader [Bootloader Option] **Note:** Multiple URLs are comma-separated.
2. Select the desired bootloader
**Recommended:** Click Tools->Burn Bootloader to set the fuses, even if the 'No bootloader' option was selected. <p align="center">
<img src="/docs/images/ide-prefs.jpg">
</p>
## Compiling / uploading firmware with the 'Flash from TX' bootloader 4. Click **OK** to save the change
1. Follow the normal compiling method.
2. Copy the compiled .hex file (usually Multiprotocol.ino.hex) in the "/firmware" directory of the SD card. 5. Click **Tools -> Board -> Boards Manager**
3. Start Ersky9x in "Maintenance Mode" by holding the horizontal trims APART while powering on the transmitter.
4. Select "Update Multi", then change "File Type" to "HEX", then select "Update", choose the firmware to flash, long pressto select it and long press to flash it. 6. Type **multi** into the search box to see the Multi 4-in-1 boards
5. When finished, long press EXIT to reboot in normal mode. <p align="center">
<img src="/docs/images/multi-boards.jpg">
</p>
7. Click on the board you require and click the **Install** button. Repeat for both boards, if required. If you are installing the STM32 board for the first time, and you have not installed any STM32 or SAMD boards before (such as Arduino Due or Zero) the dependency toolchain will also be downloaded and installed.
7. Click **Close** to close the Boards Manager
## Verify the boards are installed
1. Click **Tools -> Board**
2. Scroll down the list to the **Multi 4-in-1** board headings verify that the boards you installed are available:
* **Multi 4-in-1 (Atmega328p, 3.3V, 16MHz)** for the Atmega board
* **Multi 4-in-1 (STM32F103CB)** for the STM32 board
![Image of Yaktocat](/docs/images/boards-menu.jpg)
## Compiling and Uploading
Refer to the hardware-specific pages for information on compiling the firmware and uploading it to the multiprotocol module:
* [Compiling for Atmega](/docs/Compiling.md)
* [Compiling for STM32](/docs/Compiling_STM32.md)

View File

@ -1,124 +1,284 @@
# Compliling and Programming (STM32) # Compliling and Programming (STM32)
**If you are Compling for the Arduino ATmega328p version of the Multiprotocol Module please go to the dedicated [Compiling and Programming ATmega328](Compiling.md) page.** 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.
## IMPORTANT NOTE: **These instructions are for the STM32 version of the Multiprotocol module.** If you are Compling for the Arduino ATmega328p version of the Multiprotocol Module please go to the dedicated [ATmega328](Compiling.md) page.
Multiprotocol source can be compiled using the Arduino IDE using STM32 Core (Maple) and Arduino ARM-Cortex-M3 libraries.
On all modules with STM32F103 microcontroller, the program flash memory on the microcontroller is large enough to accommodate all the protocols. You do not have to make choices on which protocols to upload. Also, it is likely that you used the Banggood 4-in-1 RF module and you will therefore have access to all the RF modules.Now for programmng multimodule with STM32 chip you have 2 options presented below.
1. Compiling and flashing in Arduino IDE. ## Index
1. Flashing precompiled binaries from [here](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/releases) 1. [Tools Required](#tools-required)
- If using one of these TX with multimodule like Turnigy 9X,9XR,9X+ the binary file for flashing is **Multiprotocol_V1.X.X_STM32.bin**. 1. [Preparation](#preparation)
- If using TARANIS TX the binary file is **Multiprotocol_V1.X.X_STM32_INV.bin** 1. [Install the Arduino IDE](#install-the-arduino-ide)
1. [Download the Multiprotocol source and open the project](#download-the-multiprotocol-source-and-open-the-project)
1. [Install the Multi 4-in-1 board](#install-the-multi-4-in-1-board)
1. [Configure the Arduino IDE](#configure-the-arduino-ide)
1. [Configure the firmware](#configure-the-firmware)
1. [Verify the firmware](#verify-the-firmware)
1. [Preparing to upload the firmware](#preparing-to-upload-the-firmware)
1. [Connect the programmer](#connect-the-programmer)
1. [Select an upload method](#select-an-upload-method)
1. [Burn bootloader](#burn-bootloader)
1. [Uploading the firmware](#uploading-the-firmware)
1. [Flash from TX](#flash-from-tx)
1. [Upload via USB](#upload-via-usb)
1. [Install the Maple USB Drivers](#install-the-maple-usb-drivers)
1. [Upload the firmware via USB](#upload-the-firmware-via-usb)
1. [Upload via Serial](#upload-via-serial)
1. [Precompiled Binaries](#flashing-pre-compiled-binaries)
1. [Troubleshooting](#troubleshooting)
Flashing precompiled **binaries** is done very simple with the cable setup presented below and an utility(GUI) **ST Flash Loader Demonstrator.** ## Tools required
## Compiling source and flashing in Arduino. | **3.3V USB-TTL Adapter** | **4-pin Serial Programming Header** |
|:---:|:--:|
| <img src="images/FTDI_Adapter.jpeg" width="200" height="200"/> | <img src="images/4-pin-header.jpg" width="150" height="150"/>
| [(example ebay link)](https://www.ebay.co.uk/itm/FTDI-USB-to-TTL-Serial-Converter-Adapter-FT232RL-Module-5V-and-3-3V-Arduino-ARM/231918152528) | [(example ebay link)](https://www.ebay.co.uk/itm/4x-826629-4-Pin-header-pin-strips-AMPMODU-MOD-II-male-PIN4-straight/192334571714) |
### Install the Arduino IDE and the Multiprotocol project The USB-TTL adapter can be either FTDI or CH340G, as long as it works. It should have a switch or jumper to select 3.3V or 5V, which **must** be set to **3.3V**.
1. Download the Arduino IDE. The currently supported Arduino version is 1.6.11 available for [Windows]( https://www.arduino.cc/download_handler.php?f=/arduino-1.6.12-windows.exe) and [Mac OSX](http://arduino.cc/download_handler.php?f=/arduino-1.6.12-macosx.zip)
The 4-pin header needs to be soldered onto the board as indicated by the red rectangle:
| **DIY Multiprotocol Module** | **Banggood 4-in-1 Module** | **iRangeX IRX4 Plus Module** |
|:---:|:---:|:---:|
| <img src="images/Board_PCB_STM32_with_serial.jpg" width="142" height="200"/> | <img src="images/bg-multi-stm32-serial.jpg" width="195" height="200"/> | <img src="images/irx4plus-serial.jpg" width="164" height="200"/> |
**Note:** The Banggood STM32 module most likely already has the header pin in place.
## Preparation
### Install the Arduino IDE
1. Download and install the Arduino IDE. The currently supported Arduino version is 1.8.5, available for [Windows]( https://www.arduino.cc/download_handler.php?f=/arduino-1.8.5-windows.exe) and [Mac OSX](https://www.arduino.cc/download_handler.php?f=/arduino-1.8.5-macosx.zip)
1. It is recommended to upgrade Java to the [latest version](https://www.java.com/en/download/) 1. It is recommended to upgrade Java to the [latest version](https://www.java.com/en/download/)
1. Download the [STM32 Core](https://github.com/rogerclarkmelbourne/Arduino_STM32/archive/master.zip) and copy the Arduino_STM32 folder to:
- OSX: ```Arduino.app/Contents/Java/hardware``` (you can open Arduino.app by Ctl Clicking on Arduino.app and selecting "Show Package Contents")
- Windows: ```C:\Program Files (x86)\Arduino\hardware```
- Make sure the folder tree structure is like this .....\hardware\Arduino_STM32\.....and **NOT** ...... \hardware\Arduino_STM32-master\Arduino_STM32-master\......So move the folders /rename accordingly.
1. Download the zip file with the Multiprotocol module source code from [here](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)
1. Unzip and copy the source code folder ```Multiprotocol``` to a folder of your choosing
1. Click on the ```Multiprotocol.ino file``` in the ```Multiprotocol``` folder and the Arduino environment should appear and the Multiprotocol project will be loaded.
### Prepare the Arduino IDE: ### Download the Multiprotocol source and open the project
1. Either
1. Download the zip file with the Multiprotocol module source code from [here](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/archive/master.zip) and unzip and copy the source code folder **Multiprotocol** to a location of your choosing, or
1. Clone the project using Git or Github Desktop, then
1. Double-click the **Multiprotocol.ino** file in the **Multiprotocol** folder to open the project in the Arduino IDE
1. In order to compile successfully you need also to modify a maple library file. In ```....\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple\usart_f1.c``` comment out the 2 functions as shown below. This is required to have low-level access to the USART interrupt. <br> ### Install the Multi 4-in-1 board
``` 1. Follow [these instructions](/BootLoaders/README.md) to install the **Multi 4-in-1 STM32 Board** in the Arduino IDE
//void __irq_usart2(void) {
// usart_irq(&usart2_rb, &usart2_wb, USART2_BASE);
//}
//void __irq_usart3(void) { ### Configure the Arduino IDE
// usart_irq(&usart3_rb, &usart3_wb, USART3_BASE); 1. Under **Tools -> Board** select **Multi 4-in-1 (STM32FC103)**
//} 1. Under **Tools -> Programmer** select **stm32flash (FTDI)**
```
1. Run the IDE, and on the **Tools** menu, select **Board** and then **Boards manager**. <br> Click on the Arduino DUE (32 Bits ARM-Cortex M3) from the list of available boards. You must do this step, it installs the arm-none-eabi-g++ toolchain!
1. Close and reopen the Arduino IDE and load the Multiprotocol project.
1. In arduino IDE under the **Tools** -> **Board:** select the **Generic STM32F103C series** board
1. Click on the **Verify** button to test compile the before you make any changes. <br> If there are any errors check the process above and be sure to have the right version of the Arduino IDE.The binary file generated location is presented at the bottom of Arduino IDE compiling window.Now continue with flashing procedure.
## Configure the firmware
The STM32 module has more than enough flash space for all the available protocols so, unlike the Atmega328p-based module, it is not necessary to disable unused protocols.
### Flashing the multimodule You can still disable protocols if you wish, and you may also enable or disable other optional Multiprotocol features.
## Verify the firmware
To check that the program will compile correctly and fit in the Atmega click **Sketch -> Verify/Compile**, or press **Ctrl+R**.
There are three options for flashing the firmware. But We will present here only 3 methods ,the 4-th one is presented in advanced topics. If there are errors, carefully read it, go to the line number indicated and correct your typo.
The first (and strongly recommended) is flashing it while it is plugged into and powered by the transmitter.The second is preparing the board for flashing with a USB cable.
The second method is definitely the easiest in the long-term, but it does require the USB bord and setting up the bootloader on the STM32 MCU.
The third method is also highly recommended and involving flashing using TX (firmware).At this methid is available for 9X ,9X pro ,Taranis with ersky9X fimrware.
#### Option 1: Flashing with Tx power(highly recommended) If there are no errors and you see output like this:
```
Sketch uses 68564 bytes (52%) of program storage space. Maximum is 131072 bytes.
Global variables use 4064 bytes (19%) of dynamic memory, leaving 16416 bytes for local variables. Maximum is 20480 bytes.
```
You can proceed to the next step.
1. Put the module in the Tx ## Preparing to upload the firmware
1. Place a jumper over the BOOT0 pins.Skip this one if you made your own cable for flashing ,see below. If you have already burned the bootloader, and are simply recompiling firmware to re-flash using your TX or USB cable, you can skip this step and go straight to [Flash from TX](#flash-from-tx) or [Upload via USB](#upload-via-usb).
1. Connect your 3.3V/5V FTDI cable (USB - TTL serial) to Multiprotocol serial port. <br> Connect only RX, TX and GND. **Do not connect the 5V or 3.3V between the FTDI cable and the module - the power will be supplied by the transmitter**. Connect the pins as follows:
- Module RX pin to FTDI TX pin
- Module TX pin to FTDI Rx pin
- Module GND to FTDI GND
1. In arduino IDE under the **Tools** -> **Board:** check that you have selected the **Generic STM32F103C series** board
1. Under **Tools** -> **Upload Method:** select **Serial**
1. Click "Upload" and the sketch will be uploaded normally. This is valid for all arduino versions.
1. Once the firmware has uploaded, remove the BOOT0 jumper.
If you have the module inside a box and to be inserted in TX bay, you may build a flashing cable like in the picture below. ### Select an Upload Method
You can attach and solder a 5 pin header female and top outside the box.**ALways insert first the USB serial device in USB port , and TX start after.** There are three methods to upload firmware to an STM32 module:
* **Flash from TX** - highly recommended, uses maintenance mode in radios running ersky9x to upload the firmware
* **Upload via USB** - uses the USB port on the module
* **Upload via Serial (FTDI)** - uses the serial interface on the module via a USB-to-TTL adapter
<img src="images/Multi_STM32_ flashing.jpg" /> **Note:** 'Flash from TX' is only available with radios running ersky9x r221e2 or newer
See below my module for reference **Flash from TX** is highly recommended if your transmitter supports it, **Upload via USB** is recommended for all others. **Upload via Serial** can be used if your module does not have a working USB port and your trasmitter does not run ersky9x.
<img src="images/Multi_STM32 module.JPG" width="600" height="400" /> 1. Under **Tools -> Upload Method** select an upload method
#### Option 2: Flashing with USB cable. The rest of this process will vary depending on the upload method you selected.
This method use USB connector on the STM32 V1.0 board or on the maple clone board. ### Connect the programmer
1. Install first maple USB driver by running the batch file found in Arduino STM32 package folder ```..\hardware\Arduino_STM32\drivers\win\install_drivers.bat``` It is **strongly** recommended that you power your module from the transmitter when flashing it. This ensures that the module cannot be inadvertently supplied with 5V, which will damage the RF modules. This guide assumes that you will follow that advice, and instructs you to leave the V+ pin on the USB-to-TTL adapter disconnected. You may choose to ignore that advice at your own risk!
1. Download the free STM32 flash loader demonstrator from [ST.com](http://www.st.com/en/development-tools/flasher-stm32.html) and use a USB-TTL device (like FTDI cable) to flash the [StmMultiUSB.bin](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/raw/master/BootLoaders/StmMultiUSB/StmMultiUSB.bin) bootloader.
1. Open Arduino IDE,browse to multiprotocol folder,load the sketch multiprotocol.ino.Select the serial COM port(see notes below)
1. In Arduino IDE under "Upload method" select **STM32duino**-bootloader.Click upload ,wait until upload is complete.
Notes: 1. Put the module in the transmitter
- When you use multiSTM32_USB for the first time,the USB drivers are not recognized and com port is not open/recognized(arduino IDE port selection is grey/unavailable). After this first time use, any subsequent update of the program, you'll have to select the correct serial port and upload sketches normally in Arduino using USB port. 1. Connect the USB-to-TTL adapter to the module's 4-pin serial header as follows:
- More explanations how all these work you find [here](http://www.stm32duino.com/viewtopic.php?f=32&t=1774_) - USB-to-TTL TX pin <-> Module RX pin
- If the initial upload fails, make sure you are running the latest [Java version](https://www.java.com/en/download/) - USB-to-TTL RX pin <-> Module TX pin
- If using Banggood multiSTM32_USB module, follow instructions from step1(USB drivers on your computer) and jump after, to step 3(most probably generic bootloader is installed on multi module and no need to be installed again).I don't have one for test so this is an educated guess. - USB-to-TTL GND pin <-> Module GND pin
1. Plug the USB-to-TTL adapter into the PC
1. In the Arduino IDE click **Tools -> Port** and choose the COM port which matches the USB-to-TTL adapter
### Burn the bootloader
If you are using **Upload via Serial** you can skip this step and proceed to [Upload via Serial](#upload-via-serial).
#### Option 3: Flashing with TX radio(firmware) If you have selected either **Flash from TX** or **Upload via USB** the module will need to install the appropriate bootloader. The bootloader only needs to be installed once unless you decide to switch from one upload method to the other.
1. Flash new STM32 bootloader(StmMultiBoot) on multimodule:
- Flash precompiled binary [**StmMuliBoot.bin**](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/raw/master/BootLoaders/StmMultiBoot/StmMultiBoot.bin) using **ST Flash loader demonstrator** and USB serial device(FTDI) , with same custom cable presented above.This process is the same as flashing with precompiled binaries.For BG(green) module you can folow the paper instructions for flashing coming with the module using bridge pins provided.
- After this process is complete switch off TX,remove cables FTDI serila device and/or mutimodule jumper used for flashing.The multimodule should be back in the same state as before.
1. Compile multiprotocol source in arduino IDE ,choose this time Upload method **STM32duino bootloader** ,select **"Export compiled Binary"** to show the binary file in the same folder as source. In order to flash the bootloader the **BOOT0** jumper must be installed.
1. Copy the resulted binary file to the TX radio SD card in the "/firmware" folder.
1. Now flash the TX radio with the latest firmware(for ersky9x it's version P221 "e2" test version or higher).
1. Enter in TX radio maintenance mode (for ersky9X, start the transmitter with both bottom trims pushed outwards). Select **Update Multi** press menu button select also the right com port,update ,then the multiprotocol.bin file (see the correct name) and press menu and again for flashing. You'll see a bar fill slowly .Wait for the procces to be complete.Press exit( or switch off TX) several times to come out of the maintenace mode.
1. Any subsequent update of the multiprotocol will follow 2-3 and 5-6 steps. There is no need anymore to use a USB serial device or cables for flashing.
## Flashing precompiled binaries: 1. Install the **BOOT0** jumper
1. Switch on the transmitter
1. Verify that you have selected the correct upload method under **Tools -> Upload Method**
1. Verify that you have selected **stm32flash (FTDI)** as the programmer under **Tools -> Programmer**
1. Verify that the USB-to-TTL adapter is correctly connected to your module
1. Click on **Tools -> Burn Bootloader**
If you want to flash a pre-compiled binary file (like the Release .bin files) you need specialized software and the same FTDI cable setup already posted [here](Compiling_STM32.md#option-1-flashing-with-tx-powerhighly-recommended). Output will look similar to this:
```
C:\Users\blye\AppData\Local\Arduino15\packages\multi4in1\hardware\STM32F1\1.0.0/tools/win/serial_upload.bat COM4 0x0 C:\Users\blye\AppData\Local\Arduino15\packages\multi4in1\hardware\STM32F1\1.0.0/bootloaders/Multi4in1/StmMultiUSB.bin
stm32flash -v -g 0x0 -b 57600 -w C:\Users\blye\AppData\Local\Arduino15\packages\multi4in1\hardware\STM32F1\1.0.0\bootloaders\Multi4in1\StmMultiUSB.bin COM4
1. Set BOOT0 jumper(skip this step if you aready made your own cable ,see above) stm32flash 0.4
1. Connect your 3.3V FTDI cable (USB - TTL serial) to Multiprotocol serial port (RX,TX,GND pins when flashing with TX power).
1. Insert first FTDI serial to USB port.Start TX (only if using flashing with TX power method)
1. The other steps regarding power supply the same as previous recommandation regarding jumpers
For uploading binaries(.bin files) there is a specialized software you need to install on your computer. http://stm32flash.googlecode.com/
#### Windows: Using Parser : Raw BINARY
Download the **ST Flash Loader Demonstrator** from here: http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-programmers/flasher-stm32.html Interface serial_w32: 57600 8E1
Version : 0x22
Option 1 : 0x00
Option 2 : 0x00
Device ID : 0x0410 (Medium-density)
- RAM : 20KiB (512b reserved by bootloader)
- Flash : 128KiB (sector size: 4x1024)
- Option RAM : 16b
- System RAM : 2KiB
Write to memory
Erasing memory
Run the ST Flash Loader program. There are many tutorials on the web on how to use this program.For example: [here](http://www.scienceprog.com/flashing-programs-to-stm32-embedded-bootloader) Wrote and verified address 0x08000100 (3.56%)
Wrote and verified address 0x08000200 (7.13%)
...
Wrote and verified address 0x08001c00 (99.78%)
Wrote and verified address 0x08001c10 (100.00%) Done.
#### OSX: Starting execution at address 0x08000000... done.
To be checked. ```
Assuming the process is successful:
1. Power off the transmitter
1. Remove the **BOOT0** jumper
1. Disconnect the USB-to-TTL adapter now
### Report issues for the STM32 board ## Uploading the firmare
Follow the instructions which apply to the **Upload method** you previously selected.
* [Flash from TX](#flash-from-tx)
* [Upload via USB](#upload-via-usb)
* [Upload via Serial](#upload-via-serial)
## Flash from TX
1. Click **Sketch -> Export compiled Binary**, or press **Ctrl+Alt+S**
1. Locate the file named **multifw.bin** in the **Multiprotocol** folder
1. Follow the instructions [here](/docs/Flash_from_Tx.md) to upload the firmware using your radio
## Upload via USB
The **Upload via USB** bootloader enables your PC to detect the Multiprotocol module as a **Maple DFU** device. It will not be detected as a USB serial device until the firmware is uploaded to it, when it will be detected as a **Maple Serial** device.
In order for these devices to be correctly identified in Windows it is necessary to install drivers. This only needs to be done once.
### Install the Maple USB drivers
##### Windows 7 or newer:
1. Open the folder where you unzipped or cloned the Multiprotocol project
1. Browse to **\BootLoaders\Boards\stm32\drivers**
1. Run **install-drivers.bat**
1. Follow the prompts to install the two drivers
##### Windows XP or older
1. Download and install the legacy Windows XP drivers from [here](https://github.com/rogerclarkmelbourne/Arduino_STM32/tree/master/drivers/win/win_xp_legacy)
### Upload the firmware via USB
**Note:** Power to the module will be supplied via the USB cable. If the module is installed in a transmitter, the trasnmitter should be switched off.
1. Connect the USB cable to the Multiprotocol module
1. Verify that a Maple device appears in Device Manager (**Maple DFU** for a module with only a bootloader, **Maple Serial** for a module with a bootloader and firmware)
1. In the Arduino IDE click **Sketch -> Upload**, or press **Ctrl+U**
You should see output similar to this:
```
Sketch uses 68564 bytes (52%) of program storage space. Maximum is 131072 bytes.
Global variables use 4064 bytes (19%) of dynamic memory, leaving 16416 bytes for local variables. Maximum is 20480 bytes.
C:\Users\blye\AppData\Local\Arduino15\packages\multi4in1\hardware\STM32F1\1.0.0/tools/win/maple_upload.bat COM4 2 1EAF:0003 C:\Users\blye\AppData\Local\Temp\arduino_build_933551/Multiprotocol.ino.bin
maple_loader v0.1
Resetting to bootloader via DTR pulse
Reset via USB Serial Failed! Did you select the right serial port?
Searching for DFU device [1EAF:0003]...
Assuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...
Found it!
Opening USB Device 0x1eaf:0x0003...
Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=2, name="STM32duino bootloader v1.0 Upload to Flash 0x8002000"
Setting Configuration 1...
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
bytes_per_hash=1371
Starting download: [##################################################] finished!
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
error resetting after download: usb_reset: could not reset device, win error: The system cannot find the file specified.
```
**Note:** The line `Reset via USB Serial Failed! Did you select the right serial port?` is expected because the uploader initially looks for a Maple Serial device, which isn't yet available, before failing back to Maple DFU. The final line warning, stating that the device could not be reset, is also expected.
For subsequent firmware uploads you need only repeat steps 1-3 above, ensuring that you first select the correct COM port, which should be labelled **COMx (Multi 4-in-1 (STM32F103CB))**.
<p align="center"><img src="images/maple-serial-port-select.jpg"/></p>
If the module is installed in a transmitter, disconnect the USB cable before powering on the transmitter.
## Upload via Serial
Upload via Serial follows the same process as burning the bootloader and uses the same USB-to-TTL adapter.
1. Ensure you USB-to-TTL adapter is connected as described in [Connect the programmer](#connect-the-programmer)
1. Install the **BOOT0** jumper
1. Turn on the transmitter
1. Click **Sketch -> Upload**
You should see output similar to this:
```
Sketch uses 62772 bytes (47%) of program storage space. Maximum is 131072 bytes.
Global variables use 3216 bytes (15%) of dynamic memory, leaving 17264 bytes for local variables. Maximum is 20480 bytes.
C:\Users\blye\AppData\Local\Arduino15\packages\multi4in1\hardware\STM32F1\1.0.0/tools/win/serial_upload.bat COM4 0x8000000 C:\Users\blye\AppData\Local\Temp\arduino_build_868436/Multiprotocol.ino.bin
stm32flash -v -g 0x8000000 -b 57600 -w C:\Users\blye\AppData\Local\Temp\arduino_build_868436\Multiprotocol.ino.bin COM4
stm32flash 0.4
http://stm32flash.googlecode.com/
Using Parser : Raw BINARY
Interface serial_w32: 57600 8E1
Version : 0x22
Option 1 : 0x00
Option 2 : 0x00
Device ID : 0x0410 (Medium-density)
- RAM : 20KiB (512b reserved by bootloader)
- Flash : 128KiB (sector size: 4x1024)
- Option RAM : 16b
- System RAM : 2KiB
Write to memory
Erasing memory
Wrote and verified address 0x08000100 (0.41%)
Wrote and verified address 0x08000200 (0.82%)
...
Wrote and verified address 0x0800f500 (99.92%)
Wrote and verified address 0x0800f534 (100.00%) Done.
Starting execution at address 0x08000000... done.
```
Once the firmware has uploaded, remove the **BOOT0** jumper and disconnect the USB-to-TTL adapter.
## Flashing pre-compiled binaries
Pre-compiled binaries are availale [here](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/releases).
- **Multiprotocol_V1.X.X_STM32.bin** files are for transmitters with support for hardware telemetry inversion, such as Turnigy 9X, 9XR, 9X+.
- **Multiprotocol_V1.X.X_STM32_INV.bin** files are for tranismitters which require telemetry inverted in the module firmware, such as Taranis.
If you want to flash a pre-compiled binary file (like the Release .bin files) you will use the same USB-to-TTL adapter as [above](#connect-the-programmer).
You will also need to download the **ST Flash Loader Demonstrator** from [here](http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-programmers/flasher-stm32.html)
Run the **ST Flash Loader Demonstrator** program. There are many tutorials on the web on how to use this program, for example [here](http://www.scienceprog.com/flashing-programs-to-stm32-embedded-bootloader).
## Troubleshooting
You can report your problem using the [GitHub issue](https://github.com/midelic/DIY-Multiprotocol-TX-Module/issues) system or go to the [Main thread on RCGROUPS](http://www.rcgroups.com/forums/showthread.php?t=2165676) to ask your question. You can report your problem using the [GitHub issue](https://github.com/midelic/DIY-Multiprotocol-TX-Module/issues) system or go to the [Main thread on RCGROUPS](http://www.rcgroups.com/forums/showthread.php?t=2165676) to ask your question.
Please provide the following information: Please provide the following information:

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

BIN
docs/images/ch340g.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
docs/images/maple-dfu.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB