Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 859c7d0

Browse files
author
Daniel Campora
committed
esp32: Update with master up to release 1.10.1.b1
1 parent ba26742 commit 859c7d0

Some content is hidden

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

62 files changed

+400
-254
lines changed

esp32/Makefile

+3-6
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,12 @@ CFLAGS_XTENSA = -DESP_PLATFORM -Wpointer-arith -Wall -Werror=all -Wno-error=unus
4848
-mlongcalls -Wall -ffunction-sections -fdata-sections -fno-common \
4949
-Wno-sign-compare -Wno-old-style-declaration -fstrict-volatile-bitfields \
5050
-Wno-error=deprecated-declarations -Wno-unused-parameter -DWITH_POSIX \
51-
-mfix-esp32-psram-cache-issue
5251

53-
ifeq ($(TARGET), app)
5452
CFLAGS_XTENSA_OPT = -Os
55-
else
56-
CFLAGS_XTENSA_OPT = -Og
57-
endif
53+
CFLAGS_XTENSA_PSRAM = -mfix-esp32-psram-cache-issue
5854

59-
CFLAGS = $(CFLAGS_XTENSA) $(CFLAGS_XTENSA_OPT) -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD)
55+
CFLAGS = $(CFLAGS_XTENSA) $(CFLAGS_XTENSA_PSRAM) $(CFLAGS_XTENSA_OPT) -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD)
56+
CFLAGS_SIGFOX = $(CFLAGS_XTENSA) -O2 -nostdlib -std=gnu99 -g3 -ggdb -fstrict-volatile-bitfields -Iboards/$(BOARD)
6057

6158
LDFLAGS = -nostdlib -Wl,-Map=$(@:.elf=.map) -Wl,--no-check-sections -u call_user_start_cpu0
6259
LDFLAGS += -Wl,-static -Wl,--undefined=uxTopUsedPriority -Wl,--gc-sections

esp32/application.mk

+11-6
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ APP_LDFLAGS += $(LDFLAGS) -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T
273273

274274
# add the application specific CFLAGS
275275
CFLAGS += $(APP_INC) -DMICROPY_NLR_SETJMP=1 -D$(LORA_BAND) -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"' -DHAVE_CONFIG_H -DESP_PLATFORM
276+
CFLAGS_SIGFOX += $(APP_INC) -DMICROPY_NLR_SETJMP=1 -D$(LORA_BAND) -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"' -DHAVE_CONFIG_H -DESP_PLATFORM
276277

277278
# add the application archive, this order is very important
278279
APP_LIBS = -Wl,--start-group $(LIBS) $(BUILD)/application.a -Wl,--end-group -Wl,-EL
@@ -281,16 +282,19 @@ BOOT_LIBS = -Wl,--start-group $(B_LIBS) $(BUILD)/bootloader/bootloader.a -Wl,--e
281282

282283
# debug / optimization options
283284
ifeq ($(BTYPE), debug)
284-
CFLAGS += -DDEBUG_B -DNDEBUG -DPYCOM_DEBUG
285+
CFLAGS += -DDEBUG
286+
CFLAGS_SIGFOX += -DDEBUG
285287
else
286288
ifeq ($(BTYPE), release)
287289
CFLAGS += -DNDEBUG
290+
CFLAGS_SIGFOX += -DNDEBUG
288291
else
289292
$(error Invalid BTYPE specified)
290293
endif
291294
endif
292295

293296
$(BUILD)/bootloader/%.o: CFLAGS += -D BOOTLOADER_BUILD=1
297+
$(BUILD)/bootloader/%.o: CFLAGS_SIGFOX += -D BOOTLOADER_BUILD=1
294298

