8000 Merge branch 'master' into adam5wu/master · Adam5Wu/bearssl-esp8266@f9ae6a1 · GitHub
[go: up one dir, main page]

Skip to content

Commit f9ae6a1

Browse files
committed
Merge branch 'master' into adam5wu/master
2 parents 5f88ee2 + ba9df5b commit f9ae6a1

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

conf/esp8266.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BUILD = esp8266
1111
# TODO - when GCC jump tables are moved to inline, remove the -fno-jump-tables. This setting saves ~1.3KB RAM at the cose of 1.3KB of flash, but is slower by a bit
1212
TOOLCHAIN_PREFIX := xtensa-lx106-elf-
1313
CC := $(TOOLCHAIN_PREFIX)gcc
14-
CFLAGS = -W -Wall -Os -g -Wpointer-arith -Wl,-EL -nostdlib -mlongcalls -mno-text-section-literals -ffunction-sections -fdata-sections -fno-jump-tables
14+
CFLAGS = -W -Wall -g -Os -O3 -Wpointer-arith -Wl,-EL -nostdlib -mlongcalls -mno-text-section-literals -ffunction-sections -fdata-sections -fno-jump-tables
1515
CFLAGS += -D__ets__ -DICACHE_FLASH -DESP8266
1616
LD := $(TOOLCHAIN_PREFIX)ld
1717
AR := $(TOOLCHAIN_PREFIX)ar

src/inner.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,22 +2353,24 @@ br_cpuid(uint32_t mask_eax, uint32_t mask_ebx,
23532353

23542354
#if defined(ESP8266) && ESP8266_ALTSTACK
23552355

2356-
#define ESP8266_DEBUG 0
23572356
#ifdef __cplusplus
23582357
extern "C" {
23592358
#endif
2359+
2360+
#define _debugBearSSL (0)
23602361
extern void br_stack_proxy_enter();
23612362
extern void *br_stack_proxy_alloc(size_t bytes);
23622363
extern void br_stack_proxy_exit();
2363-
extern void stack(const char *fcn, const char *file, int line);
2364-
extern void PRINTIT(const char *a);
2364+
extern void _BearSSLCheckStack(const char *fcn, const char *file, int line);
2365+
extern void _BearSSLSerialPrint(const char *a);
23652366
#include <stdio.h>
2366-
#define STACK_PROXY_ENTER() { if (ESP8266_DEBUG) {char b[64]; sprintf(b, "ENTER:%s:%s\n", __FILE__, __FUNCTION__ ); PRINTIT(b);} br_stack_proxy_enter(); }
2367-
#define STACK_PROXY_EXIT() { if (ESP8266_DEBUG) {char b[64]; sprintf(b, "EXIT: %s:%s\n", __FILE__, __FUNCTION__ ); PRINTIT(b);} br_stack_proxy_exit(); }
2367+
#define STACK_PROXY_ENTER() { if (_debugBearSSL) { char b[64]; sprintf(b, "ENTER:%s:%s\n", __FILE__, __FUNCTION__ ); _BearSSLSerialPrint(b); } br_stack_proxy_enter(); }
2368+
#define STACK_PROXY_EXIT() { if (_debugBearSSL) { char b[64]; sprintf(b, "EXIT: %s:%s\n", __FILE__, __FUNCTION__ ); _BearSSLSerialPrint(b); } br_stack_proxy_exit(); }
23682369
#define STACK_PROXY_ALLOC(type, name, count) \
23692370
type *name = (type *)br_stack_proxy_alloc(sizeof(type) * (count));\
2370-
if (!name) name = (type *)alloca(sizeof(type) * (count));
2371-
#define dumpstack() if (ESP8266_DEBUG) stack(__FUNCTION__, __FILE__, __LINE__); else {}
2371+
if (!name) name = (type *)alloca(sizeof(type) * (count));
2372+
#define dumpstack() if (_debugBearSSL) _BearSSLCheckStack(__FUNCTION__, __FILE__, __LINE__); else {}
2373+
23722374
#ifdef __cplusplus
23732375
}
23742376
#endif

src/port/esp8266_stack_proxy.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <stddef.h>
1717
#include <string.h>
1818
#include <stdio.h>
19+
#include "inner.h"
1920

2021
static uint8_t *stack_proxy = NULL;
2122
static uint16_t stack_proxy_size = 0;
@@ -64,19 +65,20 @@ void *br_stack_proxy_alloc(size_t bytes)
6465

6566
if (stack_proxy_ptr + bytes <= stack_proxy_size) {
6667
uint8_t *ptr = &stack_proxy[stack_proxy_ptr];
67-
// {char a[32]; sprintf(a,"%p, %d\n", ptr, bytes); PRINTIT(a);}
6868
stack_proxy_ptr += bytes;
6969
if (stack_proxy_max_ptr < stack_proxy_ptr) {
7070
stack_proxy_max_ptr = stack_proxy_ptr;
7171
}
7272
while (stack_proxy_ptr&0x3) stack_proxy_ptr++; // Align 32-bits
73-
#if ESP8266DEBUG
74-
//{char a[32]; sprintf(a,"a%dp\n", bytes); PRINTIT(a);}
75-
#endif
7673
return (void*)ptr;
7774
}
78-
#if ESP8266DEBUG
79-
//{char a[32]; sprintf(a,"a%dF\n", bytes); PRINTIT(a);}
75+
// If we're here, the 2nd stack allocation failed. Record if in debug mode
76+
#if DEBUG_BEARSSL
77+
{
78+
char a[32];
79+
sprintf(a,"stack2 alloc %d fail\n", bytes);
80+
_BearSSLSerialPrint(a);
81+
}
8082
#endif
8183
return NULL;
8284
}

0 commit comments

Comments
 (0)
0