|
43 | 43 |
|
44 | 44 | #if defined(ESP8266) |
45 | 45 |
|
| 46 | +// Use this in #ifdef to select flash/non-flash code |
| 47 | +#define USE_FLASH_MEMORY |
| 48 | + |
46 | 49 | // For the esp8266 we need the posibility to store arrays in flash, because mem is so small |
47 | 50 | #define IN_FLASH_MEMORY __attribute__((section(".irom.literal"))) __attribute__((aligned(4))) |
48 | 51 |
|
@@ -70,9 +73,13 @@ int flash_strcmp(const char *mem, const char *flash); |
70 | 73 |
|
71 | 74 | #else |
72 | 75 |
|
| 76 | +#undef USE_FLASH_MEMORY |
| 77 | + |
73 | 78 | // On non-ESP8266, const stuff goes in flash memory anyway |
74 | 79 | #define IN_FLASH_MEMORY |
75 | 80 |
|
| 81 | +#define FLASH_STR(name, x) static const char name[] = x |
| 82 | + |
76 | 83 | /** Read a uint8_t from this pointer, which could be in RAM or Flash. |
77 | 84 | On ARM this is just a standard read, it's different on ESP8266 */ |
78 | 85 | #define READ_FLASH_UINT8(ptr) (*(uint8_t*)(ptr)) |
@@ -232,7 +239,7 @@ typedef int64_t JsSysTime; |
232 | 239 | #define JSPARSE_MODULE_CACHE_NAME "modules" |
233 | 240 |
|
234 | 241 | #if !defined(NO_ASSERT) |
235 | | - #ifdef FLASH_STR |
| 242 | + #ifdef USE_FLASH_MEMORY |
236 | 243 | // Place assert strings into flash to save RAM |
237 | 244 | #define assert(X) do { \ |
238 | 245 | FLASH_STR(flash_X, __STRING(X)); \ |
@@ -361,7 +368,7 @@ typedef enum { |
361 | 368 |
|
362 | 369 | void jsAssertFail(const char *file, int line, const char *expr); |
363 | 370 |
|
364 | | -#ifndef FLASH_STR |
| 371 | +#ifndef USE_FLASH_MEMORY |
365 | 372 | // Normal functions thet place format string in ram |
366 | 373 | void jsExceptionHere(JsExceptionType type, const char *fmt, ...); |
367 | 374 | void jsError(const char *fmt, ...); |
|
0 commit comments