Skip to content

Commit e5d7270

Browse files
author
me-no-dev
committed
Merge remote-tracking branch 'esp8266/master'
2 parents bd81ec9 + a5c3aea commit e5d7270

File tree

38 files changed

+977
-113
lines changed

38 files changed

+977
-113
lines changed

boards.txt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,3 +691,83 @@ d1_mini.menu.FlashSize.4M1M.build.spiffs_start=0x300000
691691
d1_mini.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000
692692
d1_mini.menu.FlashSize.4M1M.build.spiffs_blocksize=8192
693693
d1_mini.menu.FlashSize.4M1M.build.spiffs_pagesize=256
694+
695+
696+
##############################################################
697+
espino.name=ESPino
698+
699+
espino.upload.tool=esptool
700+
espino.upload.speed=115200
701+
espino.upload.resetmethod=ck
702+
espino.upload.maximum_size=1044464
703+
espino.upload.maximum_data_size=81920
704+
espino.upload.wait_for_upload_port=true
705+
espino.serial.disableDTR=true
706+
espino.serial.disableRTS=true
707+
708+
espino.build.mcu=esp8266
709+
espino.build.f_cpu=80000000L
710+
espino.build.board=ESP8266_ESP12
711+
espino.build.core=esp8266
712+
espino.build.variant=espino
713+
espino.build.flash_mode=qio
714+
espino.build.flash_size=4M
715+
espino.build.flash_freq=40
716+
espino.build.spiffs_pagesize=256
717+
718+
espino.menu.UploadTool.esptool=Serial
719+
espino.menu.UploadTool.esptool.upload.tool=esptool
720+
espino.menu.UploadTool.esptool.upload.verbose=-vv
721+
espino.menu.UploadTool.espota=OTA
722+
espino.menu.UploadTool.espota.upload.tool=espota
723+
724+
espino.menu.CpuFrequency.80=80 MHz
725+
espino.menu.CpuFrequency.80.build.f_cpu=80000000L
726+
espino.menu.CpuFrequency.160=160 MHz
727+
espino.menu.CpuFrequency.160.build.f_cpu=160000000L
728+
729+
espino.menu.FlashMode.dio=DIO
730+
espino.menu.FlashMode.dio.build.flash_mode=dio
731+
espino.menu.FlashMode.qio=QIO
732+
espino.menu.FlashMode.qio.build.flash_mode=qio
733+
734+
espino.menu.UploadSpeed.115200=115200
735+
espino.menu.UploadSpeed.115200.upload.speed=115200
736+
espino.menu.UploadSpeed.9600=9600
737+
espino.menu.UploadSpeed.9600.upload.speed=9600
738+
espino.menu.UploadSpeed.57600=57600
739+
espino.menu.UploadSpeed.57600.upload.speed=57600
740+
espino.menu.UploadSpeed.256000.windows=256000
741+
espino.menu.UploadSpeed.256000.upload.speed=256000
742+
espino.menu.UploadSpeed.230400.linux=230400
743+
espino.menu.UploadSpeed.230400.macosx=230400
744+
espino.menu.UploadSpeed.230400.upload.speed=230400
745+
espino.menu.UploadSpeed.460800.linux=460800
746+
espino.menu.UploadSpeed.460800.macosx=460800
747+
espino.menu.UploadSpeed.460800.upload.speed=460800
748+
espino.menu.UploadSpeed.512000.windows=512000
749+
espino.menu.UploadSpeed.512000.upload.speed=512000
750+
espino.menu.UploadSpeed.921600=921600
751+
espino.menu.UploadSpeed.921600.upload.speed=921600
752+
753+
espino.menu.FlashSize.4M1M=4M (1M SPIFFS)
754+
espino.menu.FlashSize.4M1M.build.flash_size=4M
755+
espino.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld
756+
espino.menu.FlashSize.4M1M.build.spiffs_start=0x300000
757+
espino.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000
758+
espino.menu.FlashSize.4M1M.build.spiffs_blocksize=8192
759+
espino.menu.FlashSize.4M1M.build.spiffs_pagesize=256
760+
espino.menu.FlashSize.4M1M.upload.maximum_size=1044464
761+
762+
espino.menu.FlashSize.4M3M=4M (3M SPIFFS)
763+
espino.menu.FlashSize.4M3M.build.flash_size=4M
764+
espino.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld
765+
espino.menu.FlashSize.4M3M.build.spiffs_start=0x100000
766+
espino.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000
767+
espino.menu.FlashSize.4M3M.build.spiffs_blocksize=8192
768+
espino.menu.FlashSize.4M3M.upload.maximum_size=1044464
769+
770+
espino.menu.ResetMethod.ck=ck
771+
espino.menu.ResetMethod.ck.upload.resetmethod=ck
772+
espino.menu.ResetMethod.nodemcu=nodemcu
773+
espino.menu.ResetMethod.nodemcu.upload.resetmethod=nodemcu

