Skip to content

Commit 823a245

Browse files
committed
Merge branch 'master' into ethernet
2 parents 8094f2d + 8b662ed commit 823a245

File tree

133 files changed

+6579
-1473
lines changed

Some content is hidden

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

133 files changed

+6579
-1473
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Starting with 1.6.4, Arduino allows installation of third-party platform package
3030

3131
- Install the current upstream Arduino IDE at the 1.8.9 level or later. The current version is on the [Arduino website](https://www.arduino.cc/en/main/software).
3232
- Start Arduino and open the Preferences window.
33-
- Enter ```https://arduino.esp8266.com/stable/package_esp8266com_index.json``` into the *Additional Board Manager URLs* field. You can add multiple URLs, separating them with commas.
33+
- Enter ```https://arduino.esp8266.com/stable/package_esp8266com_index.json``` into the *File>Preferences>Additional Boards Manager URLs* field of the Arduino IDE. You can add multiple URLs, separating them with commas.
3434
- Open Boards Manager from Tools > Board menu and install *esp8266* platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).
3535

3636
#### Latest release [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/)

boards.txt

Lines changed: 547 additions & 0 deletions
Large diffs are not rendered by default.

bootloaders/eboot/eboot.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ int load_app_from_flash_raw(const uint32_t flash_addr)
6868
load = true;
6969
}
7070

