diff --git a/Makefile b/Makefile index 0cdd8dad2..538f340b3 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ AR := $(TOOLCHAIN_PREFIX)ar LD := $(TOOLCHAIN_PREFIX)gcc OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy +MFORCE32 := $(shell $(CC) --help=target | grep mforce-l32) XTENSA_LIBS ?= $(shell $(CC) -print-sysroot) @@ -43,6 +44,14 @@ LDFLAGS += -L$(XTENSA_LIBS)/lib \ CFLAGS+=-std=c99 -DESP8266 CFLAGS += -Wall -Os -g -O2 -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mno-text-section-literals -D__ets__ -DICACHE_FLASH + +ifneq ($(MFORCE32),) + # Your compiler supports the -mforce-l32 flag which means that + # constants can be stored in flash (program) memory instead of SRAM. + # See: https://www.arduino.cc/en/Reference/PROGMEM + CFLAGS += -DPROGMEM="__attribute__((aligned(4))) __attribute__((section(\".irom.text\")))" -mforce-l32 +endif + BIN_DIR := bin AXTLS_AR := $(BIN_DIR)/libaxtls.a diff --git a/crypto/aes.c b/crypto/aes.c index d573f7790..ba76d301d 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -75,7 +75,7 @@ /* * AES S-box */ -static const uint8_t aes_sbox[256] = +static const uint8_t aes_sbox[256] PROGMEM = { 0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5, 0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76, @@ -114,7 +114,7 @@ static const uint8_t aes_sbox[256] = /* * AES is-box */ -static const uint8_t aes_isbox[256] = +static const uint8_t aes_isbox[256] PROGMEM = { 0x52,0x09,0x6a,0xd5,0x30,0x36,0xa5,0x38, 0xbf,0x40,0xa3,0x9e,0x81,0xf3,0xd7,0xfb, diff --git a/crypto/crypto_misc.c b/crypto/crypto_misc.c index dfd5e7642..f166bb8c3 100644 --- a/crypto/crypto_misc.c +++ b/crypto/crypto_misc.c @@ -309,7 +309,7 @@ EXP_FUNC void STDCALL print_blob(const char *format, const unsigned char *data, #if defined(CONFIG_SSL_HAS_PEM) || defined(CONFIG_HTTP_HAS_AUTHORIZATION) /* base64 to binary lookup table */ -static const uint8_t map[128] = +static const uint8_t map[128] PROGMEM = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, diff --git a/crypto/sha512.c b/crypto/sha512.c index aa2f58938..76250089c 100644 --- a/crypto/sha512.c +++ b/crypto/sha512.c @@ -42,7 +42,7 @@ #define SIGMA4(x) (ROR64(x, 19) ^ ROR64(x, 61) ^ SHR64(x, 6)) #define MIN(x, y) ((x) < (y) ? x : y) -static const uint8_t padding[128] = +static const uint8_t padding[128] PROGMEM = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/ssl/os_port.h b/ssl/os_port.h index efda6b5a4..e672f102c 100644 --- a/ssl/os_port.h +++ b/ssl/os_port.h @@ -230,6 +230,10 @@ void exit_now(const char *format, ...); #define SSL_CTX_UNLOCK(A) #endif +#ifndef PROGMEM +#define PROGMEM +#endif + #ifdef __cplusplus } #endif