From 81b18aa8d588156862559e0b22a86506fc6dac1a Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 8 Nov 2016 11:25:40 +0800 Subject: [PATCH] bootloader: move some functions out of IRAM when building in bootloader mode Fixes https://github.com/espressif/esp-idf/issues/80 --- components/log/log.c | 15 ++++++++++----- components/spi_flash/spi_flash_rom_patch.c | 10 ++++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/components/log/log.c b/components/log/log.c index a2b41d7e62..9670b82dfd 100644 --- a/components/log/log.c +++ b/components/log/log.c @@ -284,7 +284,15 @@ static inline void heap_swap(int i, int j) } #endif //BOOTLOADER_BUILD -IRAM_ATTR uint32_t esp_log_early_timestamp() + +#ifndef BOOTLOADER_BUILD +#define ATTR IRAM_ATTR +#else +#define ATTR +#endif // BOOTLOADER_BUILD + + +uint32_t ATTR esp_log_early_timestamp() { return xthal_get_ccount() / (CPU_CLK_FREQ_ROM / 1000); } @@ -305,9 +313,6 @@ uint32_t IRAM_ATTR esp_log_timestamp() #else -uint32_t IRAM_ATTR esp_log_timestamp() -{ - return esp_log_early_timestamp(); -} +uint32_t esp_log_timestamp() __attribute__((alias("esp_log_early_timestamp"))); #endif //BOOTLOADER_BUILD diff --git a/components/spi_flash/spi_flash_rom_patch.c b/components/spi_flash/spi_flash_rom_patch.c index 7e23beaea2..36e5bf8236 100644 --- a/components/spi_flash/spi_flash_rom_patch.c +++ b/components/spi_flash/spi_flash_rom_patch.c @@ -19,9 +19,15 @@ static const uint32_t STATUS_QIE_BIT = (1 << 9); /* Quad Enable */ #define SPI_IDX 1 #define OTH_IDX 0 +#ifndef BOOTLOADER_BUILD +#define ATTR IRAM_ATTR +#else +#define ATTR +#endif // BOOTLOADER_BUILD + extern SpiFlashChip SPI_flashchip_data; -static void IRAM_ATTR Wait_SPI_Idle(void) +static void ATTR Wait_SPI_Idle(void) { /* Wait for SPI state machine to be idle */ while((REG_READ(SPI_EXT2_REG(SPI_IDX)) & SPI_ST)) { @@ -42,7 +48,7 @@ static void IRAM_ATTR Wait_SPI_Idle(void) about interrupts, CPU coordination, flash mapping. However some of the functions in esp_spi_flash.c call it. */ -SpiFlashOpResult IRAM_ATTR SPIUnlock(void) +SpiFlashOpResult ATTR SPIUnlock(void) { uint32_t status;