Skip to content

Commit a85dd49

Browse files
committed
Require version suffix for loaner firmware
Enforce the calendar-style OEFW-LNR banner and document the workflow so CHIRP recognises the build. closes #10
1 parent f81731b commit a85dd49

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

BUILDING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ When you already have the toolchain locally, you can mirror the Docker steps:
3232
```
3333
The above command produces `loaner-firmware.bin`. If Python with `crcmod` is installed you will also get `loaner-firmware.packed.bin`.
3434
If you omit `TARGET=...` the files are named `firmware.bin` / `firmware.packed.bin`.
35+
The build also exports `VERSION_SUFFIX` into the binaries. Set it explicitly (for example `make TARGET=loaner-firmware VERSION_SUFFIX=LNR24A5`) or create an `LNR*` git tag that the Makefile can discover. The build errors out if neither is present.
3536

3637
## Creating a Packed Binary Manually
3738
If the packed image was not produced automatically (for example on a minimal native setup), run:
3839
```sh
3940
python3 fw-pack.py loaner-firmware.bin LNR24.03 loaner-firmware.packed.bin
4041
```
4142

42-
- The second argument is the version tag embedded in both the welcome screen and the packed metadata.
43+
- The second argument is the version tag embedded in both the welcome screen and the packed metadata (mirror the `VERSION_SUFFIX` you build with).
4344
Keep it under 10 ASCII characters (the script rejects longer strings).
4445
- The packed image is required for PC loader flashing because it carries the metadata Quansheng's tool expects.
4546

@@ -60,13 +61,14 @@ Feature flags live near the top of `Makefile` as `ENABLE_*` macros. Adjust them
6061

6162
## Firmware Metadata and Releases
6263
- A successful build leaves you with `firmware.bin` (raw) and, when Python and `crcmod` are available, `firmware.packed.bin`. The packed image is what Quansheng's loader validates.
63-
- Use `fw-pack.py` to stamp a release tag into the packed image. The second argument becomes the welcome banner and metadata field:
64+
- Use `fw-pack.py` to stamp a release tag into the packed image. `make` already invokes the script with `VERSION_SUFFIX`, so the packed file inherits the same banner. To repack manually, pass the suffix yourself:
6465
```sh
65-
python3 fw-pack.py firmware.bin LNR24.03 loaner-firmware.packed.bin
66+
python3 fw-pack.py firmware.bin "${VERSION_SUFFIX}" loaner-firmware.packed.bin
6667
```
68+
- When building outside of Docker, set `VERSION_SUFFIX` in your environment once (for example `export VERSION_SUFFIX=LNR24A5`) so every command picks up the same value.
6769
- Change the `TARGET` on the `make` command line to tweak the output filenames without editing source, for example `make TARGET=loaner-firmware`.
6870
- Before publishing a release, spot-check the welcome screen on hardware to make sure the tag matches what you intend to share with end users.
69-
- Recommended version format: mirror other UV-K5 firmware projects (Quansheng's stock firmware ships as `v2.1.27`, Open Edition uses `OEFW-2023.09`). Tag milestones as `vYY.MM[.PATCH]` and feed a matching, <=10 character suffix to `fw-pack.py` (for example `LNR24.03`). CHIRP reads the full `*OEFW-LNR24.03` banner and treats it as a known build.
71+
- Recommended version format: mirror other UV-K5 firmware projects (Quansheng's stock firmware ships as `v2.1.27`, Open Edition uses `OEFW-2023.09`). Tag milestones as `vYY.MM[.PATCH]` and feed a matching, <=10 character `VERSION_SUFFIX` (for example `LNR24.03`). CHIRP reads the full `*OEFW-LNR24.03` banner and treats it as a known build.
7072

7173
## Branching and Release Flow
7274
1. Start work on a fresh branch instead of `main`:

Makefile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,30 @@ SIZE = arm-none-eabi-size
115115

116116
GIT_HASH := $(shell git rev-parse --short HEAD)
117117

118+
VERSION_SUFFIX ?= $(shell git describe --tags --match 'LNR*' --abbrev=0 2>/dev/null)
119+
120+
ifeq ($(MAKECMDGOALS),)
121+
ifeq ($(strip $(VERSION_SUFFIX)),)
122+
$(error VERSION_SUFFIX is required. Set VERSION_SUFFIX=LNR24A5 or create an LNR* tag.)
123+
endif
124+
else
125+
ifneq ($(filter-out clean,$(MAKECMDGOALS)),)
126+
ifeq ($(strip $(VERSION_SUFFIX)),)
127+
$(error VERSION_SUFFIX is required. Set VERSION_SUFFIX=LNR24A5 or create an LNR* tag.)
128+
endif
129+
endif
130+
endif
131+
132+
VERSION_SUFFIX_ESCAPED := $(subst ",\",$(VERSION_SUFFIX))
133+
118134
ASFLAGS = -c -mcpu=cortex-m0
119135
ifeq ($(ENABLE_OVERLAY),1)
120136
ASFLAGS += -DENABLE_OVERLAY
121137
endif
122138
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
123139
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
124140
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
141+
CFLAGS += -DVERSION_SUFFIX=\"$(VERSION_SUFFIX_ESCAPED)\"
125142
ifeq ($(ENABLE_AIRCOPY),1)
126143
CFLAGS += -DENABLE_AIRCOPY
127144
endif
@@ -165,8 +182,8 @@ DEPS = $(OBJS:.o=.d)
165182

166183
all: $(TARGET)
167184
$(OBJCOPY) -O binary $< $<.bin
168-
-python fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin
169-
-python3 fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin
185+
-python fw-pack.py $<.bin $(VERSION_SUFFIX) $<.packed.bin
186+
-python3 fw-pack.py $<.bin $(VERSION_SUFFIX) $<.packed.bin
170187
$(SIZE) $<
171188

172189
debug:
@@ -194,4 +211,3 @@ bsp/dp32g030/%.h: hardware/dp32g030/%.def
194211

195212
clean:
196213
rm -f $(TARGET).bin $(TARGET).packed.bin $(TARGET) $(OBJS) $(DEPS)
197-

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ This build assumes the channel plan lives on your ICS-205. To move that plan int
3636
5. Upload the plan with `Radio -> Upload To Radio`. After the radio reboots, rotate the channel knob and verify that the display shows the ICS-205 names.
3737
6. Repeat for each handset; the standard workflow keeps the handset in channel mode, so operators only see the memories you defined.
3838

39+
Use a CHIRP build that includes the UV-K5 loaner whitelist from PR #1414 (or any newer release); older builds will block uploads because they do not recognise the `OEFW-LNR` banner yet.
40+
3941
Tip: Keep a CHIRP image with the baseline loaner plan in source control so teams can diff changes before distributing updates.
4042

4143
## Flashing

main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@
3737
#include "ui/lock.h"
3838
#include "ui/welcome.h"
3939

40+
#ifndef VERSION_SUFFIX
41+
#define VERSION_SUFFIX GIT_HASH
42+
#endif
43+
4044
#if defined(ENABLE_UART)
41-
static const char Version[] = "UV-K5 Firmware, Open Edition, OEFW-"GIT_HASH"\r\n";
45+
static const char Version[] = "UV-K5 Firmware, Open Edition, OEFW-" VERSION_SUFFIX "\r\n";
4246
#endif
4347

4448
void _putchar(char c)
@@ -149,4 +153,3 @@ void Main(void)
149153
}
150154
}
151155
}
152-

version.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
const char Version[] = "OEFW-" GIT_HASH;
1+
#ifndef VERSION_SUFFIX
2+
#define VERSION_SUFFIX GIT_HASH
3+
#endif
24

5+
const char Version[] = "OEFW-" VERSION_SUFFIX;

0 commit comments

Comments
 (0)