Skip to content

Commit 1544a6a

Browse files
committed
Merge remote-tracking branch 'remotes/esp8266/esp8266' into esp8266
2 parents b620060 + 26eede8 commit 1544a6a

17 files changed

+558
-89
lines changed

README.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,24 @@ Allows the sketch to respond to multicast DNS queries for domain names like "foo
184184
Currently the library only works on STA interface, AP interface is not supported.
185185
See attached example and library README file for details.
186186

187+
#### Servo ####
188+
189+
This library exposes the ability to control RC (hobby) servo motors. It will support upto 24 servos on any available output pin. By defualt the first 12 servos will use Timer0 and currently this will not interfere with any other support. Servo counts above 12 will use Timer1 and features that use it will be effected.
190+
While many RC servo motors will accept the 3.3v IO data pin from a esp8266, most will not be able to run off 3.3v and will require another power source that matches their specifications. Make sure to connect the grounds between the esp8266 and the servo motor power supply.
191+
187192
#### Other libraries (not included with the IDE)
188193

189194
Libraries that don't rely on low-level access to AVR registers should work well. Here are a few libraries that were verified to work:
190195

196+
- [arduinoWebSockets](https://github.com/Links2004/arduinoWebSockets) - WebSocket Server and Client compatible with esp8266 (RFC6455)
191197
- [aREST](https://github.com/marcoschwartz/aREST) REST API handler library.
192-
- [PubSubClient](https://github.com/Imroy/pubsubclient) MQTT library by @Imroy.
193-
- [DHT11](https://github.com/adafruit/DHT-sensor-library) - initialize DHT as follows: ```DHT dht(DHTPIN, DHTTYPE, 15);```
198+
- [Blynk](https://github.com/blynkkk/blynk-library) - easy IoT framework for Makers (check out the [Kickstarter page](http://tiny.cc/blynk-kick)).
194199
- [DallasTemperature](https://github.com/milesburton/Arduino-Temperature-Control-Library.git)
200+
- [DHT11](https://github.com/adafruit/DHT-sensor-library) - initialize DHT as follows: ```DHT dht(DHTPIN, DHTTYPE, 15);```
195201
- [NeoPixelBus](https://github.com/Makuna/NeoPixelBus) - Arduino NeoPixel library compatible with esp8266.
202+
- [PubSubClient](https://github.com/Imroy/pubsubclient) MQTT library by @Imroy.
196203
- [RTC](https://github.com/Makuna/Rtc) - Arduino Library for Ds1307 & Ds3231 compatible with esp8266.
197-
- [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)
204+
- [Souliss, Smart Home](https://github.com/souliss/souliss) - Framework for Smart Home based on Arduino, Android and openHAB.
199205

200206
#### Upload via serial port ####
201207
Pick the correct serial port.

bootloaders/eboot/Makefile

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
XTENSA_TOOCHAIN ?=
1+
XTENSA_TOOLCHAIN ?=
22

33
BIN_DIR := ./
44
TARGET_DIR := ./
55

66
TARGET_OBJ_FILES := \
77
eboot.o \
88
eboot_command.o \
9+
flash.o \
910

1011
TARGET_OBJ_PATHS := $(addprefix $(TARGET_DIR)/,$(TARGET_OBJ_FILES))
1112

12-
CC := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-gcc
13-
CXX := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-g++
14-
AR := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-ar
15-
LD := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-gcc
16-
OBJDUMP := $(XTENSA_TOOCHAIN)xtensa-lx106-elf-objdump
13+
CC := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-gcc
14+
CXX := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-g++
15+
AR := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-ar
16+
LD := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-gcc
17+
OBJDUMP := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-objdump
1718

1819

1920
CFLAGS += -std=gnu99

bootloaders/eboot/eboot.c

+16-41
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
#include <stddef.h>
1010
#include <stdint.h>
1111
#include <stdbool.h>
12-
#include "eboot.h"
12+
#include "flash.h"
1313
#include "eboot_command.h"
14-
extern void* flashchip;
1514

1615
#define SWRST do { (*((volatile uint32_t*) 0x60000700)) |= 0x80000000; } while(0);
1716

@@ -73,53 +72,21 @@ int load_app_from_flash_raw(const uint32_t flash_addr)
7372

7473

7574

76-
int erase(const uint32_t start, const uint32_t size)
77-
{
78-
if (start & (FLASH_SECTOR_SIZE - 1) != 0) {
79-
return 1;
80-
}
81-
82-
const uint32_t sectors_per_block = FLASH_BLOCK_SIZE / FLASH_SECTOR_SIZE;
83-
uint32_t current_sector = start / FLASH_SECTOR_SIZE;
84-
uint32_t sector_count = (size + FLASH_SECTOR_SIZE - 1) / FLASH_SECTOR_SIZE;
85-
const uint32_t end = current_sector + sector_count;
86-
87-
for (; current_sector < end && (current_sector & (sectors_per_block-1));
88-
++current_sector, --sector_count) {
89-
if (SPIEraseSector(current_sector)) {
90-
return 2;
91-
}
92-
}
93-
94-
for (;current_sector + sectors_per_block <= end;
95-
current_sector += sectors_per_block,
96-
sector_count -= sectors_per_block) {
97-
if (SPIEraseBlock(current_sector / sectors_per_block)) {
98-
return 3;
99-
}
100-
}
101-
102-
for (; current_sector < end;
103-
++current_sector, --sector_count) {
104-
if (SPIEraseSector(current_sector)) {
105-
return 4;
106-
}
107-
}
108-
109-
return 0;
110-
}
111-
11275
int copy_raw(const uint32_t src_addr,
11376
const uint32_t dst_addr,
11477
const uint32_t size)
11578
{
79+
ets_putc('\n');
80+
ets_putc('c');
81+
ets_putc('p');
82+
ets_putc('\n');
11683
// require regions to be aligned
11784
if (src_addr & 0xfff != 0 ||
11885
dst_addr & 0xfff != 0) {
11986
return 1;
12087
}
12188

122-
if (erase(dst_addr, size)) {
89+
if (SPIEraseAreaEx(dst_addr, size)) {
12390
return 2;
12491
}
12592

@@ -153,17 +120,25 @@ void main()
153120
int res = 9;
154121
struct eboot_command cmd;
155122

156-
eboot_command_read(&cmd);
123+
if (eboot_command_read(&cmd)) {
124+
cmd.action = ACTION_LOAD_APP;
125+
cmd.args[0] = 0;
126+
ets_putc('e');
127+
} else {
128+
ets_putc('@');
129+
}
130+
eboot_command_clear();
157131

158132
if (cmd.action == ACTION_COPY_RAW) {
159133
res = copy_raw(cmd.args[0], cmd.args[1], cmd.args[2]);
160134
if (res == 0) {
161135
cmd.action = ACTION_LOAD_APP;
136+
cmd.args[0] = cmd.args[1];
162137
}
163138
}
164139

165140
if (cmd.action == ACTION_LOAD_APP) {
166-
res = load_app_from_flash_raw(0);
141+
res = load_app_from_flash_raw(cmd.args[0]);
167142
}
168143

169144
if (res) {

bootloaders/eboot/eboot.elf

1.38 KB
Binary file not shown.

bootloaders/eboot/eboot_command.c

+22-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ uint32_t eboot_command_calculate_crc32(const struct eboot_command* cmd)
2828
offsetof(struct eboot_command, crc32));
2929
}
3030

31-
void eboot_command_read(struct eboot_command* cmd)
31+
int eboot_command_read(struct eboot_command* cmd)
3232
{
3333
const uint32_t dw_count = sizeof(struct eboot_command) / sizeof(uint32_t);
3434
uint32_t* dst = (uint32_t *) cmd;
@@ -39,9 +39,27 @@ void eboot_command_read(struct eboot_command* cmd)
3939
uint32_t crc32 = eboot_command_calculate_crc32(cmd);
4040
if (cmd->magic & EBOOT_MAGIC_MASK != EBOOT_MAGIC ||
4141
cmd->crc32 != crc32) {
42-
43-
cmd->action = ACTION_LOAD_APP;
44-
cmd->args[0] = 0;
42+
return 1;
4543
}
44+
45+
return 0;
46+
}
47+
48+
void eboot_command_write(struct eboot_command* cmd)
49+
{
50+
cmd->magic = EBOOT_MAGIC;
51+
cmd->crc32 = eboot_command_calculate_crc32(cmd);
52+
53+
const uint32_t dw_count = sizeof(struct eboot_command) / sizeof(uint32_t);
54+
const uint32_t* src = (const uint32_t *) cmd;
55+
for (uint32_t i = 0; i < dw_count; ++i) {
56+
RTC_MEM[i] = src[i];
57+
}
58+
}
59+
60+
void eboot_command_clear()
61+
{
62+
RTC_MEM[offsetof(struct eboot_command, magic) / sizeof(uint32_t)] = 0;
63+
RTC_MEM[offsetof(struct eboot_command, crc32) / sizeof(uint32_t)] = 0;
4664
}
4765

bootloaders/eboot/eboot_command.h

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
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+
18
#ifndef EBOOT_COMMAND_H
29
#define EBOOT_COMMAND_H
310

@@ -23,7 +30,8 @@ struct eboot_command {
2330
};
2431

2532

26-
void eboot_command_read(struct eboot_command* cmd);
27-
33+
int eboot_command_read(struct eboot_command* cmd);
34+
void eboot_command_write(struct eboot_command* cmd);
35+
void eboot_command_clear();
2836

2937
#endif //EBOOT_COMMAND_H

bootloaders/eboot/flash.c

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
#include <stddef.h>
9+
#include <stdint.h>
10+
#include <stdbool.h>
11+
#include "flash.h"
12+
13+
14+
int SPIEraseAreaEx(const uint32_t start, const uint32_t size)
15+
{
16+
if (start & (FLASH_SECTOR_SIZE - 1) != 0) {
17+
return 1;
18+
}
19+
20+
const uint32_t sectors_per_block = FLASH_BLOCK_SIZE / FLASH_SECTOR_SIZE;
21+
uint32_t current_sector = start / FLASH_SECTOR_SIZE;
22+
uint32_t sector_count = (size + FLASH_SECTOR_SIZE - 1) / FLASH_SECTOR_SIZE;
23+
const uint32_t end = current_sector + sector_count;
24+
25+
for (; current_sector < end && (current_sector & (sectors_per_block-1));
26+
++current_sector, --sector_count) {
27+
if (SPIEraseSector(current_sector)) {
28+
return 2;
29+
}
30+
}
31+
32+
for (;current_sector + sectors_per_block <= end;
33+
current_sector += sectors_per_block,
34+
sector_count -= sectors_per_block) {
35+
if (SPIEraseBlock(current_sector / sectors_per_block)) {
36+
return 3;
37+
}
38+
}
39+
40+
for (; current_sector < end;
41+
++current_sector, --sector_count) {
42+
if (SPIEraseSector(current_sector)) {
43+
return 4;
44+
}
45+
}
46+
47+
return 0;
48+
}
49+

bootloaders/eboot/eboot.h renamed to bootloaders/eboot/flash.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
* 3-clause BSD license to be found in the LICENSE file.
66
*/
77

8-
#ifndef EBOOT_H
9-
#define EBOOT_H
10-
8+
#ifndef FLASH_H
9+
#define FLASH_H
1110

1211
int SPIEraseBlock(uint32_t block);
1312
int SPIEraseSector(uint32_t sector);
1413
int SPIRead(uint32_t addr, void *dest, size_t size);
1514
int SPIWrite(uint32_t addr, void *src, size_t size);
16-
15+
int SPIEraseAreaEx(const uint32_t start, const uint32_t size);
1716

1817
#define FLASH_SECTOR_SIZE 0x1000
1918
#define FLASH_BLOCK_SIZE 0x10000
@@ -41,4 +40,4 @@ typedef struct {
4140

4241

4342

44-
#endif //EBOOT_H
43+
#endif //FLASH_H

0 commit comments

Comments
 (0)