diff --git a/.gitignore b/.gitignore index eccc7bf..20aec1e 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,7 @@ zephcore/AUDIT_FINDINGS.md # Upstream tracking (local only) UPSTREAM_TRACKER.md WEST_UPDATE.md +/westchanges/ # Side projects (not part of main firmware) /doom/ diff --git a/zephcore/patches/zephyr/0003-lora-sx126x-native.patch b/zephcore/patches/zephyr/0003-lora-sx126x-native.patch index d3cb1e5..3a70acc 100644 --- a/zephcore/patches/zephyr/0003-lora-sx126x-native.patch +++ b/zephcore/patches/zephyr/0003-lora-sx126x-native.patch @@ -1,8 +1,8 @@ diff --git a/drivers/lora/native/sx126x/sx126x.c b/drivers/lora/native/sx126x/sx126x.c -index 7b0b67f89d5..0225ff4360d 100644 +index 30243ba5dc7..0ba41d05da0 100644 --- a/drivers/lora/native/sx126x/sx126x.c +++ b/drivers/lora/native/sx126x/sx126x.c -@@ -9,10 +9,19 @@ +@@ -10,10 +10,19 @@ #include #include "sx126x.h" @@ -22,7 +22,7 @@ index 7b0b67f89d5..0225ff4360d 100644 #define SX126X_REST_STATE \ (IS_ENABLED(CONFIG_LORA_SX126X_NATIVE_SLEEP) \ ? SX126X_STATE_SLEEP : SX126X_STATE_IDLE) -@@ -176,22 +185,10 @@ static int sx126x_calibrate_image(const struct device *dev, uint32_t freq) +@@ -177,22 +186,10 @@ static int sx126x_calibrate_image(const struct device *dev, uint32_t freq) { uint8_t buf[2]; @@ -49,7 +49,7 @@ index 7b0b67f89d5..0225ff4360d 100644 return sx126x_hal_write_cmd(dev, SX126X_CMD_CALIBRATE_IMAGE, buf, 2); } -@@ -221,6 +218,7 @@ static int sx126x_set_packet_params(const struct device *dev, +@@ -222,6 +219,7 @@ static int sx126x_set_packet_params(const struct device *dev, uint8_t invert_iq) { uint8_t buf[6]; @@ -57,7 +57,7 @@ index 7b0b67f89d5..0225ff4360d 100644 sys_put_be16(preamble_len, &buf[0]); buf[2] = header_type; -@@ -228,7 +226,31 @@ static int sx126x_set_packet_params(const struct device *dev, +@@ -229,7 +227,31 @@ static int sx126x_set_packet_params(const struct device *dev, buf[4] = crc_mode; buf[5] = invert_iq; @@ -90,7 +90,7 @@ index 7b0b67f89d5..0225ff4360d 100644 } static int sx126x_set_sync_word(const struct device *dev, bool public_network) -@@ -246,6 +268,13 @@ static int sx126x_set_rx_gain(const struct device *dev, bool boosted) +@@ -247,6 +269,13 @@ static int sx126x_set_rx_gain(const struct device *dev, bool boosted) { uint8_t val = boosted ? SX126X_RX_GAIN_BOOSTED : SX126X_RX_GAIN_POWER_SAVING; @@ -104,7 +104,7 @@ index 7b0b67f89d5..0225ff4360d 100644 return sx126x_hal_write_regs(dev, SX126X_REG_RX_GAIN, &val, 1); } -@@ -261,6 +290,7 @@ static int sx126x_set_tx(const struct device *dev, uint32_t timeout_ms) +@@ -262,6 +291,7 @@ static int sx126x_set_tx(const struct device *dev, uint32_t timeout_ms) static int sx126x_set_rx(const struct device *dev, uint32_t timeout_ms) { uint32_t timeout; @@ -112,7 +112,7 @@ index 7b0b67f89d5..0225ff4360d 100644 if (timeout_ms == 0) { timeout = SX126X_RX_TIMEOUT_CONTINUOUS; -@@ -271,7 +301,23 @@ static int sx126x_set_rx(const struct device *dev, uint32_t timeout_ms) +@@ -272,7 +302,23 @@ static int sx126x_set_rx(const struct device *dev, uint32_t timeout_ms) uint8_t buf[3]; sys_put_be24(timeout, buf); @@ -137,7 +137,7 @@ index 7b0b67f89d5..0225ff4360d 100644 } static int sx126x_get_rx_buffer_status(const struct device *dev, -@@ -295,7 +341,7 @@ static int sx126x_get_packet_status(const struct device *dev, +@@ -296,7 +342,7 @@ static int sx126x_get_packet_status(const struct device *dev, uint8_t buf[3]; int ret; @@ -146,7 +146,7 @@ index 7b0b67f89d5..0225ff4360d 100644 if (ret == 0) { /* RSSI is -value/2 dBm */ *rssi = -((int16_t)buf[0] >> 1); -@@ -366,6 +412,21 @@ static int sx126x_chip_init(const struct device *dev) +@@ -367,6 +413,21 @@ static int sx126x_chip_init(const struct device *dev) return ret; } @@ -168,7 +168,7 @@ index 7b0b67f89d5..0225ff4360d 100644 /* Set packet type to LoRa */ ret = sx126x_set_packet_type(dev, SX126X_PACKET_TYPE_LORA); if (ret < 0) { -@@ -397,7 +458,7 @@ static void sx126x_dio1_callback(const struct device *dev) +@@ -398,7 +459,7 @@ static void sx126x_dio1_callback(const struct device *dev) { struct sx126x_data *data = dev->data; @@ -177,7 +177,7 @@ index 7b0b67f89d5..0225ff4360d 100644 } static void sx126x_set_rf_path(const struct device *dev, bool enable, bool tx) -@@ -405,11 +466,70 @@ static void sx126x_set_rf_path(const struct device *dev, bool enable, bool tx) +@@ -406,7 +467,14 @@ static void sx126x_set_rf_path(const struct device *dev, bool enable, bool tx) const struct sx126x_hal_config *config = dev->config; sx126x_hal_set_antenna_enable(dev, enable); @@ -193,6 +193,9 @@ index 7b0b67f89d5..0225ff4360d 100644 sx126x_hal_set_rf_switch(dev, enable, tx); } } +@@ -455,6 +523,58 @@ static int sx126x_reconnect_rf_gpios(const struct device *dev) + } + #endif /* CONFIG_PM_DEVICE */ +/* ── Lightweight RX restart ─────────────────────────────────────────── */ + @@ -249,7 +252,7 @@ index 7b0b67f89d5..0225ff4360d 100644 static int sx126x_set_sleep(const struct device *dev) { struct sx126x_data *data = dev->data; -@@ -521,19 +641,23 @@ static void sx126x_handle_irq_rx_done(const struct device *dev, uint16_t irq_sta +@@ -566,19 +686,23 @@ static void sx126x_handle_irq_rx_done(const struct device *dev, uint16_t irq_sta /* Handle async callback or signal sync receiver */ if (data->rx_cb != NULL) { @@ -282,7 +285,7 @@ index 7b0b67f89d5..0225ff4360d 100644 } else { /* Sync mode */ sx126x_set_sleep(dev); -@@ -592,6 +716,25 @@ static void sx126x_irq_work_handler(struct k_work *work) +@@ -637,6 +761,25 @@ static void sx126x_irq_work_handler(struct k_work *work) sx126x_handle_irq_timeout(dev); } @@ -308,7 +311,7 @@ index 7b0b67f89d5..0225ff4360d 100644 /* Re-enable the DIO1 interrupt for the next event (unless sleeping) */ if (atomic_get(&data->state) != SX126X_REST_STATE) { sx126x_hal_dio1_irq_enable(dev); -@@ -653,6 +796,29 @@ static int sx126x_lora_config(const struct device *dev, +@@ -698,6 +841,29 @@ static int sx126x_lora_config(const struct device *dev, goto out; } @@ -338,7 +341,7 @@ index 7b0b67f89d5..0225ff4360d 100644 /* Set sync word */ ret = sx126x_set_sync_word(dev, config->public_network); if (ret < 0) { -@@ -676,6 +842,8 @@ out: +@@ -721,6 +887,8 @@ out: return ret; } @@ -347,7 +350,7 @@ index 7b0b67f89d5..0225ff4360d 100644 static int sx126x_lora_send_async(const struct device *dev, uint8_t *data_buf, uint32_t data_len, struct k_poll_signal *async) -@@ -707,6 +875,34 @@ static int sx126x_lora_send_async(const struct device *dev, +@@ -752,6 +920,34 @@ static int sx126x_lora_send_async(const struct device *dev, return ret; } @@ -382,7 +385,7 @@ index 7b0b67f89d5..0225ff4360d 100644 data->tx_async_signal = async; k_msgq_purge(&data->tx_msgq); -@@ -732,6 +928,29 @@ static int sx126x_lora_send_async(const struct device *dev, +@@ -777,6 +973,29 @@ static int sx126x_lora_send_async(const struct device *dev, /* Enable antenna and set TX path */ sx126x_set_rf_path(dev, true, true); @@ -412,7 +415,7 @@ index 7b0b67f89d5..0225ff4360d 100644 /* Start transmission with 10 second timeout */ ret = sx126x_set_tx(dev, 10000); if (ret < 0) { -@@ -902,6 +1121,7 @@ static int sx126x_lora_recv_async(const struct device *dev, +@@ -947,6 +1166,7 @@ static int sx126x_lora_recv_async(const struct device *dev, data->rx_cb = cb; data->rx_cb_user_data = user_data; @@ -420,7 +423,7 @@ index 7b0b67f89d5..0225ff4360d 100644 /* Set packet parameters */ ret = sx126x_set_packet_params(dev, -@@ -1038,14 +1258,407 @@ static int sx126x_lora_test_cw(const struct device *dev, uint32_t frequency, +@@ -1083,14 +1303,407 @@ static int sx126x_lora_test_cw(const struct device *dev, uint32_t frequency, return 0; } @@ -834,8 +837,8 @@ index 7b0b67f89d5..0225ff4360d 100644 + .test_cw = sx126x_lora_test_cw, }; - static int sx126x_init(const struct device *dev) -@@ -1060,9 +1673,18 @@ static int sx126x_init(const struct device *dev) + #ifdef CONFIG_PM_DEVICE +@@ -1121,9 +1734,18 @@ static int sx126x_init(const struct device *dev) k_msgq_init(&data->rx_msgq, (char *)&data->rx_result, sizeof(struct sx126x_rx_result), 1); k_work_init(&data->irq_work, sx126x_irq_work_handler); diff --git a/zephcore/west.yml b/zephcore/west.yml index ef1464b..0fa5596 100644 --- a/zephcore/west.yml +++ b/zephcore/west.yml @@ -10,7 +10,7 @@ manifest: path: modules/hal/espressif - name: zephyr remote: zephyrproject-rtos - revision: b104f826ca8e3a85cb205d2962189287f59d3174 + revision: ccfd5efa09f9fed814c1947edba2739544b3c901 import: true self: