Merge pull request #1169 from Ralim/alpine

Migrating to Alpine build environment for CI and Dockerfile
This commit is contained in:
Ben V. Brown
2022-01-09 11:59:52 +11:00
committed by GitHub
5 changed files with 76 additions and 114 deletions

View File

@@ -5,32 +5,24 @@ on: [push, pull_request]
jobs: jobs:
build: build:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
container:
image: alpine:3.15
strategy: strategy:
matrix: matrix:
model: ["TS100", "TS80", "TS80P", "Pinecil", "MHP30"] model: ["TS100", "TS80", "TS80P", "Pinecil", "MHP30"]
fail-fast: true fail-fast: true
steps: 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 - uses: actions/checkout@v2
with: with:
submodules: true 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 }} - name: build ${{ matrix.model }}
run: cd source && ./build.sh -m ${{ matrix.model }} run: cd source && ./build.sh -m ${{ matrix.model }}
@@ -52,32 +44,23 @@ jobs:
build_multi-lang: build_multi-lang:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
container:
image: alpine:3.15
strategy: strategy:
matrix: matrix:
model: ["Pinecil"] model: ["Pinecil"]
fail-fast: true fail-fast: true
steps: 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 musl-dev
- name: Install dependencies (python)
run: python3 -m pip install bdflib
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
submodules: true 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 }} - 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 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 - 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 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 - name: Check formatting with clang-format
run: cd source && make clean && make check-style run: cd source && make clean && make check-style

View File

@@ -1,31 +1,19 @@
FROM ubuntu:20.04 FROM alpine:3.15
LABEL maintainer="Ben V. Brown <ralim@ralimtek.com>" LABEL maintainer="Ben V. Brown <ralim@ralimtek.com>"
WORKDIR /build WORKDIR /build
# Add extra mirrors for options # Installing the two compilers, python3, python3 pip, clang format
RUN echo "deb mirror://mirrors.ubuntu.com/mirrors.txt focal main restricted universe multiverse" > /etc/apt/sources.list && \ # Compilders ->gcc-* newlib-*
echo "deb mirror://mirrors.ubuntu.com/mirrors.txt focal-updates main restricted universe multiverse" >> /etc/apt/sources.list && \ # Python3 -> py*
echo "deb mirror://mirrors.ubuntu.com/mirrors.txt focal-security main restricted universe multiverse" >> /etc/apt/sources.list && \ # Misc -> findutils make git
DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y ca-certificates # musl-dev is required for the multi lang firmwares
# Install dependencies to build the firmware # clang is required for clang-format (for dev)
RUN apt-get install -y \
make \ 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
bzip2 \
git \ # Install Python3 packages
python3 \
python3-pip \ RUN python3 -m pip install bdflib black
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
# 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 . /build/source
COPY ./ci /build/ci COPY ./ci /build/ci

View File

@@ -5,7 +5,7 @@ services:
tty: true tty: true
build: build:
context: . context: .
command: /bin/bash command: /bin/sh
volumes: volumes:
- ./ci:/build/ci:Z - ./ci:/build/ci:Z
- ./:/build/source:Z - ./:/build/source:Z

View File

