This repository is updated by mbrusa.
This fork is based on the TSDZ2-v0.20beta1 adapted for Tongsheng protocol displays, like stock VLCD5, VLCD6, XH18 or other displays with the same protocol and 6-pin Tonsheng connector, SW102, DZ41, 850C or 860C for TSDZ2. With these last displays, the visualization of data and errors must be checked..
Endless Sphere forum reference thread: endless-sphere.com..
See the wiki for instructions
This ebike motor controller firmware project is to be used with the Tongsheng TSDZ2 mid drive motor. Note: firmware can't be written to Enerdan sold TSDZ2 motors and controllers because they are equipped with V2 controller and XMC1300 microprocessor instead of STM8.
It has the following benefits compared to the stock firmware:
- The motor runs more efficient therefore it becomes more powerful and consumes less energy.
- The ebike will feel more responsive and agile.
- Using other supported displays and pheriperals will provide more functionality and features.
- Because this project is in heavy development more features will be added.
This project is being developed and maintained for free by a community of users. Some of them are developers who work professionally developing this type of technology for very well known companies.
- Install SDCC. version 4.1.0 or higher required.
- Install ST Visual Development.
- Install Java.
- Open JavaConfigurator.jar customize the parameters and click Compile & Flash
- Or use supplied .bat scripts, e.g.
src/compile_and_flash.bat
- With 32-bit Windows systems, replace the files in the \tools\cygwin\bin folder with those in the bin_32.zip file
- Install SDCC. version 4.1.0 or higher required.
- Install Stm8flash
git clone https://github.com/vdudouyt/stm8flash.git && cd stm8flash && make && sudo make install
- Install Java.
- Open JavaConfigurator.jar customize the parameters and click Compile & Flash
- And/Or use supplied shell script
compile_and_flash_20.sh
For more information, go to the wiki instructions.
- Clone this repository
- Install the SDCC compiler
- You can do
cd src & make -j4
, import elf into STMStdudio and plot global variables in real-time - Or use VScode and one of the debugging setups from
.vscode/launch.json
- on Windows, unpack stm8-gdb.exe binary to folder located in your system's PATH environment variable
- make sure OpenOCD 0.12 is installed
- install cpptools
- press F5 in VScode to build, flash, and debug (
STM8-gdb
profile)
Initialize virtual environment (optional)::
py -m venv .venv
Enable virtual environment or let VScode to do it automatically:
.venv\Scripts\activate
or source .venv\Scripts\activate
Install dependencies:
pip install .
Run tests:
pytest
Calculate coverage and generate html report (probably will not work on Windows):
pytest --coverage
cd src/
and usemake
orcompile.bat
to compile the firmware.
- Use
make flash
orflash.bat
to flash the firmware. - If you have Android with OTG you can transfer
main.hex
to your phone and use Stm8 updater app to flash thestm8s105s6
- For advanced flashing and option bytes managment use ST Visual Programmer STM8. You can use preconfigured project file from
tools/ST_Vision_Programming.stp
.
- VScode can be used for the development.
a) open project top folder as workspace
b) install extensions from recommended popup
c) configure Intellisense by going to Settings
ctrl+,
and specifying@id:C_Cpp.default.systemIncludePath
according to SDCC installation folder, e.g:C:\\Program Files\\SDCC\\include
d)Ctrl+Shift+b
to build the firmware
- Installing this firmware will void your warranty of the TSDZ2 mid drive.
- We are not responsible for any personal injuries or accidents caused by use of this firmware.
- There is no guarantee of safety using this firmware, please use it at your own risk.
- We advise you to consult the laws of your country and tailor the motor configuration accordingly.
- Please be aware of your surroundings and maintain a safe riding style.