cores/esp8266/Arduino.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,12 @@ void loop(void);
219219
void yield(void);
220220
void optimistic_yield(uint32_t interval_us);
221221

222-
// Get the bit location within the hardware port of the given virtual pin.
223-
// This comes from the pins_*.c file for the active board configuration.
224222
#define digitalPinToPort(pin) (0)
225223
#define digitalPinToBitMask(pin) (1UL << (pin))
226224
#define digitalPinToTimer(pin) (0)
227-
#define portOutputRegister(port) ((volatile uint32_t*) GPO)
228-
#define portInputRegister(port) ((volatile uint32_t*) GPI)
229-
#define portModeRegister(port) ((volatile uint32_t*) GPE)
225+
#define portOutputRegister(port) ((volatile uint32_t*) &GPO)
226+
#define portInputRegister(port) ((volatile uint32_t*) &GPI)
227+
#define portModeRegister(port) ((volatile uint32_t*) &GPE)
230228

231229
#define NOT_A_PIN -1
232230
#define NOT_A_PORT -1

cores/esp8266/HardwareSerial.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,18 +617,15 @@ size_t HardwareSerial::write(uint8_t c) {
617617
size_t room = uart_get_tx_fifo_room(_uart);
618618
if(room > 0 && _tx_buffer->empty()) {
619619
uart_transmit_char(_uart, c);
620-
if(room < 10) {
621-
uart_arm_tx_interrupt(_uart);
622-
}
623620
return 1;
624621
}
625622

626623
while(_tx_buffer->room() == 0) {
627624
yield();
628-
uart_arm_tx_interrupt(_uart);
629625
}
630626

631627
_tx_buffer->write(c);
628+
uart_arm_tx_interrupt(_uart);
632629
return 1;
633630
}
634631

cores/esp8266/Updater.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class UpdaterClass {
2626
Call this to check the space needed for the update
2727
Will return false if there is not enough space
2828
*/
29-
bool begin(size_t size, int = U_FLASH);
29+
bool begin(size_t size, int command = U_FLASH);
3030

3131
/*
3232
Writes a buffer to the flash and increments the address

cores/esp8266/abi.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ void __throw_length_error(char const*) {
6868
void __throw_bad_alloc() {
6969
panic();
7070
}
71+
72+
void __throw_logic_error(const char* str) {
73+
panic();
74+
}
7175
}
7276

7377
// TODO: rebuild windows toolchain to make this unnecessary:

cores/esp8266/base64.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* base64.cpp
3+
*
4+
* Created on: 09.12.2015
5+
*
6+
* Copyright (c) 2015 Markus Sattler. All rights reserved.
7+
* This file is part of the ESP8266 core for Arduino.
8+
*
9+
* This library is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 2.1 of the License, or (at your option) any later version.
13+
*
14+
* This library is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with this library; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22+
*
23+
*/
24+
25+
#include "Arduino.h"
26+
extern "C" {
27+
#include "libb64/cdecode.h"
28+
#include "libb64/cencode.h"
29+
}
30+
#include "base64.h"
31+
32+
/**
33+
* convert input data to base64
34+
* @param data uint8_t *
35+
* @param length size_t
36+
* @return String
37+
*/
38+
String base64::encode(uint8_t * data, size_t length) {
39+
// base64 needs more size then the source data
40+
size_t size = ((length * 1.6f) + 1);
41+
char * buffer = (char *) malloc(size);
42+
if(buffer) {
43+
base64_encodestate _state;
44+
base64_init_encodestate(&_state);
45+
int len = base64_encode_block((const char *) &data[0], length, &buffer[0], &_state);
46+
len = base64_encode_blockend((buffer + len), &_state);
47+
48+
String base64 = String(buffer);
49+
free(buffer);
50+
return base64;
51+
}
52+
return String("-FAIL-");
53+
}
54+
55+
/**
56+
* convert input data to base64
57+
* @param text String
58+
* @return String
59+
*/
60+
String base64::encode(String text) {
61+
return base64::encode((uint8_t *) text.c_str(), text.length());
62+
}
63+

cores/esp8266/base64.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* base64.h
3+
*
4+
* Created on: 09.12.2015
5+
*
6+
* Copyright (c) 2015 Markus Sattler. All rights reserved.
7+
* This file is part of the ESP8266 core for Arduino.
8+
*
9+
* This library is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 2.1 of the License, or (at your option) any later version.
13+
*
14+
* This library is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with this library; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22+
*
23+
*/
24+
25+
#ifndef CORE_BASE64_H_
26+
#define CORE_BASE64_H_
27+
28+
class base64 {
29+
public:
30+
static String encode(uint8_t * data, size_t length);
31+
static String encode(String text);
32+
private:
33+
};
34+
35+
36+
#endif /* CORE_BASE64_H_ */

cores/esp8266/cbuf.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ class cbuf {
4242
if(_end >= _begin) {
4343
return _size - (_end - _begin) - 1;
4444
}
45-
if(_begin == _end) {
46-
return _size;
47-
}
4845
return _begin - _end - 1;
4946
}
5047

@@ -62,7 +59,7 @@ class cbuf {
6259
if(getSize() == 0) return -1;
6360

6461
char result = *_begin;
65-
if(++_begin == _bufend) _begin = _buf;
62+
_begin = wrap_if_bufend(_begin + 1);
6663
return static_cast<int>(result);
6764
}
6865

@@ -78,16 +75,15 @@ class cbuf {
7875
dst += top_size;
7976
}
8077
memcpy(dst, _begin, size_to_read);
81-
_begin += size_to_read;
82-
if(_begin == _bufend) _begin = _buf;
78+
_begin = wrap_if_bufend(_begin + size_to_read);
8379
return size_read;
8480
}
8581