@@ -42,6 +42,7 @@ HOST_CC := gcc
endif endif
HOST_OUTPUT_DIR=Objects/host HOST_OUTPUT_DIR=Objects/host
# DFU packing address to use
DEVICE_DFU_ADDRESS=0x08000000 DEVICE_DFU_ADDRESS=0x08000000
DEVICE_DFU_VID_PID=0x28E9:0x0189 DEVICE_DFU_VID_PID=0x28E9:0x0189
# Enumerate all of the include directories # Enumerate all of the include directories
@@ -63,16 +64,19 @@ MHP30_STARTUP_DIR = ./Startup
MHP30_INC_DIR = ./Core/BSP/MHP30 MHP30_INC_DIR = ./Core/BSP/MHP30
MHP30_LD_FILE = ./Core/BSP/MHP30/stm32f103.ld 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_INC_DIR = ./Core/BSP/Pine64
PINE_VENDOR_INC_DIR = ./Core/BSP/Pine64/Vendor/SoC/gd32vf103/Common/Include 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_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_NMSIS_INC_DIR = ./Core/BSP/Pine64/Vendor/NMSIS/Core/Include
PINE_FREERTOS_PORT_INC_DIR = ./Core/BSP/Pine64/Vendor/OS/FreeRTOS/Source/portable/GCC 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_THREADS_DIR = ./Core/Threads
SOURCE_CORE_DIR = ./Core/Src SOURCE_CORE_DIR = ./Core/Src
SOURCE_BRIEFLZ_DIR = ./Core/brieflz SOURCE_BRIEFLZ_DIR = ./Core/brieflz
@@ -80,10 +84,9 @@ SOURCE_DRIVERS_DIR = ./Core/Drivers
INC_PD_DRIVERS_DIR = ./Core/Drivers/usb-pd/include INC_PD_DRIVERS_DIR = ./Core/Drivers/usb-pd/include
PD_DRIVER_TESTS_DIR = ./Core/Drivers/usb-pd/tests PD_DRIVER_TESTS_DIR = ./Core/Drivers/usb-pd/tests
PD_DRIVER_DIR = ./Core/Drivers/usb-pd PD_DRIVER_DIR = ./Core/Drivers/usb-pd
SOURCE_MIDDLEWARES_DIR = ./Middlewares
# Find-all's used for formatting # 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' \) \) ) 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 # 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 \ 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 ARM_MATH_CM3 \
-D STM32F10X_MD -D STM32F10X_MD
DEV_LDFLAGS=-lm -Wl,--gc-sections DEV_LDFLAGS=
DEV_AFLAGS= DEV_AFLAGS=
DEV_CFLAGS= -D GCC_ARMCM3 \ DEV_CFLAGS=
-D ARM_MATH_CM3 \ DEV_CXXFLAGS=
-D STM32F10X_MD
DEV_CXXFLAGS= -D GCC_ARMCM3 \
-D ARM_MATH_CM3 \
-D STM32F10X_MD
CPUFLAGS= -mcpu=cortex-m3 \ CPUFLAGS= -mcpu=cortex-m3 \
-mthumb \ -mthumb \
-mfloat-abi=soft -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 \ 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 ARM_MATH_CM3 \
-D STM32F10X_MD -D STM32F10X_MD
DEV_LDFLAGS=-lm -Wl,--gc-sections DEV_LDFLAGS=
DEV_AFLAGS= DEV_AFLAGS=
DEV_CFLAGS= -D GCC_ARMCM3 \ DEV_CFLAGS=
-D ARM_MATH_CM3 \ DEV_CXXFLAGS=
-D STM32F10X_MD
DEV_CXXFLAGS= -D GCC_ARMCM3 \
-D ARM_MATH_CM3 \
-D STM32F10X_MD
CPUFLAGS= -mcpu=cortex-m3 \ CPUFLAGS= -mcpu=cortex-m3 \
-mthumb \ -mthumb \
-mfloat-abi=soft -mfloat-abi=soft
@@ -146,6 +141,8 @@ bootldr_size=32k
DEVICE_DFU_ADDRESS=0x08008000 DEVICE_DFU_ADDRESS=0x08008000
DEVICE_DFU_VID_PID=0x1209:0xDB42 DEVICE_DFU_VID_PID=0x1209:0xDB42
endif endif
ifeq ($(model),$(ALL_PINE_MODELS)) ifeq ($(model),$(ALL_PINE_MODELS))
$(info Building for Pine64 ) $(info Building for Pine64 )
DEVICE_INCLUDES = -I$(PINE_INC_DIR) \ DEVICE_INCLUDES = -I$(PINE_INC_DIR) \
@@ -163,14 +160,12 @@ bootldr_size=0x0
# Flags # Flags
CPUFLAGS= -march=rv32imac \ CPUFLAGS= -march=rv32imac \
-mabi=ilp32 \ -mabi=ilp32 \
-mcmodel=medany -fsigned-char -fno-builtin -fsingle-precision-constant \ -mcmodel=medany -fsigned-char -fno-builtin -nostartfiles
-DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP DEV_LDFLAGS=-nostartfiles --specs=patch.specs
DEV_AFLAGS=
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_GLOBAL_DEFS= -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP
DEV_AFLAGS= -nostartfiles -ffreestanding -fno-common -Os -flto DEV_CFLAGS=
DEV_GLOBAL_DEFS= DEV_CXXFLAGS=
DEV_CFLAGS= -MMD -MP -MF "$(@:%.o=%.d)" -MT "$@"
DEV_CXXFLAGS= -MMD -MP -MF "$(@:%.o=%.d)" -MT "$@"
endif endif
INCLUDES = -I$(APP_INC_DIR) \ INCLUDES = -I$(APP_INC_DIR) \
@@ -197,7 +192,7 @@ $(shell find $(DEVICE_BSP_DIR) -type f -name '*.cpp') \
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp') $(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')
# code optimisation ------------------------------------------------------------ # 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 -ffreestanding -fno-common
# global defines --------------------------------------------------------------- # global defines ---------------------------------------------------------------
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U
@@ -221,33 +216,30 @@ ifeq ($(model),$(filter $(model),$(ALL_MINIWARE_MODELS) $(ALL_MHP30_MODELS)))
COMPILER_PREFIX=arm-none-eabi COMPILER_PREFIX=arm-none-eabi
endif endif
ifeq ($(model),$(ALL_PINE_MODELS)) ifeq ($(model),$(ALL_PINE_MODELS))
COMPILER_PREFIX=riscv-nuclei-elf COMPILER_PREFIX=riscv-none-elf
endif endif
# programs --------------------------------------------------------------------- # programs ---------------------------------------------------------------------
CC=$(COMPILER_PREFIX)-gcc CC=$(COMPILER_PREFIX)-gcc
CPP=$(COMPILER_PREFIX)-g++ CPP=$(COMPILER_PREFIX)-g++
AS=$(COMPILER_PREFIX)-as
OBJCOPY=$(COMPILER_PREFIX)-objcopy OBJCOPY=$(COMPILER_PREFIX)-objcopy
OBJDUMP=$(COMPILER_PREFIX)-objdump OBJDUMP=$(COMPILER_PREFIX)-objdump
SIZE=$(COMPILER_PREFIX)-size SIZE=$(COMPILER_PREFIX)-size
# use gcc in assembler mode so we can use defines etc in assembly
# For the Pinecil, use gcc in assembler mode
ifeq ($(model),$(ALL_PINE_MODELS))
AS=$(COMPILER_PREFIX)-gcc -x assembler-with-cpp AS=$(COMPILER_PREFIX)-gcc -x assembler-with-cpp
endif
# linker flags ----------------------------------------------------------------- # linker flags -----------------------------------------------------------------
LINKER_FLAGS= -Wl,--gc-sections \ LINKER_FLAGS= -Wl,--gc-sections \
-Wl,--wrap=malloc \ -Wl,--wrap=malloc \
-Wl,--wrap=free \ -Wl,--wrap=free \
-lm \
-Wl,--undefined=vTaskSwitchContext \ -Wl,--undefined=vTaskSwitchContext \
-Wl,--undefined=pxCurrentTCB \ -Wl,--undefined=pxCurrentTCB \
-Wl,--defsym=__FLASH_SIZE__=$(flash_size) \ -Wl,--defsym=__FLASH_SIZE__=$(flash_size) \
-Wl,--defsym=__BOOTLDR_SIZE__=$(bootldr_size) \ -Wl,--defsym=__BOOTLDR_SIZE__=$(bootldr_size) \
$(DEV_LDFLAGS) \ -Wl,--print-memory-usage \
-flto \ -flto \
--specs=nano.specs --specs=nosys.specs \
--specs=nano.specs \
$(DEV_LDFLAGS)
# compiler flags --------------------------------------------------------------- # compiler flags ---------------------------------------------------------------
@@ -296,8 +288,6 @@ CXXFLAGS=$(DEV_CXXFLAGS) \
$(CHECKOPTIONS) \ $(CHECKOPTIONS) \
-std=c++14 \ -std=c++14 \
$(OPTIM) \ $(OPTIM) \
-fno-common \
-ffreestanding \
-fno-rtti \ -fno-rtti \
-fno-exceptions \ -fno-exceptions \
-fno-non-call-exceptions \ -fno-non-call-exceptions \
@@ -309,27 +299,27 @@ CXXFLAGS=$(DEV_CXXFLAGS) \
-T$(LDSCRIPT) -T$(LDSCRIPT)
CFLAGS=$(DEV_CFLAGS) \ CFLAGS=$(DEV_CFLAGS) \
$(CPUFLAGS) \ $(CPUFLAGS) \
$(DEBUG) \ $(DEBUG) \
$(INCLUDES) \ $(INCLUDES) \
$(CHECKOPTIONS_C) \ $(CHECKOPTIONS_C) \
$(GLOBAL_DEFINES) \ $(GLOBAL_DEFINES) \
-D${COMPILER} \ -D${COMPILER} \
-MMD \ -MMD \
-std=gnu99 \ -std=gnu99 \
$(OPTIM) \ $(OPTIM) \
-fno-common \
-ffreestanding \
-T$(LDSCRIPT) \ -T$(LDSCRIPT) \
-c -c
AFLAGS= $(CPUFLAGS) \ AFLAGS= $(CPUFLAGS) \
$(DEV_AFLAGS) \ $(DEV_AFLAGS) \
$(DEBUG) \ $(GLOBAL_DEFINES) \
$(ASM_INC) \ $(OPTIM) \
$(DEBUG) \
$(ASM_INC) \
$(INCLUDES) $(INCLUDES)
@@ -351,8 +341,6 @@ default : firmware-EN
firmware-%: $(HEXFILE_DIR)/$(model)_%.hex $(HEXFILE_DIR)/$(model)_%.bin $(HEXFILE_DIR)/$(model)_%.dfu firmware-%: $(HEXFILE_DIR)/$(model)_%.hex $(HEXFILE_DIR)/$(model)_%.bin $(HEXFILE_DIR)/$(model)_%.dfu
@true @true
ALL_FIRMWARE_TARGETS=$(addprefix firmware-,$(ALL_LANGUAGES))
all: $(ALL_FIRMWARE_TARGETS)
# #
# The rule to create the target directory # The rule to create the target directory

2
source/patch.specs Normal file
View File

@@ -0,0 +1,2 @@
*link:
%(nano_link) %:replace-outfile(-lm_nano -lm)