-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move distribution script here, update Readme
- Loading branch information
Showing
3 changed files
with
234 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
# Special Makefile for re-linking LGPL libraries | ||
|
||
TARGET_BIN=$(TARGET).bin | ||
TARGET_ELF=$(TARGET).elf | ||
|
||
# If you have the arm-none-eabi- toolchain located in a particular place, but not installed for the entire system, add the path here: | ||
# GCC_PATH= | ||
|
||
# Build path | ||
BUILD_DIR = build | ||
RESOURCE_DIR = resource | ||
|
||
####################################### | ||
# binaries | ||
####################################### | ||
PREFIX = arm-none-eabi- | ||
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) | ||
# either it can be added to the PATH environment variable. | ||
ifdef GCC_PATH | ||
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp | ||
CP = $(GCC_PATH)/$(PREFIX)objcopy | ||
else | ||
CXX = $(PREFIX)g++ | ||
CP = $(PREFIX)objcopy | ||
endif | ||
HEX = $(CP) -O ihex | ||
BIN = $(CP) -O binary -S | ||
|
||
####################################### | ||
# CFLAGS | ||
####################################### | ||
# cpu | ||
CPU = -mcpu=cortex-m7 | ||
|
||
# fpu | ||
FPU = -mfpu=fpv5-d16 | ||
|
||
# float-abi | ||
FLOAT-ABI = -mfloat-abi=hard | ||
|
||
# mcu | ||
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) | ||
|
||
####################################### | ||
# Boot Management | ||
####################################### | ||
|
||
INTERNAL_ADDRESS = 0x08000000 | ||
QSPI_ADDRESS ?= 0x90040000 | ||
|
||
# For the time being, we'll keep the Daisy Bootloader's PID as df11 | ||
# DAISY_PID = a360 | ||
DAISY_PID = df11 | ||
STM_PID = df11 | ||
|
||
BOOT_BIN ?= $(wildcard $(RESOURCE_DIR)/dsy_bootloader*) | ||
APP_TYPE ?= BOOT_NONE | ||
|
||
ifeq ($(APP_TYPE), BOOT_NONE) | ||
|
||
LDSCRIPT ?= $(RESOURCE_DIR)/STM32H750IB_flash.lds | ||
USBPID = $(STM_PID) | ||
FLASH_ADDRESS ?= $(INTERNAL_ADDRESS) | ||
|
||
else ifeq ($(APP_TYPE), BOOT_SRAM) | ||
|
||
LDSCRIPT ?= $(RESOURCE_DIR)/STM32H750IB_sram.lds | ||
USBPID = $(DAISY_PID) | ||
FLASH_ADDRESS ?= $(QSPI_ADDRESS) | ||
C_DEFS += -DBOOT_APP | ||
|
||
else ifeq ($(APP_TYPE), BOOT_QSPI) | ||
|
||
LDSCRIPT ?= $(RESOURCE_DIR)/STM32H750IB_qspi.lds | ||
USBPID = $(DAISY_PID) | ||
FLASH_ADDRESS ?= $(QSPI_ADDRESS) | ||
C_DEFS += -DBOOT_APP | ||
|
||
else | ||
|
||
$(error Unkown app type "$(APP_TYPE)") | ||
|
||
endif | ||
|
||
####################################### | ||
# LDFLAGS | ||
####################################### | ||
# libraries | ||
LIBS += -ldaisy -lc -lm -lnosys | ||
LIBDIR += -L $(RESOURCE_DIR) | ||
#LIBDIR = -L./VisualGDB/Release | ||
|
||
LIBS += -ldaisysp | ||
LIBDIR += -L $(RESOURCE_DIR) | ||
|
||
LIBS += -ldaisysp-lgpl | ||
LIBDIR += -L $(RESOURCE_DIR) | ||
|
||
LDFLAGS ?= | ||
LDFLAGS += $(MCU) --specs=nano.specs --specs=nosys.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(RESOURCE_DIR)/$(TARGET).map,--cref -Wl,--gc-sections -Wl,--print-memory-usage | ||
|
||
# default action: build all | ||
all: $(BUILD_DIR) $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin | ||
|
||
####################################### | ||
# build the application | ||
####################################### | ||
|
||
OBJECTS = $(wildcard $(RESOURCE_DIR)/*.o) | ||
|
||
$(BUILD_DIR)/$(TARGET).elf: Makefile | ||
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@ | ||
|
||
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) | ||
$(HEX) $< $@ | ||
|
||
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) | ||
$(BIN) $< $@ | ||
|
||
$(BUILD_DIR): | ||
mkdir $@ | ||
|
||
####################################### | ||
# clean up | ||
####################################### | ||
clean: | ||
-rm -fR $(BUILD_DIR) | ||
|
||
|
||
####################################### | ||
# dfu-util | ||
####################################### | ||
|
||
program-dfu: | ||
dfu-util -a 0 -s $(FLASH_ADDRESS):leave -D $(BUILD_DIR)/$(TARGET_BIN) -d ,0483:$(USBPID) | ||
|
||
program-boot: | ||
dfu-util -a 0 -s $(INTERNAL_ADDRESS):leave -D $(BOOT_BIN) -d ,0483:$(STM_PID) | ||
|
||
####################################### | ||
# dependencies | ||
####################################### | ||
-include $(wildcard $(BUILD_DIR)/*.d) | ||
|
||
# *** EOF *** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/bash | ||
|
||
# Check for the required project name | ||
if [[ $# -lt 1 || ${1:0:1} == "-" ]]; then | ||
echo "Usage: $0 PROJECT_NAME [-l libdaisy_location] [-d daisysp_location]" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Set the project name value | ||
PROJECT="$1" | ||
|
||
shift | ||
|
||
# Parse command line options | ||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
-l) | ||
LIBDAISY_DIR="$2" | ||
shift 2 | ||
;; | ||
-d) | ||
DAISYSP_DIR="$2" | ||
shift 2 | ||
;; | ||
*) | ||
echo "Usage: $0 PROJECT_NAME [-l libdaisy_location] [-d daisysp_location]" >&2 | ||
exit; | ||
;; | ||
esac | ||
done | ||
|
||
# Default variable value | ||
: "${LIBDAISY_DIR:="../../../libDaisy"}" | ||
: "${DAISYSP_DIR:="../../../DaisySP"}" | ||
|
||
# Make the folders if they don't exist | ||
mkdir -p distribution/ | ||
mkdir -p distribution/licenses | ||
mkdir -p distribution/resource | ||
|
||
# copy .a files | ||
cp $DAISYSP_DIR/build/libdaisysp.a distribution/resource || { echo 'Invalid libDaisy location. Try -l flag' ; exit 1; } | ||
cp $DAISYSP_DIR/DaisySP-LGPL/build/libdaisysp-lgpl.a distribution/resource || { echo 'Invalid DaisySP location. Try -d flag' ; exit 1; } | ||
cp $LIBDAISY_DIR/build/libdaisy.a distribution/resource || { echo 'Invalid DaisySP location. Try -d flag' ; exit 1; } | ||
|
||
# copy bootloader files | ||
cp $LIBDAISY_DIR/core/dsy_bootloader* distribution/resource || { echo 'Invalid libDaisy location. Try -l flag' ; exit 1; } | ||
cp $LIBDAISY_DIR/core/STM32H750IB_flash.lds distribution/resource || { echo 'Invalid libDaisy location. Try -l flag' ; exit 1; } | ||
cp $LIBDAISY_DIR/core/STM32H750IB_sram.lds distribution/resource || { echo 'Invalid libDaisy location. Try -l flag' ; exit 1; } | ||
cp $LIBDAISY_DIR/core/STM32H750IB_qspi.lds distribution/resource || { echo 'Invalid libDaisy location. Try -l flag' ; exit 1; } | ||
|
||
# copy and prepend vars to local makefile | ||
cp $DAISYSP_DIR/DaisySP-LGPL/distribution/Makefile_LGPL distribution/Makefile || { echo 'Invalid libDaisy location. Try -l flag' ; exit 1; } | ||
|
||
prepend="# Project Name\nTARGET = $PROJECT\n" | ||
sed -i -e "1i $prepend" distribution/Makefile | ||
|
||
# copy .o and .map files | ||
cp build/*.o distribution/resource | ||
cp build/*.map distribution/resource | ||
|
||
# Copy LICENSE files | ||
cp $DAISYSP_DIR/DaisySP-LGPL/LICENSE distribution/licenses/DaisySP-LGPL | ||
cp $DAISYSP_DIR/LICENSE distribution/licenses/DaisySP | ||
cp $LIBDAISY_DIR/LICENSE distribution/licenses/libDaisy | ||
|
||
# make a little readme | ||
readme="To rebuild with an updated or modified version of any of the static libraries:\n | ||
1. Install the Daisy-Toolchain.\n | ||
2. Build the library you would like to replace, for example by running make inside of DaisySP-LGPL.\n | ||
3. Copy the generated .a file to the resources folder. In this case it would be libdaisy-lgpl.a \n | ||
4. Run the make command in this folder. Your .bin file will be in the build folder. " | ||
|
||
echo -e $readme > distribution/Readme.md |