Skip to content

Commit b9d6e22

Browse files
committed
Merge branch 'master' of github.com:espruino/Espruino
2 parents 3182c0f + 21e8473 commit b9d6e22

File tree

9 files changed

+78
-24
lines changed

9 files changed

+78
-24
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
Ensure it's possible to get a solid background when using 4x6 font
7676
Bangle.js: Add Bangle.showLauncher
7777
Add append optimisation for string '+', and don't append to flat/native/etc strings (fix #1746)
78+
ESP8266_4MB: add optional build flag FLASH_1MB for ESP8255 & ESP01s with 1MB flash
79+
ESP8266: add optional build flag NO_FOTA to remove flash over the air functionality
7880
Add Bangle.getCompass and Bangle.getAccel to get the latest compass/accelerometer readings without a callback
7981
Fix `parseInt("0b",16)` as well as some other non-compliant behaviour (fix #1722)
8082
Bangle.js: Disable touch buttons if screen off

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,13 @@ ifeq ($(USE_NET),1)
518518
INCLUDE += -I$(ROOT)/libs/network/esp8266
519519
SOURCES += \
520520
libs/network/esp8266/network_esp8266.c\
521-
libs/network/esp8266/pktbuf.c\
522-
libs/network/esp8266/ota.c
521+
libs/network/esp8266/pktbuf.c
522+
endif
523+
524+
ifndef NO_FOTA
525+
SOURCES += libs/network/esp8266/ota.c
526+
else
527+
DEFINES += -DNO_FOTA
523528
endif
524529

525530
ifdef USE_TELNET

boards/ESP8266_4MB.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ def get_pins():
125125
{ "name":"PD9", "sortingname":"D09", "port":"D", "num":"9", "functions":{}, "csv":{} },
126126
{ "name":"PD10", "sortingname":"D10", "port":"D", "num":"10", "functions":{}, "csv":{} },
127127
{ "name":"PD11", "sortingname":"D11", "port":"D", "num":"11", "functions":{}, "csv":{} },
128-
{ "name":"PD12", "sortingname":"D12", "port":"D", "num":"12", "functions":{}, "csv":{} },
129-
{ "name":"PD13", "sortingname":"D13", "port":"D", "num":"13", "functions":{}, "csv":{} },
130-
{ "name":"PD14", "sortingname":"D14", "port":"D", "num":"14", "functions":{}, "csv":{} },
128+
{ "name":"PD12", "sortingname":"D12", "port":"D", "num":"12", "functions":{"SPI1_MISO":0}, "csv":{} },
129+
{ "name":"PD13", "sortingname":"D13", "port":"D", "num":"13", "functions":{"SPI1_MOSI":0}, "csv":{} },
130+
{ "name":"PD14", "sortingname":"D14", "port":"D", "num":"14", "functions":{"SPI1_SCK":0}, "csv":{} },
131131
{ "name":"PD15", "sortingname":"D15", "port":"D", "num":"15", "functions":{}, "csv":{} },
132132
{ "name":"PD16", "sortingname":"D16", "port":"D", "num":"16", "functions":{}, "csv":{} },
133133
{ "name":"PA0", "sortingname":"A00", "port":"A", "num":"17", "functions":{ "ADC1_IN0":0 }, "csv":{} }

make/family/ESP8266.make

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ OPTIMIZEFLAGS+=-Os -std=gnu11 -fgnu89-inline -Wl,--allow-multiple-definition
1414
endif
1515

1616
ET_FM ?= qio # Valid values are keep, qio, qout, dio, dout
17+
1718
ifdef FLASH_4MB
1819
ESP_FLASH_MAX ?= 831488 # max bin file: 940KB
1920
ESP_FLASH_SIZE ?= 6 # 6->4MB (1024KB+1024KB)
@@ -23,6 +24,7 @@ ET_FS ?= 4MB-c1 # 32Mbit (4MB) flash size in esptool flash comma
2324
ET_FF ?= 80m # 80Mhz flash speed in esptool flash command
2425
ET_BLANK ?= 0x3FE000 # where to flash blank.bin
2526
ET_DEFAULTS ?= 0x3FC000 # where to flash esp_init_data_default.bin to default SDK settings
27+
CFLAGS += -mforce-l32
2628
else ifdef 2MB
2729
ESP_FLASH_MAX ?= 479232 # max bin file: 468KB
2830
ESP_FLASH_SIZE ?= 3 # 3->2MB (512KB+512KB)
@@ -46,34 +48,43 @@ ESP_FLASH_MAX ?= 479232 # max bin file: 468KB
4648
ESP_FLASH_SIZE ?= 0 # 0->512KB
4749
ESP_FLASH_MODE ?= 0 # 0->QIO
4850
ESP_FLASH_FREQ_DIV ?= 0 # 0->40Mhz
49-
ET_FS ?= 4m # 4Mbit (512KB) flash size in esptool flash command
51+
ET_FS ?= 512KB # 4Mbit (512KB) flash size in esptool flash command
5052
ET_FF ?= 40m # 40Mhz flash speed in esptool flash command
5153
ET_BLANK ?= 0x7E000 # where to flash blank.bin
5254
ET_DEFAULTS ?= 0x7C000 # where to flash esp_init_data_default.bin to default SDK settings
5355
endif
5456

55-
FLASH_BAUD ?= 115200 # The flash baud rate
57+
58+
ifdef FLASH_1MB
59+
ESP_FLASH_MAX = 831488 # max bin file: 812KB
60+
ESP_FLASH_SIZE = 2 # 2->1MB (1024)
61+
ESP_FLASH_MODE = 0 # 0->QIO, 2->DIO
62+
ESP_FLASH_FREQ_DIV = 15 # 15->80Mhz
63+
ET_FS = 1MB # 8Mbit (1MB) flash size in esptool flash command
64+
ET_FF = 80m # 80Mhz flash speed in esptool flash command
65+
ET_FM = dout # Valid values are keep, qio, qout, dio, dout
66+
ET_BLANK = 0xFE000 # where to flash blank.bin
67+
ET_DEFAULTS = 0xFC000 # where to flash esp_init_data_default.bin to default SDK settings
68+
DEFINES += -DFLASH_1MB
69+
CFLAGS += -mforce-l32
70+
endif
71+
72+
FLASH_BAUD ?= 115200 # The flash baud rate
5673

5774

5875
# move os_printf strings into flash to save RAM space
5976
DEFINES += -DUSE_OPTIMIZE_PRINTF
6077
DEFINES += -D__ETS__ -DICACHE_FLASH -DXTENSA -DUSE_US_TIMER
61-
LIBS += -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip_536 -lwpa -lmain -lpwm -lcrypto
62-
CFLAGS+= -fno-builtin \
78+
LIBS += -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip_536 -lwpa -lmain -lpwm -lcrypto
79+
CFLAGS += -fno-builtin \
6380
-Wno-maybe-uninitialized -Wno-old-style-declaration -Wno-conversion -Wno-unused-variable \
64-
-Wno-unused-parameter -Wno-ignored-qualifiers -Wno-discarded-qualifiers -Wno-float-conversion \
81+
-Wno-unused-parameter -Wno-ignored-qualifiers \
6582
-Wno-parentheses -Wno-type-limits -Wno-unused-function -Wno-unused-value \
6683
-Wl,EL -Wl,--gc-sections -nostdlib -mlongcalls -mtext-section-literals \
6784
-fno-guess-branch-probability -freorder-blocks-and-partition -fno-cse-follow-jumps \
6885
-fno-tree-fre -fno-ipa-sra -fno-signed-zeros -fno-trapping-math -fassociative-math \
6986
-fno-caller-saves -fno-move-loop-invariants -fno-tree-tail-merge -fno-tree-copy-prop
7087

71-
# only use mfore-l32 if 4MB board for now
72-
ifdef FLASH_4MB
73-
CFLAGS += -mforce-l32
74-
endif
75-
76-
#
7788
# The Root of the ESP8266_SDK distributed by Espressif
7889
# This must be supplied as a Make environment variable.
7990
ifndef ESP8266_SDK_ROOT

make/targets/ESP8266.make

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,23 @@ USER2_BIN = espruino_esp8266_user2.bin
1919
USER1_ELF = espruino_esp8266_user1.elf
2020
USER2_ELF = espruino_esp8266_user2.elf
2121
PARTIAL = espruino_esp8266_partial.o
22+
2223
ifdef FLASH_4MB
2324
ESP_COMBINED_SIZE = 4096
2425
ESP_FLASH_ADDONS = $(ET_DEFAULTS) $(INIT_DATA) $(ET_BLANK) $(BLANK)
2526
LD_SCRIPT1 = ./targets/esp8266/eagle.app.v6.new.2048.ld
2627
LD_SCRIPT2 = ./targets/esp8266/eagle.app.v6.new.2048.ld
27-
LD_RENAME = --rename-section .text=.irom.text --rename-section .literal=.irom.literal
2828
else
2929
ESP_COMBINED_SIZE = 512
3030
LD_SCRIPT1 = ./targets/esp8266/eagle.app.v6.new.1024.app1.ld
3131
LD_SCRIPT2 = ./targets/esp8266/eagle.app.v6.new.1024.app2.ld
32-
LD_RENAME = --rename-section .text=.irom.text --rename-section .literal=.irom.literal
3332
endif
33+
34+
ifdef FLASH_1MB
35+
ESP_COMBINED_SIZE = 1024
36+
endif
37+
38+
LD_RENAME = --rename-section .text=.irom.text --rename-section .literal=.irom.literal
3439
ESP_COMBINED = $(PROJ_NAME)_combined_$(ESP_COMBINED_SIZE).bin
3540
APPGEN_TOOL = $(ESP8266_SDK_ROOT)/tools/gen_appbin.py
3641
BOOTLOADER = $(ESP8266_SDK_ROOT)/bin/boot_v1.6.bin

targets/esp8266/README_flash.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,16 @@ esptool.py --port [/dev/ttyUSB0|COM1] --baud 460800 write_flash \
4343
0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin \
4444
0x3FC000 esp_init_data_default.bin 0x3FE000 blank.bin
4545

46+
47+
Special hints for a broken device after flashing
48+
------------------------------------------------
49+
50+
newer ESP01 like ESP01s have 1MB flash size
51+
52+
try different --flash_mode values like dio or dout
53+
54+
try to use a combined file to flash like
55+
espruino_..._combined_512.bin or
56+
espruino_..._combined_4096.bin
57+
58+

targets/esp8266/jshardware.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,8 @@ JsVar *jshFlashGetFree() {
14111411
if (!jsFreeFlash) return 0;
14121412

14131413
uint32_t map = system_get_flash_size_map();
1414+
extern uint16_t espFlashKB; // in user_main,c
1415+
14141416
if ( map == 6 ) {
14151417
addFlashArea(jsFreeFlash, 0x200000, 0x100000);
14161418
addFlashArea(jsFreeFlash, 0x300000, 0x40000);
@@ -1419,9 +1421,11 @@ JsVar *jshFlashGetFree() {
14191421
addFlashArea(jsFreeFlash, 0x3C0000, 0x40000-0x5000);
14201422
return jsFreeFlash;
14211423
}
1422-
1424+
// there is no flash for running on 1MB flash without FOTA
1425+
if ( map == 2 && espFlashKB == 1024 && strcmp(PC_BOARD_ID, "ESP8266_4MB") == 0)
1426+
return jsFreeFlash;
1427+
14231428
// need 1MB of flash to have more space...
1424-
extern uint16_t espFlashKB; // in user_main,c
14251429
if (espFlashKB > 512) {
14261430
addFlashArea(jsFreeFlash, 0x80000, 0x1000);
14271431
if (espFlashKB > 1024) {

targets/esp8266/jswrap_esp8266.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,13 @@ JsVar *jswrap_ESP8266_getState() {
236236
uint32_t map = system_get_flash_size_map();
237237
extern char *flash_maps[]; // in user_main.c
238238
extern uint16_t flash_kb[]; // in user_main.c
239-
jsvObjectSetChildAndUnLock(esp8266State, "flashMap", jsvNewFromString(flash_maps[map]));
239+
extern char *flash_maps_alt[]; // in user_main.c
240+
241+
jsvObjectSetChildAndUnLock(esp8266State, "flashMap", jsvNewFromString(
242+
// ( map == 2 && flash_kb[map] == 1024 && is4MB ? flash_maps_alt[map] : flash_maps[map] )));
243+
( map == 2 && flash_kb[map] == 1024 && strcmp(PC_BOARD_ID, "ESP8266_4MB") == 0) ? flash_maps_alt[map] : flash_maps[map] ));
244+
// ( map == 2 && flash_kb[map] == 1024 ? flash_maps_alt[map] : flash_maps[map] )));
245+
240246
jsvObjectSetChildAndUnLock(esp8266State, "flashKB", jsvNewFromInteger(flash_kb[map]));
241247

242248
uint32_t fid = spi_flash_get_id();

targets/esp8266/user_main.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ typedef long long int64_t;
2727
#include <jsinteractive.h>
2828
#include <jswrap_esp8266_network.h>
2929
#include <jswrap_esp8266.h>
30-
#include <ota.h>
3130
#include <log.h>
3231
#include "ESP8266_board.h"
3332

@@ -90,6 +89,10 @@ char *flash_maps[] = { // used in jswrap_ESP8266_network.c
9089
"512KB:256/256", "256KB", "1MB:512/512", "2MB:512/512", "4MB:512/512",
9190
"2MB:1024/1024", "4MB:1024/1024"
9291
};
92+
char *flash_maps_alt[] = { // used in jswrap_ESP8266_network.c
93+
"512KB:256/256", "256KB", "1MB:1024", "2MB:1024", "4MB:512/512",
94+
"2MB:1024/1024", "4MB:1024/1024"
95+
};
9396
uint16_t flash_kb[] = { // used in jswrap_ESP8266_network.c
9497
512, 256, 1024, 2048, 4096, 2048, 4096,
9598
};
@@ -122,8 +125,9 @@ void jshPrintBanner() {
122125
os_printf("Espruino "JS_VERSION"\nFlash map %s, manuf 0x%lx chip 0x%lx\n",
123126
flash_maps[map], (long unsigned int) (fid & 0xff), (long unsigned int)chip);
124127
jsiConsolePrintf(
125-
"Flash map %s, manuf 0x%x chip 0x%x\n",
126-
flash_maps[map], fid & 0xff, chip);
128+
"Flash map %s, manuf 0x%x chip 0x%x\n",
129+
(( map == 2 && flash_kb[map] == 1024 && strcmp(PC_BOARD_ID, "ESP8266_4MB") == 0) ? flash_maps_alt[map] : flash_maps[map]),
130+
fid & 0xff, chip);
127131
if ((chip == 0x4013 && map != 0) || (chip == 0x4016 && map != 4 && map != 6)) {
128132
jsiConsolePrint("WARNING: *** Your flash chip does not match your flash map ***\n");
129133
}
@@ -238,7 +242,11 @@ static void mainLoop() {
238242
*/
239243
static void initDone() {
240244
os_printf("> initDone\n");
245+
246+
#ifndef NO_FOTA
247+
#include <ota.h>
241248
otaInit(88);
249+
#endif
242250

243251
#ifdef DEBUG
244252
extern void gdbstub_init();

0 commit comments

Comments
 (0)