Skip to content

Commit

Permalink
build: add Docker support for building the firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
leoli0605 committed Feb 21, 2024
1 parent 5d3f2be commit 2c45932
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,30 @@ $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(BUILD_DIR):
mkdir $@

#######################################
# docker build
#######################################
docker:
ifeq ($(OS),Windows_NT)
@powershell -Command "$$IMAGE_NAME='jafee201153/arm-none-eabi-gcc:13.2.Rel1-ubuntu-20.04'; \
$$DOCKER_RUN='docker run -it --rm -v $${PWD}:/share $$IMAGE_NAME'; \
$$imageExists = docker images -q $$IMAGE_NAME; \
if (-not $$imageExists) { \
Write-Host 'Image $$IMAGE_NAME not found locally, pulling...'; \
docker pull $$IMAGE_NAME; \
}; \
$$DOCKER_CMD = $$DOCKER_RUN + ' sh -c \"cd /share && make clean && make\"'; \
Invoke-Expression $$DOCKER_CMD"
else
@IMAGE_NAME="jafee201153/arm-none-eabi-gcc:13.2.Rel1-ubuntu-20.04"; \
DOCKER_RUN="docker run -it --rm -v $${PWD}:/share $$IMAGE_NAME"; \
if [ -z "$$(docker images -q $$IMAGE_NAME)" ]; then \
echo "Image $$IMAGE_NAME not found locally, pulling..."; \
docker pull $$IMAGE_NAME; \
fi; \
$$DOCKER_RUN sh -c "cd /share && make clean && make"
endif

#######################################
# clean up
#######################################
Expand All @@ -256,8 +280,11 @@ rebuild: clean all
#######################################
# upgrade
#######################################
upgrade:
update:
git submodule update --init --recursive

upgrade:
make update
# ifeq ($(OS),Windows_NT)
# copy $(subst /,\,$(CURDIR))\assets\utility_config.h $(subst /,\,$(CURDIR))\Source\UtilityClang\utility_config.h
# else
Expand Down
6 changes: 6 additions & 0 deletions README_.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ To build the firmware using Makefile, run:
make clean && make
```

or build the firmware using Docker:

``` bash
make update && make docker
```

## Flashing the Firmware

We use [pyOCD](https://pypi.org/project/pyocd/) for cross-platform
Expand Down

0 comments on commit 2c45932

Please sign in to comment.