Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Build on CircleCI with XC16 1.36B and MPLABX 5.10 #118

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
version: 2

shared: &shared
docker:
- image: debian:stretch
environment: &shared_environment
CLICOLOR_FORCE: 1
mplabx_dir: /opt/mplabx

steps:
- run:
name: Install dependencies
command: |
dpkg --add-architecture i386
apt-get update
apt-get install -y --no-install-recommends \
wget \
git \
ca-certificates \
libc6:i386 \
make \
procps \

- checkout

- restore_cache:
name: Restore XC16 installation from cache
keys:
- xc16-{{ checksum ".circleci/xc16.envs" }}
- run:
name: Install XC16
command: |
source ./.circleci/xc16.envs
url="https://ww1.microchip.com/downloads/en/DeviceDoc/xc16-v${xc16_version}-full-install-linux-installer.run"
xc16_inst='/tmp/xc16'
xc16_install_marker="/opt/microchip/xc16/hash-$xc16_inst_sha256"
if [ -f "$xc16_install_marker" ]; then
echo 'XC16 in cache'
exit 0
fi

wget -O "$xc16_inst" "$url"
chmod +x "$xc16_inst"
sha256sum -c <(echo "${xc16_inst_sha256} *${xc16_inst}")
"$xc16_inst" --version
"$xc16_inst" \
--mode unattended \
--unattendedmodeui none \
--netservername localhost \
--LicenseType FreeMode \

rm -fv "$xc16_inst"
touch "$xc16_install_marker"
- save_cache:
name: Save XC16 installation to cache
key: xc16-{{ checksum ".circleci/xc16.envs" }}
paths:
- /opt/microchip

- restore_cache:
name: Restore MBLAB X installation from cache
keys:
- mplabx-{{ checksum ".circleci/mplabx.envs" }}
- run:
name: Install MPLAB X
command: |
source ./.circleci/mplabx.envs
mplabx_url="https://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v${mplabx_version}-linux-installer.tar"
mplabx_tar='mplabx.tar'
mplabx_inst="./MPLABX-v${mplabx_version}-linux-installer.sh"
mplabx_install_marker="$mplabx_dir/hash-$mplabx_tar_sha256"
if [ -f "$mplabx_install_marker" ]; then
echo 'MPLABX in cache'
exit 0
fi

wget -O "$mplabx_tar" "$mplabx_url"
sha256sum -c <(echo "${mplabx_tar_sha256} *${mplabx_tar}")
tar xf "$mplabx_tar"
USER=root "$mplabx_inst" --nolibrarycheck -- --version
USER=root "$mplabx_inst" --nolibrarycheck --nox11 -- \
--unattendedmodeui none \
--mode unattended \
--ipe 0 \
--installdir "$mplabx_dir" \

rm -fv "$mplabx_tar" "$mplabx_inst"
touch "$mplabx_install_marker"
- save_cache:
name: Save MPLAB X installation to cache
key: mplabx-{{ checksum ".circleci/mplabx.envs" }}
paths:
- /opt/mplabx

- run:
name: Configure
command: |
$mplabx_dir/mplab_platform/bin/prjMakefilesGenerator.sh -v "$project_dir"


- run:
name: Build
command: |
make -C "$project_dir" CONF="$build_config" build

