@@ -196,17 +196,17 @@ extern void Cache_Read_Disable(void);
196
196
extern void Cache_Read_Enable (uint8_t map, uint8_t p, uint8_t v);
197
197
#endif // #if (MMU_ICACHE_SIZE == 0x4000)
198
198
199
- #if 1 // New experimental code
200
199
/*
201
200
* This wrapper is for running code early from IROM (flash) before the SDK
202
201
* starts. Since the NONOS SDK will do a full and proper flash device init for
203
202
* speed and mode, we only do a minimum to make ICACHE functional, keeping IRAM
204
203
* use to a minimum. After the SDK has started, this function is not needed and
205
- * should not be called.
204
+ * must not be called.
206
205
*/
207
206
void IRAM_ATTR mmu_wrap_irom_fn (void (*fn)(void )) {
208
- // ?? If the problem is not resolved add this line back.
209
- // ?? Cache_Read_Disable();
207
+ // Cache Read must be disabled. This is always the case on entry when called
208
+ // from the right context.
209
+ // Cache_Read_Disable();
210
210
211
211
// The SPI_CS_SETUP parameter has been observed set by RTOS SDK and NONOS SDK
212
212
// as part of flash init/configuration. It may be necessary for some flash
@@ -218,28 +218,20 @@ void IRAM_ATTR mmu_wrap_irom_fn(void (*fn)(void)) {
218
218
// defaults to 1.
219
219
SPI0U |= SPIUCSSETUP; // SPI_CS_SETUP or BIT5
220
220
221
- // I am not sure what this is does. It appears to be the key function called
222
- // from `fix_cache_bug` in the NONOS SDK - Will this help PUYA Flash work?
223
- // It appears to do some, lowlevel undocumented register maniplation and
224
- // device specific init based on OTP CHIPID model bits.
221
+ // phy_get_bb_evm is the key function, called from fix_cache_bug in the NONOS
222
+ // SDK. This addition resolves the PUYA Flash issue with exception 0, when
223
+ // early Cache_Read_Enable is used.
225
224
extern uint32_t phy_get_bb_evm (void ); // undocumented
226
225
phy_get_bb_evm ();
227
226
228
- // For early Cache_Read_Enable only do ICACHE_SIZE_16. The affected registers
229
- // are fully restored when Cache_Read_Disable is called . With ICACHE_SIZE_32
230
- // one bit is missed at disable . Leave the full commitment to ICACHE_SIZE_32
231
- // for the NONOS SDK.
227
+ // For early Cache_Read_Enable, only do ICACHE_SIZE_16. With this option,
228
+ // Cache_Read_Disable will fully restore the original register states . With
229
+ // ICACHE_SIZE_32, one bit is missed when disabling . Leave the full access
230
+ // calls for the NONOS SDK.
232
231
// This only works with image slice 0, which is all we do presently.
233
232
Cache_Read_Enable (0 , 0 , ICACHE_SIZE_16);
234
233
fn ();
235
234
Cache_Read_Disable ();
236
235
}
237
- #else
238
- void IRAM_ATTR mmu_wrap_irom_fn(void (*fn)(void)) {
239
- Cache_Read_Enable(0, 0, ICACHE_SIZE_16);
240
- fn();
241
- Cache_Read_Disable();
242
- }
243
- #endif
244
236
245
237
};
0 commit comments