File tree Expand file tree Collapse file tree 4 files changed +28
-14
lines changed Expand file tree Collapse file tree 4 files changed +28
-14
lines changed Original file line number Diff line number Diff line change 30
30
#include " spi_flash.h"
31
31
}
32
32
33
- #define CONFIG_START_SECTOR 0x3C
33
+ #define CONFIG_START_SECTOR 0x7b
34
34
#define CONFIG_SECTOR (CONFIG_START_SECTOR + 0 )
35
35
#define CONFIG_ADDR (SPI_FLASH_SEC_SIZE * CONFIG_SECTOR)
36
36
37
37
EEPROMClass::EEPROMClass ()
38
- : _data(0 ), _size(0 )
38
+ : _data(0 ), _size(0 ), _dirty( false )
39
39
{
40
40
}
41
41
@@ -67,31 +67,43 @@ void EEPROMClass::end()
67
67
68
68
uint8_t EEPROMClass::read (int address)
69
69
{
70
- if (address < 0 || address >= _size)
70
+ if (address < 0 || ( size_t ) address >= _size)
71
71
return 0 ;
72
72
73
73
return _data[address];
74
74
}
75
75
76
76
void EEPROMClass::write (int address, uint8_t value)
77
77
{
78
- if (address < 0 || address >= _size)
78
+ if (address < 0 || ( size_t ) address >= _size)
79
79
return ;
80
80
81
81
_data[address] = value;
82
82
_dirty = true ;
83
83
}
84
84
85
- void EEPROMClass::commit ()
85
+ bool EEPROMClass::commit ()
86
86
{
87
- if (!_size || !_dirty)
88
- return ;
87
+ bool ret = false ;
88
+ if (!_size)
89
+ return false ;
90
+ if (!_dirty)
91
+ return true ;
89
92
90
93
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
+ }
93
100
ETS_UART_INTR_ENABLE ();
94
- _dirty = false ;
101
+ return ret;
102
+ }
103
+
104
+ uint8_t * EEPROMClass::getDataPtr ()
105
+ {
106
+ return &_data[0 ];
95
107
}
96
108
97
109
Original file line number Diff line number Diff line change @@ -33,9 +33,11 @@ class EEPROMClass
33
33
void begin (size_t size);
34
34
uint8_t read (int address);
35
35
void write (int address, uint8_t val);
36
- void commit ();
36
+ bool commit ();
37
37
void end ();
38
38
39
+ uint8_t * getDataPtr ();
40
+
39
41
template <typename T> T &get (int address, T &t)
40
42
{
41
43
if (address < 0 || address + sizeof (T) > _size)
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ recipe.objcopy.eep.pattern=
74
74
## Create hex
75
75
#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"
76
76
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
78
78
79
79
## Compute size
80
80
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
91
91
tools.esptool.upload.protocol=esp
92
92
tools.esptool.upload.params.verbose=-vv
93
93
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"
Original file line number Diff line number Diff line change 5
5
dport0_0_seg : org = 0x3FF00000, len = 0x10
6
6
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
7
7
iram1_0_seg : org = 0x40100000, len = 0x8000
8
- irom0_0_seg : org = 0x40240000 , len = 0x3C000
8
+ irom0_0_seg : org = 0x40210000 , len = 0x6B000
9
9
}
10
10
11
11
PHDRS
You can’t perform that action at this time.
0 commit comments