Skip to content

Commit

Permalink
Makefile enhancements to optimize local workflows (KinesisCorporation…
Browse files Browse the repository at this point in the history
…#363)

- Enhance the Makefile to enable firmware building exclusively for the left side.

To modify the keymap, flashing only the left side's firmware suffices.

This change facilitates the creation of firmware for the left side only,
thereby expediting the build process.

Usage: make left

This update maintains existing functionality. Without specifying the
left target, firmware for both halves will be generated.

- Add separate make targets to clean firmware and docker image

Add targets clean_firmware and clean_image independently while maintaing clean to run both

- Ensure files modified by the build process are reset at the end

The current build process dynamically generates the content of the version macro
in config/version.dtsi to enable users to print out the precise version and commit
the firmware was built on via a keybinding on the keymap.

This change ensurs that the changes to this macro file are reset at the end of the
build process to ensure it isn't shown as modified and added to keymap commit changes.
  • Loading branch information
huber-th authored and cr0rc committed Feb 25, 2024
1 parent 963201d commit c03d1e7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Here's all notable changes and commits to both the configuration repo and the ba
Many thanks to all those who have submitted issues and pull requests to make this firmware better!
## Config repo

2/2/2024 - Makefile enhancements (build left side firmware only, separate clean targets for firmware and docker, reset of version.dtsi after build) [#363](https://github.com/KinesisCorporation/Adv360-Pro-ZMK/pull/363)

1/16/2024 - Change the makefile to fis WSL2 compatibility [#335](https://github.com/KinesisCorporation/Adv360-Pro-ZMK/pull/335)

1/14/2024 - Update base ZMK, change KConfig attributes to support, Enable experimental BLE features for improved stability [#326](https://github.com/KinesisCorporation/Adv360-Pro-ZMK/pull/326)
Expand Down
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SELINUX1 := :z
SELINUX2 := ,z
endif

.PHONY: all clean
.PHONY: all left clean_firmware clean_image clean

all:
$(shell bin/get_version.sh >> /dev/null)
Expand All @@ -20,8 +20,26 @@ all:
-v $(PWD)/config:/app/config:ro$(SELINUX2) \
-e TIMESTAMP=$(TIMESTAMP) \
-e COMMIT=$(COMMIT) \
-e BUILD_RIGHT=true \
zmk
$(shell git checkout config/version.dtsi)

clean:
left:
$(shell bin/get_version.sh >> /dev/null)
$(DOCKER) build --tag zmk --file Dockerfile .
$(DOCKER) run --rm -it --name zmk \
-v $(PWD)/firmware:/app/firmware$(SELINUX1) \
-v $(PWD)/config:/app/config:ro$(SELINUX2) \
-e TIMESTAMP=$(TIMESTAMP) \
-e COMMIT=$(COMMIT) \
-e BUILD_RIGHT=false \
zmk
$(shell git checkout config/version.dtsi)

clean_firmware:
rm -f firmware/*.uf2

clean_image:
$(DOCKER) image rm zmk docker.io/zmkfirmware/zmk-build-arm:stable

clean: clean_firmware clean_image
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,33 @@ Certain ZMK features (e.g. combos) require knowing the exact key positions in th
* Install make using `sudo apt-get install make` inside the WSL2 instance.
* The repository can be cloned directly into the WSL2 instance or accessed through the C: mount point WSL provides by default (`/mnt/c/path-to-repo`).

### Build firmware
#### macOS specific

On macOS [brew](https://brew.sh) can be used to install the required components.

* docker
* [colima](https://github.com/abiosoft/colima) can be used as the docker engine

```shell
brew install docker colima
colima start
```
> Note: On Apple Silicon (ARM based) systems you need to make sure to start colima with the correct architecture for the container being used.
> ```
> colima start --arch x86_64
> ```
1. Execute `make`.
2. Check the `firmware` directory for the latest firmware build.
### Build firmware locally
1. Execute `make` to build firmware for both halves or `make left` to only build firmware for the left hand side.
2. Check the `firmware` directory for the latest firmware build. The first part of the filename is the timestamp when the firmware was built.
### Cleanup
The built docker container and compiled firmware files can be deleted with `make clean`. This might be necessary if you updated your fork from V2.0 to V3.0 and are encountering build failures.
The built docker container and compiled firmware files can be deleted with `make clean`. This might be necessary if you updated your fork from V2.0 to V3.0 and are encountering build failures.
Creating the docker container takes some time. Therefore `make clean_firmware` can be used to only clean firmware without removing the docker container. Similarly `make clean_image` can be used to remove the docker container without removing compiled firmware files.
## Flashing firmware
Expand Down Expand Up @@ -116,4 +135,4 @@ Further support resources can be found on Kinesis.com:
* https://kinesis-ergo.com/support/kb360pro/#manuals
In the event of a hardware issue it may be necessary to open a support ticket directly with Kinesis as opposed to a GitHub issue in this repository.
* https://kinesis-ergo.com/support/kb360pro/#ticket
* https://kinesis-ergo.com/support/kb360pro/#ticket
16 changes: 11 additions & 5 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ COMMIT="${COMMIT:-$(echo xxxxxx)}"
west build -s zmk/app -d build/left -b adv360_left -- -DZMK_CONFIG="${PWD}/config"
# Adv360 Left Kconfig file
grep -vE '(^#|^$)' build/left/zephyr/.config
# West Build (right)
west build -s zmk/app -d build/right -b adv360_right -- -DZMK_CONFIG="${PWD}/config"
# Adv360 Right Kconfig file
grep -vE '(^#|^$)' build/right/zephyr/.config
# Rename zmk.uf2
cp build/left/zephyr/zmk.uf2 "./firmware/${TIMESTAMP}-${COMMIT}-left.uf2" && cp build/right/zephyr/zmk.uf2 "./firmware/${TIMESTAMP}-${COMMIT}-right.uf2"
cp build/left/zephyr/zmk.uf2 "./firmware/${TIMESTAMP}-${COMMIT}-left.uf2"

# Build right side if selected
if [ "${BUILD_RIGHT}" = true ]; then
# West Build (right)
west build -s zmk/app -d build/right -b adv360_right -- -DZMK_CONFIG="${PWD}/config"
# Adv360 Right Kconfig file
grep -vE '(^#|^$)' build/right/zephyr/.config
# Rename zmk.uf2
cp build/right/zephyr/zmk.uf2 "./firmware/${TIMESTAMP}-${COMMIT}-right.uf2"
fi

0 comments on commit c03d1e7

Please sign in to comment.