Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,7 @@ itself; a human has to edit it too.

- **ARM GCC version matters.** CI pins exactly `12.3.Rel1`; 13.3.Rel1 also
compiles clean and is the closest verified-working version if you can't
get the exact CI-pinned one. GCC 15 is unverified here; Adafruit's scoped
`#pragma GCC diagnostic` for its `-Werror=array-bounds` false positive in
`lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.c`
(a fixed MBR-address read) is in.
get the exact CI-pinned one. GCC 15 is unverified here.
- **MeshCore/Ripple content has been deliberately removed** from the docs
(README, changelog) — this is Meshtastic's own branded fork now, not a
place to re-add other companion-firmware documentation. If you're
Expand Down
3 changes: 2 additions & 1 deletion lib/sdk11/components/ble/ble_services/ble_dfu/ble_dfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#include "ble_srv_common.h"
#include <stddef.h>
#include "sdk_common.h"
#include "ble_dfu_cfg.h"

#define MAX_DFU_PKT_LEN (247 - 3) // MTU - 3 bytes for ATT header /**< Maximum length (in bytes) of the DFU Packet characteristic. */
#define MAX_DFU_PKT_LEN (BLEGATT_ATT_MTU_MAX - 3) // MTU - 3 bytes for ATT header /**< Maximum length (in bytes) of the DFU Packet characteristic. */
#define PKT_START_DFU_PARAM_LEN 2 /**< Length (in bytes) of the parameters for Packet Start DFU Request. */
#define PKT_INIT_DFU_PARAM_LEN 2 /**< Length (in bytes) of the parameters for Packet Init DFU Request. */
#define PKT_RCPT_NOTIF_REQ_LEN 3 /**< Length (in bytes) of the Packet Receipt Notification Request. */
Expand Down
2 changes: 2 additions & 0 deletions lib/sdk11/components/libraries/bootloader_dfu/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ static void wait_for_events(void)
// uint32_t err_code = sd_app_evt_wait();
// APP_ERROR_CHECK(err_code);

// Firmware arms a 90 s watchdog that survives the soft reset into the bootloader;
// every path outside this loop must stay under it.
// Feed all Watchdog just in case application enable it
// WDT cannot be disabled once started. It even last through NVIC soft reset
if ( nrf_wdt_started_check(NRF_WDT) )
Expand Down
2 changes: 0 additions & 2 deletions lib/sdk11/components/libraries/bootloader_dfu/bootloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ uint32_t bootloader_dfu_sd_update_continue(void);
uint32_t bootloader_dfu_sd_update_finalize(void);


void bootloader_mbr_addrs_populate(void);

#endif // BOOTLOADER_H__

/**@} */
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,3 @@ void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_s

*pp_bootloader_settings = p_bootloader_settings;
}

void bootloader_mbr_addrs_populate(void)
{
#if defined(__GNUC__) && (__GNUC__ >= 12)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
if (*(const uint32_t *)MBR_BOOTLOADER_ADDR == 0xFFFFFFFF)
{
nrfx_nvmc_word_write(MBR_BOOTLOADER_ADDR, BOOTLOADER_REGION_START);
}

if (*(const uint32_t *)MBR_PARAM_PAGE_ADDR == 0xFFFFFFFF)
{
nrfx_nvmc_word_write(MBR_PARAM_PAGE_ADDR, BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS);
}
#if defined(__GNUC__) && (__GNUC__ >= 12)
#pragma GCC diagnostic pop
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
#include "dfu_ble_svc_internal.h"
#include "nrf_delay.h"
#include "sdk_common.h"


#define BLEGAP_EVENT_LENGTH 6
#define BLEGATT_ATT_MTU_MAX 247
enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
#include "ble_dfu_cfg.h"

#define DFU_REV_MAJOR 0x00 /** DFU Major revision number to be exposed. */
#define DFU_REV_MINOR 0x08 /** DFU Minor revision number to be exposed. */
Expand Down
8 changes: 8 additions & 0 deletions src/ble_dfu_cfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef BLE_DFU_CFG_H__
#define BLE_DFU_CFG_H__

#define BLEGAP_EVENT_LENGTH 6
#define BLEGATT_ATT_MTU_MAX 247
enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };

#endif // BLE_DFU_CFG_H__
19 changes: 3 additions & 16 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include "nrf_error.h"

#include "boards.h"
#include "ble_dfu_cfg.h"

#include "pstorage_platform.h"
#include "nrf_mbr.h"
Expand Down Expand Up @@ -121,13 +122,6 @@ extern void tusb_hal_nrf_power_event(uint32_t event);
// DFU_DBL_RESET magic is used to determined which mode is entered
#define APP_ASKS_FOR_SINGLE_TAP_RESET() (*((uint32_t*)(DFU_BANK_0_REGION_START + 0x200)) == 0x87eeb07c)

// These values must match the values in dfu_transport_ble.c and MAX_DFU_PKT_LEN should match BLEGATT_ATT_MTU_MAX - 3
#define BLEGAP_EVENT_LENGTH 6
#define BLEGATT_ATT_MTU_MAX 247
enum {
BLE_CONN_CFG_HIGH_BANDWIDTH = 1
};

//--------------------------------------------------------------------+
//
//--------------------------------------------------------------------+
Expand All @@ -136,6 +130,7 @@ uint32_t* dbl_reset_mem = ((uint32_t*) DFU_DBL_RESET_MEM);
// true if ble, false if serial
bool _ota_dfu = false;
bool _ota_connected = false;
// Set when the OTA session initializes the SoftDevice, so the app jump does not initialize it twice.
bool _sd_inited = false;

bool is_ota(void) {
Expand All @@ -157,11 +152,6 @@ static void mbr_init_sd(void) {
//
//--------------------------------------------------------------------+
int main(void) {
// Populate Boot Address and MBR Param into MBR if not already
// MBR_BOOTLOADER_ADDR/MBR_PARAM_PAGE_ADDR are used if available, else UICR registers are used
// Note: skip it for now since this will prevent us to change the size of bootloader in the future
// bootloader_mbr_addrs_populate();

// Save bootloader version to pre-defined register, retrieved by application
// TODO move to CF2
BOOTLOADER_VERSION_REGISTER = (MK_BOOTLOADER_VERSION);
Expand Down Expand Up @@ -228,9 +218,6 @@ int main(void) {
static void check_dfu_mode(void) {
uint32_t const gpregret = NRF_POWER->GPREGRET;

// SD is already Initialized in case of BOOTLOADER_DFU_OTA_MAGIC
_sd_inited = (gpregret == DFU_MAGIC_OTA_APPJUM);

// Start Bootloader in BLE OTA mode
_ota_dfu = (gpregret == DFU_MAGIC_OTA_APPJUM) || (gpregret == DFU_MAGIC_OTA_RESET);

Expand Down Expand Up @@ -335,7 +322,7 @@ static void check_dfu_mode(void) {
}
#endif
led_state(STATE_BLE_DISCONNECTED);
if (!_sd_inited) mbr_init_sd();
mbr_init_sd();
_sd_inited = true;
ble_stack_init();
} else {
Expand Down
Loading