Skip to content

Commit bca0997

Browse files
committed
Merge pull request #2 from esp8266/esp8266
merged
2 parents 63f9129 + 5465f70 commit bca0997

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1113
-195
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ Libraries that don't rely on low-level access to AVR registers should work well.
195195
- [NeoPixelBus](https://github.com/Makuna/NeoPixelBus) - Arduino NeoPixel library compatible with esp8266.
196196
- [RTC](https://github.com/Makuna/Rtc) - Arduino Library for Ds1307 & Ds3231 compatible with esp8266.
197197
- [Blynk](https://github.com/blynkkk/blynk-library) - easy IoT framework for Makers (check out the [Kickstarter page](http://tiny.cc/blynk-kick)).
198+
- [arduinoWebSockets](https://github.com/Links2004/arduinoWebSockets) - WebSocket Server and Client compatible with esp8266 (RFC6455)
198199

199200
#### Upload via serial port ####
200201
Pick the correct serial port.

boards.txt

+56-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ generic.name=Generic ESP8266 Module
99
generic.upload.tool=esptool
1010
generic.upload.speed=115200
1111
generic.upload.resetmethod=ck
12-
generic.upload.maximum_size=372736
12+
generic.upload.maximum_size=434160
1313
generic.upload.maximum_data_size=81920
1414
generic.upload.wait_for_upload_port=true
1515
generic.serial.disableDTR=true
@@ -59,55 +59,55 @@ generic.menu.FlashSize.512K.build.flash_ld=eagle.flash.512k.ld
5959
generic.menu.FlashSize.512K.build.spiffs_start=0x6B000
6060
generic.menu.FlashSize.512K.build.spiffs_end=0x7B000
6161
generic.menu.FlashSize.512K.build.spiffs_blocksize=4096
62-
generic.menu.FlashSize.512K.upload.maximum_size=372736
62+
generic.menu.FlashSize.512K.upload.maximum_size=434160
6363

6464
generic.menu.FlashSize.1M512=1M (512K SPIFFS)
6565
generic.menu.FlashSize.1M512.build.flash_size=1M
6666
generic.menu.FlashSize.1M512.build.flash_ld=eagle.flash.1m512.ld
67-
generic.menu.FlashSize.1M512.build.spiffs_start=0x6B000
67+
generic.menu.FlashSize.1M512.build.spiffs_start=0x7B000
6868
generic.menu.FlashSize.1M512.build.spiffs_end=0xFB000
6969
generic.menu.FlashSize.1M512.build.spiffs_blocksize=8192
70-
generic.menu.FlashSize.1M512.upload.maximum_size=438272
70+
generic.menu.FlashSize.1M512.upload.maximum_size=499696
7171

7272
generic.menu.FlashSize.1M256=1M (256K SPIFFS)
7373
generic.menu.FlashSize.1M256.build.flash_size=1M
7474
generic.menu.FlashSize.1M256.build.flash_ld=eagle.flash.1m256.ld
75-
generic.menu.FlashSize.1M256.build.spiffs_start=0xAB000
75+
generic.menu.FlashSize.1M256.build.spiffs_start=0xBB000
7676
generic.menu.FlashSize.1M256.build.spiffs_end=0xFB000
7777
generic.menu.FlashSize.1M256.build.spiffs_blocksize=4096
78-
generic.menu.FlashSize.1M256.upload.maximum_size=700416
78+
generic.menu.FlashSize.1M256.upload.maximum_size=761840
7979

8080
generic.menu.FlashSize.1M128=1M (128K SPIFFS)
8181
generic.menu.FlashSize.1M128.build.flash_size=1M
8282
generic.menu.FlashSize.1M128.build.flash_ld=eagle.flash.1m128.ld
83-
generic.menu.FlashSize.1M128.build.spiffs_start=0xCB000
83+
generic.menu.FlashSize.1M128.build.spiffs_start=0xDB000
8484
generic.menu.FlashSize.1M128.build.spiffs_end=0xFB000
8585
generic.menu.FlashSize.1M128.build.spiffs_blocksize=4096
86-
generic.menu.FlashSize.1M128.upload.maximum_size=831488
86+
generic.menu.FlashSize.1M128.upload.maximum_size=892912
8787

8888
generic.menu.FlashSize.1M64=1M (64K SPIFFS)
8989
generic.menu.FlashSize.1M64.build.flash_size=1M
9090
generic.menu.FlashSize.1M64.build.flash_ld=eagle.flash.1m64.ld
9191
generic.menu.FlashSize.1M64.build.spiffs_start=0xEB000
9292
generic.menu.FlashSize.1M64.build.spiffs_end=0xFB000
9393
generic.menu.FlashSize.1M64.build.spiffs_blocksize=4096
94-
generic.menu.FlashSize.1M64.upload.maximum_size=897024
94+
generic.menu.FlashSize.1M64.upload.maximum_size=958448
9595

9696
generic.menu.FlashSize.2M=2M (1M SPIFFS)
9797
generic.menu.FlashSize.2M.build.flash_size=2M
9898
generic.menu.FlashSize.2M.build.flash_ld=eagle.flash.2m.ld
9999
generic.menu.FlashSize.2M.build.spiffs_start=0x100000
100100
generic.menu.FlashSize.2M.build.spiffs_end=0x1FB000
101101
generic.menu.FlashSize.2M.build.spiffs_blocksize=8192
102-
generic.menu.FlashSize.2M.upload.maximum_size=983040
102+
generic.menu.FlashSize.2M.upload.maximum_size=1044464
103103

104104
generic.menu.FlashSize.4M=4M (3M SPIFFS)
105105
generic.menu.FlashSize.4M.build.flash_size=4M
106106
generic.menu.FlashSize.4M.build.flash_ld=eagle.flash.4m.ld
107107
generic.menu.FlashSize.4M.build.spiffs_start=0x100000
108108
generic.menu.FlashSize.4M.build.spiffs_end=0x3FB000
109109
generic.menu.FlashSize.4M.build.spiffs_blocksize=8192
110-
generic.menu.FlashSize.4M.upload.maximum_size=983040
110+
generic.menu.FlashSize.4M.upload.maximum_size=1044464
111111

112112
# disabled because espressif's bootloader refuses to write above 4M
113113
# generic.menu.FlashSize.8M=8M (7M SPIFFS)
@@ -134,7 +134,7 @@ modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV)
134134
modwifi.upload.tool=esptool
135135
modwifi.upload.speed=115200
136136
modwifi.upload.resetmethod=ck
137-
modwifi.upload.maximum_size=983040
137+
modwifi.upload.maximum_size=1044464
138138
modwifi.upload.maximum_data_size=81920
139139
modwifi.upload.wait_for_upload_port=true
140140
modwifi.serial.disableDTR=true
@@ -186,7 +186,7 @@ nodemcu.name=NodeMCU 0.9 (ESP-12 Module)
186186
nodemcu.upload.tool=esptool
187187
nodemcu.upload.speed=115200
188188
nodemcu.upload.resetmethod=ck
189-
nodemcu.upload.maximum_size=983040
189+
nodemcu.upload.maximum_size=1044464
190190
nodemcu.upload.maximum_data_size=81920
191191
nodemcu.upload.wait_for_upload_port=true
192192
nodemcu.serial.disableDTR=true
@@ -237,7 +237,7 @@ nodemcuv2.name=NodeMCU 1.0 (ESP-12E Module)
237237
nodemcuv2.upload.tool=esptool
238238
nodemcuv2.upload.speed=115200
239239
nodemcuv2.upload.resetmethod=ck
240-
nodemcuv2.upload.maximum_size=983040
240+
nodemcuv2.upload.maximum_size=1044464
241241
nodemcuv2.upload.maximum_data_size=81920
242242
nodemcuv2.upload.wait_for_upload_port=true
243243
nodemcuv2.serial.disableDTR=true
@@ -282,6 +282,48 @@ nodemcuv2.menu.UploadSpeed.512000.upload.speed=512000
282282
nodemcuv2.menu.UploadSpeed.921600=921600
283283
nodemcuv2.menu.UploadSpeed.921600.upload.speed=921600
284284

285+
##############################################################
286+
huzzah.name=Adafruit HUZZAH ESP8266
287+
288+
huzzah.upload.tool=esptool
289+
huzzah.upload.speed=115200
290+
huzzah.upload.resetmethod=ck
291+
huzzah.upload.maximum_size=1044464
292+
huzzah.upload.maximum_data_size=81920
293+
huzzah.upload.wait_for_upload_port=true
294+
huzzah.serial.disableDTR=true
295+
huzzah.serial.disableRTS=true
296+
297+
huzzah.build.mcu=esp8266
298+
huzzah.build.f_cpu=80000000L
299+
huzzah.build.board=ESP8266_ESP12
300+
huzzah.build.core=esp8266
301+
huzzah.build.variant=adafruit
302+
huzzah.build.flash_mode=qio
303+
huzzah.build.flash_size=4M
304+
huzzah.build.flash_freq=40
305+
huzzah.build.flash_ld=eagle.flash.4m.ld
306+
huzzah.build.spiffs_start=0x100000
307+
huzzah.build.spiffs_end=0x3FB000
308+
huzzah.build.spiffs_pagesize=256
309+
huzzah.build.spiffs_blocksize=8192
310+
311+
huzzah.menu.CpuFrequency.80=80 MHz
312+
huzzah.menu.CpuFrequency.80.build.f_cpu=80000000L
313+
huzzah.menu.CpuFrequency.160=160 MHz
314+
huzzah.menu.CpuFrequency.160.build.f_cpu=160000000L
315+
316+
huzzah.menu.UploadSpeed.115200=115200
317+
huzzah.menu.UploadSpeed.115200.upload.speed=115200
318+
huzzah.menu.UploadSpeed.9600=9600
319+
huzzah.menu.UploadSpeed.9600.upload.speed=9600
320+
huzzah.menu.UploadSpeed.57600=57600
321+
huzzah.menu.UploadSpeed.57600.upload.speed=57600
322+
huzzah.menu.UploadSpeed.256000=256000
323+
huzzah.menu.UploadSpeed.256000.upload.speed=256000
324+
huzzah.menu.UploadSpeed.921600=921600
325+
huzzah.menu.UploadSpeed.921600.upload.speed=921600
326+
285327
##############################################################
286328
# wifio.name=Wifio
287329
#

bootloaders/eboot/LICENSE

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright (c) 2015 Ivan Grokhotkov
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice,
8+
this list of conditions and the following disclaimer.
9+
2. Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation
11+
and/or other materials provided with the distribution.
12+
3. The name of the authors may not be used to endorse or promote products
13+
derived from this software without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
18+
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
20+
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
23+
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
24+
OF SUCH DAMAGE.
25+
26+
Authors: Ivan Grokhotkov

bootloaders/eboot/Makefile

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
XTENSA_TOOCHAIN ?=
2+
3+
BIN_DIR := ./
4+
TARGET_DIR := ./
5+
6+
TARGET_OBJ_FILES := \
7+
eboot.o \
8+
9+
TARGET_OBJ_PATHS := $(addprefix $(TARGET_DIR)/,$(TARGET_OBJ_FILES))
10+
11+
CC := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-gcc
12+
CXX := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-g++
13+
AR := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-ar
14+
LD := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-gcc
15+
OBJDUMP := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-objdump
16+
17+
18+
CFLAGS += -std=gnu99
19+
20+
CFLAGS += -O0 -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mno-text-section-literals
21+
22+
LDFLAGS += -nostdlib -Wl,--no-check-sections -umain
23+
24+
LD_SCRIPT := -Teboot.ld
25+
26+
APP_OUT:= eboot.elf
27+
APP_AR := eboot.a
28+
APP_FW := eboot.bin
29+
30+
all: $(APP_FW)
31+
32+
$(APP_AR): $(TARGET_OBJ_PATHS)
33+
$(AR) cru $@ $^
34+
35+
36+
$(APP_OUT): $(APP_AR)
37+
$(LD) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group -Wl,--whole-archive $(APP_AR) -Wl,--end-group -o $@
38+
39+
$(APP_FW): $(APP_OUT)
40+
$(ESPTOOL) -vvv -eo $(APP_OUT) -bo $@ -bs .text -bs .data -bs .rodata -bc -ec || true
41+
42+
43+
clean:
44+
rm -f *.o
45+
rm -f $(APP_AR)
46+
rm -f $(APP_OUT)
47+
48+
49+
.PHONY: all clean default
50+

bootloaders/eboot/eboot.c

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
2+
* This file is part of eboot bootloader.
3+
*
4+
* Redistribution and use is permitted according to the conditions of the
5+
* 3-clause BSD license to be found in the LICENSE file.
6+
*/
7+
8+
9+
#include <stddef.h>
10+
#include <stdint.h>
11+
#include <stdbool.h>
12+
#include "eboot.h"
13+
extern void* flashchip;
14+
15+
#define SWRST do { (*((volatile uint32_t*) 0x60000700)) |= 0x80000000; } while(0);
16+
17+
18+
int load_app_from_flash_raw(const uint32_t flash_addr)
19+
{
20+
image_header_t image_header;
21+
uint32_t pos = flash_addr + APP_START_OFFSET;
22+
23+
if (SPIRead(pos, &image_header, sizeof(image_header))) {
24+
return 1;
25+
}
26+
pos += sizeof(image_header);
27+
28+
29+
for (uint32_t section_index = 0;
30+
section_index < image_header.num_segments;
31+
++section_index)
32+
{
33+
section_header_t section_header = {0};
34+
if (SPIRead(pos, &section_header, sizeof(section_header))) {
35+
return 2;
36+
}
37+
pos += sizeof(section_header);
38+
39+
const uint32_t address = section_header.address;
40+
41+
bool load = false;
42+
43+
if (address < 0x40000000) {
44+
load = true;
45+
}
46+
47+
if (address >= 0x40100000 && address < 0x40108000) {
48+
load = true;
49+
}
50+
51+
if (address >= 0x60000000) {
52+
load = true;
53+
}
54+
55+
if (!load) {
56+
pos += section_header.size;
57+
continue;
58+
}
59+
60+
if (SPIRead(pos, (void*)address, section_header.size))
61+
return 3;
62+
63+
pos += section_header.size;
64+
}
65+
66+
register uint32_t sp asm("a1") = 0x3ffffff0;
67+
register uint32_t pc asm("a3") = image_header.entry;
68+
__asm__ __volatile__ ("jx a3");
69+
70+
return 0;
71+
}
72+
73+
74+
void main()
75+
{
76+
int res = load_app_from_flash_raw(0);
77+
if (res) {
78+
ets_putc('\n');
79+
ets_putc('#');
80+
ets_putc('0' + res);
81+
ets_putc('\n');
82+
SWRST;
83+
}
84+
85+
while(true){}
86+
}

bootloaders/eboot/eboot.elf

5.09 KB
Binary file not shown.

bootloaders/eboot/eboot.h

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
2+
* This file is part of eboot bootloader.
3+
*
4+
* Redistribution and use is permitted according to the conditions of the
5+
* 3-clause BSD license to be found in the LICENSE file.
6+
*/
7+
8+
#ifndef EBOOT_H
9+
#define EBOOT_H
10+
11+
12+
int SPIEraseBlock(uint32_t block);
13+
int SPIEraseSector(uint32_t sector);
14+
int SPIRead(uint32_t addr, void *dest, size_t size);
15+
int SPIWrite(uint32_t addr, void *src, size_t size);
16+
17+
#define APP_START_OFFSET 0x1000
18+
19+
typedef struct {
20+
unsigned char magic;
21+
unsigned char num_segments;
22+
23+
/* SPI Flash Interface (0 = QIO, 1 = QOUT, 2 = DIO, 0x3 = DOUT) */
24+
unsigned char flash_mode;
25+
26+
/* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M,
27+
Low four bits: 0 = 40MHz, 1= 26MHz, 2 = 20MHz, 0xf = 80MHz */
28+
unsigned char flash_size_freq;
29+
30+
uint32_t entry;
31+
} image_header_t;
32+
33+
34+
typedef struct {
35+
uint32_t address;
36+
uint32_t size;
37+
} section_header_t;
38+
39+
40+
41+
#endif //EBOOT_H

0 commit comments

Comments
 (0)