mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 03:15:37 +00:00
21 lines
1.1 KiB
Bash
Executable File
21 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
APP="$(basename "$PWD")"
|
|
APP_NAME="Triple VFO"
|
|
APP_VER="1.0"
|
|
APP_VMA=${APP_VMA:-0x20000280}
|
|
OUT="${APP_NAME// /}"
|
|
CC=/opt/toolchain/bin/arm-none-eabi-gcc
|
|
OBJCOPY=/opt/toolchain/bin/arm-none-eabi-objcopy
|
|
command -v arm-none-eabi-gcc >/dev/null 2>&1 && { CC=arm-none-eabi-gcc; OBJCOPY=arm-none-eabi-objcopy; }
|
|
CFLAGS="-mcpu=cortex-m0plus -mthumb -Os -std=gnu11 -ffreestanding -fno-builtin -fno-common -fomit-frame-pointer -ffunction-sections -fdata-sections -Wall -Wextra"
|
|
LDFLAGS="-nostdlib -nostartfiles -T app.ld -Wl,--defsym,APP_VMA=${APP_VMA} -Wl,--gc-sections -Wl,-Map=${APP}.map -Wl,--build-id=none -Wl,--no-warn-rwx-segments"
|
|
rm -f ./*.app ./*.elf ./*.bin
|
|
"$CC" $CFLAGS $LDFLAGS "${APP}_app.c" -lgcc -o "${APP}.elf"
|
|
"$OBJCOPY" -O binary "${APP}.elf" "${APP}.bin"
|
|
python3 ../pack_app.py "${APP}.bin" "${OUT}.app" --name "$APP_NAME" --ver "$APP_VER" --vma "${APP_VMA}" >/dev/null
|
|
BYTES=$(wc -c < "${APP}.bin")
|
|
test "$BYTES" -le 4096
|
|
printf ' ✅ %-13s %4d B (%d%% of 4 KiB) -> %s.app\n' \
|
|
"$APP_NAME" "$BYTES" "$(( BYTES * 100 / 4096 ))" "$OUT"
|