Hi -
I am trying to use the ICACHE_FLASH_ATTR (to put data tables into
the SFLASH).
There are a couple of problems that I have:
1. I cannot access variables here (Read only) as a character array - Only integer access
seems to be allowed.
2. Often times when I merely have this in my code (even when not executing). The
system will not boot.
I saw only one example of ICACHE_RODATA_ATTR being used in lwip (for ip_addr_any).
I noticed that your memory alloc (debug version) uses this sometimes
Questions:
1. Have you tested this ability to put RO data into flash
2. What are the restrictions (Address, access, alignment) etc.
I am aware this is how your code that resides on flash works (through some cache refresh mechanism).
Does data not work the same way?
Thanks in advance for your help
Narayan
Data access on SFLASH (ICACHE_RODATA_ATTR)
Re: Data access on SFLASH (ICACHE_RODATA_ATTR)
Postby ESP_Faye » Thu Apr 21, 2016 11:39 am
Hi,
To put the array into flash, you can define it as below, otherwise it will be stored in ram.
Please notice that the flash read/write has to be 4 bytes aligned, so it has to be as type uint32.
Thanks for your interest in ESP8266 !
To put the array into flash, you can define it as below, otherwise it will be stored in ram.
Code: Select all
static const char XXXX[] ICACHE_RODATA_ATTR = { ........ }
Please notice that the flash read/write has to be 4 bytes aligned, so it has to be as type uint32.
Thanks for your interest in ESP8266 !
-
- Posts: 14
- Joined: Tue Feb 07, 2017 1:49 pm
Re: Data access on SFLASH (ICACHE_RODATA_ATTR)
Postby gustavomassa » Fri Apr 28, 2017 9:52 am
Hello, I would like to understand the os_printf:
/* NOTE: don't use printf_opt in irq handler, for test */
#define os_printf(fmt, ...) do { \
static const char flash_str[] ICACHE_RODATA_ATTR STORE_ATTR = fmt; \
printf(flash_str, ##__VA_ARGS__); \
} while(0)
Where inside the flash the variable flash_str is being saved? What address?
If I use the same logic to save another string into the flash:
static const char flashString[] ICACHE_RODATA_ATTR STORE_ATTR = "TEST";
How can I read the flashString variable? If I read it directly it results in a fatal exception(3).
I can copy the content of the flashString to another buffer using memcpy, but I would like to read it directly without memcpy.
/* NOTE: don't use printf_opt in irq handler, for test */
#define os_printf(fmt, ...) do { \
static const char flash_str[] ICACHE_RODATA_ATTR STORE_ATTR = fmt; \
printf(flash_str, ##__VA_ARGS__); \
} while(0)
Where inside the flash the variable flash_str is being saved? What address?
If I use the same logic to save another string into the flash:
static const char flashString[] ICACHE_RODATA_ATTR STORE_ATTR = "TEST";
How can I read the flashString variable? If I read it directly it results in a fatal exception(3).
I can copy the content of the flashString to another buffer using memcpy, but I would like to read it directly without memcpy.
Who is online
Users browsing this forum: No registered users and 0 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.