8000 Merge branch 'esp8266' of https://github.com/Links2004/Arduino into L… · swkim01/Arduino@748d6a6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 748d6a6

Browse files
committed
Merge branch 'esp8266' of https://github.com/Links2004/Arduino into Links2004-esp8266
2 parents d19aaf6 + 8272e87 commit 748d6a6

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.cpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
#include "spi_flash.h"
3131
}
3232

33-
#define CONFIG_START_SECTOR 0x3C
33+
#define CONFIG_START_SECTOR 0x7b
3434
#define CONFIG_SECTOR (CONFIG_START_SECTOR + 0)
3535
#define CONFIG_ADDR (SPI_FLASH_SEC_SIZE * CONFIG_SECTOR)
3636

3737
EEPROMClass::EEPROMClass()
38-
: _data(0), _size(0)
38+
: _data(0), _size(0), _dirty(false)
3939
{
4040
}
4141

@@ -67,31 +67,43 @@ void EEPROMClass::end()
6767

6868
uint8_t EEPROMClass::read(int address)
6969
{
70-
if (address < 0 || address >= _size)
70+
if (address < 0 || (size_t)address >= _size)
7171
return 0;
7272

7373
return _data[address];
7474
}
7575

7676
void EEPROMClass::write(int address, uint8_t value)
7777
{
78-
if (address < 0 || address >= _size)
78+
if (address < 0 || (size_t)address >= _size)
7979
return;
8080

8181
_data[address] = value;
8282
_dirty = true;
8383
}
8484

85-
void EEPROMClass::commit()
85+
bool EEPROMClass::commit()
8686
{
87-
if (!_size || !_dirty)
88-
return;
87+
bool ret = false;
88+
if (!_size)
89+
return false;
90+
if(!_dirty)
91+
return true;
8992

9093
ETS_UART_INTR_DISABLE();
91-
spi_flash_erase_sector(CONFIG_SECTOR);
92-
spi_flash_write(CONFIG_ADDR, reinterpret_cast<uint32_t*>(_data), _size);
94+
if(spi_flash_erase_sector(CONFIG_SECTOR) == SPI_FLASH_RESULT_OK) {
95+
if(spi_flash_write(CONFIG_ADDR, reinterpret_cast<uint32_t*>(_data), _size) == SPI_FLASH_RESULT_OK) {
96+
_dirty = false;
97+
ret = true;
98+
}
99+
}
93100
ETS_UART_INTR_ENABLE();
94-
_dirty = false;
101+
return ret;
102+
}
103+
104+
uint8_t * EEPROMClass::getDataPtr()
105+
{
106+
return &_data[0];
95107
}
96108

97109

hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h

Copy file name to clipboard
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ class EEPROMClass
3333
void begin(size_t size);
3434
uint8_t read(int address);
3535
void write(int address, uint8_t val);
36-
void commit();
36+
bool commit();
3737
void end();
3838

39+
uint8_t * getDataPtr();
40+
3941
template<typename T> T &get(int address, T &t)
4042
{
4143
if (address < 0 || address + sizeof(T) > _size)

hardware/esp8266com/esp8266/platform.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ recipe.objcopy.eep.pattern=
7474
## Create hex
7575
#recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
7676

77-
recipe.objcopy.hex.pattern="{compiler.tools.path}{compiler.esptool.cmd}" -eo "{build.path}/{build.project_name}.elf" -bo "{build.path}/{build.project_name}_00000.bin" -bm {build.flash_mode} -bf {build.flash_freq} -bz {build.flash_size} -bs .text -bs .data -bs .rodata -bc -ec -eo "{build.path}/{build.project_name}.elf" -es .irom0.text "{build.path}/{build.project_name}_40000.bin" -ec
77+
recipe.objcopy.hex.pattern="{compiler.tools.path}{compiler.esptool.cmd}" -eo "{build.path}/{build.project_name}.elf" -bo "{build.path}/{build.project_name}_00000.bin" -bm {build.flash_mode} -bf {build.flash_freq} -bz {build.flash_size} -bs .text -bs .data -bs .rodata -bc -ec -eo "{build.path}/{build.project_name}.elf" -es .irom0.text "{build.path}/{build.project_name}_10000.bin" -ec
7878

7979
## Compute size
8080
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
@@ -91,4 +91,4 @@ tools.esptool.path={runtime.ide.path}/hardware/tools/esp8266
9191
tools.esptool.upload.protocol=esp
9292
tools.esptool.upload.params.verbose=-vv
9393
tools.esptool.upload.params.quiet=
94-
tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}_00000.bin" -ca 0x40000 -cf "{build.path}/{build.project_name}_40000.bin"
94+
tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}_00000.bin" -ca 0x10000 -cf "{build.path}/{build.project_name}_10000.bin"

hardware/tools/esp8266/sdk/ld/eagle.app.v6.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ MEMORY
55
dport0_0_seg : org = 0x3FF00000, len = 0x10
66
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
77
iram1_0_seg : org = 0x40100000, len = 0x8000
8-
irom0_0_seg : org = 0x40240000, len = 0x3C000
8+
irom0_0_seg : org = 0x40210000, len = 0x6B000
99
}
1010

1111
PHDRS

0 commit comments

Comments
 (0)
0