diff --git a/components/esp8266/source/chip_boot.c b/components/esp8266/source/chip_boot.c index 24a53bbb..b2d5b7ca 100644 --- a/components/esp8266/source/chip_boot.c +++ b/components/esp8266/source/chip_boot.c @@ -86,7 +86,7 @@ void chip_boot(size_t start_addr, size_t map) ret = spi_flash_read(start_addr, &fhdr, sizeof(flash_hdr_t)); if (ret) { - ESP_LOGE(TAG, "SPI flash read result %d\n", ret); + ESP_EARLY_LOGE(TAG, "SPI flash read result %d\n", ret); } if (3 > fhdr.spi_speed) @@ -100,7 +100,7 @@ void chip_boot(size_t start_addr, size_t map) flash_size = flash_map_table[fhdr.spi_size_map]; } else { flash_size = 0; - ESP_LOGE(TAG, "SPI size error is %d\n", fhdr.spi_size_map); + ESP_EARLY_LOGE(TAG, "SPI size error is %d\n", fhdr.spi_size_map); } sect_size = 4 * 1024; @@ -117,7 +117,7 @@ void chip_boot(size_t start_addr, size_t map) ret = esp_get_boot_param(flash_size, sect_size, &bhdr, sizeof(boot_hdr_t)); if (ret) { - ESP_LOGE(TAG, "Get boot parameters %d\n", ret); + ESP_EARLY_LOGE(TAG, "Get boot parameters %d\n", ret); } cache_init(map, 0, 0); diff --git a/components/esp8266/source/startup.c b/components/esp8266/source/startup.c index bb40565d..a7b81d8c 100644 --- a/components/esp8266/source/startup.c +++ b/components/esp8266/source/startup.c @@ -87,19 +87,25 @@ void call_user_start(size_t start_addr, size_t map) *dest++ = *src++; } + /* + * When finish copying IRAM program, the exception vect must be initialized. + * And then user can load/store data which is not aligned by 4-byte. + */ + __asm__ __volatile__( + "movi a2, 0x40100000\n" + "wsr a2, vecbase\n"); + + chip_boot(start_addr, map); + /* clear bss data */ for (p = &_bss_start; p < &_bss_end; p++) *p = 0; - chip_boot(start_addr, map); - __asm__ __volatile__( "rsil a2, 2\n" "movi a1, _chip_interrupt_tmp\n" "movi a2, 0xffffff00\n" - "and a1, a1, a2\n" - "movi a2, 0x40100000\n" - "wsr a2, vecbase\n"); + "and a1, a1, a2\n"); wifi_os_init(); diff --git a/components/spi_flash/src/spi_flash.c b/components/spi_flash/src/spi_flash.c index 275fa908..340c7f24 100644 --- a/components/spi_flash/src/spi_flash.c +++ b/components/spi_flash/src/spi_flash.c @@ -25,7 +25,8 @@ #include "esp8266/pin_mux_register.h" #include "driver/spi_register.h" -#define spi_debug(fmt, ...) ESP_LOGD(TAG, fmt, ##__VA_ARGS__) +/* Todo: Refactor SPI debug */ +#define spi_debug(fmt, ...) //ESP_LOGD(TAG, fmt, ##__VA_ARGS__) #define SPI_EXT2(i) (REG_SPI_BASE(i) + 0xF8) #define SPI_EXT3(i) (REG_SPI_BASE(i) + 0xFC)