Skip to content

Commit

Permalink
Move distribution script here, update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
beserge committed Dec 21, 2023
1 parent 1a1fa32 commit 847e31a
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 11 deletions.
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1>
<img width=3% src="https://raw.github.com/electro-smith/daisysp/master/resources/assets/banner.png">
DaisySP-LGPL • LGPL DSP Modules for <a href="https://www.github.com/electro-smith/DaisySP/">DaisySP</a>
</h1>
<div align=center>
<img width=15% src="https://raw.github.com/electro-smith/daisysp/master/resources/assets/banner.png">

# DaisySP-LGPL • LGPL DSP Modules for [DaisySP](https://www.github.com/electro-smith/DaisySP/)

[![Style Badge](https://github.com/electro-smith/DaisySP-LGPL/workflows/Style/badge.svg)](https://github.com/electro-smith/DaisySP-LPGL/actions?query=workflow%3AStyle)
[![Documentation Badge](https://github.com/electro-smith/DaisySP-LGPL/workflows/Documentation/badge.svg)](https://electro-smith.github.io/DaisySP-LGPL/index.html)
Expand All @@ -11,27 +11,31 @@

> DaisySP-LGPL is a set of LGPL licensed DSP (Digital Signal Processing) modules for use in the DaisySP library.
## DaisySP and Contribution
</div>
<br>

## 🧐 DaisySP and Contribution

This is not a standalone library, and requires [DaisySP](https://www.github.com/electro-smith/DaisySP) to work properly.

Any contributions to this library are welcome under the same guidelines as DaisySP.

## License
## ⚠️ License

DaisySP-LGPL uses the LGPL-2.1 license.

For the full license, read the [LICENSE](https://github.com/electro-smith/DaisySP-LGPL/blob/master/LICENSE) file in the root directory.

## Distribution
## ✉️ Distribution
If you distribute code that makes use of DaisySP-LGPL, you are obligated to give end users the option to recompile with the LGPL components having been replaced.

To make this easier, we have provided a script called [gather_lgpl.sh](https://github.com/electro-smith/libDaisy/tree/master/core/gather_lgpl.sh) which can gather the required files with a simple build system for that purpose.
To make this easier, we have provided a script called [gather_lgpl.sh](https://github.com/electro-smith/DaisySP-LGPL/tree/master/distribution/gather_lgpl.sh) which can gather the required files with a simple build system for that purpose.

1. From your project directory run `<LIBDAISY_DIR>/core/gather_lgpl.sh <PROJECT_NAME>`
1. From your project directory run `<DAISYSP-LGPL_DIR>/distribution/gather_lgpl.sh <PROJECT_NAME>`
2. Use the `-l` and `-d` flags to override the default libDaisy and DaisySP locations.
3. A standalone `lgpl` folder will be created containing:
3. A standalone `distribution` folder will be created containing:
- A Readme
- The LICENSE file(s)
- A standalone Makefile
- And any relevant build files under a `resources` folder.
4. End users with the `lgpl` folder can relink from source with their own modified copy of `libdaisy-lgpl.a` by replacing that file in the `resources` folder, and running `make`
4. End users with the `distribution` folder can relink from source with their own modified copy of `libdaisy-lgpl.a` by replacing that file in the `resources` folder, and running `make`.
145 changes: 145 additions & 0 deletions distribution/Makefile_LGPL
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 ***
74 changes: 74 additions & 0 deletions distribution/gather_lgpl.sh
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

0 comments on commit 847e31a

Please sign in to comment.