1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-15 19:22:45 +03:00

decrease RAM usage using PROGMEM

This commit is contained in:
AndreiD
2017-02-19 14:53:17 +02:00
committed by Ivan Grokhotkov
parent 8afe55267a
commit feed1ca219
9 changed files with 103 additions and 35 deletions

View File

@@ -45,7 +45,7 @@
#define CONFIG_SSL_HAS_PEM 1
#undef CONFIG_SSL_USE_PKCS12
#define CONFIG_SSL_EXPIRY_TIME 24
#define CONFIG_X509_MAX_CA_CERTS 150
#define CONFIG_X509_MAX_CA_CERTS 10
#define CONFIG_SSL_MAX_CERTS 1
#undef CONFIG_SSL_CTX_MUTEXING
#undef CONFIG_USE_DEV_URANDOM

View File

@@ -98,6 +98,31 @@ extern "C" {
void ax_wdt_feed();
#ifndef PROGMEM
#define PROGMEM __attribute__((aligned(4))) __attribute__((section(".irom.text")))
#endif
#ifndef WITH_PGM_READ_HELPER
#define ax_array_read_u8(x, y) x[y]
#else
static inline uint8_t pgm_read_byte(const void* addr) {
register uint32_t res;
__asm__("extui %0, %1, 0, 2\n" /* Extract offset within word (in bytes) */
"sub %1, %1, %0\n" /* Subtract offset from addr, yielding an aligned address */
"l32i.n %1, %1, 0x0\n" /* Load word from aligned address */
"slli %0, %0, 3\n" /* Multiply offset by 8, yielding an offset in bits */
"ssr %0\n" /* Prepare to shift by offset (in bits) */
"srl %0, %1\n" /* Shift right; now the requested byte is the first one */
:"=r"(res), "=r"(addr)
:"1"(addr)
:);
return (uint8_t) res; /* This masks the lower byte from the returned word */
}
#define ax_array_read_u8(x, y) pgm_read_byte((x)+(y))
#endif //WITH_PGM_READ_HELPER
#elif defined(WIN32)
/* Windows CE stuff */

View File

@@ -233,6 +233,20 @@ EXP_FUNC void STDCALL ssl_ctx_free(SSL_CTX *ssl_ctx);
*/
EXP_FUNC SSL_EXTENSIONS * STDCALL ssl_ext_new();
/**
* @brief Set the host name for SNI extension
* @param ssl_ext pointer returned by ssl_ext_new
* @param host_name pointer to a zero-terminated string containing host name
*/
EXP_FUNC void STDCALL ssl_ext_set_host_name(SSL_EXTENSIONS * ext, const char* host_name);
/**
* @brief Set the maximum fragment size for the fragment size negotiation extension
* @param ssl_ext pointer returned by ssl_ext_new
* @param fragment_size fragment size, allowed values: 2^9, 2^10 ... 2^14
*/
EXP_FUNC void STDCALL ssl_ext_set_max_fragment_size(SSL_EXTENSIONS * ext, unsigned fragment_size);
/**
* @brief Frees SSL extensions structure
*

View File

@@ -140,7 +140,7 @@ void DISPLAY_BYTES(SSL *ssl, const char *format,
#endif
/**
* Allocates new SSL extensions structure and returns pointer to it
* Allocate new SSL extensions structure and return pointer to it
*
*/
EXP_FUNC SSL_EXTENSIONS * STDCALL ssl_ext_new()
@@ -153,7 +153,7 @@ EXP_FUNC SSL_EXTENSIONS * STDCALL ssl_ext_new()
}
/**
* Allocates new SSL extensions structure and returns pointer to it
* Free SSL extensions structure
*
*/
EXP_FUNC void STDCALL ssl_ext_free(SSL_EXTENSIONS *ssl_ext)
@@ -168,6 +168,23 @@ EXP_FUNC void STDCALL ssl_ext_free(SSL_EXTENSIONS *ssl_ext)
free(ssl_ext);
}
EXP_FUNC void STDCALL ssl_ext_set_host_name(SSL_EXTENSIONS * ext, const char* host_name)
{
free(ext->host_name);
ext->host_name = NULL;
if (host_name) {
ext->host_name = strdup(host_name);
}
}
/**
* Set the maximum fragment size for the fragment size negotiation extension
*/
EXP_FUNC void STDCALL ssl_ext_set_max_fragment_size(SSL_EXTENSIONS * ext, unsigned fragment_size)
{
ext->max_fragment_size = fragment_size;
}
/**
* Establish a new client/server context.
*/
@@ -2426,10 +2443,6 @@ EXP_FUNC void STDCALL ssl_display_error(int error_code)
printf("\n");
}
/**
* Debugging routine to display alerts.
*/
/**
* Debugging routine to display alerts.
*/