Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
111 changes: 111 additions & 0 deletions SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,117 @@ if GetDepend(['BSP_USING_BLE']) :
cwd + '/components/vfs/private_include/'
]

if GetDepend(['SOC_ESP32_C6']):
import os

def to_c6(items):
out = []
for item in items:
if 'esp32c3' not in item:
out.append(item)
continue
alt = item.replace('esp32c3', 'esp32c6')
if os.path.exists(os.path.join(cwd, alt)):
out.append(alt)
return out

drop_hal = ('i2c_hal', 'ledc_hal', 'rmt_hal', 'i2s_hal', 'twai_hal', 'sdm_hal', 'spi_slave', 'temperature', 'adc_hal', 'adc_oneshot', 'spi_hal', 'xt_wdt')
for group_src in [
esp32c3_src,
esp32c3_riscv_src,
esp32c3_mbedtls_src,
esp32c3_esp_system_src,
esp32c3_hal_src,
esp32c3_soc_src,
esp32c3_esp_hw_support_src,
esp32c3_bootloader_support_src,
esp32c3_esp_rom_src,
esp32c3_heap_src,
esp32c3_spi_flash_src,
esp32c3_newlib_src,
esp32c3_log_src,
esp32c3_driver_src,
esp32c3_pthread_src,
esp32c3_efuse_src,
esp32c3_esp_timer_src]:
picked = to_c6(group_src)
if group_src is esp32c3_driver_src:
picked = [p for p in picked if p.endswith('gpio/gpio.c') or p.endswith('gpio/rtc_io.c') or p.endswith('uart.c') or p.endswith('spi_bus_lock.c')]
elif group_src is esp32c3_hal_src:
picked = [p for p in picked if not any(name in os.path.basename(p) for name in drop_hal)]
src += picked
drop_src = (
'gdma.c', 'async_memcpy_impl_gdma.c', 'esp_async_memcpy.c', 'rtc_module.c',
'sleep_mac_bb.c', 'sleep_gpio.c', 'sleep_modes.c', 'sleep_retention.c',
'pm_impl.c',
)
src = [p for p in src if 'adc' not in os.path.basename(p).lower() and 'i2s' not in os.path.basename(p).lower() and os.path.basename(p) not in drop_src]
src.append('components/esp_rom/patches/esp_rom_hp_regi2c_esp32c6.c')
src.append('components/hal/lp_timer_hal.c')
src.append('components/esp_hw_support/modem_clock.c')

have = set(src)
skip_name = (
'ieee802154', 'parlio', 'wifi', 'coexist', 'adc',
'io_mux', 'pmu_sleep', 'i2s', 'twai', 'timer_periph', 'temperature',
'sdm', 'rmt', 'pcnt', 'mcpwm', 'ledc', 'i2c', 'dedic', 'sdio',
'bootloader_sha',
)
for root in [
'components/hal/esp32c6',
'components/esp_hw_support/port/esp32c6',
'components/esp_system/port/soc/esp32c6',
'components/soc/esp32c6',
'components/bootloader_support/src/esp32c6',
'components/efuse/esp32c6',
'components/heap/port/esp32c6']:
full = os.path.join(cwd, root)
if not os.path.isdir(full):
continue
for name in os.listdir(full):
if not name.endswith(('.c', '.S', '.cpp')):
continue
if any(part in name for part in skip_name):
continue
rel = root + '/' + name
if rel not in have:
src.append(rel)
have.add(rel)

for item in esp32c3_path:
if 'esp32c3' not in item:
path.append(item)
continue
alt = item.replace('esp32c3', 'esp32c6')
if os.path.isdir(alt):
path.append(alt)
for extra in [
'/components/hal/esp32c6/include',
'/components/soc/esp32c6/include',
'/components/esp_hw_support/include/soc/esp32c6',
'/components/esp_rom/esp32c6/include',
'/components/esp_rom/include/esp32c6',
'/components/efuse/esp32c6/include',
'/components/esp_hw_support/port/esp32c6/private_include']:
inc = cwd + extra
if os.path.isdir(inc) and inc not in path:
path.append(inc)

src = [p for p in src if all(part not in p.replace('\\', '/') for part in ('gdma', '/aes/dma/', '/sha/dma/'))]
src = [p for p in src if not p.endswith('.cpp')]

if GetDepend(['BSP_ENABLE_GDBSTUB']):
src += [
'components/esp_gdbstub/esp32c6/gdbstub_esp32c6.c',
'components/esp_gdbstub/riscv/gdbstub_riscv.c',
'components/esp_gdbstub/src/gdbstub.c',
'components/esp_gdbstub/src/packet.c',
]