- run:
name: Prepare artifacts
command: |
# part of this is a workaround for CircleCI not supporting string interpolation or symlinks in store_artifacts
artifacts_dir="${project_dir}/dist/${build_config}/production"
git_describe="$(git describe --tags --always --long)"
mkdir ./artifacts/
for file in $artifacts_dir/*; do
filename=$(basename -- "$file")
extension="${filename##*.}"
filename="${filename%.*}"
cp -av "$file" "./artifacts/${CIRCLE_JOB}-${filename}-${git_describe}-${CIRCLE_BUILD_NUM}.${extension}"
done

- store_artifacts:
path: ./artifacts/
destination: artifacts



jobs:
firmware-bp-v4:
<<: *shared
environment:
<<: *shared_environment
build_config: BusPirate_v4
project_dir: ./Firmware/busPirate.X

firmware-bp-v3:
<<: *shared
environment:
<<: *shared_environment
build_config: BusPirate_v3
project_dir: ./Firmware/busPirate.X

boot-bp-v4:
<<: *shared
environment:
<<: *shared_environment
build_config: default
project_dir: ./Bootloaders/BPv4-bootloader/firmware-v1/bpv4-bootloader.X

boot-bp-v3:
<<: *shared
environment:
<<: *shared_environment
build_config: default
project_dir: ./Bootloaders/BPv3-bootloader/firmware-v4.5/ds30loader.X

workflows:
version: 2
build:
jobs:
- firmware-bp-v4
- firmware-bp-v3
- boot-bp-v4
- boot-bp-v3

2 changes: 2 additions & 0 deletions .circleci/mplabx.envs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mplabx_version='5.10'
mplabx_tar_sha256='44da76b8f3f64876a427a474e17ce398f3af42319694acdcc8a7587e2be7337c'
2 changes: 2 additions & 0 deletions .circleci/xc16.envs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
xc16_version='1.36B'
xc16_inst_sha256='37c1d9bd53d65556f87482e20bd5384d6f5ffa855123f7f8c65fd02b811849e6'
49 changes: 9 additions & 40 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,43 +1,12 @@
/Bootloaders/BPv3-bootloader/firmware-v4.5/ds30loader.X/dist/default/
/Bootloaders/BPv3-bootloader/firmware-v4.5/ds30loader.X/nbproject/private/
/Bootloaders/BPv4-bootloader/firmware-v1/bpv4-bootloader.X/build/default/
/Bootloaders/BPv4-bootloader/firmware-v1/bpv4-bootloader.X/dist/default/
/Bootloaders/BPv4-bootloader/firmware-v1/bpv4-bootloader.X/nbproject/Makefile-default.mk
/Bootloaders/BPv4-bootloader/firmware-v1/bpv4-bootloader.X/nbproject/Makefile-genesis.properties
/Bootloaders/BPv4-bootloader/firmware-v1/bpv4-bootloader.X/nbproject/Makefile-impl.mk
/Bootloaders/BPv4-bootloader/firmware-v1/bpv4-bootloader.X/nbproject/Makefile-local-default.mk
/Bootloaders/BPv4-bootloader/firmware-v1/bpv4-bootloader.X/nbproject/Makefile-variables.mk
/Bootloaders/BPv4-bootloader/firmware-v1/bpv4-bootloader.X/nbproject/Package-default.bash
/Bootloaders/BPv4-bootloader/firmware-v1/bpv4-bootloader.X/nbproject/private/
/Firmware-Alternates/ADC2UART/ADC2UART.X/build/default/
/Firmware-Alternates/ADC2UART/ADC2UART.X/dist/default/
/Firmware-Alternates/ADC2UART/ADC2UART.X/nbproject/private/
/Firmware-Alternates/Blink_MODE_LED/Blink_MODE_LED.X/dist/default/
/Firmware-Alternates/Blink_MODE_LED/Blink_MODE_LED.X/nbproject/private/
/Firmware-Alternates/BusPirateADCDemo/Bus Pirate ADC Demo.X/nbproject/private/
/Firmware-Alternates/BusPirateUARTDEMOTEST/UARTdemo.X/nbproject/private/
/Firmware-Alternates/firmware-STK500v2/BusPirate-stk500.X/build/default/
/Firmware-Alternates/firmware-STK500v2/BusPirate-stk500.X/dist/default/
/Firmware-Alternates/firmware-STK500v2/BusPirate-stk500.X/nbproject/private/
# MPLAB X
**/*.X/build/
**/*.X/debug/
**/*.X/dist/
**/*.X/nbproject/Makefile*
**/*.X/nbproject/Package-*.bash
**/*.X/nbproject/private/


/Firmware/Documentation/
/Firmware/busPirate.X/*.[is]
/Firmware/busPirate.X/*.map
/Firmware/busPirate.X/build/BusPirate_v3/
/Firmware/busPirate.X/build/BusPirate_v4/
/Firmware/busPirate.X/build/default/
/Firmware/busPirate.X/debug/
/Firmware/busPirate.X/dist/
/Firmware/busPirate.X/nbproject/Makefile-BusPirate_v3.mk
/Firmware/busPirate.X/nbproject/Makefile-BusPirate_v4.mk
/Firmware/busPirate.X/nbproject/Makefile-default.mk
/Firmware/busPirate.X/nbproject/Makefile-genesis.properties
/Firmware/busPirate.X/nbproject/Makefile-impl.mk
/Firmware/busPirate.X/nbproject/Makefile-local-BusPirate_v3.mk
/Firmware/busPirate.X/nbproject/Makefile-local-BusPirate_v4.mk
/Firmware/busPirate.X/nbproject/Makefile-local-default.mk
/Firmware/busPirate.X/nbproject/Makefile-variables.mk
/Firmware/busPirate.X/nbproject/Package-BusPirate_v3.bash
/Firmware/busPirate.X/nbproject/Package-BusPirate_v4.bash
/Firmware/busPirate.X/nbproject/Package-default.bash
/Firmware/busPirate.X/nbproject/private/
/Bootloaders/BPv3-bootloader/firmware-v4.5/ds30loader.X/build/default/
4 changes: 3 additions & 1 deletion Firmware/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
#include "messages.h"
#include "types.h"

#include "bp-version.h"

/**
* @brief Firmware version string, used at startup and for the 'i' command.
*/
#define BP_FIRMWARE_STRING "Community Firmware v7.1 - goo.gl/gCzQnW "
#define BP_FIRMWARE_STRING "Community Firmware " BP_GIT_VERSION_STRING " - goo.gl/gCzQnW "

