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:
build:
runs-on: ubuntu-20.04
container:
image: alpine:3.15
strategy:
matrix:
model: ["TS100", "TS80", "TS80P", "Pinecil", "MHP30"]
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 && ./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 musl-dev
- 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

View File

@@ -1,31 +1,19 @@
FROM ubuntu:20.04
FROM alpine:3.15
LABEL maintainer="Ben V. Brown <ralim@ralimtek.com>"
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
# 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 bash
# 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

View File

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

View File

@@ -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=-lm -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=-lm -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
@@ -146,6 +141,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,14 +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= -lstdc++ -nostartfiles -Xlinker --gc-sections --specs=nosys.specs -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 "$@"
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) \
@@ -197,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
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
@@ -221,33 +216,30 @@ 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
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 \
-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) \
-Wl,--print-memory-usage \
-flto \
--specs=nano.specs
--specs=nosys.specs \
--specs=nano.specs \
$(DEV_LDFLAGS)
# compiler flags ---------------------------------------------------------------
@@ -296,8 +288,6 @@ CXXFLAGS=$(DEV_CXXFLAGS) \
$(CHECKOPTIONS) \
-std=c++14 \
$(OPTIM) \
-fno-common \
-ffreestanding \
-fno-rtti \
-fno-exceptions \
-fno-non-call-exceptions \
@@ -309,27 +299,27 @@ 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 \
-ffreestanding \
-MMD \
-std=gnu99 \
$(OPTIM) \
-T$(LDSCRIPT) \
-c
AFLAGS= $(CPUFLAGS) \
$(DEV_AFLAGS) \
$(DEBUG) \
$(ASM_INC) \
AFLAGS= $(CPUFLAGS) \
$(DEV_AFLAGS) \
$(GLOBAL_DEFINES) \
$(OPTIM) \
$(DEBUG) \
$(ASM_INC) \
$(INCLUDES)
@@ -351,8 +341,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

2
source/patch.specs Normal file
View File

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