CPPDEFINES = ['IDF_VER=\\"999\\\"', 'PROJECT_VER=\\"999\\"', '_GNU_SOURCE', 'MULTI_HEAP_FREERTOS', 'ESP_PLATFORM=1', 'IDF_TARGET=esp32c6', 'SOC_MMU_PAGE_SIZE=0x10000', '_POSIX_READER_WRITER_LOCKS', 'PROJECT_NAME=\\"rtthread\\"', 'MBEDTLS_CONFIG_FILE=\\"mbedtls/esp_config.h\\"', 'ESPRESSIF_USE', 'CONFIG_CRYPTO_MBEDTLS', 'UNITY_INCLUDE_CONFIG_H', '__ets__', 'ESP_PLATFORM']
LIB_PATH = []
LIB = []

group = DefineGroup('esp-idf', src, depend = ['PKG_USING_ESP_IDF'], CPPPATH = path, LIBS = LIB, LIBPATH = LIB_PATH, CPPDEFINES = CPPDEFINES)

Return('group')
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -25,16 +25,6 @@ extern "C" {
*/
uint32_t bootloader_read_flash_id(void);

#if SOC_CACHE_SUPPORT_WRAP
/**
* @brief Set the burst mode setting command for specified wrap mode.
*
* @param mode The specified warp mode.
* @return always ESP_OK
*/
esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode);
#endif

/**
* @brief Startup flow recommended by XMC. Call at startup before any erase/write operation.
*
Expand All @@ -57,6 +47,20 @@ esp_err_t __attribute__((weak)) bootloader_flash_unlock(void);
*/
esp_err_t bootloader_flash_reset_chip(void);

/**
* @brief Check if octal flash mode is enabled in eFuse
*
* @return True if flash is in octal mode, false else
*/
bool bootloader_flash_is_octal_mode_enabled(void);

/**
* @brief Get the spi flash working mode.
*
* @return The mode of flash working mode, see `esp_rom_spiflash_read_mode_t`
*/
esp_rom_spiflash_read_mode_t bootloader_flash_get_spi_mode(void);

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -109,6 +109,17 @@ extern const bootloader_qio_info_t __attribute__((weak)) bootloader_flash_qe_sup
*/
esp_err_t __attribute__((weak)) bootloader_flash_unlock(void);

#if CONFIG_BOOTLOADER_CACHE_32BIT_ADDR_OCTAL_FLASH
/**
* @brief Enable 32bits address flash(larger than 16MB) can map to cache.
*
* @param flash_mode SPI flash working mode.
*
* @note This can be overridden because it's attribute weak.
*/
void __attribute__((weak)) bootloader_flash_32bits_address_map_enable(esp_rom_spiflash_read_mode_t flash_mode);
#endif

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern "C" {

#define FLASH_SECTOR_SIZE 0x1000
#define FLASH_BLOCK_SIZE 0x10000
#define MMAP_ALIGNED_MASK 0x0000FFFF
#define MMAP_ALIGNED_MASK (SPI_FLASH_MMU_PAGE_SIZE - 1)
#define MMU_FLASH_MASK (~(SPI_FLASH_MMU_PAGE_SIZE - 1))

/**
Expand Down Expand Up @@ -49,10 +49,11 @@ extern "C" {
#define CMD_RDSR3 0x15 /* Not all SPI flash uses this command */
#define CMD_OTPEN 0x3A /* Enable OTP mode, not all SPI flash uses this command */
#define CMD_RDSFDP 0x5A /* Read the SFDP of the flash */
#define CMD_WRAP 0x77 /* Set burst with wrap command */
#define CMD_RESUME 0x7A /* Resume command to clear flash suspend bit */
#define CMD_RESETEN 0x66
#define CMD_RESET 0x99
#define CMD_FASTRD_4B 0x0C
#define CMD_SLOWRD_4B 0x13


/* Provide a Flash API for bootloader_support code,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include <esp_err.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Initialize spi_flash in bootloader and print flash info
*
* @return ESP_OK on success, otherwise see esp_err_t
*/
esp_err_t bootloader_init_spi_flash(void);

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#else
# include "soc/spi_mem_struct.h"
# include "soc/spi_mem_reg.h"
# if CONFIG_IDF_TARGET_ESP32C6
# include "hal/spimem_flash_ll.h"
# endif
/* SPI flash controller */
# define SPIFLASH SPIMEM1
#endif
Expand Down Expand Up @@ -771,6 +774,8 @@ esp_err_t IRAM_ATTR bootloader_flash_reset_chip(void)
if (SPI1.ext2.st != 0)
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
if (SPIMEM1.fsm.st != 0)
#elif CONFIG_IDF_TARGET_ESP32C6
if (!spimem_flash_ll_host_idle(&SPIMEM1))
#else
if (SPIMEM1.fsm.spi0_mst_st != 0)
#endif
Expand Down
Loading