/**
* @brief Current mode configuration settings structure.
Expand Down
29 changes: 25 additions & 4 deletions Firmware/busPirate.X/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,38 @@
# NOCDDL


# Environment
MKDIR=mkdir
# Environment
ifeq ($(OS),Windows_NT)
MKDIR=gnumkdir
else
MKDIR=mkdir
endif
CP=cp
CCADMIN=CCadmin
RANLIB=ranlib

# This will automatically pick the .bat-file on Windows.
GENERATE_VERSION_HEADER=../../scripts/generate-version-header
# CND_BUILDDIR is not used at all, "build" is hardcoded in generated Makefiles.
# Use our own variable BUILD_DIR instead.
BUILD_DIR=build
BP_VERSION_H=$(BUILD_DIR)/bp-version.h
# BUILD_DIR is added to include path in MPLAB X project file.

# build
build: .build-post

.build-pre:
# Add your pre 'build' code here...

ifeq ($(OS),Windows_NT)
windows-workaround: clean
@echo Had to clean because of Windows-only bug: https://www.microchip.com/forums/m1061336.aspx
else
windows-workaround:
endif

.build-pre: windows-workaround
$(MKDIR) -p $(BUILD_DIR)
$(GENERATE_VERSION_HEADER) $(BP_VERSION_H)

.build-post: .build-impl
# Add your post 'build' code here...
Expand All @@ -65,6 +85,7 @@ clean: .clean-post

.clean-pre:
# Add your pre 'clean' code here...
rm -f $(BP_VERSION_H)

.clean-post: .clean-impl
# Add your post 'clean' code here...
Expand Down
4 changes: 2 additions & 2 deletions Firmware/busPirate.X/nbproject/configurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
<property key="warn-section-align" value="true"/>
</C30-LD>
<C30Global>
<property key="common-include-directories" value=""/>
<property key="common-include-directories" value="build"/>
<property key="dual-boot-partition" value="0"/>
<property key="fast-math" value="false"/>
<property key="generic-16-bit" value="false"/>
Expand Down Expand Up @@ -952,7 +952,7 @@
<property key="warn-section-align" value="true"/>
</C30-LD>
<C30Global>
<property key="common-include-directories" value=""/>
<property key="common-include-directories" value="build"/>
<property key="dual-boot-partition" value="0"/>
<property key="fast-math" value="false"/>
<property key="generic-16-bit" value="false"/>
Expand Down
32 changes: 32 additions & 0 deletions scripts/generate-version-header
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh -eu
if [ $# -ne 1 ]; then
echo "Usage: $0 <output-filename>" >&2
exit 1
fi


output_file="$1"
output_file_tmp="$(mktemp)"
trap finish EXIT

finish() {
rm -f "$output_file_tmp"
}

version="$(git describe --tags --always --dirty)"

cat > "$output_file_tmp" <<HEREDOC
/**
* @brief Version string generated using git describe, @see BP_FIRMWARE_STRING
*/
#define BP_GIT_VERSION_STRING "$version"

HEREDOC

# Only update file if it has changed (avoids unneccessary rebuilds)
if ! cmp -s "$output_file" "$output_file_tmp"; then
mv -f "$output_file_tmp" "$output_file"
echo "Updated Git version string in $output_file: $version."
else
echo "No update needed for Git version string in $output_file: $version"
fi
36 changes: 36 additions & 0 deletions scripts/generate-version-header.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@echo off
if "%1" == "" (
echo "Usage: %0 <output-filename>" 1>&2
exit 1
)

set output_file=%1
rem Accept forward slashes as directory separator for better portability.
set "output_file=%output_file:/=\%"
set output_file_tmp=%output_file%.tmp

for /f %%i in ('git describe --tags --always --dirty') do set version=%%i
set e=%ERRORLEVEL%
if "%version%" == "" (
echo Failed to get version info via git. 1>&2
echo Ensure git is in path and project is cloned by git. 1>&2
exit %e%
)

echo /**>%output_file_tmp%
echo * @brief Version string generated using git describe, @see BP_FIRMWARE_STRING>>%output_file_tmp%
echo */>>%output_file_tmp%
echo #define BP_GIT_VERSION_STRING "%version%">>%output_file_tmp%


rem Only update file if it has changed (avoids unneccessary rebuilds)
fc /b %output_file% %output_file_tmp% > NUL
IF %ERRORLEVEL% NEQ 0 (
copy %output_file_tmp% %output_file%
echo Updated Git version string in %output_file%: %version%.
) else (
echo No update needed for Git version string in %output_file%: %version%.
)

rem Cleanup
del %output_file_tmp% > NUL