Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ workspace.code-workspace
*.pro.shared

.vscode
.idea

compile_commands.json
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ sudo mv 49-stlinkv2.rules /etc/udev/rules.d/
sudo udevadm trigger
```

## IDE
## IDE(Qt Creator)
### Prerequisites
#### On macOS/Linux

Expand All @@ -96,6 +96,17 @@ sudo udevadm trigger
4. With Qt Creator, open the vesc firmware Qt Creator project, named vesc.pro. You will find it in `Project/Qt Creator/vesc.pro`
5. The IDE is configured by default to build 100_250 firmware, this can be changed in the bottom of the left panel, there you will find all hardware variants supported by VESC

## IDE(Visual Studio Code & CLion)

### On macOS/Linux

1. `brew install bear` or some other way to install [bear](https://github.com/rizsotto/Bear) on macOS/Linux.
2. Choose a target via `make`, for example `60_mk5`.
3. Make sure it will be a full build, otherwise you need to run `make fw_60_mk5_clean` first.
4. `CC=./tools/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-gcc bear --force-wrapper -- make fw_60_mk5`.
5. It will generate a `compile_commands.json` file in the root directory of the project.
6. See the IDE documentation to use the `compile_commands.json` file. For Visual Studio Code, see [here](https://code.visualstudio.com/docs/cpp/configure-intellisense#_project-level-intellisense-configuration). For CLion, just open the json file.

## Upload to VESC
### Method 1 - Flash it using an STLink SWD debugger

Expand Down
40 changes: 30 additions & 10 deletions make/fw.mk
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,39 @@ endif
MCU = cortex-m4

TRGT = $(TCHAIN_PREFIX)
#TRGT = /home/benjamin/Dokument/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-
CC = $(TRGT)gcc
CPPC = $(TRGT)g++
# if CC is set from environment, we try use it first
CC ?= $(TRGT)gcc

# check if the compiler is ARM GCC
CC_VERSION := $(shell $(CC) --version 2>/dev/null | head -n 1)
IS_ARM_GCC := $(findstring arm-none-eabi,$(CC_VERSION))

ifeq ($(strip $(IS_ARM_GCC)),)
# if not, we use the default toolchain
override CC = $(TRGT)gcc
# try detect again
CC_VERSION := $(shell $(CC) --version 2>/dev/null | head -n 1)
IS_ARM_GCC := $(findstring arm-none-eabi,$(CC_VERSION))

ifeq ($(strip $(IS_ARM_GCC)),)
$(error [ERROR] The selected compiler '$(CC)' is not an ARM GCC toolchain. Please give an ARM GCC to CC or run 'make arm_sdk_install'.)
endif
endif

$(info [INFO] Using ARM GCC : $(CC_VERSION))

# use other tools from the same toolchain
CPPC := $(patsubst %gcc,%g++,$(CC))
# Enable loading with g++ only if you need C++ runtime support.
# NOTE: You can use C++ even without C++ support if you are careful. C++
# runtime support makes code size explode.
LD = $(TRGT)gcc
#LD = $(TRGT)g++
CP = $(TRGT)objcopy
AS = $(TRGT)gcc -x assembler-with-cpp
AR = $(TRGT)ar
OD = $(TRGT)objdump
SZ = $(TRGT)size
LD := $(CC)
#LD := $(CPPC)
CP := $(patsubst %gcc,%objcopy,$(CC))
AS := $(CC) -x assembler-with-cpp
AR := $(patsubst %gcc,%ar,$(CC))
OD := $(patsubst %gcc,%objdump,$(CC))
SZ := $(patsubst %gcc,%size,$(CC))
HEX = $(CP) -O ihex
BIN = $(CP) -O binary

Expand Down