-
Notifications
You must be signed in to change notification settings - Fork 34
OS X and Linux installation
NBrouard edited this page on 14 Feb · 2 revisions
You have to buy a STLink-V2 or clone, to flash the firmware to the motor. See the main wiki page on how to wire the STLink to the motor connector. Keep the wires from the STLink V2 to the 6-pin male connector (speed sensor) as short as possible. If you a longer distance from your computer to the bike, use an USB extension cable (it can be very very long).
A few steps are required to set up the software on a Unix computer with some differences between OS/X and Linux. But they should also be feasible for inexperienced computer users :-).
-
Java is usually installed on Linux and OS/X
-
Installed SDCC either using homebrew on OS/X (brew install sdcc) or from the sources. SDCC (a Small Device C Compiler) is required to compile all ".c" files from the "src/controller" directory and to link the output ".rel" files into a "main.ihx" file. This is the unique file which will be flashed to the motor controller. No need to flash the stock LCD monitor (VLCD5, VLCD6, XH18).
-
Instead of ST Visual Development which is available only on Windows, install stm8flash. It is currently not on homebrew but easy to install with the standard procedure (./configure && make && sudo make install).
-
download or clone the Github repository in some chosen directory. Copy the shell scripts compile_20.sh, edit_advanced.sh which have been adapted from the Windows .bat scripts (to be upload on github (13February 2020). You will find the source of the JavaConfigurator in the sub-directory ./tools/Java_Configurator_Source. It should be patched to run on Unix (and will work on Windows too) (not done yet).
-
Before sending your new firmware to the TSDZ2 controller, you might be interested in testing your STMLINK-V2 connection and wiring cable with your TSDZ2 motor. The idea is to transfer the original firmware and save it on your hard disk. The battery should be disconnected. On a Terminal window, go to the src/controller directory and type the command: 'stm8flash -c stlinkv2 -p stm8s105?6 -r TSDZ_orig.bin'. It takes a few seconds to be flashed. If it works, you can restore back the original firmware with the command 'stm8flash -c stlinkv2 -p stm8s105?6 -w TSDZ_orig.bin' (a simple '-w' instead of '-r'). I DON'T KNOW IF BY RESTORING THE ORIGINAL FIRMWARE YOU BROKE THE WARRANTY! If you want to backup all three firmwares, Option, Data and Eeprom, just do 'make backupall' and 'make restoreall'. You may have an error for the eeprom (too many tries) but it doesn't matter.
-
Now, you know that the transfer between your computer and the motor controller is working. You can now play with configurator and build a new firmware. On the root directory of the locally cloned repository, you can find the file JavaConfigurator.jar and either double-click on it or use the standard command line (java -jar JavaConfigurator.jar &) . You MUST adjust the settings which correspond to your TSDZ2 motor, voltage, maximum speed (limited to 25km/h in a city of the EU) etc. The Compile & Flash button will do three different things. It will create a (1) config.h file, (2) compile and create a main.ihx file and (3) flash the main.ihx to your motor controller. If your java configurator has not been patched to work on OS/X and Linux, only steps (1) and (2) will be done by clicking on the Compile & flash button of the configurator and you will get errors from the useless Windows .bat scripts. But it doesn't matter, just type 'make flash' or 'stm8flash -c stlinkv2 -p stm8s105?6 -w main.ihx' and it will flash the new 'main.ihx'
Determine FLASH area Due to its file extension (or lack thereof), "main.ihx" is considered as INTEL HEX format! 29380 bytes at 0x8000... OK Bytes written: 29380
The advantage of the configurator is that you can simply click on the list items on the right to restore former settings. If your cloned repository has been patched for OS/X and Linux, the third step will work. And, in order to mimic the process on a Windows computer, the compile_20.sh procedure opens a Terminal using either the Terminal App on OS/X or the gnome-terminal on Linux. If the process doesn't work look at the tmp/tmp-${DATE}.sh script and change it for your terminal command app (there are many on Linux).
-
To edit the advanced settings, click on the advanced settings button, do the necessary changes in the texteditor, save your changes, then click Compile & Flash to bring the changes to your bike (the advanced.h include file will be changed). Hopefully someone adds the advanced settings to the GUI, some day ;-)
-
Optional for brave people who want to add more features themselves, the development is done under a special version of Eclipse, see [https://opensourceebikefirmware.bitbucket.io/FLEXIBLE_OPENSOURCE_FIRMWARE.html](Casainho development site). You also need to install OpenOCD software to debug.
For detailed information read the manuals in the manuals folder.
Forum discussions:
French: Programmation du contrôleur Moteur Tongsheng TSDZ2
German
English
Italian
Spanish