Browse Source

esp8266: Change bignum from mpz to longlong; move some rodata to iram.

Some rodata items can go in iram/irom segment, but not others.  With
this patch ESP now has 24256 bytes of heap ram.  It passes 228 out of
248 tests from tests/basics directory.
pull/990/head
Damien George 10 years ago
parent
commit
fbea810043
  1. 3
      esp8266/Makefile
  2. 73
      esp8266/esp8266.ld
  3. 3
      esp8266/main.c
  4. 2
      esp8266/mpconfigport.h
  5. 29
      esp8266/strtoll.c

3
esp8266/Makefile

@ -27,7 +27,7 @@ LDFLAGS = -nostdlib -T esp8266.ld -Map=$(@:.elf=.map) --cref
LIBS = -L$(ESP_SDK)/lib -lmain -ljson -llwip -lpp -lnet80211 -lwpa -lphy -lnet80211
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
LIBS += -L $(dir $(LIBGCC_FILE_NAME)) -lgcc
LIBS += -L$(dir $(LIBGCC_FILE_NAME)) -lgcc
# Debugging/Optimization
ifeq ($(DEBUG), 1)
@ -40,6 +40,7 @@ LDFLAGS += --gc-sections
endif
SRC_C = \
strtoll.c \
main.c \
esp_mphal.c \
gccollect.c \

73
esp8266/esp8266.ld

@ -69,6 +69,47 @@ SECTIONS
_dport0_data_end = ABSOLUTE(.);
} >dport0_0_seg :dport0_0_phdr
.irom0.text : ALIGN(4)
{
_irom0_text_start = ABSOLUTE(.);
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
*py*.o*(.literal* .text*)
*gccollect.o*(.literal* .text*)
*gchelper.o*(.literal* .text*)
_irom0_text_end = ABSOLUTE(.);
} >irom0_0_seg :irom0_0_phdr
.text : ALIGN(4)
{
_stext = .;
_text_start = ABSOLUTE(.);
*(.entry.text)
*(.init.literal)
*(.init)
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
*(.fini.literal)
*(.fini)
*(.gnu.version)
*qstr.o(.rodata.const_pool)
*.o(.rodata.mp_type_*)
/*
can't put these here for some reason...
*builtin.o(.rodata.mp_builtin_*_obj)
*parse.o(.rodata.rule_*)
*/
_text_end = ABSOLUTE(.);
_etext = .;
} >iram1_0_seg :iram1_0_phdr
.lit4 : ALIGN(4)
{
_lit4_start = ABSOLUTE(.);
*(*.lit4)
*(.lit4.*)
*(.gnu.linkonce.lit4.*)
_lit4_end = ABSOLUTE(.);
} >iram1_0_seg :iram1_0_phdr
.data : ALIGN(4)
{
_data_start = ABSOLUTE(.);
@ -145,38 +186,6 @@ SECTIONS
_bss_end = ABSOLUTE(.);
_heap_start = ABSOLUTE(.);
} >dram0_0_seg :dram0_0_bss_phdr
.irom0.text : ALIGN(4)
{
_irom0_text_start = ABSOLUTE(.);
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
*py*.o*(.literal* .text*)
_irom0_text_end = ABSOLUTE(.);
} >irom0_0_seg :irom0_0_phdr
.text : ALIGN(4)
{
_stext = .;
_text_start = ABSOLUTE(.);
*(.entry.text)
*(.init.literal)
*(.init)
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
*(.fini.literal)
*(.fini)
*(.gnu.version)
_text_end = ABSOLUTE(.);
_etext = .;
} >iram1_0_seg :iram1_0_phdr
.lit4 : ALIGN(4)
{
_lit4_start = ABSOLUTE(.);
*(*.lit4)
*(.lit4.*)
*(.gnu.linkonce.lit4.*)
_lit4_end = ABSOLUTE(.);
} >iram1_0_seg :iram1_0_phdr
}
/* get ROM code address */

3
esp8266/main.c

@ -44,6 +44,7 @@
#include MICROPY_HAL_H
void user_init(void) {
soft_reset:
//mp_stack_set_limit((char*)&_ram_end - (char*)&_heap_end - 1024);
mp_hal_init();
gc_init(&_heap_start, &_heap_end);
@ -65,6 +66,8 @@ void user_init(void) {
}
}
}
goto soft_reset;
}
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {

2
esp8266/mpconfigport.h

@ -31,7 +31,7 @@
#define MICROPY_PY_SYS_EXIT (1)
#define MICROPY_PY_SYS_STDFILES (1)
#define MICROPY_CPYTHON_COMPAT (0)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)

29
esp8266/strtoll.c

@ -0,0 +1,29 @@
#include <stdlib.h>
// assumes endptr != NULL
// doesn't check for sign
// doesn't check for base-prefix
long long int strtoll(const char *nptr, char **endptr, int base) {
long long val = 0;
for (; *nptr; nptr++) {
int v = *nptr;
if ('0' <= v && v <= '9') {
v -= '0';
} else if ('A' <= v && v <= 'Z') {
v -= 'A' - 10;
} else if ('a' <= v && v <= 'z') {
v -= 'a' - 10;
} else {
break;
}
if (v >= base) {
break;
}
val = val * base + v;
}
*endptr = (char*)nptr;
return val;
}
Loading…
Cancel
Save