diff --git a/components/ulp/cmake/toolchain-esp32s2-ulp-riscv.cmake b/components/ulp/cmake/toolchain-esp32s2-ulp-riscv.cmake index 15d6145ded..5e1b497b6a 100644 --- a/components/ulp/cmake/toolchain-esp32s2-ulp-riscv.cmake +++ b/components/ulp/cmake/toolchain-esp32s2-ulp-riscv.cmake @@ -1,18 +1,15 @@ # CMake toolchain file for ULP-RISC-V set(CMAKE_SYSTEM_NAME Generic) -# Not best solution, needs to figure why the compiler detection -# fails in CI -set(CMAKE_C_COMPILER_FORCED TRUE) -set(CMAKE_CXX_COMPILER_FORCED TRUE) +set(CMAKE_C_COMPILER "riscv32-esp-elf-gcc") +set(CMAKE_CXX_COMPILER "riscv32-esp-elf-g++") +set(CMAKE_ASM_COMPILER "riscv32-esp-elf-gcc") -set(CMAKE_C_COMPILER "riscv-none-embed-gcc") -set(CMAKE_ASM_COMPILER "riscv-none-embed-gcc") - -if(NOT ASM_DIALECT) - set(ASM_DIALECT "") -endif() - -set(CMAKE_C_FLAGS "-Os -march=rv32imc -mdiv -fdata-sections -ffunction-sections") -set(CMAKE_ASM_FLAGS "-march=rv32imc -mdiv -x assembler-with-cpp -fdata-sections -ffunction-sections") -set(CMAKE_EXE_LINKER_FLAGS "-march=rv32imc --specs=nano.specs --specs=nosys.specs") +set(CMAKE_C_FLAGS "-Os -march=rv32imc -mdiv -fdata-sections -ffunction-sections" + CACHE STRING "C Compiler Base Flags") +set(CMAKE_CXX_FLAGS "-Os -march=rv32imc -mdiv -fdata-sections -ffunction-sections" + CACHE STRING "C++ Compiler Base Flags") +set(CMAKE_ASM_FLAGS "-march=rv32imc -x assembler-with-cpp" + CACHE STRING "Assembler Base Flags") +set(CMAKE_EXE_LINKER_FLAGS "-march=rv32imc --specs=nano.specs --specs=nosys.specs" + CACHE STRING "Linker Base Flags") diff --git a/docs/en/api-guides/tools/idf-tools-notes.inc b/docs/en/api-guides/tools/idf-tools-notes.inc index 41ca6e01d4..9b076e96a3 100644 --- a/docs/en/api-guides/tools/idf-tools-notes.inc +++ b/docs/en/api-guides/tools/idf-tools-notes.inc @@ -25,11 +25,6 @@ .. tool-esp32s2ulp-elf-notes ---- - -.. tool-riscv-none-embed-gcc-notes - - --- .. tool-openocd-esp32-notes diff --git a/docs/en/api-guides/ulp-risc-v.rst b/docs/en/api-guides/ulp-risc-v.rst index b058fd30f5..3b3e559464 100644 --- a/docs/en/api-guides/ulp-risc-v.rst +++ b/docs/en/api-guides/ulp-risc-v.rst @@ -11,11 +11,11 @@ The ULP-RISC-V coprocessor is a variant of the ULP, present in ESP32-S2. Similar Installing the ULP-RISC-V Toolchain ----------------------------------- -The ULP-RISC-V coprocessor code is written in C (assembly is also possible) and compiled using the `riscv-embedded toolchain`_. +The ULP-RISC-V coprocessor code is written in C (assembly is also possible) and compiled using RISC-V toolchain based on GCC. -If you have already set up ESP-IDF with CMake build system according to the :doc:`Getting Started Guide <../../get-started/index>`, then you need to perform an extra step to get the ULP-RISC-V toolchain installed, execute the command below inside the IDF folder:: +If you have already set up ESP-IDF with CMake build system according to the :doc:`Getting Started Guide <../../get-started/index>`, then the toolchain should already be installed. -$ idf_tools.py install riscv-none-embed-gcc +.. note: In earlier versions of ESP-IDF, RISC-V toolchain had a different prefix: `riscv-none-embed-gcc`. Compiling the ULP-RISC-V Code @@ -56,7 +56,7 @@ To compile the ULP-RISC-V code as part of the component, the following steps mus 5. **Dump the contents of the ELF file into a binary** (``ulp_app_name.bin``) which can then be embedded into the application. - 6. **Generate a list of global symbols** (``ulp_app_name.sym``) in the ELF file using ``riscv-none-embed-nm``. + 6. **Generate a list of global symbols** (``ulp_app_name.sym``) in the ELF file using ``riscv32-esp-elf-nm``. 7. **Create an LD export script and header file** (``ulp_app_name.ld`` and ``ulp_app_name.h``) containing the symbols from ``ulp_app_name.sym``. This is done using the ``esp32ulp_mapgen.py`` utility. @@ -147,5 +147,3 @@ The program runs until the field ``RTC_CNTL_COCPU_DONE`` in register ``RTC_CNTL_ To disable the timer (effectively preventing the ULP program from running again), please clear the ``RTC_CNTL_ULP_CP_SLP_TIMER_EN`` bit in the ``RTC_CNTL_STATE0_REG`` register. This can be done both from the ULP code and from the main program. - -.. _riscv-embedded toolchain: https://xpack.github.io/riscv-none-embed-gcc/ diff --git a/docs/zh_CN/api-guides/tools/idf-tools-notes.inc b/docs/zh_CN/api-guides/tools/idf-tools-notes.inc index 3e22db2113..37eda3df41 100644 --- a/docs/zh_CN/api-guides/tools/idf-tools-notes.inc +++ b/docs/zh_CN/api-guides/tools/idf-tools-notes.inc @@ -27,11 +27,6 @@ .. tool-esp32s2ulp-elf-notes ---- - -.. tool-riscv-none-embed-gcc-notes - - --- .. tool-openocd-esp32-notes diff --git a/docs/zh_CN/api-guides/ulp-risc-v.rst b/docs/zh_CN/api-guides/ulp-risc-v.rst index 2eb1ade778..307afabccb 100644 --- a/docs/zh_CN/api-guides/ulp-risc-v.rst +++ b/docs/zh_CN/api-guides/ulp-risc-v.rst @@ -11,12 +11,11 @@ ULP-RISC-V 协处理器是 ULP 的一种变体,用于 ESP32-S2。与 ULP 类 安装 ULP-RISC-V 工具链 ----------------------------------- -ULP-RISC-V 协处理器代码以 C 语言编写(也可能是汇编语言),使用 `riscv-embedded toolchain`_ 进行编译。 +ULP-RISC-V 协处理器代码以 C 语言编写(也可能是汇编语言),使用基于GCC的 RISC-V 工具链进行编译。 -如果你已依照 :doc:`快速入门指南 <../../get-started/index>` 中的介绍安装好了 ESP-IDF 及其 CMake 构建系统,还需要在 IDF 文件夹中执行以下指令,安装 ULP-RISC-V 工具链:: - -$ idf_tools.py install riscv-none-embed-gcc +如果你已依照 :doc:`快速入门指南 <../../get-started/index>` 中的介绍安装好了 ESP-IDF 及其 CMake 构建系统,那么 ULP-RISC-V 工具链已经被默认安装到了你的开发环境中。 +.. note: 在早期版本的ESP-IDF中,RISC-V工具链具有不同的名称:`riscv-none-embed-gcc`。 编译 ULP-RISC-V 代码 ----------------------------- @@ -25,7 +24,7 @@ $ idf_tools.py install riscv-none-embed-gcc 1. ULP-RISC-V 代码以 C 语言或汇编语言编写(必须使用 `.S` 扩展名),必须放在组件目录中一个独立的目录中,例如 `ulp/`。 -.. 注意:当注册组件时(通过 ``idf_component_register``),该目录不应被添加至 ``SRC_DIRS`` 参数,因为目前 ULP-FSM 需要进行此步骤。如何正确添加 ULP 源文件,请见以下步骤。 +.. note: 当注册组件时(通过 ``idf_component_register``),该目录不应被添加至 ``SRC_DIRS`` 参数,因为目前 ULP-FSM 需要进行此步骤。如何正确添加 ULP 源文件,请见以下步骤。 2. 注册后从组件 CMakeLists.txt 中调用 ``ulp_embed_binary`` 示例如下:: @@ -147,5 +146,3 @@ ULP-RISC-V 协处理器由定时器启动,调用 :cpp:func:`ulp_riscv_run` 即 如需禁用定时器(有效防止 ULP 程序再次运行),请清除 ``RTC_CNTL_STATE0_REG`` 寄存器中的 ``RTC_CNTL_ULP_CP_SLP_TIMER_EN`` 位,此项操作可在 ULP 代码或主程序中进行。 - -.. _riscv-embedded toolchain: https://xpack.github.io/riscv-none-embed-gcc/ diff --git a/tools/ci/config/build.yml b/tools/ci/config/build.yml index 21d35a1469..eab66f9395 100644 --- a/tools/ci/config/build.yml +++ b/tools/ci/config/build.yml @@ -115,9 +115,6 @@ build_ssc_esp32s2: TEST_TYPE: "unit_test" PYTHON_VER: 3 script: - # RISC-V toolchain is optional but ULP may need it, so install: - - $IDF_PATH/tools/idf_tools.py install riscv-none-embed-gcc - - . $IDF_PATH/export.sh - ${IDF_PATH}/tools/ci/find_apps_build_apps.sh - cd $CI_PROJECT_DIR/tools/unit-test-app - python tools/UnitTestParser.py ${BUILD_PATH} @@ -155,9 +152,6 @@ build_esp_idf_tests_cmake_esp32s3: BUILD_PATH: ${CI_PROJECT_DIR}/build_${TEST_PREFIX} PYTHON_VER: 3 script: - # RISC-V toolchain is optional but ULP may need it, so install: - - $IDF_PATH/tools/idf_tools.py install riscv-none-embed-gcc - - . $IDF_PATH/export.sh # it's not possible to build 100% out-of-tree and have the "artifacts" # mechanism work, but this is the next best thing - ${IDF_PATH}/tools/ci/find_apps_build_apps.sh diff --git a/tools/tools.json b/tools/tools.json index 3fa458330e..0f4a6cc904 100644 --- a/tools/tools.json +++ b/tools/tools.json @@ -51,7 +51,7 @@ "win64": { "sha256": "58419852fefb7111fdec056ac2fd7c4bd09c1f4c17610a761a97b788413527cf", "size": 106855139, - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-2020r3/xtensa-esp32-elf-gcc8_4_0-esp-2020r3-win64.zip" + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_4_0-esp-2020r3-win64.zip" } } ] @@ -169,58 +169,56 @@ ] }, { - "description": "Toolchain for RISC-V", + "description": "Toolchain for 32-bit RISC-V based on GCC", "export_paths": [ [ - "xPacks", - "riscv-none-embed-gcc", - "8.2.0-3.1", + "riscv32-esp-elf", "bin" ] ], "export_vars": {}, - "info_url": "https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack", - "install": "on_request", - "license": "MIT", - "name": "riscv-none-embed-gcc", + "info_url": "https://github.com/espressif/crosstool-NG", + "install": "always", + "license": "GPL-3.0-with-GCC-exception", + "name": "riscv32-esp-elf", "version_cmd": [ - "riscv-none-embed-gcc", + "riscv32-esp-elf-gcc", "--version" ], - "version_regex": "(riscv-none-embed-gcc) \\(xPack GNU RISC-V Embedded GCC, 64-bit\\) (8.2.0)", + "version_regex": "\\(crosstool-NG\\s+(?:crosstool-ng-)?([0-9a-zA-Z\\.\\-_]+)\\)\\s*([0-9\\.]+)", "version_regex_replace": "\\1-\\2", "versions": [ { "linux-amd64": { - "sha256": "3d40fab50ebad8424ff85748f25d2eaee50f86a5d5222abd7a45a2e490f1e4f5", - "size": 216042047, - "url": "https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v8.2.0-3.1/xpack-riscv-none-embed-gcc-8.2.0-3.1-linux-x64.tgz" + "sha256": "425454c5c4e2cde5dd2dd3a1d398befc70addf71547840fb6d0ec4b307b08894", + "size": 152042971, + "url": "https://dl.espressif.com/dl/toolchains/preview/riscv32-esp-elf-gcc8_4_0-crosstool-ng-1.24.0-123-g64eb9ff-linux-amd64.tar.gz" }, - "linux-i686": { - "sha256": "2e856ee33ef544a2405183366cdf299da2cca697e8cc57627dfaad8ab4460a99", - "size": 219854326, - "url": "https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v8.2.0-3.1/xpack-riscv-none-embed-gcc-8.2.0-3.1-linux-x32.tgz" + "linux-armel": { + "sha256": "8ae098751b5196ca8a80d832cc9930bc4d639762a6cb22be3cfe0a8d71b2f230", + "size": 150801079, + "url": "https://dl.espressif.com/dl/toolchains/preview/riscv32-esp-elf-gcc8_4_0-crosstool-ng-1.24.0-123-g64eb9ff-linux-armel.tar.gz" }, "macos": { - "sha256": "48ece50b7272a8e49e56e37f54f9962f93dce4ca44f1bb4c8113fab0230fbdf1", - "size": 214715632, - "url": "https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v8.2.0-3.1/xpack-riscv-none-embed-gcc-8.2.0-3.1-darwin-x64.tgz" + "sha256": "35b1aef85b7e6b4268774f627e8e835d087bcf8b9972cfb6436614aa2e40d4a9", + "size": 158594401, + "url": "https://dl.espressif.com/dl/toolchains/preview/riscv32-esp-elf-gcc8_4_0-crosstool-ng-1.24.0-123-g64eb9ff-macos.tar.gz" }, - "name": "riscv-none-embed-gcc-8.2.0", + "name": "1.24.0.123_64eb9ff-8.4.0", "status": "recommended", "win32": { - "sha256": "78bcd52f7b404133de3b2f9568e7101c1de747f98db3a7b0d6251b75a1754867", - "size": 232387519, - "url": "https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v8.2.0-3.1/xpack-riscv-none-embed-gcc-8.2.0-3.1-win32-x32.zip" + "sha256": "4f576b08620f57c270ac677cc94dce2767fff72d27a539e348d448f63b480d1f", + "size": 190014086, + "url": "https://dl.espressif.com/dl/toolchains/preview/riscv32-esp-elf-gcc8_4_0-crosstool-ng-1.24.0-123-g64eb9ff-win32.zip" }, "win64": { - "sha256": "98b60720607f1400081806d60d70796b30399f8b426e2c790a4abb0bffb9e5ec", - "size": 241927614, - "url": "https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v8.2.0-3.1/xpack-riscv-none-embed-gcc-8.2.0-3.1-win32-x64.zip" + "sha256": "51e392ed88498f3fc4ad07e9ff4b5225f6533b1c363ecd7dd67c10d8d31b6b23", + "size": 191565525, + "url": "https://dl.espressif.com/dl/toolchains/preview/riscv32-esp-elf-gcc8_4_0-crosstool-ng-1.24.0-123-g64eb9ff-win64.zip" } } ] - }, + } { "description": "Toolchain for ESP32 ULP coprocessor", "export_paths": [