Skip to content

Commit

Permalink
No-WiFi flash fixes (#2353)
Browse files Browse the repository at this point in the history
Fixes the following issues:

- Call to `spi_flash_get_id()` hangs in application code
- ROMs must be located below 1M

Both due to SDK implementation of `Cache_Read_Enable_New()` which requires a variable to be set to 0 at startup.

Also, `system_os_post` must be in IRAM.

* Update README
  • Loading branch information
mikee47 committed Jul 20, 2021
1 parent 9fe9cb5 commit 0a448d1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 0 additions & 4 deletions Sming/Arch/Esp8266/Components/esp_no_wifi/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ If you want to disassemble other SDK libraries, do this::
Known issues
------------

- Call to `spi_flash_get_id()` hangs in application code
- ROMs must be located below 1M
SDK implementation of `Cache_Read_Enable_New()` has internal flag which doesn't get initialised (default is 0xff, must be 1 or the function does nothing).

Further work is required to implement the following (list incomplete):

- Sleep/power saving modes
Expand Down
12 changes: 12 additions & 0 deletions Sming/Arch/Esp8266/Components/esp_no_wifi/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,24 @@ void set_pll(void)
}
}

static void init_flash_code()
{
spi_flash_set_read_func(NULL);
// Variable resets to 0xff, must be 0 or Cache_Read_Enable_New hangs
uint32_t addr = (uint32_t)&Cache_Read_Enable_New;
addr -= 8;
uint32_t** varptr = (uint32_t**)addr;
**varptr = 0;
}

static void user_start(void)
{
ets_isr_mask(0x3FE); // disable interrupts 1..9
sleep_reset_analog_rtcreg_8266(); // spoils the PLL!
set_pll();

init_flash_code();

memset(&_bss_start, 0, &_bss_end - &_bss_start);

ets_timer_init();
Expand Down
2 changes: 1 addition & 1 deletion Sming/Arch/Esp8266/Components/esp_no_wifi/user_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void system_print_meminfo(void)
#undef ADDR
}

bool system_os_post(uint8_t prio, os_signal_t sig, os_param_t par)
bool IRAM_ATTR system_os_post(uint8_t prio, os_signal_t sig, os_param_t par)
{
if(prio >= USER_TASK_PRIO_MAX) {
os_printf("err: post prio >= %u\n", USER_TASK_PRIO_MAX);
Expand Down
3 changes: 0 additions & 3 deletions samples/Basic_Storage/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ void listDevices()
Serial.print(toString(dev.getType()));
Serial.print(_F(", size = 0x"));
Serial.print(dev.getSize(), HEX);
#ifndef DISABLE_WIFI
// KNOWN ISSUE: Call to `spi_flash_get_id()` hangs in application code
Serial.print(_F(", ID = 0x"));
Serial.print(dev.getId(), HEX);
#endif
Serial.println();
}
Serial.println();
Expand Down

0 comments on commit 0a448d1

Please sign in to comment.