Skip to content

Commit 3f16c4a

Browse files
fdcavalcantiacassis
authored andcommitted
arch/risc-v: custom compilation options on some cache sources
This change sets three new compilation flags for avoiding cache miss when using optimized builds and cache is manipulated. Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
1 parent 723051d commit 3f16c4a

3 files changed

Lines changed: 52 additions & 14 deletions

File tree

arch/risc-v/src/common/espressif/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ if(CONFIG_ESPRESSIF_EFUSE)
364364
list(APPEND _esp_startup_u_opts "SHELL:-u esp_efuse_startup_include_func")
365365
endif()
366366

367+
list(APPEND _esp_startup_u_opts "SHELL:-u esp_flash_spi_init_include_func")
368+
367369
target_link_options(nuttx PRIVATE ${_esp_startup_u_opts})
368370

369371
# ##############################################################################

arch/risc-v/src/esp32c3/hal_esp32c3.cmake

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,6 @@ list(
422422
list(
423423
APPEND
424424
HAL_SRCS
425-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_os_func_noos.c
426-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_os_func_app.c
427425
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_chip_generic.c
428426
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_chip_boya.c
429427
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_chip_gd.c
@@ -432,14 +430,34 @@ list(
432430
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_chip_mxic_opi.c
433431
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_chip_mxic.c
434432
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_chip_th.c
435-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/esp_flash_api.c
436-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/flash_ops.c
437433
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_chip_drivers.c
438434
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/memspi_host_driver.c
439-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/esp_flash_spi_init.c
435+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/flash_brownout_hook.c)
436+
437+
# Cache (relates to SPI Flash)
438+
439+
set(CACHE_SRCS)
440+
list(
441+
APPEND
442+
CACHE_SRCS
443+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/cache_utils.c
440444
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/flash_mmap.c
441-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/flash_brownout_hook.c
442-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/cache_utils.c)
445+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/flash_ops.c
446+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/esp_flash_api.c
447+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/esp_flash_spi_init.c
448+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_os_func_app.c
449+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_os_func_noos.c
450+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_wrap.c)
451+
452+
list(APPEND HAL_SRCS ${CACHE_SRCS})
453+
454+
# Avoid cache miss by unexpected inlineing when built by -Os
455+
set_source_files_properties(
456+
${CACHE_SRCS} DIRECTORY ../../../../
457+
PROPERTIES
458+
COMPILE_FLAGS
459+
"-fno-inline-functions -fno-inline-small-functions -fno-inline-functions-called-once"
460+
)
443461

444462
# SOC sources (paths from hal_esp32c3.mk: esp_hal_* periph and soc)
445463
list(

arch/risc-v/src/esp32c6/hal_esp32c6.cmake

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -463,19 +463,37 @@ list(
463463
list(
464464
APPEND
465465
HAL_SRCS
466-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_os_func_noos.c
467-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_os_func_app.c
468466
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_chip_generic.c
469467
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_chip_gd.c
470468
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_chip_winbond.c
471-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/esp_flash_api.c
472-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/flash_ops.c
473469
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_chip_drivers.c
474470
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/memspi_host_driver.c
475-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/esp_flash_spi_init.c
471+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/flash_brownout_hook.c)
472+
473+
# Cache (relates to SPI Flash)
474+
475+
set(CACHE_SRCS)
476+
list(
477+
APPEND
478+
CACHE_SRCS
479+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/cache_utils.c
476480
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/flash_mmap.c
477-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/flash_brownout_hook.c
478-
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/cache_utils.c)
481+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/flash_ops.c
482+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/esp_flash_api.c
483+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/esp_flash_spi_init.c
484+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_os_func_app.c
485+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_os_func_noos.c
486+
${ESP_HAL_3RDPARTY_REPO}/components/spi_flash/spi_flash_wrap.c)
487+
488+
list(APPEND HAL_SRCS ${CACHE_SRCS})
489+
490+
# Avoid cache miss by unexpected inlineing when built by -Os
491+
set_source_files_properties(
492+
${CACHE_SRCS} DIRECTORY ../../../../
493+
PROPERTIES
494+
COMPILE_FLAGS
495+
"-fno-inline-functions -fno-inline-small-functions -fno-inline-functions-called-once"
496+
)
479497

480498
# ULP lp_core
481499
list(

0 commit comments

Comments
 (0)