diff --git a/.gitignore b/.gitignore index ffff840..6ee35a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ build/ .vscode/ - +tools/ +.cache/ +.west/ +.vscode/ +zephyr/ +modules/ +bootloader/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 96c8708..d363691 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,10 @@ cmake_minimum_required(VERSION 3.20.0) -set(BOARD adafruit_feather_nrf52840) +set(BOARD rpi_pico) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + project(passr) target_sources(app PRIVATE src/main.c) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c4c183f --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +.ONESHELL: + +TARGET=rpi_pico + +CMAKE_ZEPHYR_PATH=../zephyrproject/zephyr +CMAKE_ZEPHYR_COMMAND=west build +CMAKE_ZEPHYR_FLAGS=-b $(TARGET) + +all: flash + +compile: + $(CMAKE_ZEPHYR_COMMAND) $(CMAKE_ZEPHYR_FLAGS) + +# FIXME: This is entirely board specific, for example the pi pico will vibe differently +flash: + west flash + +clean: + rm -rf build/ + mkdir build diff --git a/README.md b/README.md new file mode 100644 index 0000000..78ad8a4 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Passr + +## Building + +Install Zephyr, the Zephyr SDK and West + +```sh +west init +west update +make build +``` + +The project is currently configured to run on a Pi Pico as my nrf development board is misbehaving + diff --git a/app.overlay b/app.overlay deleted file mode 100644 index e69de29..0000000 diff --git a/app.zip b/app.zip deleted file mode 100644 index d11b160..0000000 Binary files a/app.zip and /dev/null differ diff --git a/buildflash.sh b/buildflash.sh index 334db9f..8bc1e7a 100644 --- a/buildflash.sh +++ b/buildflash.sh @@ -1,3 +1,5 @@ west build -b adafruit_feather_nrf52840 . -nrfutil dfu genpkg --application build/zephyr/zephyr.hex --application-version 0xFF --dev-revision 0xFF --dev-type 0xFFFF --sd-req 0x81 feather_nrf52840_express_bootloader-0.7.0_s140_6.1.1.zip +# nrfutil dfu genpkg --application build/zephyr/zephyr.hex --application-version 0xFF --dev-revision 0xFF --dev-type 0xFFFF --sd-req 0x81 feather_nrf52840_express_bootloader-0.7.0_s140_6.1.1.zip # nrfutil dfu usb-serial -pkg app.zip -p ttyACM0 // DO NOT FUCKING DO THIS +# ./uf2conv.py build/zephyr/zephyr.hex -c -f 0xADA52840 +cp build/zephyr/zephyr.uf2 . diff --git a/feather_nrf52840_express_bootloader-0.7.0_s140_6.1.1.zip b/feather_bootloader/feather_bootloader.zip similarity index 100% rename from feather_nrf52840_express_bootloader-0.7.0_s140_6.1.1.zip rename to feather_bootloader/feather_bootloader.zip diff --git a/feather_bootloader/manifest.json b/feather_bootloader/manifest.json new file mode 100644 index 0000000..243b0e3 --- /dev/null +++ b/feather_bootloader/manifest.json @@ -0,0 +1,20 @@ +{ + "manifest": { + "dfu_version": 0.5, + "softdevice_bootloader": { + "bin_file": "sd_bl.bin", + "bl_size": 39000, + "dat_file": "sd_bl.dat", + "init_packet_data": { + "application_version": 4294967295, + "device_revision": 52840, + "device_type": 82, + "firmware_crc16": 40783, + "softdevice_req": [ + 65534 + ] + }, + "sd_size": 151016 + } + } +} \ No newline at end of file diff --git a/feather_bootloader/sd_bl.bin b/feather_bootloader/sd_bl.bin new file mode 100644 index 0000000..078abd2 Binary files /dev/null and b/feather_bootloader/sd_bl.bin differ diff --git a/feather_bootloader/sd_bl.dat b/feather_bootloader/sd_bl.dat new file mode 100644 index 0000000..31fa19d Binary files /dev/null and b/feather_bootloader/sd_bl.dat differ diff --git a/prj.conf b/prj.conf index 53f6453..ce800eb 100644 --- a/prj.conf +++ b/prj.conf @@ -1,3 +1,4 @@ +CONFIG_BUILD_OUTPUT_UF2=y CONFIG_GPIO=y # CONFIG_BT=y # CONFIG_BT_DEBUG_LOG=y diff --git a/src/main.c b/src/main.c index 0ac9b11..74cea2d 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ #define SLEEP_TIME_MS 1000 /* The devicetree node identifier for the "led0" alias. */ -#define LED0_NODE DT_ALIAS(led1) +#define LED0_NODE DT_ALIAS(led0) /* * A build error on this line means your board is unsupported. @@ -18,8 +18,7 @@ void main(void) { int ret; - if (!device_is_ready(led.port)) { - return; + while (!device_is_ready(led.port)) { } ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE); @@ -27,11 +26,13 @@ void main(void) return; } - while (1) { - ret = gpio_pin_toggle_dt(&led); - if (ret < 0) { - return; - } - k_msleep(SLEEP_TIME_MS); - } + gpio_pin_set_dt(&led, GPIO_OUTPUT_HIGH); + + while (1) { + ret = gpio_pin_toggle_dt(&led); + if (ret < 0) { + return; + } + k_msleep(SLEEP_TIME_MS); + } }