10000 Fix pre-SDK Cache_Read_Enable for PUYA flash by mhightower83 · Pull Request #8658 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Fix pre-SDK Cache_Read_Enable for PUYA flash #8658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Change umm_init to default to IRAM
Some flash chips (PUYA) have some unknown requirements for running with
early `Cache_Read_Enable`. They work fine after the SDK is started.
For now, change umm_init to default to IRAM.
Define UMM_INIT_USE_ICACHE to move to ICACHE and free up IRAM.

Added some experimental code that may indirectly support PUYA.

Note, until this issue is resolved, that HWDT Stack Dump is not
going to work with PUYA flash.
  • Loading branch information
mhightower83 committed Sep 13, 2022
commit f04dedf4df83be6ac131fd4fa508618722faa97d
1 change: 1 addition & 0 deletions cores/esp8266/hwdt_app_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@
#include <esp8266_peri.h>
8000 #include <uart.h>
#include <pgmspace.h>
#include "<umm_malloc/umm_malloc.h"
#include "mmu_iram.h"

extern "C" {
Expand Down
27 changes: 24 additions & 3 deletions cores/esp8266/mmu_iram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,18 @@ extern void Cache_Read_Disable(void);
extern void Cache_Read_Enable(uint8_t map, uint8_t p, uint8_t v);
#endif // #if (MMU_ICACHE_SIZE == 0x4000)

#if 1 // New experimental code
/*
* This wrapper is for running code early from IROM (flash) before the SDK starts.
* Since the NONOS SDK will do a full/proper init for handling the flash device,
* we only do a minimum to make ICACHE functional, keeping IRAM use to a minimum.
* This wrapper is for running code early from IROM (flash) before the SDK
* starts. Since the NONOS SDK will do a full and proper flash device init for
* speed and mode, we only do a minimum to make ICACHE functional, keeping IRAM
* use to a minimum. After the SDK has started, this function is not needed and
* should not be called.
*/
void IRAM_ATTR mmu_wrap_irom_fn(void (*fn)(void)) {
//?? If the problem is not resolved add this line back.
//?? Cache_Read_Disable();

// The SPI_CS_SETUP parameter has been observed set by RTOS SDK and NONOS SDK
// as part of flash init/configuration. It may be necessary for some flash
// chips to perform correctly with ICACHE hardware access. Turning on and
Expand All @@ -212,13 +218,28 @@ void IRAM_ATTR mmu_wrap_irom_fn(void (*fn)(void)) {
// defaults to 1.
SPI0U |= SPIUCSSETUP; // SPI_CS_SETUP or BIT5

// I am not sure what this is does. It appears to be the key function called
// from `fix_cache_bug` in the NONOS SDK - Will this help PUYA Flash work?
// It appears to do some, lowlevel undocumented register maniplation and
// device specific init based on OTP CHIPID model bits.
extern uint32_t phy_get_bb_evm(void); // undocumented
phy_get_bb_evm();

// For early Cache_Read_Enable only do ICACHE_SIZE_16. The affected registers
// are fully restored when Cache_Read_Disable is called. With ICACHE_SIZE_32
// one bit is missed at disable. Leave the full commitment to ICACHE_SIZE_32
// for the NONOS SDK.
// This only works with image slice 0, which is all we do presently.
Cache_Read_Enable(0, 0, ICACHE_SIZE_16);
fn();
Cache_Read_Disable();
}
#else
void IRAM_ATTR mmu_wrap_irom_fn(void (*fn)(void)) {
Cache_Read_Enable(0, 0, ICACHE_SIZE_16);
fn();
Cache_Read_Disable();
}
#endif

};
14 changes: 10 additions & 4 deletions cores/esp8266/umm_malloc/umm_malloc_cfgport.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "c_types.h"

/*
* -DUMM_INIT_USE_IRAM
* -DUMM_INIT_USE_ICACHE
*
* Historically, the umm_init() call path has been in IRAM. The umm_init() call
* path is now in ICACHE (flash). Use the build option UMM_INIT_USE_IRAM to
Expand All @@ -30,10 +30,16 @@
* app_entry_redefinable() in core_esp8266_app_entry_noextra4k.cpp for an
* example of how to toggle between ICACHE and IRAM in your build.
*
* The default is to use ICACHE.
* ~The default is to use ICACHE.~
* For now revert default back to IRAM
* define UMM_INIT_USE_ICACHE to use ICACHE/IROM
*/
// #define UMM_INIT_USE_IRAM 1

#ifdef UMM_INIT_USE_ICACHE
#undef UMM_INIT_USE_IRAM
#else
#undef UMM_INIT_USE_IRAM
#define UMM_INIT_USE_IRAM 1
#endif

/*
* Start addresses and the size of the heap
Expand Down
0