Skip to content

Commit

Permalink
🔀 Merge branch 'yann/feature/rename-release-output' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Jan 11, 2023
2 parents 8d2680f + 624a69e commit 1fe3e43
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 69 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ jobs:
name: bootloader_os_firmware
retention-days: 7
path: |
_release/firmware.hex
_release/application-signed.bin
_release/Firmware-*.hex
_release/LekaOS-*.bin
45 changes: 45 additions & 0 deletions tools/firmware/build_application_os.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# ? application_os: "application" is the term used by MCUBoot, "os" is the term used by Leka

mkdir -p _tmp
mkdir -p _release

# Variables
RECOMPILE_APPLICATION_OS="$1"

APPLICATION_OS_HEX_SOURCE="_build/LEKA_V1_2_DEV/app/os/LekaOS.hex"
APPLICATION_OS_HEX_DESTINATION="$2"

APPLICATION_OS_VERSION="$3"
APPLICATION_OS_HEX="_tmp/LekaOS.hex"
APPLICATION_OS_SIGNED_HEX=$APPLICATION_OS_HEX_DESTINATION
APPLICATION_OS_SIGNED_BIN="_release/LekaOS-$APPLICATION_OS_VERSION.bin"

if [ -z "$APPLICATION_OS_VERSION" ]; then
echo "APPLICATION_OS_VERSION is unset"
exit 1
fi

if [ -z "$APPLICATION_OS_HEX_DESTINATION" ]; then
echo "APPLICATION_OS_HEX_DESTINATION is unset"
exit 1
fi

# Compile application_os
if [ "$RECOMPILE_APPLICATION_OS" = "true" ];
then
make deep_clean
make config BUILD_TARGETS_TO_USE_WITH_BOOTLOADER=ON
fi;

make

# Get application_os binary
cp $APPLICATION_OS_HEX_SOURCE $APPLICATION_OS_HEX

# Sign application_os with private key
imgtool sign -k signing-keys.pem --align 4 -v $APPLICATION_OS_VERSION --header-size 4096 --pad-header -S 0x180000 $APPLICATION_OS_HEX $APPLICATION_OS_SIGNED_HEX

# Convert in binary
arm-none-eabi-objcopy -I ihex -O binary $APPLICATION_OS_SIGNED_HEX $APPLICATION_OS_SIGNED_BIN
10 changes: 6 additions & 4 deletions tools/firmware/build_bootloader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

# Variables
BOOTLOADER_HEX_SOURCE="_build/LEKA_V1_2_DEV/app/bootloader/bootloader.hex"
BOOTLOADER_HEX_DEST="_tmp/bootloader.hex"
BOOTLOADER_HEX_DESTINATION="$1"

# Create dir
mkdir -p _tmp
if [ -z "$BOOTLOADER_HEX_DESTINATION" ]; then
echo "APPLICATION_HEX_SOURCE is unset"
exit 1
fi

# Compile bootloader
make deep_clean
make config
make bootloader

# Get bootloader binary
cp $BOOTLOADER_HEX_SOURCE $BOOTLOADER_HEX_DEST
cp $BOOTLOADER_HEX_SOURCE $BOOTLOADER_HEX_DESTINATION
38 changes: 24 additions & 14 deletions tools/firmware/build_firmware.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# ? application_os: "application" is the term used by MCUBoot, "os" is the term used by Leka

mkdir -p _tmp
mkdir -p _release

Expand All @@ -9,30 +11,38 @@ while getopts rv: flag
do
case "${flag}" in
r) RECOMPILE_BOOTLOADER="true";;
v) APPLICATION_VERSION=$OPTARG;;
v) APPLICATION_OS_VERSION=$OPTARG;;
esac
done

BOOTLOADER_HEX="_tmp/bootloader.hex"
if [ -z "$APPLICATION_OS_VERSION" ]; then
echo "APPLICATION_OS_VERSION is unset"
exit 1
fi

APPLICATION_HEX_SOURCE="_build/LEKA_V1_2_DEV/app/os/LekaOS.hex"
APPLICATION_SIGNED_HEX="_tmp/application-signed.hex"
BUILD_NUMBER=$(date +%s)
APPLICATION_OS_VERSION="$APPLICATION_OS_VERSION+$BUILD_NUMBER"

FIRMWARE_HEX="_release/firmware.hex"
FIRMWARE_RELEASE="_release/firmware.bin"
BOOTLOADER_HEX="_tmp/bootloader.hex"
APPLICATION_OS_HEX="_tmp/LekaOS-$APPLICATION_OS_VERSION.hex"

FIRMWARE_HEX="_release/Firmware-$APPLICATION_OS_VERSION.hex"
FIRMWARE_BIN="_release/Firmware-$APPLICATION_OS_VERSION.bin"

# Get bootloader
if [ "$RECOMPILE_BOOTLOADER" = "true" ];
then
echo "Build bootloader"
./tools/firmware/build_bootloader.sh
./tools/firmware/build_bootloader.sh $BOOTLOADER_HEX
fi;

# Get application
echo "Build application"
./tools/firmware/build_os.sh $RECOMPILE_BOOTLOADER $APPLICATION_HEX_SOURCE $APPLICATION_VERSION $APPLICATION_SIGNED_HEX
# Get application_os
echo "Build application_os"
./tools/firmware/build_application_os.sh $RECOMPILE_BOOTLOADER $APPLICATION_OS_HEX $APPLICATION_OS_VERSION

# Merge bootloader and application_os
echo "Merge bootloader & application_os"
hexmerge.py -o $FIRMWARE_HEX --no-start-addr $BOOTLOADER_HEX $APPLICATION_OS_HEX

# Merge bootloader and application
echo "Merge bootloader & applications"
hexmerge.py -o $FIRMWARE_HEX --no-start-addr $BOOTLOADER_HEX $APPLICATION_SIGNED_HEX
arm-none-eabi-objcopy -I ihex -O binary $FIRMWARE_HEX $FIRMWARE_RELEASE
# Convert in binary
arm-none-eabi-objcopy -I ihex -O binary $FIRMWARE_HEX $FIRMWARE_BIN
49 changes: 0 additions & 49 deletions tools/firmware/build_os.sh

This file was deleted.

0 comments on commit 1fe3e43

Please sign in to comment.