295299
BOOT_OFFSET = 0x1000
296300
PART_OFFSET = 0x8000
@@ -306,9 +310,10 @@ ifeq ($(BOARD), LOPY)
306310
else
307311
ifeq ($(BOARD), SIPY)
308312
APP_BIN = $(BUILD)/sipy.bin
309-
$(BUILD)/sigfox/radio.o: CFLAGS += -O2
310-
$(BUILD)/sigfox/timer.o: CFLAGS += -O2
311-
$(BUILD)/sigfox/targets/%.o: CFLAGS += -O2
313+
$(BUILD)/sigfox/radio.o: CFLAGS = $(CFLAGS_SIGFOX)
314+
$(BUILD)/sigfox/timer.o: CFLAGS = $(CFLAGS_SIGFOX)
315+
$(BUILD)/sigfox/transmission.o: CFLAGS = $(CFLAGS_SIGFOX)
316+
$(BUILD)/sigfox/targets/%.o: CFLAGS = $(CFLAGS_SIGFOX)
312317
else
313318
APP_BIN = $(BUILD)/wipy.bin
314319
endif
@@ -320,8 +325,8 @@ PART_BIN = $(BUILD)/lib/partitions.bin
320325
ESPPORT ?= /dev/ttyUSB0
321326
ESPBAUD ?= 921600
322327

323-
FLASH_SIZE = 4MB
324-
ESPFLASHFREQ = 40m
328+
FLASH_SIZE = detect
329+
ESPFLASHFREQ = 80m
325330
ESPFLASHMODE = dio
326331

327332
PIC_TOOL = $(PYTHON) tools/pypic.py --port $(ESPPORT)

esp32/bootloader/bootloader.c

+112-18
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "esp_system.h"
2424

2525
#include "rom/cache.h"
26+
#include "rom/efuse.h"
2627
#include "rom/ets_sys.h"
2728
#include "rom/spi_flash.h"
2829
#include "rom/crc.h"
@@ -84,6 +85,8 @@ static void set_cache_and_start_app(uint32_t drom_addr,
8485
uint32_t irom_size,
8586
uint32_t entry_addr);
8687
static void update_flash_config(const esp_image_header_t* pfhdr);
88+
static void vddsdio_configure();
89+
static void flash_gpio_configure();
8790
static void clock_configure(void);
8891
static void uart_console_configure(void);
8992
static void wdt_reset_check(void);
@@ -106,13 +109,15 @@ void call_start_cpu0()
106109
cpu_configure_region_protection();
107110

108111
/* Sanity check that static RAM is after the stack */
112+
#ifndef NDEBUG
109113
{
110114
int *sp = get_sp();
111115
assert(&_bss_start <= &_bss_end);
112116
assert(&_data_start <= &_data_end);
113117
assert(sp < &_bss_start);
114118
assert(sp < &_data_start);
115119
}
120+
#endif
116121

