Просмотр исходного кода

Merge branch 'feature/support_riscv_floatingpoint_library_selection' into 'master'

esp32c2: Support riscv floating-point library selection

See merge request espressif/esp-idf!17725
morris 3 лет назад
Родитель
Сommit
f3e8a17285

+ 20 - 1
Kconfig

@@ -278,6 +278,26 @@ mainmenu "Espressif IoT Development Framework Configuration"
 
         endchoice # assertions
 
+        choice COMPILER_FLOAT_LIB_FROM
+            prompt "Compiler float lib source"
+            default COMPILER_FLOAT_LIB_FROM_RVFPLIB if ESP_ROM_HAS_RVFPLIB
+            default COMPILER_FLOAT_LIB_FROM_GCCLIB
+            help
+                In the soft-fp part of libgcc, riscv version is written in C,
+                and handles all edge cases in IEEE754, which makes it larger
+                and performance is slow.
+
+                RVfplib is an optimized RISC-V library for FP arithmetic on 32-bit
+                integer processors, for single and double-precision FP.
+                RVfplib is "fast", but it has a few exceptions from IEEE 754 compliance.
+
+            config COMPILER_FLOAT_LIB_FROM_GCCLIB
+                bool "libgcc"
+            config COMPILER_FLOAT_LIB_FROM_RVFPLIB
+                depends on ESP_ROM_HAS_RVFPLIB
+                bool "librvfp"
+        endchoice # COMPILER_FLOAT_LIB_FROM
+
         config COMPILER_OPTIMIZATION_ASSERTION_LEVEL
             int
             default 0 if COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE
@@ -418,7 +438,6 @@ mainmenu "Espressif IoT Development Framework Configuration"
                 If enabled, RTL files will be produced during compilation. These files
                 can be used by other tools, for example to calculate call graphs.
 
-
     endmenu # Compiler Options
 
     menu "Component config"

+ 5 - 1
components/esp_rom/CMakeLists.txt

@@ -58,7 +58,11 @@ if(target STREQUAL "linux")
 else()
     target_linker_script(${COMPONENT_LIB} INTERFACE "${target}/${ld_folder}/${target}.rom.ld")
     rom_linker_script("api")
-    rom_linker_script("libgcc")
+    if(CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB)
+        rom_linker_script("libgcc")
+    else()
+        rom_linker_script("rvfp")
+    endif()
 endif()
 
 idf_build_get_property(time_t_size TIME_T_SIZE)

+ 4 - 0
components/esp_rom/esp32c2/Kconfig.soc_caps.in

@@ -22,3 +22,7 @@ config ESP_ROM_HAS_RETARGETABLE_LOCKING
 config ESP_ROM_GET_CLK_FREQ
     bool
     default y
+
+config ESP_ROM_HAS_RVFPLIB
+    bool
+    default y

+ 1 - 0
components/esp_rom/esp32c2/esp_rom_caps.h

@@ -11,3 +11,4 @@
 #define ESP_ROM_UART_CLK_IS_XTAL            (1) // UART clock source is selected to XTAL in ROM
 #define ESP_ROM_HAS_RETARGETABLE_LOCKING    (1) // ROM was built with retargetable locking
 #define ESP_ROM_GET_CLK_FREQ                (1) // Get clk frequency with rom function `ets_get_cpu_frequency`
+#define ESP_ROM_HAS_RVFPLIB 				(1) // ROM has the rvfplib

+ 2 - 0
tools/test_apps/system/build_test/sdkconfig.ci.rvfplib

@@ -0,0 +1,2 @@
+CONFIG_IDF_TARGET="esp32c2"
+CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB=y