commit 95f4961875530115c45cd9ce496de1fb179d8cb0 from: witcher date: Mon Mar 13 16:41:08 2023 UTC build: Introduce Makefile commit - b54c50eebbe1e0ae36993107d6685e1d54c976bb commit + 95f4961875530115c45cd9ce496de1fb179d8cb0 blob - 567609b1234a9b8806c5a05da6c866e480aa148d blob + b34069220d755e0fbb322f6cf860bf0d65da7196 --- .gitignore +++ .gitignore @@ -1 +1,2 @@ build/ +.build/ blob - e37535900c8c4e1ea4d11f5fbd8f8e76c5d7d3bb blob + 169da40068e936b0db07ce683065e61b1bf8636a --- README.md +++ README.md @@ -12,11 +12,33 @@ The only changes made here are to the `prj.conf` to al ## Compiling + Install the [Zephyr toolchain](https://docs.zephyrproject.org/latest/develop/getting_started/index.html). -After compiling, the output files will be in `build/zephyr/` in various formats. +After compiling, the output files will be in `$(OUTDIR)/zephyr/` in various +formats. +### Using the Makefile + +To compile the image using the Makefile use + +```sh +make +``` + +Flashing is done with + +```sh +make flash FLASH_PORT=/path/to/device +``` + +where `/path/to/device` is the path the device that should be flashed can be +accessed from, e.g. `/dev/ttyACM2`. + +The variable `FLASH_PORT` can also be set in `config.mk`. If set it doesn't need +to be given as a parameter anymore. + ### Using CMake/Ninja Simply invoke the following commands: blob - /dev/null blob + 40f4e01b06803011196107429d86aaa3d9bbe952 (mode 644) --- /dev/null +++ Makefile @@ -0,0 +1,30 @@ +.POSIX: + +include config.mk + +all: generate-zip + +build: + cmake -B$(OUTDIR) -GNinja -DBOARD=nrf52840dongle_nrf52840 . + ninja -C$(OUTDIR) + +generate-zip: build + nrfutil pkg generate \ + --hw-version 52 \ + --sd-req=0x00 \ + --application $(OUTDIR)/zephyr/zephyr.hex \ + --application-version 1 \ + $(OUTDIR)/hci_usb.zip + +flash: generate-zip +ifndef FLASH_PORT + $(error Variable "FLASH_PORT" has to be set) +endif + nrfutil dfu usb-serial \ + --package $(OUTDIR)/hci_usb.zip \ + -p $(FLASH_PORT) + +clean: + @rm -rf $(OUTDIR) + +.PHONY: all build generate-zip flash clean blob - /dev/null blob + 11e5753f7b259079e0b67623f0cf12017e7d84df (mode 644) --- /dev/null +++ config.mk @@ -0,0 +1,3 @@ +OUTDIR=.build +# the port of the device that should be flashed goes here +#FLASH_PORT=/dev/ttyACM2