117122
//Clear bss
118123
memset(&_bss_start, 0, (&_bss_end - &_bss_start) * sizeof(_bss_start));
@@ -272,13 +277,10 @@ static IRAM_ATTR void calculate_signature (uint8_t *signature) {
272277
MD5Init(&md5_context);
273278
ESP_LOGI(TAG, "md5 init sig");
274279
while (total_len < 0x7000) {
275-
// Cache_Read_Disable(0);
276280
if (ESP_ROM_SPIFLASH_RESULT_OK != bootloader_flash_read(0x1000 + total_len, (void *)bootloader_buf, SPI_SEC_SIZE, false)) {
277281
ESP_LOGE(TAG, SPI_ERROR_LOG);
278-
// Cache_Read_Enable(0);
279282
return;
280283
}
281-
// Cache_Read_Enable(0);
282284
total_len += SPI_SEC_SIZE;
283285
MD5Update(&md5_context, (void *)bootloader_buf, SPI_SEC_SIZE);
284286
}
@@ -372,16 +374,9 @@ static bool get_image_from_partition(const esp_partition_pos_t *partition, esp_i
372374

373375
static bool find_active_image(bootloader_state_t *bs, esp_partition_pos_t *partition)
374376
{
375-
uint32_t chip_revision = 0;
376377
boot_info_t *boot_info;
377378
boot_info_t _boot_info;
378379

379-
// TODO
380-
// uint32_t reg = REG_READ(EFUSE_BLK0_RDATA3_REG);
381-
// if ((reg & EFUSE_RD_CHIP_VER_REV1_M) != 0) {
382-
// chip_revision = 1;
383-
// }
384-
385380
if (bs->ota_info.size < 2 * sizeof(esp_ota_select_entry_t)) {
386381
ESP_LOGE(TAG, "ERROR: ota_info partition size %d is too small (minimum %d bytes)", bs->ota_info.size, sizeof(esp_ota_select_entry_t));
387382
return false;
@@ -440,10 +435,8 @@ static bool find_active_image(bootloader_state_t *bs, esp_partition_pos_t *parti
440435

441436
// do we have a new image that needs to be verified?
442437
if ((boot_info->ActiveImg != IMG_ACT_FACTORY) && (boot_info->Status == IMG_STATUS_CHECK)) {
443-
if (chip_revision == 0) {
444-
if (boot_info->ActiveImg == IMG_ACT_UPDATE2) {
445-
boot_info->ActiveImg = IMG_ACT_FACTORY; // we only have space for 1 OTAA image
446-
}
438+
if (boot_info->ActiveImg == IMG_ACT_UPDATE2) {
439+
boot_info->ActiveImg = IMG_ACT_FACTORY; // we only have space for 1 OTAA image
447440
}
448441
if (!bootloader_verify(&bs->image[boot_info->ActiveImg], boot_info->size)) {
449442
// switch to the previous image
@@ -494,15 +487,17 @@ static bool find_active_image(bootloader_state_t *bs, esp_partition_pos_t *parti
494487

495488
static void bootloader_main()
496489
{
490+
vddsdio_configure();
491+
flash_gpio_configure();
497492
clock_configure();
498493
uart_console_configure();
499494
wdt_reset_check();
500495
ESP_LOGI(TAG, "ESP-IDF %s 2nd stage bootloader");
501496

502-
esp_image_header_t fhdr;
503-
bootloader_state_t bootloader_state;
504-
esp_partition_pos_t partition;
505-
esp_image_metadata_t image_data;
497+
esp_image_header_t fhdr __attribute__((aligned (4)));
498+
bootloader_state_t bootloader_state __attribute__((aligned (4)));
499+
esp_partition_pos_t partition __attribute__((aligned (4)));
500+
esp_image_metadata_t image_data __attribute__((aligned (4)));
506501

507502
memset(&bootloader_state, 0, sizeof(bootloader_state));
508503
ets_set_appcpu_boot_addr(0);
@@ -755,6 +750,105 @@ static void print_flash_info(const esp_image_header_t* phdr)
755750
}
756751

757752

753+
static void vddsdio_configure()
754+
{
755+
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST
756+
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
757+
if (cfg.tieh == 0) { // 1.8V is used
758+
cfg.drefh = 3;
759+
cfg.drefm = 3;
760+
cfg.drefl = 3;
761+
cfg.force = 1;
762+
cfg.enable = 1;
763+
rtc_vddsdio_set_config(cfg);
764+
ets_delay_us(10); // wait for regulator to become stable
765+
}
766+
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
767+
}
768+
769+
770+
#define FLASH_CLK_IO 6
771+
#define FLASH_CS_IO 11
772+
#define FLASH_SPIQ_IO 7
773+
#define FLASH_SPID_IO 8
774+
#define FLASH_SPIWP_IO 10
775+
#define FLASH_SPIHD_IO 9
776+
#define FLASH_IO_MATRIX_DUMMY_40M 1
777+
#define FLASH_IO_MATRIX_DUMMY_80M 2
778+
static void IRAM_ATTR flash_gpio_configure()
779+
{
780+
int spi_cache_dummy = 0;
781+
int drv = 2;
782+
#if CONFIG_FLASHMODE_QIO
783+
spi_cache_dummy = SPI0_R_QIO_DUMMY_CYCLELEN; //qio 3
784+
#elif CONFIG_FLASHMODE_QOUT
785+
spi_cache_dummy = SPI0_R_FAST_DUMMY_CYCLELEN; //qout 7
786+
#elif CONFIG_FLASHMODE_DIO
787+
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN; //dio 3
788+
#elif CONFIG_FLASHMODE_DOUT
789+
spi_cache_dummy = SPI0_R_FAST_DUMMY_CYCLELEN; //dout 7
790+
#endif
791+
/* dummy_len_plus values defined in ROM for SPI flash configuration */
792+
extern uint8_t g_rom_spiflash_dummy_len_plus[];
793+
#if CONFIG_ESPTOOLPY_FLASHFREQ_40M
794+
g_rom_spiflash_dummy_len_plus[0] = FLASH_IO_MATRIX_DUMMY_40M;
795+
g_rom_spiflash_dummy_len_plus[1] = FLASH_IO_MATRIX_DUMMY_40M;
796+
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_40M, SPI_USR_DUMMY_CYCLELEN_S); //DUMMY
797+
#elif CONFIG_ESPTOOLPY_FLASHFREQ_80M
798+
g_rom_spiflash_dummy_len_plus[0] = FLASH_IO_MATRIX_DUMMY_80M;
799+
g_rom_spiflash_dummy_len_plus[1] = FLASH_IO_MATRIX_DUMMY_80M;
800+
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_80M, SPI_USR_DUMMY_CYCLELEN_S); //DUMMY
801+
drv = 3;
802+
#endif
803+
804+
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
805+
uint32_t pkg_ver = chip_ver & 0x7;
806+
807+
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5) {
808+
// For ESP32D2WD the SPI pins are already configured
809+
ESP_LOGI(TAG, "Detected ESP32D2WD");
810+
//flash clock signal should come from IO MUX.
811+
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
812+
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
813+
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) {
814+
// For ESP32PICOD2 the SPI pins are already configured
815+
ESP_LOGI(TAG, "Detected ESP32PICOD2");
816+
//flash clock signal should come from IO MUX.
817+
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
818+
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
819+
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
820+
// For ESP32PICOD4 the SPI pins are already configured
821+
ESP_LOGI(TAG, "Detected ESP32PICOD4");
822+
//flash clock signal should come from IO MUX.
823+
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
824+
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
825+
} else {
826+
ESP_LOGI(TAG, "Detected ESP32");
827+
const uint32_t spiconfig = ets_efuse_get_spiconfig();
828+
if (spiconfig == EFUSE_SPICONFIG_SPI_DEFAULTS) {
829+
gpio_matrix_out(FLASH_CS_IO, SPICS0_OUT_IDX, 0, 0);
830+
gpio_matrix_out(FLASH_SPIQ_IO, SPIQ_OUT_IDX, 0, 0);
831+
gpio_matrix_in(FLASH_SPIQ_IO, SPIQ_IN_IDX, 0);
832+
gpio_matrix_out(FLASH_SPID_IO, SPID_OUT_IDX, 0, 0);
833+
gpio_matrix_in(FLASH_SPID_IO, SPID_IN_IDX, 0);
834+
gpio_matrix_out(FLASH_SPIWP_IO, SPIWP_OUT_IDX, 0, 0);
835+
gpio_matrix_in(FLASH_SPIWP_IO, SPIWP_IN_IDX, 0);
836+
gpio_matrix_out(FLASH_SPIHD_IO, SPIHD_OUT_IDX, 0, 0);
837+
gpio_matrix_in(FLASH_SPIHD_IO, SPIHD_IN_IDX, 0);
838+
//select pin function gpio
839+
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA0_U, PIN_FUNC_GPIO);
840+
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA1_U, PIN_FUNC_GPIO);
841+
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA2_U, PIN_FUNC_GPIO);
842+
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U, PIN_FUNC_GPIO);
843+
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CMD_U, PIN_FUNC_GPIO);
844+
// flash clock signal should come from IO MUX.
845+
// set drive ability for clock
846+
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
847+
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
848+
}
849+
}
850+
}
851+
758852
static void clock_configure(void)
759853
{
760854
/* Set CPU to 80MHz. Keep other clocks unmodified. */
-96 Bytes
Binary file not shown.

esp32/bootloader/lib/liblog.a

-52 Bytes
Binary file not shown.

esp32/bootloader/lib/libmicro-ecc.a

0 Bytes
Binary file not shown.

esp32/bootloader/lib/libsoc.a

7.12 KB
Binary file not shown.

esp32/bootloader/lib/libspi_flash.a

0 Bytes
Binary file not shown.

esp32/fatfs/src/diskio.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ DRESULT disk_ioctl (
145145
case CTRL_SYNC:
146146
return sflash_disk_flush();
147147
case GET_SECTOR_COUNT:
148-
*((DWORD*)buff) = SFLASH_FS_SECTOR_COUNT;
148+
*((DWORD*)buff) = sflash_get_sector_count();
149149
return RES_OK;
150150
case GET_SECTOR_SIZE:
151151
*((DWORD*)buff) = SFLASH_FS_SECTOR_SIZE;

esp32/fatfs/src/drivers/sflash_diskio.c

+18-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ static bool sflash_cache_is_dirty;
1818
static uint32_t sflash_prev_block_addr;
1919
static bool sflash_init_done = false;
2020

21+
static uint32_t sflash_start_address;
22+
static uint32_t sflash_fs_sector_count;
23+
2124

2225
static bool sflash_write (void) {
2326
// erase the block first
@@ -30,6 +33,13 @@ static bool sflash_write (void) {
3033

3134
DRESULT sflash_disk_init (void) {
3235
if (!sflash_init_done) {
36+
if (esp_get_revision() > 0) {
37+
sflash_start_address = SFLASH_START_ADDR_8MB;
38+
sflash_fs_sector_count = SFLASH_FS_SECTOR_COUNT_8MB;
39+
} else {
40+
sflash_start_address = SFLASH_START_ADDR_4MB;
41+
sflash_fs_sector_count = SFLASH_FS_SECTOR_COUNT_4MB;
42+
}
3343
sflash_block_cache = (uint8_t *)heap_caps_malloc(SFLASH_BLOCK_SIZE, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
3444
sflash_prev_block_addr = UINT32_MAX;
3545
sflash_cache_is_dirty = false;
@@ -48,7 +58,7 @@ DRESULT sflash_disk_status(void) {
4858
DRESULT sflash_disk_read(BYTE *buff, DWORD sector, UINT count) {
4959
uint32_t secindex;
5060

51-
if ((sector + count > SFLASH_FS_SECTOR_COUNT) || !count) {
61+
if ((sector + count > sflash_fs_sector_count) || !count) {
5262
// TODO sl_LockObjLock (&flash_LockObj, SL_OS_WAIT_FOREVER);
5363
sflash_disk_flush();
5464
// TODO sl_LockObjUnlock (&flash_LockObj);
@@ -58,7 +68,7 @@ DRESULT sflash_disk_read(BYTE *buff, DWORD sector, UINT count) {
5868
// TODO sl_LockObjLock (&flash_LockObj, SL_OS_WAIT_FOREVER);
5969
for (int index = 0; index < count; index++) {
6070
secindex = (sector + index) % SFLASH_SECTORS_PER_BLOCK;
61-
uint32_t sflash_block_addr = SFLASH_START_ADDR + (((sector + index) / SFLASH_SECTORS_PER_BLOCK) * SFLASH_BLOCK_SIZE);
71+
uint32_t sflash_block_addr = sflash_start_address + (((sector + index) / SFLASH_SECTORS_PER_BLOCK) * SFLASH_BLOCK_SIZE);
6272
// Check if it's a different block than last time
6373
if (sflash_prev_block_addr != sflash_block_addr) {
6474
if (sflash_disk_flush() != RES_OK) {
@@ -84,7 +94,7 @@ DRESULT sflash_disk_write(const BYTE *buff, DWORD sector, UINT count) {
8494
uint32_t secindex;
8595
uint32_t index = 0;
8696

87-
if ((sector + count > SFLASH_FS_SECTOR_COUNT) || !count) {
97+
if ((sector + count > sflash_fs_sector_count) || !count) {
8898
// TODO sl_LockObjLock (&flash_LockObj, SL_OS_WAIT_FOREVER);
8999
sflash_disk_flush();
90100
// TODO sl_LockObjUnlock (&flash_LockObj);
@@ -94,7 +104,7 @@ DRESULT sflash_disk_write(const BYTE *buff, DWORD sector, UINT count) {
94104
// TODO sl_LockObjLock (&flash_LockObj, SL_OS_WAIT_FOREVER);
95105
do {
96106
secindex = (sector + index) % SFLASH_SECTORS_PER_BLOCK;
97-
uint32_t sflash_block_addr = SFLASH_START_ADDR + (((sector + index) / SFLASH_SECTORS_PER_BLOCK) * SFLASH_BLOCK_SIZE);
107+
uint32_t sflash_block_addr = sflash_start_address + (((sector + index) / SFLASH_SECTORS_PER_BLOCK) * SFLASH_BLOCK_SIZE);
98108
// Check if it's a different block than last time
99109
if (sflash_prev_block_addr != sflash_block_addr) {
100110
if (sflash_disk_flush() != RES_OK) {
@@ -127,3 +137,7 @@ DRESULT sflash_disk_flush (void) {
127137
}
128138
return RES_OK;
129139
}
140+
141+
uint32_t sflash_get_sector_count(void) {
142+
return sflash_fs_sector_count;
143+
}

esp32/fatfs/src/drivers/sflash_diskio.h

+13-5
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,26 @@
1111
#include "mpconfigport.h"
1212

1313
#define SFLASH_BLOCK_SIZE SPI_FLASH_SEC_SIZE
14-
#define SFLASH_BLOCK_COUNT MICROPY_PORT_SFLASH_BLOCK_COUNT
1514
#define SFLASH_FS_SECTOR_SIZE 512
16-
#define SFLASH_FS_SECTOR_COUNT ((SFLASH_BLOCK_SIZE * SFLASH_BLOCK_COUNT) / SFLASH_FS_SECTOR_SIZE)
1715
#define SFLASH_SECTORS_PER_BLOCK (SFLASH_BLOCK_SIZE / SFLASH_FS_SECTOR_SIZE)
18-
#define SFLASH_START_ADDR 0x00380000
19-
#define SFLASH_START_BLOCK (SFLASH_START_ADDR / SFLASH_BLOCK_SIZE)
20-
#define SFLASH_END_BLOCK (SFLASH_START_BLOCK + (SFLASH_BLOCK_COUNT - 1))
16+
17+
#define SFLASH_BLOCK_COUNT_4MB MICROPY_PORT_SFLASH_BLOCK_COUNT_4MB
18+
#define SFLASH_FS_SECTOR_COUNT_4MB ((SFLASH_BLOCK_SIZE * SFLASH_BLOCK_COUNT_4MB) / SFLASH_FS_SECTOR_SIZE)
19+
#define SFLASH_START_ADDR_4MB 0x00380000
20+
#define SFLASH_START_BLOCK_4MB (SFLASH_START_ADDR_4MB / SFLASH_BLOCK_SIZE)
21+
#define SFLASH_END_BLOCK_4MB (SFLASH_START_BLOCK_4MB + (SFLASH_BLOCK_COUNT - 1))
22+
23+
#define SFLASH_BLOCK_COUNT_8MB MICROPY_PORT_SFLASH_BLOCK_COUNT_8MB
24+
#define SFLASH_FS_SECTOR_COUNT_8MB ((SFLASH_BLOCK_SIZE * SFLASH_BLOCK_COUNT_8MB) / SFLASH_FS_SECTOR_SIZE)
25+
#define SFLASH_START_ADDR_8MB 0x00400000
26+
#define SFLASH_START_BLOCK_8MB (SFLASH_START_ADDR_8MB / SFLASH_BLOCK_SIZE)
27+
#define SFLASH_END_BLOCK_8MB (SFLASH_START_BLOCK_8MB + (SFLASH_BLOCK_COUNT - 1))
2128

2229
DRESULT sflash_disk_init(void);
2330
DRESULT sflash_disk_status(void);
2431
DRESULT sflash_disk_read(BYTE *buff, DWORD sector, UINT count);
2532
DRESULT sflash_disk_write(const BYTE *buff, DWORD sector, UINT count);
2633
DRESULT sflash_disk_flush(void);
34+
uint32_t sflash_get_sector_count(void);
2735

2836
#endif /* SFLASH_DISKIO_H_ */

esp32/frozen/MQTTClient.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(self, clientID, cleanSession, protocol):
4040
self._baseReconnectTimeSecond=1
4141
self._maximumReconnectTimeSecond=32
4242
self._minimumConnectTimeSecond=20
43-
self._msgHandler=msgHandler.MsgHandler(self._recv_callback)
43+
self._msgHandler=msgHandler.MsgHandler(self._recv_callback, self.connect)
4444

4545
def getClientID(self):
4646
return self.client_id

0 commit comments

Comments
 (0)