From b32c52874d4dd7bad957141bd63c72f69eaa6fb8 Mon Sep 17 00:00:00 2001 From: Dong Heng Date: Tue, 31 Jul 2018 10:23:15 +0800 Subject: [PATCH] feat(esp8266): Add full icache mode Use full 32 KB iram as icache. --- .../subproject/main/esp8266.bootloader.ld | 2 +- components/esp8266/Kconfig | 7 ++++ .../esp8266/include/esp8266/rom_functions.h | 1 + components/esp8266/lib/VERSION | 2 +- components/esp8266/lib/libcore.a | Bin 74920 -> 74260 bytes components/esp8266/source/chip_boot.c | 5 +-- components/esp8266/source/esp_cache.c | 39 ++++++++++++++++++ components/freertos/port/esp8266/heap_5.c | 4 ++ 8 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 components/esp8266/source/esp_cache.c diff --git a/components/bootloader/subproject/main/esp8266.bootloader.ld b/components/bootloader/subproject/main/esp8266.bootloader.ld index df37355d..122dfd33 100644 --- a/components/bootloader/subproject/main/esp8266.bootloader.ld +++ b/components/bootloader/subproject/main/esp8266.bootloader.ld @@ -16,7 +16,7 @@ MEMORY dram_seg : org = 0x3FFE8000, len = 0x18000 /* Functions which are critical should be put in this segment. */ - iram_seg : org = 0x40100000, len = 0xC000 + iram_seg : org = 0x40100000, len = 0x8000 } /* Default entry point: */ diff --git a/components/esp8266/Kconfig b/components/esp8266/Kconfig index d2c9655a..0ce6ee46 100644 --- a/components/esp8266/Kconfig +++ b/components/esp8266/Kconfig @@ -28,6 +28,13 @@ config NEWLIB_STDOUT_LINE_ENDING_CR bool "CR" endchoice +config SOC_FULL_ICACHE + bool "Enable full cache mode" + default n + help + Enable this option, full 32 KB iram instead of 16 KB iram will be used as icache, so the heap use can use + may reduce a lot. + endmenu menu WIFI diff --git a/components/esp8266/include/esp8266/rom_functions.h b/components/esp8266/include/esp8266/rom_functions.h index 5f847846..c1f20370 100644 --- a/components/esp8266/include/esp8266/rom_functions.h +++ b/components/esp8266/include/esp8266/rom_functions.h @@ -33,5 +33,6 @@ int SPI_read_status(esp_spi_flash_chip_t *chip, uint32_t *status); int Enable_QMode(esp_spi_flash_chip_t *chip); void Cache_Read_Disable(); +void Cache_Read_Enable(uint8_t map, uint8_t p, uint8_t v); #endif diff --git a/components/esp8266/lib/VERSION b/components/esp8266/lib/VERSION index 5bdda5a0..6a00e507 100644 --- a/components/esp8266/lib/VERSION +++ b/components/esp8266/lib/VERSION @@ -1,7 +1,7 @@ gwen: crypto: 8943c89 espnow: 8943c89 - core: 2f2b0ef + core: f4f0d3d net80211: 80fc165 pp: 06e0988 pwm: 0181338 diff --git a/components/esp8266/lib/libcore.a b/components/esp8266/lib/libcore.a index 7ead303180d7b8b8db02a3a1d66956094b7df264..a7165fe09d64a852f6008460a1074aa88773c3a6 100644 GIT binary patch delta 3899 zcmb_eeP~r>7=NF$dv)8{-N(JNJ2lvKkpnKSC~ za`(P;#2D)w7n^?%mki7o4b) z$^J;mh62;r=y%5I{GQlYzdzQjGi>m9tkhBLACDymua|8~+uD=O-@6t+KG&(t)vfA0 zeaC&R%l?Yqu2&5%?ru4HJ5NSuW||*O`JLT$iQSyX1;(@@7*lT&rhI7T7`a#=Cb(53 z83(bYSe_d?QY?EMuZtovrUda6VkP2Q$C#<)(M$xf4Y3@tPxAr9Lgd#p0%q@HWP4H{ z#s`40n#@Lc5&R(h1vvX6-eHXQZ{ZaXd$o|lgN#*N2TUtOqxM1BK`Z!Y!Lx(Iz%fKN z`d*ISz7X}7z%NjJnPbeXtRCxc0g?yx<~6`Hc4ofrhF7%j8+IIu0sFWnJ&`qrYi2&|8b>5Fz&~ z+v7v?%VoL9O<(raM1P3mp@VZ3QWI^!+!KG^Q;Fd33MrSSAQqRpXcO4=V3R>dTuPks z@xiLNJmd^Sf?bG`3XVY~&j+7U{0L@IM<5BbHZb0p{$Lv6RZ^XbtEOlhW)weX+}~7P9X*Q$FeCUWA-{8?8NNY&J9D|z{sdHIdJ{O3D!&)m9` zFvWNqPNrq>I2N8=a+L9bxYX!dv-JWq7uXu>OOSJUy$#IQU!7O)Ma~s;AY1ne%$7XC z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q z3ST4qQp6x!3tuZdIbt)KFd}+8=Z>}r&dY+fq;Fe9Pc!1rFKUm!G9wT_awD(8=M;U) TB@}GGl7e}CyS%*@{Eq%_SA)a| diff --git a/components/esp8266/source/chip_boot.c b/components/esp8266/source/chip_boot.c index 9cc08586..7e9020a9 100644 --- a/components/esp8266/source/chip_boot.c +++ b/components/esp8266/source/chip_boot.c @@ -52,9 +52,8 @@ void chip_boot(size_t start_addr, size_t map) extern esp_spi_flash_chip_t flashchip; extern void phy_get_bb_evm(void); - extern void cache_init(uint32_t , uint32_t, uint32_t); + extern void cache_init(uint8_t); extern void user_spi_flash_dio_to_qio_pre_init(void); - extern int esp_get_boot_param(uint32_t, uint32_t, void *, uint32_t); phy_get_bb_evm(); @@ -93,7 +92,7 @@ void chip_boot(size_t start_addr, size_t map) SET_PERI_REG_BITS(PERIPHS_SPI_FLASH_CTRL, 0xfff, freqbits, 0); ESP_EARLY_LOGD(TAG, "SPI flash cache map is %d\n", map); - cache_init(map, 0, 0); + cache_init(map); if (fhdr.spi_mode == ESP_IMAGE_SPI_MODE_QIO) { ESP_EARLY_LOGD(TAG, "SPI flash enable QIO mode\n"); diff --git a/components/esp8266/source/esp_cache.c b/components/esp8266/source/esp_cache.c new file mode 100644 index 00000000..411b7a19 --- /dev/null +++ b/components/esp8266/source/esp_cache.c @@ -0,0 +1,39 @@ +// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "sdkconfig.h" +#include +#include "esp_attr.h" +#include "esp8266/rom_functions.h" + +#ifdef CONFIG_SOC_FULL_ICACHE +#define SOC_CACHE_SIZE 1 // 32KB +#else +#define SOC_CACHE_SIZE 0 // 16KB +#endif + +static uint8_t s_cache_map; +static uint8_t s_cache_size = SOC_CACHE_SIZE; + +void IRAM_ATTR Cache_Read_Enable_New(void) +{ + Cache_Read_Enable(s_cache_map, 0, s_cache_size); +} + +void cache_init(int map) +{ + s_cache_map = map; + + Cache_Read_Enable_New(); +} diff --git a/components/freertos/port/esp8266/heap_5.c b/components/freertos/port/esp8266/heap_5.c index 0e94d843..f2ce1f39 100644 --- a/components/freertos/port/esp8266/heap_5.c +++ b/components/freertos/port/esp8266/heap_5.c @@ -105,6 +105,8 @@ * Note 0x80000000 is the lower address so appears in the array first. * */ +#include "sdkconfig.h" + #include #include #include @@ -363,8 +365,10 @@ static bool is_inited = false; xHeapRegions[0].pucStartAddress = ( uint8_t * )&_heap_start; xHeapRegions[0].xSizeInBytes = (( size_t)( 0x40000000 - (uint32_t)&_heap_start)); +#ifndef CONFIG_SOC_FULL_ICACHE xHeapRegions[1].pucStartAddress = ( uint8_t * )&_lit4_end; xHeapRegions[1].xSizeInBytes = (( size_t)( 0x4010C000 - (uint32_t)&_lit4_end)); +#endif is_inited = true; vPortDefineHeapRegions(xHeapRegions);