Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit b8883c9

Browse files
committed
Fix crash when pin ISR handler fires (i.e. LoRa TX done) during flash operation (i.e. ota_write() call)
I was seeing crashes with "Cache disabled but cached memory region accessed" as reason. The coredump showed one of the threads being inside spi_flash_op_block_func(), while the thread that caused the crash was an ISR (with LoRa's OnRadioTxDone handler somewhere in the stacktrace). The comment above spi_flash_op_block_func(), suggests that interrupt handlers must be in IRAM when being accessed during a flash operation. This change will put code/data that is accessed from ISR handlers into IRAM/DRAM to prevent the crash.
1 parent 7b83c6d commit b8883c9

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

esp32/lora/sx1272-board.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Maintainer: Miguel Luis and Gregory Cristian
1414
*/
1515

1616
#include "board.h"
17+
#include "esp_attr.h"
1718

1819
#if defined(LOPY) || defined (FIPY)
1920

@@ -25,7 +26,7 @@ Maintainer: Miguel Luis and Gregory Cristian
2526
/*!
2627
* Radio driver structure initialization
2728
*/
28-
const struct Radio_s Radio =
29+
DRAM_ATTR const struct Radio_s Radio =
2930
{
3031
SX1272Init,
3132
SX1272GetStatus,

esp32/lora/sx1276-board.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Maintainer: Miguel Luis and Gregory Cristian
1414
*/
1515

1616
#include "board.h"
17+
#include "esp_attr.h"
1718

1819
#if defined(LOPY4)
1920

@@ -24,7 +25,7 @@ Maintainer: Miguel Luis and Gregory Cristian
2425
/*!
2526
* Radio driver structure initialization
2627
*/
27-
const struct Radio_s Radio =
28+
DRAM_ATTR const struct Radio_s Radio =
2829
{
2930
SX1276Init,
3031
SX1276GetStatus,

lib/lora/mac/region/Region.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ bool RegionIsActive( LoRaMacRegion_t region )
629629
}
630630
}
631631

632-
PhyParam_t RegionGetPhyParam( LoRaMacRegion_t region, GetPhyParams_t* getPhy )
632+
IRAM_ATTR PhyParam_t RegionGetPhyParam( LoRaMacRegion_t region, GetPhyParams_t* getPhy )
633633
{
634634
PhyParam_t phyParam = { 0 };
635635
switch( region )

lib/lora/mac/region/RegionEU868.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static uint8_t CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t
184184
return nbEnabledChannels;
185185
}
186186

187-
PhyParam_t RegionEU868GetPhyParam( GetPhyParams_t* getPhy )
187+
IRAM_ATTR PhyParam_t RegionEU868GetPhyParam( GetPhyParams_t* getPhy )
188188
{
189189
PhyParam_t phyParam = { 0 };
190190

0 commit comments

Comments
 (0)