Skip to content

Commit

Permalink
Merge pull request #42 from xrobot-org/dev
Browse files Browse the repository at this point in the history
Support esp-idf v5.1.
  • Loading branch information
Jiu-xiao authored Jan 6, 2024
2 parents 5fda58a + ec66217 commit a6de53b
Show file tree
Hide file tree
Showing 17 changed files with 1,956 additions and 929 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
run: git config --global --add safe.directory /__w/XRobot/XRobot && git submodule init && git submodule update

- name: Build
run: export HOME=/root && bash -c "source ~/.idf_profile && python project.py build all all"
run: export HOME=/root && bash -c "python project.py build all all"
2 changes: 1 addition & 1 deletion .github/workflows/build_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: git config --global --add safe.directory /__w/XRobot/XRobot && git submodule init && git submodule update

- name: Build
run: export HOME=/root && bash -c "source ~/.idf_profile && python project.py build all all"
run: export HOME=/root && bash -c "python project.py build all all"

- name: Pack firmware
run: zip -r ./firmware.zip ./firmware
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@
],
"clangd.path": "clangd",
"editor.inlayHints.enabled": "offUnlessPressed",
"cmake.options.statusBarVisibility": "visible",
}
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-Werror -gdwarf-4)

elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(CMAKE_C_FLAGS_RELEASE "-O3 -g")
set(CMAKE_ASM_FLAGS_RELEASE "-O3 -g")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g")
set(CMAKE_ASM_FLAGS_RELWITHDEBINFO "-O3 -g")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "")
add_compile_definitions(MCU_DEBUG_BUILD)
add_compile_options(-Werror -gdwarf-4)

Expand All @@ -53,9 +53,9 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_definitions()

elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
set(CMAKE_C_FLAGS_RELEASE "-Os")
set(CMAKE_ASM_FLAGS_RELEASE "-Os")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os")
set(CMAKE_ASM_FLAGS_MINSIZEREL "-Os")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "")
add_compile_definitions()
else()
message(FATAL_ERROR "Unknown build type.")
Expand Down
26 changes: 16 additions & 10 deletions hw/bsp/esp32-c3-arduino/board.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
cmake_minimum_required(VERSION 3.16)

include_directories(
PUBLIC $ENV{IDF_PATH}/components/esp_http_client/include
PUBLIC $ENV{IDF_PATH}/components/mdns/include
PUBLIC $ENV{IDF_PATH}/components/lwip/lwip/src/include/lwip/apps
PUBLIC $ENV{IDF_PATH}/components/libhelix-mp3/libhelix-mp3/pub
)

# Include for ESP-IDF build system functions
include($ENV{IDF_PATH}/tools/cmake/idf.cmake)

add_compile_options(-Wno-missing-field-initializers -Wno-write-strings)
add_compile_definitions(ARDUINO_USB_CDC_ON_BOOT=1 ARDUINO_USB_MODE=1)

# Create idf::{target} and idf::freertos static libraries
Expand All @@ -14,7 +20,7 @@ idf_build_process("esp32c3"
# although esptool_py does not generate static library,
# processing the component is needed for flashing related
# targets and file generation
COMPONENTS freertos esptool_py driver nvs_flash bt esp_http_client esp_https_ota arduino-esp32
COMPONENTS freertos esptool_py driver nvs_flash bt mdns libhelix-mp3 esp_http_client esp_https_ota arduino-esp32
SDKCONFIG ${BOARD_DIR}/sdkconfig
BUILD_DIR ${CMAKE_BINARY_DIR})

Expand All @@ -31,6 +37,8 @@ target_link_libraries(
idf::spi_flash
idf::driver
idf::nvs_flash
idf::mdns
idf::libhelix-mp3
idf::esp_wifi
idf::esp_http_client
idf::esp_https_ota
Expand All @@ -39,19 +47,17 @@ target_link_libraries(
system
robot
)
# Attach additional targets to the executable file for flashing,
# linker script generation, partition_table generation, etc.
idf_build_executable(${elf_file})

add_subdirectory(${BOARD_DIR}/drivers)

# add_compile_options(-Wno-missing-field-initializers)

target_include_directories(
${PROJECT_NAME}.elf
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE $ENV{IDF_PATH}/components/esp_http_client/include
PRIVATE $<TARGET_PROPERTY:bsp,INTERFACE_INCLUDE_DIRECTORIES>
PRIVATE $<TARGET_PROPERTY:system,INTERFACE_INCLUDE_DIRECTORIES>
PRIVATE $<TARGET_PROPERTY:robot,INTERFACE_INCLUDE_DIRECTORIES>
PUBLIC $<TARGET_PROPERTY:idf::mdns,INTERFACE_INCLUDE_DIRECTORIES>
PUBLIC $<TARGET_PROPERTY:bsp,INTERFACE_INCLUDE_DIRECTORIES>
PUBLIC $<TARGET_PROPERTY:system,INTERFACE_INCLUDE_DIRECTORIES>
PUBLIC $<TARGET_PROPERTY:robot,INTERFACE_INCLUDE_DIRECTORIES>
)

idf_build_executable(${elf_file})
2 changes: 2 additions & 0 deletions hw/bsp/esp32-c3-arduino/drivers/bsp_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ bsp_status_t bsp_flash_init() {
err = nvs_flash_init();
}
ESP_ERROR_CHECK(err);

return err == ESP_OK ? BSP_OK : BSP_ERR;
}

size_t bsp_flash_check_blog(const char* name) {
Expand Down
2 changes: 1 addition & 1 deletion hw/bsp/esp32-c3-arduino/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

void setup() {}

void loop() { sleep(1000); }
void loop() { delay(1000); }
Loading

0 comments on commit a6de53b

Please sign in to comment.