mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
nRF52: Fix upgrade from older firmwares if saved code is in flash, reduce virtual pages to 2
This commit is contained in:
parent
7a22bfe3f0
commit
c3866e67e3
@ -39,6 +39,7 @@
|
||||
Increase max graphics size from 1023 to 32767
|
||||
Add Fat File System to boards with large Flash (ESP32)
|
||||
nRF52: Don't get stuck in 'HID Busy' state if a HID send failed
|
||||
nRF52: Fix upgrade from older firmwares if saved code is in flash, reduce virtual pages to 2
|
||||
|
||||
1v91 : Fix recent regression if no Boot Code defined at startup
|
||||
Fix handling of return of rejected promise within a promise
|
||||
|
||||
@ -56,7 +56,7 @@ chip = {
|
||||
'adc' : 1,
|
||||
'dac' : 0,
|
||||
'saved_code' : {
|
||||
'address' : ((117 - 3) * 4096), # Bootloader takes pages 120-127, FS takes 117-119
|
||||
'address' : ((118 - 3) * 4096), # Bootloader takes pages 120-127, FS takes 118-119
|
||||
'page_size' : 4096,
|
||||
'pages' : 3,
|
||||
'flash_available' : 512 - ((31 + 8 + 1 + 3)*4) # Softdevice uses 31 pages of flash, bootloader 8, FS 1, code 3. Each page is 4 kb.
|
||||
|
||||
@ -30,11 +30,11 @@ info = {
|
||||
'optimizeflags' : '-Os',
|
||||
'libraries' : [
|
||||
'BLUETOOTH',
|
||||
'NET',
|
||||
'GRAPHICS',
|
||||
'CRYPTO',
|
||||
'NFC',
|
||||
'NEOPIXEL'
|
||||
# 'NET',
|
||||
# 'GRAPHICS',
|
||||
# 'CRYPTO',
|
||||
# 'NFC',
|
||||
# 'NEOPIXEL'
|
||||
#'HASHLIB'
|
||||
#'FILESYSTEM'
|
||||
#'TLS'
|
||||
@ -59,7 +59,7 @@ chip = {
|
||||
'adc' : 1,
|
||||
'dac' : 0,
|
||||
'saved_code' : {
|
||||
'address' : ((117 - 3) * 4096), # Bootloader takes pages 120-127, FS takes 117-119
|
||||
'address' : ((118 - 3) * 4096), # Bootloader takes pages 120-127, FS takes 118-119
|
||||
'page_size' : 4096,
|
||||
'pages' : 3,
|
||||
'flash_available' : 512 - ((31 + 8 + 1 + 3)*4) # Softdevice uses 31 pages of flash, bootloader 8, FS 1, code 3. Each page is 4 kb.
|
||||
|
||||
@ -59,7 +59,7 @@ chip = {
|
||||
'adc' : 1,
|
||||
'dac' : 0,
|
||||
'saved_code' : {
|
||||
'address' : ((114 - 3) * 4096), # Bootloader takes pages 117-127 on RuuviTag, FS takes 114-116
|
||||
'address' : ((115 - 3) * 4096), # Bootloader takes pages 117-127 on RuuviTag, FS takes 115-116
|
||||
'page_size' : 4096,
|
||||
'pages' : 3,
|
||||
'flash_available' : 512 - ((31 + 11 + 1 + 3)*4) # Softdevice uses 31 pages of flash, bootloader 11, code 3. Each page is 4 kb.
|
||||
|
||||
@ -1866,7 +1866,7 @@
|
||||
// <i> @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes.
|
||||
|
||||
#ifndef FDS_VIRTUAL_PAGES
|
||||
#define FDS_VIRTUAL_PAGES 3
|
||||
#define FDS_VIRTUAL_PAGES 2
|
||||
#endif
|
||||
|
||||
// <o> FDS_VIRTUAL_PAGE_SIZE - The size of a virtual page of flash memory, expressed in number of 4-byte words.
|
||||
|
||||
@ -55,6 +55,9 @@ static pm_peer_id_t m_peer_id; /**< Device referenc
|
||||
static pm_peer_id_t m_whitelist_peers[BLE_GAP_WHITELIST_ADDR_MAX_COUNT]; /**< List of peers currently in the whitelist. */
|
||||
static uint32_t m_whitelist_peer_cnt; /**< Number of peers currently in the whitelist. */
|
||||
static bool m_is_wl_changed; /**< Indicates if the whitelist has been changed since last time it has been updated in the Peer Manager. */
|
||||
// needed for peer_manager_init so we can smoothly upgrade from pre 1v92 firmwares
|
||||
#include "fds_internal_defs.h"
|
||||
#include "fstorage_internal_defs.h"
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
@ -1163,6 +1166,18 @@ static void peer_manager_init(bool erase_bonds) {
|
||||
if (bleStatus & BLE_PM_INITIALISED) return;
|
||||
bleStatus |= BLE_PM_INITIALISED;
|
||||
|
||||
/* Deal with what happens if we had saved code in pages already.
|
||||
This happens if we had a pre-1v92 firmware with saved code
|
||||
and then updated to something with peer manager so the pages
|
||||
got swapped around */
|
||||
uint32_t *magicWord = ((uint32_t *)FS_PAGE_END_ADDR)-1;
|
||||
if (FLASH_MAGIC == *magicWord) {
|
||||
int i;
|
||||
for (i=1;i<=FDS_PHY_PAGES;i++)
|
||||
jshFlashErasePage(FS_PAGE_END_ADDR - i*FS_PAGE_SIZE);
|
||||
}
|
||||
|
||||
|
||||
ble_gap_sec_params_t sec_param;
|
||||
ret_code_t err_code;
|
||||
|
||||
@ -1483,7 +1498,6 @@ void jsble_advertising_stop() {
|
||||
|
||||
/** Initialise the BLE stack */
|
||||
void jsble_init() {
|
||||
|
||||
ble_stack_init();
|
||||
#if PEER_MANAGER_ENABLED
|
||||
peer_manager_init(true /*erase_bonds*/);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user