Skip to content

Commit 4c16457

Browse files
committed
Initial ESP32_C5 build + Build diagnostic message
1 parent f47ac2b commit 4c16457

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1697
-13
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# Copyright (c) .NET Foundation and Contributors
3+
# See LICENSE file in the project root for full license information.
4+
#
5+
6+
# need to specify linker flags here
7+
set(CMAKE_EXE_LINKER_FLAGS " -Wl,--print-memory-usage " CACHE INTERNAL "executable linker flags")
8+
9+
# TARGET parameter to set the target that's setting them for
10+
# optional EXTRA_COMPILE_OPTIONS with compile options to be added
11+
macro(nf_set_compile_options)
12+
13+
# parse arguments
14+
cmake_parse_arguments(NFSCO "" "TARGET" "EXTRA_COMPILE_OPTIONS" ${ARGN})
15+
16+
if(NOT NFSCO_TARGET OR "${NFSCO_TARGET}" STREQUAL "")
17+
message(FATAL_ERROR "Need to set TARGET argument when calling nf_set_compile_options()")
18+
endif()
19+
20+
# include any extra options coming from any extra args?
21+
target_compile_options(${NFSCO_TARGET} PUBLIC ${NFSCO_EXTRA_COMPILE_OPTIONS} -Wall -Wextra -Werror -Wno-sign-compare -Wno-unused-parameter -Wshadow -Wimplicit-fallthrough -fshort-wchar -fno-builtin -fno-common -fno-exceptions -fcheck-new )
22+
23+
# this series has FPU
24+
target_compile_definitions(${NFSCO_TARGET} PUBLIC -DTARGET=esp32c6 -DUSE_FPU=TRUE -DPLATFORM_ESP32 -DESP_PLATFORM)
25+
26+
endmacro()
27+
28+
# TARGET parameter to set the target that's setting them for
29+
# optional EXTRA_LINK_FLAGS with link flags to be added
30+
macro(nf_set_link_options)
31+
32+
# parse arguments
33+
cmake_parse_arguments(NFSLO "" "TARGET;EXTRA_LINK_FLAGS" "" ${ARGN})
34+
35+
if(NOT NFSLO_TARGET OR "${NFSLO_TARGET}" STREQUAL "")
36+
message(FATAL_ERROR "Need to set TARGET argument when calling nf_set_link_options()")
37+
endif()
38+
39+
# set optimization linker flags for RELEASE and MinSizeRel
40+
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
41+
set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Os ")
42+
endif()
43+
44+
# include libraries in build
45+
nf_include_libraries_in_build(${NFSLO_TARGET})
46+
47+
# set extra linker flags
48+
set_property(TARGET ${NFSLO_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " ${NFSLO_EXTRA_LINK_FLAGS} ")
49+
50+
# set optimization flags
51+
nf_set_optimization_options(${NFSLO_TARGET})
52+
53+
endmacro()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#
2+
# Copyright (c) .NET Foundation and Contributors
3+
# See LICENSE file in the project root for full license information.
4+
#

CMake/binutils.ESP32.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ function(nf_set_esp32_target_series)
221221
set(TARGET_SERIES_SHORT ${TARGET_SERIES_2} CACHE INTERNAL "ESP32 target series lower case, short version")
222222

223223
# set the CPU type
224-
if(${TARGET_SERIES_SHORT} STREQUAL "esp32c3" OR ${TARGET_SERIES_SHORT} STREQUAL "esp32c6" OR ${TARGET_SERIES_SHORT} STREQUAL "esp32h2" OR ${TARGET_SERIES_SHORT} STREQUAL "esp32p4")
224+
if(${TARGET_SERIES_SHORT} STREQUAL "esp32c3" OR ${TARGET_SERIES_SHORT} STREQUAL "esp32c5" OR ${TARGET_SERIES_SHORT} STREQUAL "esp32c6" OR ${TARGET_SERIES_SHORT} STREQUAL "esp32h2" OR ${TARGET_SERIES_SHORT} STREQUAL "esp32p4")
225225
set(ESP32_CPU_TYPE "riscv" CACHE INTERNAL "Setting CPU type")
226226
else()
227227
set(ESP32_CPU_TYPE "xtensa" CACHE INTERNAL "Setting CPU type")
@@ -503,6 +503,7 @@ macro(nf_setup_partition_tables_generator)
503503

504504
if(${TARGET_SERIES_SHORT} STREQUAL "esp32" OR
505505
${TARGET_SERIES_SHORT} STREQUAL "esp32c3" OR
506+
${TARGET_SERIES_SHORT} STREQUAL "esp32c5" OR
506507
${TARGET_SERIES_SHORT} STREQUAL "esp32c6" OR
507508
${TARGET_SERIES_SHORT} STREQUAL "esp32h2" OR
508509
${TARGET_SERIES_SHORT} STREQUAL "esp32p4" OR
@@ -519,6 +520,7 @@ macro(nf_setup_partition_tables_generator)
519520
endif()
520521

521522
if(${TARGET_SERIES_SHORT} STREQUAL "esp32" OR
523+
${TARGET_SERIES_SHORT} STREQUAL "esp32c5" OR
522524
${TARGET_SERIES_SHORT} STREQUAL "esp32c6" OR
523525
${TARGET_SERIES_SHORT} STREQUAL "esp32p4" OR
524526
${TARGET_SERIES_SHORT} STREQUAL "esp32s2" OR
@@ -656,6 +658,7 @@ macro(nf_add_idf_as_library)
656658
message(FATAL_ERROR "Couldn't get IDF version from target __idf_build_target")
657659
endif()
658660

661+
message(STATUS "ESP_IDF_VERSION: $ENV{ESP_IDF_VERSION}")
659662
message(STATUS "Current IDF version is: ${MY_IDF_VER}")
660663

661664
string(FIND ${MY_IDF_VER} "-dirty" MY_IDF_VER_DIRTY)

CMake/riscv-esp32c5.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"version": 4,
3+
"include": [
4+
"base.json"
5+
],
6+
"configurePresets": [
7+
{
8+
"name": "riscv-esp32c5-preset",
9+
"description": "Preset for ESP32-C5 series",
10+
"inherits": "general-preset",
11+
"hidden": true,
12+
"cacheVariables": {
13+
"CMAKE_TOOLCHAIN_FILE": {
14+
"type": "FILEPATH",
15+
"value": "${sourceDir}/CMake/toolchain.riscv32-esp32c5-elf.cmake"
16+
},
17+
"NF_INTEROP_ASSEMBLIES": null,
18+
"NF_TARGET_HAS_NANOBOOTER": "OFF",
19+
"RTOS": "ESP32",
20+
"TARGET_SERIES": "ESP32_C5",
21+
"TARGET_BOARD": "ESP32_C5",
22+
"NF_FEATURE_HAS_CONFIG_BLOCK": "ON",
23+
"NF_FEATURE_USE_LITTLEFS": "ON",
24+
"NF_FEATURE_HAS_ACCESSIBLE_STORAGE": "ON",
25+
"SUPPORT_ANY_BASE_CONVERSION": "ON",
26+
"API_System.Net": "ON",
27+
"API_System.Math": "ON",
28+
"API_System.Device.Adc": "OFF",
29+
"API_System.Device.Gpio": "ON",
30+
"API_System.Device.I2c": "ON",
31+
"API_System.Device.I2c.Slave": "ON",
32+
"API_System.Device.I2s": "ON",
33+
"API_System.Device.Spi": "ON",
34+
"API_System.Device.Pwm": "ON",
35+
"API_System.Device.Wifi": "ON",
36+
"API_System.IO.Ports": "ON",
37+
"API_System.IO.FileSystem": "ON",
38+
"API_nanoFramework.System.IO.Hashing": "ON",
39+
"API_nanoFramework.System.Security.Cryptography": "ON",
40+
"API_Hardware.Esp32": "ON",
41+
"API_nanoFramework.Hardware.Esp32.Rmt": "ON",
42+
"API_nanoFramework.ResourceManager": "ON",
43+
"API_nanoFramework.System.Collections": "ON",
44+
"API_nanoFramework.System.Text": "ON"
45+
}
46+
}
47+
]
48+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#
2+
# Copyright (c) .NET Foundation and Contributors
3+
# See LICENSE file in the project root for full license information.
4+
#
5+
6+
include(CMakeForceCompiler)
7+
8+
# the name of the operating system for which CMake is to build
9+
set(CMAKE_SYSTEM_NAME Generic)
10+
11+
# macro to setup compilers
12+
macro(nf_set_compiler_var var name)
13+
find_program(
14+
CMAKE_${var}
15+
riscv32-esp-elf-${name}
16+
CMAKE_FIND_ROOT_PATH_BOTH
17+
REQUIRED)
18+
endmacro()
19+
20+
# safer to have these here as a check if the toolchain are accessible in the PATH
21+
22+
# setup C compiler
23+
nf_set_compiler_var(C_COMPILER gcc)
24+
25+
# setup C++ compiler
26+
nf_set_compiler_var(CXX_COMPILER g++)
27+
28+
# setup Assembler compiler
29+
nf_set_compiler_var(ASM_COMPILER gcc)
30+
31+
# other toolchain configurations
32+
find_program(
33+
CMAKE_OBJCOPY
34+
riscv32-esp-elf-objcopy
35+
CMAKE_FIND_ROOT_PATH_BOTH)
36+
37+
find_program(
38+
CMAKE_OBJDUMP
39+
riscv32-esp-elf-objdump
40+
CMAKE_FIND_ROOT_PATH_BOTH)
41+
42+
find_program(
43+
CMAKE_SIZE
44+
riscv32-esp-elf-size
45+
CMAKE_FIND_ROOT_PATH_BOTH)
46+
47+
set(CMAKE_C_FLAGS " -march=rv32imac_zicsr_zifencei -Wno-frame-address" CACHE STRING "C Compiler Base Flags")
48+
set(CMAKE_CXX_FLAGS " -march=rv32imac_zicsr_zifencei -Wno-frame-address -Wno-literal-suffix" CACHE STRING "C++ Compiler Base Flags")
49+
50+
# root paths to search on the filesystem for cross-compiling
51+
get_filename_component(CMAKE_FIND_ROOT_PATH ${CMAKE_C_COMPILER} DIRECTORY CACHE)
52+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
53+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
54+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
55+
56+
# set required C and C++ standard for ALL targets
57+
set(CMAKE_C_STANDARD 11 CACHE INTERNAL "C standard for all targets")
58+
set(CMAKE_CXX_STANDARD 11 CACHE INTERNAL "C++ standard for all targets")
59+
60+
# Perform compiler test with static library
61+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

targets/ESP32/CMakePresets.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"include": [
44
"../../CMake/xtensa-esp32.json",
55
"../../CMake/riscv-esp32c3.json",
6+
"../../CMake/riscv-esp32c5.json",
67
"../../CMake/riscv-esp32c6.json",
78
"../../CMake/riscv-esp32h2.json",
89
"../../CMake/riscv-esp32p4.json",
@@ -275,6 +276,33 @@
275276
"API_nanoFramework.Device.Bluetooth": "ON"
276277
}
277278
},
279+
{
280+
"name": "ESP32_C5_UART",
281+
"inherits": [
282+
"riscv-esp32c5-preset",
283+
"user-tools-repos",
284+
"user-prefs"
285+
],
286+
"hidden": false,
287+
"cacheVariables": {
288+
"TARGET_NAME": "${presetName}",
289+
"SDK_CONFIG_FILE": "sdkconfig.default.esp32c5",
290+
"NF_BUILD_RTM": "OFF",
291+
"NF_FEATURE_DEBUGGER": "ON",
292+
"NF_FEATURE_RTC": "ON",
293+
"NF_FEATURE_HAS_SDCARD": "ON",
294+
"HAL_WP_USE_USB_CDC": "ON",
295+
"API_nanoFramework.Device.OneWire": "OFF",
296+
"API_nanoFramework.Device.Bluetooth": "ON",
297+
"API_nanoFramework.Networking.Thread": "OFF",
298+
"THREAD_DEVICE_TYPE": "FTD",
299+
"API_nanoFramework.Graphics": "ON",
300+
"GRAPHICS_DISPLAY": "Generic_SPI.cpp",
301+
"TOUCHPANEL_DEVICE": "XPT2046.cpp",
302+
"GRAPHICS_DISPLAY_INTERFACE": "Spi_To_Display.cpp",
303+
"TOUCHPANEL_INTERFACE": "Spi_To_TouchPanel.cpp"
304+
}
305+
},
278306
{
279307
"name": "ESP32_C6_THREAD",
280308
"inherits": [
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Copyright (c) .NET Foundation and Contributors
3+
# See LICENSE file in the project root for full license information.
4+
#
5+
6+
include(binutils.ESP32)
7+
8+
##############################
9+
10+
nf_setup_target_build()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#
2+
# Copyright (c) .NET Foundation and Contributors
3+
# See LICENSE file in the project root for full license information.
4+
#

0 commit comments

Comments
 (0)