Skip to content
xvlvx0 edited this page Oct 20, 2019 · 31 revisions

Table of Contents

Various

See here technical notes about TSDZ2: https://opensourceebikefirmware.bitbucket.io/development_tsdz2

Development Software

On this wiki page the development software for the OpenSource-EBike-firmware is discribed. Although the examples are shown for OSX these steps are also applicable for other operating systems like Linux and Windows.

Step 1 - Install ARM toolchain

Download and install the GNU ARM toolchain from the website link. Move the package to a separate folder, I've put all my development tools in a folder in my HomeFolder called "Development". There you can unpack the package. Use your command line tool of choice to go to this folder and dive into the "bin" folder, run the command "arm-none-eabi-gcc --version". If this shows the below code then the toolchain is working.

$ bin/arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 8-2019-q3-update)
8.3.1 20190703 (release) [gcc-8-branch revision 273027]
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Step 2 - Install JDK

Download and install the most current version of jdk (Java Development Kit) from the Oracle website link.

Step 3 - Install Eclipse

Download and install Eclipse prepared for C/C++ development: "Eclipse IDE for C/C++ Developers" from the website link. After installing you can close Eclipse.

Step 4 - MCU communication

Eclipse Install GNU MCU tools

Start Eclipse and go to Help->Marketplace, wait for the marketplace to update.

Then type "GNU ARM" in the search field, the top result should show "GNU ARM Eclipse" press the install button. Wait for it to install, Eclipse will ask for a restart, you can do so.

When Eclipse is restarted close the welcome screen and click in the toolbar on the icon "Packs". In the new window click on the double arrow sync icon called "Update the packages definitions from all repositories". Wait for it to sync. Once the sync is completed you can find in the left pane in the tree the "STMicroelectronics" folder, unfold it and search for "STM32F1 Series". In the middle pane right click on the STM32F1xx file and click install. When the installation is done you can close the packs windows (on the right most icon right mouse click a choose close)

OSX - OpenOCD

...info...

Linux - OpenOCD

...info...

Windows - OpenOCD...

...info...

Step 5 - Eclipse Import project from Github

Open a browser and navigate to the github site and into the "OpenSource-EBike-firmware/Color_LCD" click on the clone/copy dropdown arrow and copy the "url".
Open Eclipse and click in the menu bar on "File" and navigate to "import". Search for the option "Git", unfold it and select "Projects from Git (with smart import)" click "Next". Select the option "Clone URL", click "Next". The URL is automatically pasted, if not, copy and paste it yourself. Click "Next". Select the "master" repository, click "Next". Change the location as you like and make sure the "master" branch is selected. Click "Next". Uncheck the "search for nested projects" and click "Finish".

Step 6 - Compile Code

Graphical with Eclipse

Once the project is added to Eclipse the project has to be converted to a C/C++ project. Right click on the project folder and select "New" and then "Convert to a C/C++ project", select the "Makefile project" and "ARM Cross GCC" and click "Finish"

Then go to the project properties:

There a few settings have to be set:

  1. "build tools"
  2. "make settings"
Set the build tools to the location of the "ARM toolchain" in 'Step 2'

Uncheck the "Use default build command" and add the command: "make all" in the box below. At the bottom make sure the path is set to the "firmware" path, this is where the Makefile lives.

Now go to "Project" in the toolbar and click "Build All", if everything is set correctly the project will build and the compile message will be shown in the console window.

Command Line (OSX and Linux)

You don't need to use Eclipse, you can use any text editor you like. After editing the code to your needs, just open a terminal and change directory to the "firmware" folder. There you run "make all". This will make the "main.bin" file. This file can then be flashed to the hardware.

If you receive an error that the arm tool chain can not be found:

user@pc:~/git/OpenSource-EBike-firmware/Color_LCD/firmware$ make all
# cd SW102; make
cd 850C/src; make clean; make
rm -f main.lst main.elf main.bin
rm ../../common/src/*.o
find *.o | xargs rm
find spl/src/*.o | xargs rm
find spl/CMSIS/*.o | xargs rm
.compiling
arm-none-eabi-gcc -I./GD32F10x_standard_peripheral/Include -I./ -I./spl/CMSIS -I./spl/CMSIS/inc -I./spl/inc -DUSE_FULL_ASSERT -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -c -fno-common -O0 -g -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections -l libgcc  -fno-builtin -std=c99 --specs=nano.specs --specs=nosys.specs -Wall -Werror -I../../common/include -DVERSION_STRING=\"0.19.17\" spl/CMSIS/system_stm32f10x.c -o spl/CMSIS/system_stm32f10x.o
make[1]: arm-none-eabi-gcc: No such file or directory
make[1]: *** [spl/CMSIS/system_stm32f10x.o] Error 1
make: *** [all] Error 2

This is caused by the "Makefile", in there the toolchain is expected to be in the firmware directory, this can be changed by editing the "Makefile", for the '850C LCD' search for this line in the "Makefile" of the '850C LCD' directory:

TCPREFIX = arm-none-eabi-
and change it to:
ARM_GCC = /path/to/your/arm-tool-chain/bin/
TCPREFIX = $(ARM_GCC)arm-none-eabi-

And for the 'SW102 LCD' the line:

GNU_INSTALL_ROOT := /path/to/the/toolchain/bin/
TCPREFIX  = $(ARM_GCC)arm-none-eabi-
in the Makefile.windows in the directory:"⁨./git⁩/OpenSource-EBike-firmware⁩/Color_LCD⁩/firmware⁩/SW102⁩/⁨nRF5_SDK_12.3.0⁩/⁨components⁩/toolchain⁩/gcc⁩" change it to reflect your GNU-ARM directory from Step 1.

On Windows

  1. Install the Small Device C Compiler (SDCC) (https://sourceforge.net/projects/sdcc/files/snapshot_builds/x86_64-w64-mingw32-setup) version 3.7 or 3.8 (NOTE: 3.9 has a bug which causes it to crash while building LCD3). Make sure to add it to your PATH (option in one of the last screens of the installer... )
  2. Git clone the project or download zip file: https://github.com/OpenSource-EBike-firmware/TSDZ2-Smart-EBike (make sure to get the master branch)
  3. Use any text editor to make the desired firmware changes.
  4. Double-click Start_Compiling.bat to compile the firmware. The resulting main.ihx can be programmed in the controller.

On Linux

The stm8 eforth project is developed on linux (https://github.com/TG9541/stm8ef/wiki/STM8S-Programming)

Step 7 - Flashing

Graphical with Eclipse

Command line

Clone this wiki locally