summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-11-28 14:58:25 +0000
committerDamien George <damien.p.george@gmail.com>2014-11-28 14:58:25 +0000
commitfbea8100432abbdfde3d866d5bea1d8b4f87d217 (patch)
treef78953ebda69a6c76df5ef509f17955d711e9944
parent5f100657188c3f6e53db9d90f7ceebc4753bf44b (diff)
downloadmicropython-fbea8100432abbdfde3d866d5bea1d8b4f87d217.tar.gz
micropython-fbea8100432abbdfde3d866d5bea1d8b4f87d217.zip
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.
-rw-r--r--esp8266/Makefile3
-rw-r--r--esp8266/esp8266.ld83
-rw-r--r--esp8266/main.c3
-rw-r--r--esp8266/mpconfigport.h2
-rw-r--r--esp8266/strtoll.c29
5 files changed, 81 insertions, 39 deletions
diff --git a/esp8266/Makefile b/esp8266/Makefile
index 1e5555a3ab..10f6d7e2d2 100644
--- a/esp8266/Makefile
+++ b/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 \
diff --git a/esp8266/esp8266.ld b/esp8266/esp8266.ld
index 34171c357f..b845fad219 100644
--- a/esp8266/esp8266.ld
+++ b/esp8266/esp8266.ld
@@ -52,7 +52,7 @@ SECTIONS
*(.dport.rodata)
_dport0_rodata_end = ABSOLUTE(.);
} >dport0_0_seg :dport0_0_phdr
-
+
.dport0.literal : ALIGN(4)
{
_dport0_literal_start = ABSOLUTE(.);
@@ -60,7 +60,7 @@ SECTIONS
*(.dport.literal)
_dport0_literal_end = ABSOLUTE(.);
} >dport0_0_seg :dport0_0_phdr
-
+
.dport0.data : ALIGN(4)
{
_dport0_data_start = ABSOLUTE(.);
@@ -68,7 +68,48 @@ SECTIONS
*(.dport.data)
_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(.);
@@ -85,7 +126,7 @@ SECTIONS
*(.jcr)
_data_end = ABSOLUTE(.);
} >dram0_0_seg :dram0_0_phdr
-
+
.rodata : ALIGN(4)
{
_rodata_start = ABSOLUTE(.);
@@ -123,7 +164,7 @@ SECTIONS
_bss_table_end = ABSOLUTE(.);
_rodata_end = ABSOLUTE(.);
} >dram0_0_seg :dram0_0_phdr
-
+
.bss ALIGN(8) (NOLOAD) : ALIGN(4)
{
. = ALIGN (8);
@@ -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 */
diff --git a/esp8266/main.c b/esp8266/main.c
index bab79d6fc5..2f05ed0226 100644
--- a/esp8266/main.c
+++ b/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) {
diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h
index 8a225a0c18..fbf77f645c 100644
--- a/esp8266/mpconfigport.h
+++ b/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)
diff --git a/esp8266/strtoll.c b/esp8266/strtoll.c
new file mode 100644
index 0000000000..4e8a4d0566
--- /dev/null
+++ b/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;
+}