8682
size_t write(char c) {
8783
if(room() == 0) return 0;
8884

8985
*_end = c;
90-
if(++_end == _bufend) _end = _buf;
86+
_end = wrap_if_bufend(_end + 1);
9187
return 1;
9288
}
9389

@@ -103,8 +99,7 @@ class cbuf {
10399
src += top_size;
104100
}
105101
memcpy(_end, src, size_to_write);
106-
_end += size_to_write;
107-
if(_end == _bufend) _end = _buf;
102+
_end = wrap_if_bufend(_end + size_to_write);
108103
return size_written;
109104
}
110105

@@ -114,6 +109,10 @@ class cbuf {
114109
}
115110

116111
private:
112+
inline char* wrap_if_bufend(char* ptr) {
113+
return (ptr == _bufend) ? _buf : ptr;
114+
}
115+
117116
size_t _size;
118117
char* _buf;
119118
char* _bufend;

cores/esp8266/core_esp8266_features.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727

2828
#define CORE_HAS_LIBB64
29+
#define CORE_HAS_BASE64_CLASS
2930

3031

3132
#endif

cores/esp8266/esp8266_peri.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ extern uint8_t esp8266_gpioToFn[16];
494494

495495
//SPI Phase Length Locations
496496
#define SPILCOMMAND 28 //4 bit in SPIxU2 default 7 (8bit)
497-
#define SPILADDR 16 //6 bit in SPIxU1 default:23 (24bit)
497+
#define SPILADDR 26 //6 bit in SPIxU1 default:23 (24bit)
498498
#define SPILDUMMY 0 //8 bit in SPIxU1 default:0 (0 cycles)
499499
#define SPILMISO 8 //9 bit in SPIxU1 default:0 (1bit)
500500
#define SPILMOSI 17 //9 bit in SPIxU1 default:0 (1bit)
@@ -834,4 +834,10 @@ extern uint8_t esp8266_gpioToFn[16];
834834
#define I2STXCMM (0x7) //I2S_TX_CHAN_MOD
835835
#define I2STXCM (0) //I2S_TX_CHAN_MOD_S
836836

837+
/**
838+
Random Number Generator 32bit
839+
http://esp8266-re.foogod.com/wiki/Random_Number_Generator
840+
**/
841+
#define RANDOM_REG32 ESP8266_DREG(0x20E44)
842+
837843
#endif

0 commit comments

Comments
 (0)