From b6d2846ead7c392325a4c4ea2b2fd1740bc57e1d Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Thu, 6 Jan 2022 18:58:58 +1100 Subject: [PATCH 01/10] test --- Dockerfile | 35 ++++++++++------------------------- docker-compose.yml | 2 +- source/Makefile | 4 ++-- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7f52cd61b6..9e8356168f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,16 @@ -FROM ubuntu:20.04 +FROM alpine:3.15 LABEL maintainer="Ben V. Brown " WORKDIR /build -# Add extra mirrors for options -RUN echo "deb mirror://mirrors.ubuntu.com/mirrors.txt focal main restricted universe multiverse" > /etc/apt/sources.list && \ - echo "deb mirror://mirrors.ubuntu.com/mirrors.txt focal-updates main restricted universe multiverse" >> /etc/apt/sources.list && \ - echo "deb mirror://mirrors.ubuntu.com/mirrors.txt focal-security main restricted universe multiverse" >> /etc/apt/sources.list && \ - DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y ca-certificates -# Install dependencies to build the firmware -RUN apt-get install -y \ - make \ - bzip2 \ - git \ - python3 \ - python3-pip \ - clang-format \ - dfu-util \ - wget --no-install-recommends && \ - apt-get clean -RUN python3 -m pip install bdflib -# Download the two compilers -RUN wget -qO- "https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2" | tar -xj -# This is the same as the one from Nuclei, just mirrored on Github as their download server is horrifically slow -RUN wget -qO- "https://github.com/Ralim/nuclei-compiler/releases/download/2020.08/nuclei_riscv_newlibc_prebuilt_linux64_2020.08.tar.bz2" | tar -xj +# Installing the two compilers, python3, python3 pip, clang format +# Compilders ->gcc-* newlib-* +# Python3 -> py* +# Misc -> findutils make git clang (for clang-format) +RUN apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi python3 py3-pip make git clang newlib-riscv-none-elf newlib-arm-none-eabi findutils + +# Install Python3 packages + +RUN python3 -m pip install bdflib black -# Add compiler to the path -ENV PATH "/build/gcc-arm-none-eabi-10-2020-q4-major/bin:$PATH" -ENV PATH "/build/gcc/bin/:$PATH" COPY . /build/source COPY ./ci /build/ci diff --git a/docker-compose.yml b/docker-compose.yml index 31ded28217..9a029eae7d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: tty: true build: context: . - command: /bin/bash + command: /bin/sh volumes: - ./ci:/build/ci:Z - ./:/build/source:Z diff --git a/source/Makefile b/source/Makefile index 51373f1be3..2a131e752a 100644 --- a/source/Makefile +++ b/source/Makefile @@ -166,7 +166,7 @@ CPUFLAGS= -march=rv32imac \ -mcmodel=medany -fsigned-char -fno-builtin -fsingle-precision-constant \ -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP -DEV_LDFLAGS= -lstdc++ -nostartfiles -Xlinker --gc-sections --specs=nosys.specs -u _isatty -u _write -u _sbrk -u _read -u _close -u _fstat -u _lseek +DEV_LDFLAGS= -lstdc++ -nostartfiles -Xlinker --gc-sections -u _isatty -u _write -u _sbrk -u _read -u _close -u _fstat -u _lseek DEV_AFLAGS= -nostartfiles -ffreestanding -fno-common -Os -flto DEV_GLOBAL_DEFS= DEV_CFLAGS= -MMD -MP -MF "$(@:%.o=%.d)" -MT "$@" @@ -221,7 +221,7 @@ ifeq ($(model),$(filter $(model),$(ALL_MINIWARE_MODELS) $(ALL_MHP30_MODELS))) COMPILER_PREFIX=arm-none-eabi endif ifeq ($(model),$(ALL_PINE_MODELS)) -COMPILER_PREFIX=riscv-nuclei-elf +COMPILER_PREFIX=riscv-none-elf endif # programs --------------------------------------------------------------------- CC=$(COMPILER_PREFIX)-gcc From 333529825054375c0ce33b68c84007b216d79ddf Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Thu, 6 Jan 2022 23:50:48 +1100 Subject: [PATCH 02/10] Update Dockerfile --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9e8356168f..d183f77656 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,9 @@ WORKDIR /build # Installing the two compilers, python3, python3 pip, clang format # Compilders ->gcc-* newlib-* # Python3 -> py* -# Misc -> findutils make git clang (for clang-format) -RUN apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi python3 py3-pip make git clang newlib-riscv-none-elf newlib-arm-none-eabi findutils +# Misc -> findutils make git + +RUN apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git # Install Python3 packages From 93de082b06f9317b14adf86f5e3fc982c1ace92b Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Thu, 6 Jan 2022 23:51:32 +1100 Subject: [PATCH 03/10] Make patch specs to not use nano math Since Alpine isnt shipping it --- source/Makefile | 38 ++++++++++++++++++++------------------ source/patch.specs | 2 ++ 2 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 source/patch.specs diff --git a/source/Makefile b/source/Makefile index 2a131e752a..678a8c7836 100644 --- a/source/Makefile +++ b/source/Makefile @@ -100,7 +100,7 @@ LDSCRIPT=$(MINIWARE_LD_FILE) DEV_GLOBAL_DEFS= -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D GCC_ARMCM3 \ -D ARM_MATH_CM3 \ -D STM32F10X_MD -DEV_LDFLAGS=-lm -Wl,--gc-sections +DEV_LDFLAGS=-Wl,--gc-sections DEV_AFLAGS= DEV_CFLAGS= -D GCC_ARMCM3 \ -D ARM_MATH_CM3 \ @@ -130,7 +130,7 @@ LDSCRIPT=$(MHP30_LD_FILE) DEV_GLOBAL_DEFS= -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D GCC_ARMCM3 \ -D ARM_MATH_CM3 \ -D STM32F10X_MD -DEV_LDFLAGS=-lm -Wl,--gc-sections +DEV_LDFLAGS= -Wl,--gc-sections DEV_AFLAGS= DEV_CFLAGS= -D GCC_ARMCM3 \ -D ARM_MATH_CM3 \ @@ -146,6 +146,8 @@ bootldr_size=32k DEVICE_DFU_ADDRESS=0x08008000 DEVICE_DFU_VID_PID=0x1209:0xDB42 endif + + ifeq ($(model),$(ALL_PINE_MODELS)) $(info Building for Pine64 ) DEVICE_INCLUDES = -I$(PINE_INC_DIR) \ @@ -163,12 +165,12 @@ bootldr_size=0x0 # Flags CPUFLAGS= -march=rv32imac \ -mabi=ilp32 \ - -mcmodel=medany -fsigned-char -fno-builtin -fsingle-precision-constant \ - -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP + -mcmodel=medany -fsigned-char -fno-builtin + -DEV_LDFLAGS= -lstdc++ -nostartfiles -Xlinker --gc-sections -u _isatty -u _write -u _sbrk -u _read -u _close -u _fstat -u _lseek -DEV_AFLAGS= -nostartfiles -ffreestanding -fno-common -Os -flto -DEV_GLOBAL_DEFS= +DEV_LDFLAGS=-nostartfiles -Xlinker --gc-sections -u _isatty -u _write -u _sbrk -u _read -u _close -u _fstat -u _lseek --specs=patch.specs +DEV_AFLAGS=-nostartfiles -ffreestanding -fno-common -Os -flto +DEV_GLOBAL_DEFS=-DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP DEV_CFLAGS= -MMD -MP -MF "$(@:%.o=%.d)" -MT "$@" DEV_CXXFLAGS= -MMD -MP -MF "$(@:%.o=%.d)" -MT "$@" endif @@ -197,7 +199,7 @@ $(shell find $(DEVICE_BSP_DIR) -type f -name '*.cpp') \ $(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp') # code optimisation ------------------------------------------------------------ -OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums +OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant # global defines --------------------------------------------------------------- GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U @@ -240,14 +242,14 @@ endif LINKER_FLAGS= -Wl,--gc-sections \ -Wl,--wrap=malloc \ -Wl,--wrap=free \ - -lm \ -Wl,--undefined=vTaskSwitchContext \ -Wl,--undefined=pxCurrentTCB \ -Wl,--defsym=__FLASH_SIZE__=$(flash_size) \ -Wl,--defsym=__BOOTLDR_SIZE__=$(bootldr_size) \ - $(DEV_LDFLAGS) \ -flto \ - --specs=nano.specs + --specs=nosys.specs \ + --specs=nano.specs \ + $(DEV_LDFLAGS) # compiler flags --------------------------------------------------------------- @@ -309,17 +311,17 @@ CXXFLAGS=$(DEV_CXXFLAGS) \ -T$(LDSCRIPT) -CFLAGS=$(DEV_CFLAGS) \ - $(CPUFLAGS) \ - $(DEBUG) \ +CFLAGS=$(DEV_CFLAGS) \ + $(CPUFLAGS) \ + $(DEBUG) \ $(INCLUDES) \ $(CHECKOPTIONS_C) \ $(GLOBAL_DEFINES) \ -D${COMPILER} \ - -MMD \ - -std=gnu99 \ - $(OPTIM) \ - -fno-common \ + -MMD \ + -std=gnu99 \ + $(OPTIM) \ + -fno-common \ -ffreestanding \ -T$(LDSCRIPT) \ -c diff --git a/source/patch.specs b/source/patch.specs new file mode 100644 index 0000000000..312b1d49ef --- /dev/null +++ b/source/patch.specs @@ -0,0 +1,2 @@ +*link: +%(nano_link) %:replace-outfile(-lm_nano -lm) \ No newline at end of file From 724b0c49361e8a09e2b2100f29c72075823f1b75 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Fri, 7 Jan 2022 00:04:20 +1100 Subject: [PATCH 04/10] Update ci specs --- .github/workflows/push.yml | 48 +++++++++++++------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 7c74d60117..b77f418716 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -5,31 +5,23 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-20.04 + container: + image: alpine:3.15 strategy: matrix: model: ["TS100", "TS80", "TS80P", "Pinecil", "MHP30"] fail-fast: true steps: - - uses: actions/checkout@v2 - with: - submodules: true + - name: Install dependencies (apk) + run: apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git bash - - name: chmod - run: chmod +x setup.sh && chmod +x source/build.sh && sudo mkdir -p /build/cache && sudo chmod -R 777 /build + - name: Install dependencies (python) + run: python3 -m pip install bdflib - - name: Cached compiler source files - uses: actions/cache@v2.1.7 - env: - cache-name: cache-compilers + - uses: actions/checkout@v2 with: - path: /build/cache - key: ${{ runner.os }}-build-${{ env.cache-name }} - restore-keys: | - ${{ runner.os }}- - - - name: setup - run: ./setup.sh + submodules: true - name: build ${{ matrix.model }} run: cd source && ./build.sh -m ${{ matrix.model }} @@ -52,32 +44,23 @@ jobs: build_multi-lang: runs-on: ubuntu-20.04 + container: + image: alpine:3.15 strategy: matrix: model: ["Pinecil"] fail-fast: true steps: + - name: Install dependencies (apk) + run: apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git bash + - name: Install dependencies (python) + run: python3 -m pip install bdflib + - uses: actions/checkout@v2 with: submodules: true - - name: chmod - run: chmod +x setup.sh && chmod +x source/build.sh && sudo mkdir -p /build/cache && sudo chmod -R 777 /build - - - name: Cached compiler source files - uses: actions/cache@v2.1.7 - env: - cache-name: cache-compilers - with: - path: /build/cache - key: ${{ runner.os }}-build-${{ env.cache-name }} - restore-keys: | - ${{ runner.os }}- - - - name: setup - run: ./setup.sh - - name: build ${{ matrix.model }} run: cd source && make -j$(nproc) model="${{ matrix.model }}" firmware-multi_compressed_European firmware-multi_compressed_Bulgarian+Russian+Serbian+Ukrainian firmware-multi_Chinese+Japanese @@ -142,6 +125,7 @@ jobs: - name: setup run: sudo apt-get update && sudo apt-get install -y make clang git python3 python3-pip && python3 -m pip install bdflib black flake8 + - name: Check formatting with clang-format run: cd source && make clean && make check-style From 15d4da9b816a81378f381165edaeec7133c9f3e0 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Fri, 7 Jan 2022 08:38:27 +1100 Subject: [PATCH 05/10] Update Makefile --- source/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Makefile b/source/Makefile index 678a8c7836..74082f5672 100644 --- a/source/Makefile +++ b/source/Makefile @@ -165,7 +165,7 @@ bootldr_size=0x0 # Flags CPUFLAGS= -march=rv32imac \ -mabi=ilp32 \ - -mcmodel=medany -fsigned-char -fno-builtin + -mcmodel=medany -fsigned-char DEV_LDFLAGS=-nostartfiles -Xlinker --gc-sections -u _isatty -u _write -u _sbrk -u _read -u _close -u _fstat -u _lseek --specs=patch.specs From d712f6875b81f3b877baf0e661067ea211a364f3 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Fri, 7 Jan 2022 21:28:25 +1100 Subject: [PATCH 06/10] Update Makefile --- source/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/Makefile b/source/Makefile index 74082f5672..797496a32b 100644 --- a/source/Makefile +++ b/source/Makefile @@ -165,12 +165,13 @@ bootldr_size=0x0 # Flags CPUFLAGS= -march=rv32imac \ -mabi=ilp32 \ - -mcmodel=medany -fsigned-char + -mcmodel=medany -fsigned-char -fno-builtin -fsingle-precision-constant \ + -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP DEV_LDFLAGS=-nostartfiles -Xlinker --gc-sections -u _isatty -u _write -u _sbrk -u _read -u _close -u _fstat -u _lseek --specs=patch.specs DEV_AFLAGS=-nostartfiles -ffreestanding -fno-common -Os -flto -DEV_GLOBAL_DEFS=-DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP +DEV_GLOBAL_DEFS= DEV_CFLAGS= -MMD -MP -MF "$(@:%.o=%.d)" -MT "$@" DEV_CXXFLAGS= -MMD -MP -MF "$(@:%.o=%.d)" -MT "$@" endif From cd86c34b904ceb6911d88156c0339af8bc9ccbe6 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Fri, 7 Jan 2022 21:57:42 +1100 Subject: [PATCH 07/10] Add musl headers for multi-lang --- .github/workflows/push.yml | 2 +- Dockerfile | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index b77f418716..116f570ac0 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -53,7 +53,7 @@ jobs: steps: - name: Install dependencies (apk) - run: apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git bash + run: apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git bash musl-dev - name: Install dependencies (python) run: python3 -m pip install bdflib diff --git a/Dockerfile b/Dockerfile index d183f77656..5071dbfa74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,10 @@ WORKDIR /build # Compilders ->gcc-* newlib-* # Python3 -> py* # Misc -> findutils make git +# musl-dev is required for the multi lang firmwares +# clang is required for clang-format (for dev) -RUN apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git +RUN apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git musl-dev clang # Install Python3 packages From e52da0088deac7480bc4727c101ec7ec936d6552 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sat, 8 Jan 2022 12:25:03 +1100 Subject: [PATCH 08/10] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5071dbfa74..9da5c84192 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ WORKDIR /build # musl-dev is required for the multi lang firmwares # clang is required for clang-format (for dev) -RUN apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git musl-dev clang +RUN apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf newlib-arm-none-eabi findutils python3 py3-pip make git musl-dev clang bash # Install Python3 packages From 18c376deffcd875d24e0fc687db10cfa66874544 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sat, 8 Jan 2022 12:25:08 +1100 Subject: [PATCH 09/10] Cleanup Makefile --- source/Makefile | 73 +++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 42 deletions(-) diff --git a/source/Makefile b/source/Makefile index 797496a32b..8562e70a46 100644 --- a/source/Makefile +++ b/source/Makefile @@ -42,6 +42,7 @@ HOST_CC := gcc endif HOST_OUTPUT_DIR=Objects/host +# DFU packing address to use DEVICE_DFU_ADDRESS=0x08000000 DEVICE_DFU_VID_PID=0x28E9:0x0189 # Enumerate all of the include directories @@ -63,16 +64,19 @@ MHP30_STARTUP_DIR = ./Startup MHP30_INC_DIR = ./Core/BSP/MHP30 MHP30_LD_FILE = ./Core/BSP/MHP30/stm32f103.ld -FRTOS_CMIS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -FRTOS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/include -DRIVER_INC_DIR =./Core/Drivers -BSP_INC_DIR = ./Core/BSP -THREADS_INC_DIR = ./Core/Threads PINE_INC_DIR = ./Core/BSP/Pine64 PINE_VENDOR_INC_DIR = ./Core/BSP/Pine64/Vendor/SoC/gd32vf103/Common/Include PINE_VENDOR_USB_INC_DIR = ./Core/BSP/Pine64/Vendor/SoC/gd32vf103/Common/Include/Usb PINE_NMSIS_INC_DIR = ./Core/BSP/Pine64/Vendor/NMSIS/Core/Include PINE_FREERTOS_PORT_INC_DIR = ./Core/BSP/Pine64/Vendor/OS/FreeRTOS/Source/portable/GCC + +SOURCE_MIDDLEWARES_DIR = ./Middlewares +FRTOS_CMIS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS +FRTOS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/include +DRIVER_INC_DIR =./Core/Drivers +BSP_INC_DIR = ./Core/BSP +THREADS_INC_DIR = ./Core/Threads + SOURCE_THREADS_DIR = ./Core/Threads SOURCE_CORE_DIR = ./Core/Src SOURCE_BRIEFLZ_DIR = ./Core/brieflz @@ -80,10 +84,9 @@ SOURCE_DRIVERS_DIR = ./Core/Drivers INC_PD_DRIVERS_DIR = ./Core/Drivers/usb-pd/include PD_DRIVER_TESTS_DIR = ./Core/Drivers/usb-pd/tests PD_DRIVER_DIR = ./Core/Drivers/usb-pd -SOURCE_MIDDLEWARES_DIR = ./Middlewares # Find-all's used for formatting -ALL_INCLUDES = $(shell find ./Core -type d \( -path $(BRIEFLZ_INC_DIR) -o -path $(PD_DRIVER_DIR) \) -prune -false -o \( -type f \( -name '*.h' -o -name '*.hpp' \) \) ) +ALL_INCLUDES = $(shell find ./Core -type d \( -path $(BRIEFLZ_INC_DIR) -o -path $(PD_DRIVER_DIR) \) -prune -false -o \( -type f \( -name '*.h' -o -name '*.hpp' \) \) ) ALL_SOURCE = $(shell find ./Core -type d \( -path $(SOURCE_BRIEFLZ_DIR) -o -path $(PD_DRIVER_DIR) \) -prune -false -o \( -type f \( -name '*.c' -o -name '*.cpp' \) \) ) # Device dependent settings @@ -100,14 +103,10 @@ LDSCRIPT=$(MINIWARE_LD_FILE) DEV_GLOBAL_DEFS= -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D GCC_ARMCM3 \ -D ARM_MATH_CM3 \ -D STM32F10X_MD -DEV_LDFLAGS=-Wl,--gc-sections +DEV_LDFLAGS= DEV_AFLAGS= -DEV_CFLAGS= -D GCC_ARMCM3 \ - -D ARM_MATH_CM3 \ - -D STM32F10X_MD -DEV_CXXFLAGS= -D GCC_ARMCM3 \ - -D ARM_MATH_CM3 \ - -D STM32F10X_MD +DEV_CFLAGS= +DEV_CXXFLAGS= CPUFLAGS= -mcpu=cortex-m3 \ -mthumb \ -mfloat-abi=soft @@ -130,14 +129,10 @@ LDSCRIPT=$(MHP30_LD_FILE) DEV_GLOBAL_DEFS= -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D GCC_ARMCM3 \ -D ARM_MATH_CM3 \ -D STM32F10X_MD -DEV_LDFLAGS= -Wl,--gc-sections +DEV_LDFLAGS= DEV_AFLAGS= -DEV_CFLAGS= -D GCC_ARMCM3 \ - -D ARM_MATH_CM3 \ - -D STM32F10X_MD -DEV_CXXFLAGS= -D GCC_ARMCM3 \ - -D ARM_MATH_CM3 \ - -D STM32F10X_MD +DEV_CFLAGS= +DEV_CXXFLAGS= CPUFLAGS= -mcpu=cortex-m3 \ -mthumb \ -mfloat-abi=soft @@ -165,15 +160,12 @@ bootldr_size=0x0 # Flags CPUFLAGS= -march=rv32imac \ -mabi=ilp32 \ - -mcmodel=medany -fsigned-char -fno-builtin -fsingle-precision-constant \ - -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP - - -DEV_LDFLAGS=-nostartfiles -Xlinker --gc-sections -u _isatty -u _write -u _sbrk -u _read -u _close -u _fstat -u _lseek --specs=patch.specs -DEV_AFLAGS=-nostartfiles -ffreestanding -fno-common -Os -flto -DEV_GLOBAL_DEFS= -DEV_CFLAGS= -MMD -MP -MF "$(@:%.o=%.d)" -MT "$@" -DEV_CXXFLAGS= -MMD -MP -MF "$(@:%.o=%.d)" -MT "$@" + -mcmodel=medany -fsigned-char -fno-builtin -nostartfiles +DEV_LDFLAGS=-nostartfiles --specs=patch.specs +DEV_AFLAGS= +DEV_GLOBAL_DEFS= -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP +DEV_CFLAGS= +DEV_CXXFLAGS= endif INCLUDES = -I$(APP_INC_DIR) \ @@ -200,12 +192,12 @@ $(shell find $(DEVICE_BSP_DIR) -type f -name '*.cpp') \ $(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp') # code optimisation ------------------------------------------------------------ -OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant +OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -ffreestanding -fno-common # global defines --------------------------------------------------------------- GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U -DEBUG=-g3 +DEBUG=-g3 ifdef swd_enable GLOBAL_DEFINES += -DSWD_ENABLE endif @@ -247,6 +239,7 @@ LINKER_FLAGS= -Wl,--gc-sections \ -Wl,--undefined=pxCurrentTCB \ -Wl,--defsym=__FLASH_SIZE__=$(flash_size) \ -Wl,--defsym=__BOOTLDR_SIZE__=$(bootldr_size) \ + -Wl,--print-memory-usage \ -flto \ --specs=nosys.specs \ --specs=nano.specs \ @@ -299,8 +292,6 @@ CXXFLAGS=$(DEV_CXXFLAGS) \ $(CHECKOPTIONS) \ -std=c++14 \ $(OPTIM) \ - -fno-common \ - -ffreestanding \ -fno-rtti \ -fno-exceptions \ -fno-non-call-exceptions \ @@ -322,17 +313,17 @@ CFLAGS=$(DEV_CFLAGS) \ -MMD \ -std=gnu99 \ $(OPTIM) \ - -fno-common \ - -ffreestanding \ -T$(LDSCRIPT) \ -c -AFLAGS= $(CPUFLAGS) \ - $(DEV_AFLAGS) \ - $(DEBUG) \ - $(ASM_INC) \ +AFLAGS= $(CPUFLAGS) \ + $(DEV_AFLAGS) \ + $(GLOBAL_DEFINES) \ + $(OPTIM) \ + $(DEBUG) \ + $(ASM_INC) \ $(INCLUDES) @@ -354,8 +345,6 @@ default : firmware-EN firmware-%: $(HEXFILE_DIR)/$(model)_%.hex $(HEXFILE_DIR)/$(model)_%.bin $(HEXFILE_DIR)/$(model)_%.dfu @true -ALL_FIRMWARE_TARGETS=$(addprefix firmware-,$(ALL_LANGUAGES)) -all: $(ALL_FIRMWARE_TARGETS) # # The rule to create the target directory From 12e8e01ca7f21af9db4034557aaba16c051bf1cb Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sat, 8 Jan 2022 12:28:55 +1100 Subject: [PATCH 10/10] Update Makefile --- source/Makefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/source/Makefile b/source/Makefile index 8562e70a46..094b28e1f6 100644 --- a/source/Makefile +++ b/source/Makefile @@ -221,15 +221,11 @@ endif # programs --------------------------------------------------------------------- CC=$(COMPILER_PREFIX)-gcc CPP=$(COMPILER_PREFIX)-g++ -AS=$(COMPILER_PREFIX)-as OBJCOPY=$(COMPILER_PREFIX)-objcopy OBJDUMP=$(COMPILER_PREFIX)-objdump SIZE=$(COMPILER_PREFIX)-size - -# For the Pinecil, use gcc in assembler mode -ifeq ($(model),$(ALL_PINE_MODELS)) +# use gcc in assembler mode so we can use defines etc in assembly AS=$(COMPILER_PREFIX)-gcc -x assembler-with-cpp -endif # linker flags ----------------------------------------------------------------- LINKER_FLAGS= -Wl,--gc-sections \