From a5aac9305109f80ffe8a2a61c89e50d2dceaeea2 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 22 Dec 2020 18:24:39 +1100 Subject: [PATCH] esp_rom: Small changes for esp32c3 support Updated from internal commit 6d894813 --- components/esp_rom/CMakeLists.txt | 6 +-- components/esp_rom/component.mk | 3 +- components/esp_rom/esp32c3/ld/esp32c3.rom.ld | 3 +- components/esp_rom/include/esp32/rom/aes.h | 2 +- .../esp_rom/include/esp32c3/rom/apb_dma.h | 25 +++++++++++ .../esp_system/port/soc/esp32c3/apb_dma.c | 44 +++++++++++++++++++ 6 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 components/esp_rom/include/esp32c3/rom/apb_dma.h create mode 100644 components/esp_system/port/soc/esp32c3/apb_dma.c diff --git a/components/esp_rom/CMakeLists.txt b/components/esp_rom/CMakeLists.txt index 01dd91140e..52787a6d7f 100644 --- a/components/esp_rom/CMakeLists.txt +++ b/components/esp_rom/CMakeLists.txt @@ -3,8 +3,7 @@ idf_build_get_property(target IDF_TARGET) idf_component_register(SRCS "patches/esp_rom_crc.c" "patches/esp_rom_sys.c" "patches/esp_rom_uart.c" - INCLUDE_DIRS include - PRIV_INCLUDE_DIRS "${target}" + INCLUDE_DIRS include "${target}" PRIV_REQUIRES soc hal) # Append a target linker script at the target-specific path, @@ -33,8 +32,7 @@ if(BOOTLOADER_BUILD) rom_linker_script("spiflash") elseif(target STREQUAL "esp32c3") - # currently nothing additional here - + rom_linker_script("newlib") endif() else() # Regular app build diff --git a/components/esp_rom/component.mk b/components/esp_rom/component.mk index f83357ffec..05e486568e 100644 --- a/components/esp_rom/component.mk +++ b/components/esp_rom/component.mk @@ -1,6 +1,5 @@ -COMPONENT_ADD_INCLUDEDIRS := include +COMPONENT_ADD_INCLUDEDIRS := include esp32 COMPONENT_SRCDIRS := patches . -COMPONENT_PRIV_INCLUDEDIRS := esp32 #Linker scripts used to link the final application. #Warning: These linker scripts are only used when the normal app is compiled; the bootloader diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld index 3716fbc61f..91e1cf5fb9 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld @@ -1728,10 +1728,9 @@ ieee80211_is_tx_allowed = 0x40001860; ieee80211_output_pending_eb = 0x40001864; ieee80211_output_process = 0x40001868; ieee80211_set_tx_desc = 0x4000186c; -sta_input = 0x40001870; +rom_sta_input = 0x40001870; wifi_get_macaddr = 0x40001874; wifi_rf_phy_disable = 0x40001878; -wifi_rf_phy_enable = 0x4000187c; ic_ebuf_alloc = 0x40001880; ieee80211_classify = 0x40001884; ieee80211_copy_eb_header = 0x40001888; diff --git a/components/esp_rom/include/esp32/rom/aes.h b/components/esp_rom/include/esp32/rom/aes.h index 4657d5223e..bbe13d22e4 100644 --- a/components/esp_rom/include/esp32/rom/aes.h +++ b/components/esp_rom/include/esp32/rom/aes.h @@ -2,7 +2,7 @@ ROM functions for hardware AES support. It is not recommended to use these functions directly, - use the wrapper functions in aes/esp_aes.h instead. + use the wrapper functions in esp32/aes.h instead. */ // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD diff --git a/components/esp_rom/include/esp32c3/rom/apb_dma.h b/components/esp_rom/include/esp32c3/rom/apb_dma.h new file mode 100644 index 0000000000..d4e709b742 --- /dev/null +++ b/components/esp_rom/include/esp32c3/rom/apb_dma.h @@ -0,0 +1,25 @@ +// Copyright 2010-2020 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. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +void ets_apb_backup_init_lock_func(void(* _apb_backup_lock)(void), void(* _apb_backup_unlock)(void)); + +#ifdef __cplusplus +} +#endif diff --git a/components/esp_system/port/soc/esp32c3/apb_dma.c b/components/esp_system/port/soc/esp32c3/apb_dma.c new file mode 100644 index 0000000000..5702d4b763 --- /dev/null +++ b/components/esp_system/port/soc/esp32c3/apb_dma.c @@ -0,0 +1,44 @@ + +// Copyright 2015-2020 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 "esp_attr.h" +#include "freertos/FreeRTOS.h" +#include "freertos/portmacro.h" +#include "esp32c3/rom/apb_dma.h" + +static portMUX_TYPE apb_backup_mutex = portMUX_INITIALIZER_UNLOCKED; + +static void IRAM_ATTR apb_backup_lock(void) +{ + if (xPortInIsrContext()) { + portENTER_CRITICAL_ISR(&apb_backup_mutex); + } else { + portENTER_CRITICAL(&apb_backup_mutex); + } +} + +static void IRAM_ATTR apb_backup_unlock(void) +{ + if (xPortInIsrContext()) { + portEXIT_CRITICAL_ISR(&apb_backup_mutex); + } else { + portEXIT_CRITICAL(&apb_backup_mutex); + } +} + +void esp_apb_backup_lock_init(void) +{ + ets_apb_backup_init_lock_func(apb_backup_lock, apb_backup_unlock); +}