Skip to content

Commit 1c6ab8d

Browse files
committed
resolve FLASH_STR ifdef snafu
1 parent 2c8c866 commit 1c6ab8d

5 files changed

Lines changed: 16 additions & 9 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ wiflash: all $(USER1_BIN) $(USER2_BIN)
18411841
ifndef ESPHOSTNAME
18421842
$(error "In order to flash over wifi, we need to have the ESPHOSTNAME variable defined")
18431843
endif
1844-
./scripts/wiflash $(ESPHOSTNAME) $(USER1_BIN) $(USER2_BIN)
1844+
./scripts/wiflash.sh $(ESPHOSTNAME) $(USER1_BIN) $(USER2_BIN)
18451845

18461846
#else ifdef WICED
18471847
#

src/jsinteractive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ NO_INLINE void jsiConsolePrintString(const char *str) {
185185
}
186186
}
187187

188-
#ifdef FLASH_STR
188+
#ifdef USE_FLASH_MEMORY
189189
// internal version that copies str from flash to an internal buffer
190190
NO_INLINE void jsiConsolePrintString_int(const char *str) {
191191
size_t len = flash_strlen(str);
@@ -199,7 +199,7 @@ NO_INLINE void jsiConsolePrintString_int(const char *str) {
199199
* Perform a printf to the console.
200200
* Execute a printf command to the current JS console.
201201
*/
202-
#ifndef FLASH_STR
202+
#ifndef USE_FLASH_MEMORY
203203
void jsiConsolePrintf(const char *fmt, ...) {
204204
va_list argp;
205205
va_start(argp, fmt);

src/jsinteractive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ IOEventFlags jsiGetConsoleDevice();
6767
void jsiConsolePrintChar(char data);
6868
/// Transmit a string (may be any string)
6969
void jsiConsolePrintString(const char *str);
70-
#ifndef FLASH_STR
70+
#ifndef USE_FLASH_MEMORY
7171
#define jsiConsolePrint jsiConsolePrintString
7272
/// Write the formatted string to the console (see vcbprintf)
7373
void jsiConsolePrintf(const char *fmt, ...);

src/jsutils.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ long long stringToInt(const char *s) {
162162
return stringToIntWithRadix(s,0,0);
163163
}
164164

165-
#ifndef FLASH_STR
165+
#ifndef USE_FLASH_MEMORY
166166

167167
// JsError, jsWarn, jsExceptionHere implementations that expect the format string to be in normal
168168
// RAM where is can be accessed normally.
@@ -313,7 +313,7 @@ NO_INLINE void jsAssertFail(const char *file, int line, const char *expr) {
313313
inAssertFail = true;
314314
jsiConsoleRemoveInputLine();
315315
if (expr) {
316-
#ifndef FLASH_STR
316+
#ifndef USE_FLASH_MEMORY
317317
jsiConsolePrintf("ASSERT(%s) FAILED AT ", expr);
318318
#else
319319
jsiConsolePrintString("ASSERT(");
@@ -350,7 +350,7 @@ NO_INLINE void jsAssertFail(const char *file, int line, const char *expr) {
350350
inAssertFail = false;
351351
}
352352

353-
#ifdef FLASH_STR
353+
#ifdef USE_FLASH_MEMORY
354354
// Helpers to deal with constant strings stored in flash that have to be accessed using word-aligned
355355
// and word-sized reads
356356

src/jsutils.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343

4444
#if defined(ESP8266)
4545

46+
// Use this in #ifdef to select flash/non-flash code
47+
#define USE_FLASH_MEMORY
48+
4649
// For the esp8266 we need the posibility to store arrays in flash, because mem is so small
4750
#define IN_FLASH_MEMORY __attribute__((section(".irom.literal"))) __attribute__((aligned(4)))
4851

@@ -70,9 +73,13 @@ int flash_strcmp(const char *mem, const char *flash);
7073

7174
#else
7275

76+
#undef USE_FLASH_MEMORY
77+
7378
// On non-ESP8266, const stuff goes in flash memory anyway
7479
#define IN_FLASH_MEMORY
7580

81+
#define FLASH_STR(name, x) static const char name[] = x
82+
7683
/** Read a uint8_t from this pointer, which could be in RAM or Flash.
7784
On ARM this is just a standard read, it's different on ESP8266 */
7885
#define READ_FLASH_UINT8(ptr) (*(uint8_t*)(ptr))
@@ -232,7 +239,7 @@ typedef int64_t JsSysTime;
232239
#define JSPARSE_MODULE_CACHE_NAME "modules"
233240

234241
#if !defined(NO_ASSERT)
235-
#ifdef FLASH_STR
242+
#ifdef USE_FLASH_MEMORY
236243
// Place assert strings into flash to save RAM
237244
#define assert(X) do { \
238245
FLASH_STR(flash_X, __STRING(X)); \
@@ -361,7 +368,7 @@ typedef enum {
361368

362369
void jsAssertFail(const char *file, int line, const char *expr);
363370

364-
#ifndef FLASH_STR
371+
#ifndef USE_FLASH_MEMORY
365372
// Normal functions thet place format string in ram
366373
void jsExceptionHere(JsExceptionType type, const char *fmt, ...);
367374
void jsError(const char *fmt, ...);

0 commit comments

Comments
 (0)