1. Hardware tools flash firmware
    1. Open controller and solder programming header
  2. Tools build and flash firmware
    1. stm8-binutils-gdb
    2. How to erase and unlock protected read memory
  3. Firmware configuration tool
  4. Motor phases and hall sensor connections

Tools build and flash firmware



The next instructions were written by the developer Stancecoke on the page that he maintains.

A few steps are required to set up the software. But they should also be feasible for inexperienced computer users :-).

1. download and install Java Runtime Environment
Java runtime

2. download the SDCC archive, a 32 bit version is no longer available. Create a folder named "SDCC" directly at C:\ and extract the archive to this folder (use eg. Winrar for extracting) If you extract the files to a different path, you have to adapt the path information in the Start_Compiling.bat in the firmware folder of C#ROME-B, see next step.

3. download the Github repository and unpack it to the desiredlocation, in the simplest case directly to C: \
Flexible OpenSource EBike motor controller firmware


4. download and install ST Visual Development with the default settings. If the path to the file "STVP_CmdLine.exe" is different from "C:\Program Files (x86)\STMicroelectronics\st_toolset\stvp", you have to edit the first line of the "Start_Compiling.bat" and the"WriteOptionBytes.bat" according to your path (right click on the .bat-file -->edit) . To download the software you have to enter an e-mail address, to which the download link will be sent. This has not caused any unwanted advertising mails/newsletters for me.


Tools to build the firmware

To be able to build the firmware, you will need to install the SDCC C compiler (and other tools like OpenOCD that will let you flash and debug the firmware). Please start by installing stm8-binutils-gdb.

After having stm8-binutils-gdb installed, download (or git clone) the firmware sources from the github repository (see if you are interested to user other branch than master):

You many need to edit the Makefile on the sources folder, to point “CC=” to the path were you installed SDCC.

Testing (only if you want to test the build process)

To build the firmware, on the sources folder, do:
make -f Makefile_linux clean
make -f Makefile_linux

You will get main.bin firmware file that will be ready to be flashed.


Tools to flash the firmware

To install stm8flash, follow the next steps:
• download the stm8flash sources from original github repository:
• there is an executable stm8flash included on the sources but in case it does not work, you will need to build it from the sources - execute the standard “make”; “sudo make install” on the source folder, that will build stm8flash and you will then be able to execute it

Testing (only if you want to test the build process)

Before being able to flash, you will need to erase and unlock protected read memory.

To flash the firmware, you can use the following commands:
• stm8flash -c stlinkv2 -p stm8s105?6 -w main.bin

Example (flashing to STM8S003F3):