# VESC firmware [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Travis CI Status](https://travis-ci.com/vedderb/bldc.svg?branch=master)](https://travis-ci.com/vedderb/bldc) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/75e90ffbd46841a3a7be2a9f7a94c242)](https://www.codacy.com/app/vedderb/bldc?utm_source=github.com&utm_medium=referral&utm_content=vedderb/bldc&utm_campaign=Badge_Grade) [![Contributors](https://img.shields.io/github/contributors/vedderb/bldc.svg)](https://github.com/vedderb/bldc/graphs/contributors) [![Watchers](https://img.shields.io/github/watchers/vedderb/bldc.svg)](https://github.com/vedderb/bldc/watchers) [![Stars](https://img.shields.io/github/stars/vedderb/bldc.svg)](https://github.com/vedderb/bldc/stargazers) [![Forks](https://img.shields.io/github/forks/vedderb/bldc.svg)](https://github.com/vedderb/bldc/network/members) An open source motor controller firmware. This is the source code for the VESC DC/BLDC/FOC controller. Read more at [https://vesc-project.com/](https://vesc-project.com/) ## Supported boards All of them! Check the supported boards by typing `make` ``` [Firmware] fw - Build firmware for default target supported boards are: 100_250 100_250_no_limits 100_500... ``` There are also many other options that can be changed in [conf_general.h](conf_general.h). ## Prerequisites ### On Ubuntu (Linux)/macOS - Tools: `git`, `wget, and `make` - Additional Linux requirements: `libgl-dev` and `libxcb-xinerama0` - Helpful macOS tools: ```bash brew install stlink brew install openocd ``` ### On Windows - MS Visual Compiler - Chocolately: https://chocolatey.org/install - Powershell: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows - Git: https://git-scm.com/download/win. Make sure to click any boxes to add Git to your Environment (aka PATH) ## Install Dev environment and build ### On Ubuntu (Linux)/MacOS Open up a terminal 5. `git clone http://github.com/vedderb/bldc.git` 6. `cd bldc` 6. Continue with [On all platforms](#on-all-platforms) ### On Windows 3. Open up a Powershell terminal (Resist the urger to run Powershell as administrator, that will break things) 4. Type `choco install make` 5. `git clone http://github.com/vedderb/vesc_tool` 6. `cd bldc` 6. Unzip the file at https://discordapp.com/channels/904830990319485030/910181652192448532/917451210791989248 into this directory 6. Continue with [On all platforms](#on-all-platforms) ### On all platforms 7. `git checkout origin/master` 8. `make arm_sdk_install` 10. `make` <-- Pick out the name of your target device from the supported boards list. For instance, I have a Trampa **VESC 100/250**, so my target is `100_250` 11. `make 100_250` <-- This will build the **VESC 100/250** firmware and place it into the `bldc/builds/100_250/` directory ## Other tools **Linux Optional - Add udev rules to use the stlink v2 programmer without being root** ```bash wget vedder.se/Temp/49-stlinkv2.rules sudo mv 49-stlinkv2.rules /etc/udev/rules.d/ sudo udevadm trigger ``` ## IDE ### Prerequisites #### On macOS/Linux - `python3`, and `pip` #### On Windows - Python 3: https://www.python.org/downloads/. Make sure to click the box to add Python3 to your Environment. ### All platforms 1. `pip install aqtinstall` 9. `make qt_install` ## Upload to VESC ### Method 1 - Flash it using an STLink SWD debugger 1. Build and flash the [bootloader](https://github.com/vedderb/bldc-bootloader) first 2. Then `_flash` to the target of your choice. So for instance, for the VESC 100/250: ```bash make 100_250_flash ``` ### Method 2 - Upload Firmware via VESC tool through USB 1. Clone and build the firmware in **.bin** format as in the above Build instructions In VESC tool 2. Connect to the VESC 3. Navigate to the Firmware tab on the left side menu 4. Click on Custom file tab 5. Click on the folder icon to select the built firmware in .bin format (e.g. `build/100_250/100_250.bin`) ##### [ Reminder : It is normal to see VESC disconnects during the firmware upload process ] ##### **[ Warning : DO NOT DISCONNECT POWER/USB to VESC during the upload process, or you will risk bricking your VESC ]** ##### **[ Warning : ONLY DISCONNECT your VESC 10s after the upload loading bar completed and "FW Upload DONE" ]** 6. Press the upload firmware button (downward arrow) on the bottom right to start upload the selected firmware. 7. Wait for **10s** after the loading bar completed (Warning: unplug sooner will risk bricking your VESC) 8. The VESC will disconnect itself after new firmware is uploaded. ## In case you bricked your VESC you will need to upload a new working firmware to the VESC. However, to upload a firmware to a bricked VESC, you have to use a SWD Debugger. ## Contribute Head to the [forums](https://vesc-project.com/forum) to get involved and improve this project. Join the [Discord](https://discord.gg/JgvV5NwYts) for real-time support and chat ## License The software is released under the GNU General Public License version 3.0