71-
if (address >= 0x40100000 && address < 0x40108000) {
71+
// The final IRAM size, once boot has completed, can be either 32K or 48K.
72+
// Allow for the higher in range testing.
73+
if (address >= 0x40100000 && address < 0x4010C000) {
7274
load = true;
7375
}
7476

bootloaders/eboot/eboot.elf

-72 Bytes
Binary file not shown.

cores/esp8266/Arduino.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ void optimistic_yield(uint32_t interval_us);
225225
#include <cstdlib>
226226
#include <cmath>
227227

228+
229+
#include "mmu_iram.h"
230+
231+
228232
using std::min;
229233
using std::max;
230234
using std::round;

cores/esp8266/Esp-frag.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ void EspClass::getHeapStats(uint32_t* hfree, uint16_t* hmax, uint8_t* hfrag)
3030
// 100 * (1 - sqrt(sum(hole-size²)) / sum(hole-size))
3131

3232
umm_info(NULL, false);
33-
uint8_t block_size = umm_block_size();
33+
34+
uint32_t free_size = umm_free_heap_size_core(umm_get_current_heap());
3435
if (hfree)
35-
*hfree = ummHeapInfo.freeBlocks * block_size;
36+
*hfree = free_size;
3637
if (hmax)
37-
*hmax = (uint16_t)ummHeapInfo.maxFreeContiguousBlocks * block_size;
38+
*hmax = (uint16_t)umm_max_block_size_core(umm_get_current_heap());
3839
if (hfrag) {
39-
if (ummHeapInfo.freeBlocks) {
40-
*hfrag = 100 - (sqrt32(ummHeapInfo.freeBlocksSquared) * 100) / ummHeapInfo.freeBlocks;
40+
if (free_size) {
41+
*hfrag = umm_fragmentation_metric_core(umm_get_current_heap());
4142
} else {
4243
*hfrag = 0;
4344
}
@@ -46,11 +47,5 @@ void EspClass::getHeapStats(uint32_t* hfree, uint16_t* hmax, uint8_t* hfrag)
4647

4748
uint8_t EspClass::getHeapFragmentation()
4849
{
49-
#ifdef UMM_INLINE_METRICS
50-
return (uint8_t)umm_fragmentation_metric();
51-
#else
52-
uint8_t hfrag;
53-
getHeapStats(nullptr, nullptr, &hfrag);
54-
return hfrag;
55-
#endif
50+
return (uint8_t)umm_fragmentation_metric();
5651
}

cores/esp8266/Esp.cpp

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "cont.h"
2929

3030
#include "coredecls.h"
31+
#include "umm_malloc/umm_malloc.h"
32+
// #include "core_esp8266_vm.h"
3133
#include <pgmspace.h>
3234

3335
extern "C" {
@@ -516,45 +518,45 @@ uint8_t *EspClass::random(uint8_t *resultArray, const size_t outputSizeBytes) co
516518
{
517519
/**
518520
* The ESP32 Technical Reference Manual v4.1 chapter 24 has the following to say about random number generation (no information found for ESP8266):
519-
*
521+
*
520522
* "When used correctly, every 32-bit value the system reads from the RNG_DATA_REG register of the random number generator is a true random number.
521523
* These true random numbers are generated based on the noise in the Wi-Fi/BT RF system.
522524
* When Wi-Fi and BT are disabled, the random number generator will give out pseudo-random numbers.
523-
*
525+
*
524526
* When Wi-Fi or BT is enabled, the random number generator is fed two bits of entropy every APB clock cycle (normally 80 MHz).
525527
* Thus, for the maximum amount of entropy, it is advisable to read the random register at a maximum rate of 5 MHz.
526528
* A data sample of 2 GB, read from the random number generator with Wi-Fi enabled and the random register read at 5 MHz,
527529
* has been tested using the Dieharder Random Number Testsuite (version 3.31.1).
528530
* The sample passed all tests."
529-
*
531+
*
530532
* Since ESP32 is the sequal to ESP8266 it is unlikely that the ESP8266 is able to generate random numbers more quickly than 5 MHz when run at a 80 MHz frequency.
531533
* A maximum random number frequency of 0.5 MHz is used here to leave some margin for possibly inferior components in the ESP8266.
532534
* It should be noted that the ESP8266 has no Bluetooth functionality, so turning the WiFi off is likely to cause RANDOM_REG32 to use pseudo-random numbers.
533-
*
534-
* It is possible that yield() must be called on the ESP8266 to properly feed the hardware random number generator new bits, since there is only one processor core available.
535+
*
536+
* It is possible that yield() must be called on the ESP8266 to properly feed the hardware random number generator new bits, since there is only one processor core available.
535537
* However, no feeding requirements are mentioned in the ESP32 documentation, and using yield() could possibly cause extended delays during number generation.
536538
* Thus only delayMicroseconds() is used below.
537-
*/
539+
*/
538540

539541
constexpr uint8_t cooldownMicros = 2;
540542
static uint32_t lastCalledMicros = micros() - cooldownMicros;
541543

542544
uint32_t randomNumber = 0;
543-
545+
544546
for(size_t byteIndex = 0; byteIndex < outputSizeBytes; ++byteIndex)
545547
{
546548
if(byteIndex % 4 == 0)
547549
{
548550
// Old random number has been used up (random number could be exactly 0, so we can't check for that)
549-
551+
550552
uint32_t timeSinceLastCall = micros() - lastCalledMicros;
551553
if(timeSinceLastCall < cooldownMicros)
552554
delayMicroseconds(cooldownMicros - timeSinceLastCall);
553-
555+
554556
randomNumber = RANDOM_REG32;
555557
lastCalledMicros = micros();
556558
}
557-
559+
558560
resultArray[byteIndex] = randomNumber;
559561
randomNumber >>= 8;
560562
}
@@ -969,3 +971,57 @@ String EspClass::getSketchMD5()
969971
result = md5.toString();
970972
return result;
971973
}
974+
975+
void EspClass::enableVM()
976+
{
977+
#ifdef UMM_HEAP_EXTERNAL
978+
if (!vmEnabled)
979+
install_vm_exception_handler();
980+
vmEnabled = true;
981+
#endif
982+
}
983+
984+
void EspClass::setExternalHeap()
985+
{
986+
#ifdef UMM_HEAP_EXTERNAL
987+
if (vmEnabled)
988+
umm_push_heap(UMM_HEAP_EXTERNAL);
989+
#endif
990+
}
991+
992+
void EspClass::setIramHeap()
993+
{
994+
#ifdef UMM_HEAP_IRAM
995+
umm_push_heap(UMM_HEAP_IRAM);
996+
#endif
997+
}
998+
999+
void EspClass::setDramHeap()
1000+
{
1001+
#if defined(UMM_HEAP_EXTERNAL) && !defined(UMM_HEAP_IRAM)
1002+
if (vmEnabled) {
1003+
if (!umm_push_heap(UMM_HEAP_DRAM)) {
1004+
panic();
1005+
}
1006+
}
1007+
#elif defined(UMM_HEAP_IRAM)
1008+
if (!umm_push_heap(UMM_HEAP_DRAM)) {
1009+
panic();
1010+
}
1011+
#endif
1012+
}
1013+
1014+
void EspClass::resetHeap()
1015+
{
1016+
#if defined(UMM_HEAP_EXTERNAL) && !defined(UMM_HEAP_IRAM)
1017+
if (vmEnabled) {
1018+
if (!umm_pop_heap()) {
1019+
panic();
1020+
}
1021+
}
1022+
#elif defined(UMM_HEAP_IRAM)
1023+
if (!umm_pop_heap()) {
1024+
panic();
1025+
}
1026+
#endif
1027+
}

cores/esp8266/Esp.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class EspClass {
123123
uint8_t getBootMode();
124124

125125
#if defined(F_CPU) || defined(CORE_MOCK)
126-
constexpr
126+
constexpr
127127
#endif
128128
inline uint8_t getCpuFreqMHz() const __attribute__((always_inline))
129129
{
@@ -215,7 +215,15 @@ class EspClass {
215215
#else
216216
uint32_t getCycleCount();
217217
#endif // !defined(CORE_MOCK)
218+
void enableVM();
219+
void setDramHeap();
220+
void setIramHeap();
221+
void setExternalHeap();
222+
void resetHeap();
218223
private:
224+
#ifdef UMM_HEAP_EXTERNAL
225+
bool vmEnabled = false;
226+
#endif
219227
/**
220228
* @brief Replaces @a byteCount bytes of a 4 byte block on flash
221229
*

cores/esp8266/FS.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ int File::available() {
4646
return _p->size() - _p->position();
4747
}
4848

49+
int File::availableForWrite() {
50+
if (!_p)
51+
return false;
52+
53+
return _p->availableForWrite();
54+
}
55+
56+
4957
int File::read() {
5058
if (!_p)
5159
return -1;

cores/esp8266/FS.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class File : public Stream
5757
// Print methods:
5858
size_t write(uint8_t) override;
5959
size_t write(const uint8_t *buf, size_t size) override;
60+
int availableForWrite() override;
6061

6162
// Stream methods:
6263
int available() override;

0 commit comments

Comments
 (0)