Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Cross Compiler with Make #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
*.swo


# Custom
# Custom

bin/
build/
.venv/
36 changes: 31 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ include mcu.mk
# Define result paths
BUILD_PATH := bin
OBJ_PATH := $(BUILD_PATH)/obj
BUILD_DIR := build

# Define cross compiler variables
CROSS_COMPILER_SRC := gcc-arm-none-eabi-5_4-2016q3
CROSS_COMPILER_BASE := $(CROSS_COMPILER_SRC)-20160926-linux
CROSS_COMPILER_TAR := $(CROSS_COMPILER_BASE).tar.bz2
CROSS_COMPILER_URL := "https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/$(CROSS_COMPILER_TAR)"
CROSS_COMPILER_TAR_BUILD := $(BUILD_DIR)/$(CROSS_COMPILER_TAR)
CROSS_COMPILER_SRC_BUILD := $(BUILD_DIR)/$(CROSS_COMPILER_SRC)
CC_PATH := $(CROSS_COMPILER_SRC_BUILD)/bin



# Define dependencies and targets
Expand Down Expand Up @@ -105,11 +116,7 @@ endif

# Make commands
.PHONY: all
all: $(CROSS_TARGET)

.PHONY: test
test: $(NTV_TEST_TARGET)
./$(NTV_TEST_TARGET)
all: hw_setup $(CROSS_TARGET)

.PHONY: help
help:
Expand All @@ -123,6 +130,25 @@ help:
$(E)"clean: Remove any files created by this Makefile"
$(E)

.PHONY: test
test: $(NTV_TEST_TARGET)
./$(NTV_TEST_TARGET)

.PHONY: hw_setup
hw_setup: $(CROSS_COMPILER_SRC_BUILD)

$(CROSS_COMPILER_SRC_BUILD): $(CROSS_COMPILER_TAR_BUILD)
cd $(BUILD_DIR) && tar -xjf $(CROSS_COMPILER_TAR)
# Ensure src build is newer than tar build
rm $(CROSS_COMPILER_SRC_BUILD)/flag
touch $(CROSS_COMPILER_SRC_BUILD)/flag

$(CROSS_COMPILER_TAR_BUILD): $(BUILD_DIR)
wget $(CROSS_COMPILER_URL) -O $(CROSS_COMPILER_TAR_BUILD)

$(BUILD_DIR):
$(Q)mkdir -p $@

.PHONY: flash
flash: $(CROSS_TARGET)
st-flash write $(CROSS_TARGET) 0x8000000
Expand Down