Przeglądaj źródła

Merge branch 'bugfix/idf_5_0_compat' into 'master'

compatibility with IDF 5.0 and 3.3, ci fixes

See merge request espressif/esp-serial-flasher!35
Ivan Grokhotkov 4 lat temu
rodzic
commit
3cde821c34

+ 2 - 1
.gitignore

@@ -1,3 +1,4 @@
 build
 sdkconfig
-empty_file.bin
+empty_file.bin
+binaries.c

+ 50 - 35
.gitlab-ci.yml

@@ -11,56 +11,71 @@ workflow:
     - if: "$CI_COMMIT_BRANCH"
 
 variables:
-  IDF_REPO: https://github.com/espressif/esp-idf.git
   STM32_CUBE_F4_REPO: https://github.com/STMicroelectronics/STM32CubeF4
-  SERIAL_FLASHER_REPO: ${GITLAB_SSH_SERVER}/espressif/esp-serial-flasher.git
+  STM32_CUBE_F4_REPO_TAG: v1.26.2
+  ARM_TOOLCHAIN_URL: https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2?revision=05382cca-1721-44e1-ae19-1e7c3dc96118&la=en&hash=D7C9D18FCA2DD9F894FD9F3C3DC9228498FA281A
   QEMU_PATH: /opt/qemu/bin/qemu-system-xtensa
 
-.clone_and_setup_idf: &clone_and_setup_idf |
-  git clone "${IDF_REPO}"
-  cd esp-idf
-  tools/idf_tools.py --non-interactive install all && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1
-  git submodule update --init
-  export IDF_PATH=$(pwd)
-
-.clone_and_setup_stm32: &clone_and_setup_stm32 |
-  cd $CI_PROJECT_DIR
-  git submodule update --init
-  git clone "${STM32_CUBE_F4_REPO}"
-  mkdir $CI_PROJECT_DIR/examples/stm32_example/build
-
-  wget -O gcc-arm-none-eabi.tar.bz2 'https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2?revision=05382cca-1721-44e1-ae19-1e7c3dc96118&la=en&hash=D7C9D18FCA2DD9F894FD9F3C3DC9228498FA281A'
-  tar -xjf gcc-arm-none-eabi.tar.bz2
-  mv gcc-arm-none-eabi-* gcc-arm-none-eabi
-
-.build_test_template:
-  before_script:
-    # Use CI Tools
-    - curl -sSL ${CIT_LOADER_URL} | sh
-    - source citools/import_functions
-    - PATH=$CI_PROJECT_DIR/esp-idf/tools:$PATH
-
-build_with_idf:
-  extends: .build_test_template
+.build_idf_template:
   stage: build
-  image: $CI_DOCKER_REGISTRY/esp-env:v4.4-1
+  image: espressif/idf:latest
   tags:
     - build
     - internet
+  variables:
+    PEDANTIC_FLAGS: "-Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function"
+    EXTRA_CFLAGS: "${PEDANTIC_FLAGS}"
+    EXTRA_CXXFLAGS: "${PEDANTIC_FLAGS}"
   script:
-    - source /opt/pyenv/activate && pyenv global 3.6.13
-    - *clone_and_setup_idf
     - cd $CI_PROJECT_DIR/examples/esp32_example
-    # Build for all supported targets
     - idf.py build -DMD5_ENABLED=1
     - idf.py build -DMD5_ENABLED=0
 
-    - *clone_and_setup_stm32
+build_idf_v3.3:
+  extends: .build_idf_template
+  image: espressif/idf:release-v3.3
+
+build_idf_v4.1:
+  extends: .build_idf_template
+  image: espressif/idf:release-v4.1
+
+build_idf_v4.2:
+  extends: .build_idf_template
+  image: espressif/idf:release-v4.2
+
+build_idf_v4.3:
+  extends: .build_idf_template
+  image: espressif/idf:release-v4.3
+
+build_idf_v4.4:
+  extends: .build_idf_template
+  image: espressif/idf:release-v4.4
+
+build_idf_master:
+  extends: .build_idf_template
+  image: espressif/idf:latest
+
+build_stm32:
+  stage: build
+  # IDF is not necessary for STM32 build, but this image is already used in another job
+  # and it comes with a recent enough CMake version.
+  image: espressif/idf:latest
+  tags:
+    - build
+    - internet
+  script:
+    - cd $CI_PROJECT_DIR
+    - git submodule update --init
+    - git clone --depth=1 -b ${STM32_CUBE_F4_REPO_TAG} ${STM32_CUBE_F4_REPO}
+    - wget --no-verbose -O gcc-arm-none-eabi.tar.bz2 ${ARM_TOOLCHAIN_URL}
+    - tar -xjf gcc-arm-none-eabi.tar.bz2
+    - mv gcc-arm-none-eabi-* gcc-arm-none-eabi
+    - mkdir $CI_PROJECT_DIR/examples/stm32_example/build
     - cd $CI_PROJECT_DIR/examples/stm32_example/build
-    - cmake -DTOOLCHAIN_PREFIX=$CI_PROJECT_DIR/gcc-arm-none-eabi -DSTM32Cube_DIR=$CI_PROJECT_DIR/STM32CubeF4 .. && cmake --build .
+    - cmake -DTOOLCHAIN_PREFIX=$CI_PROJECT_DIR/gcc-arm-none-eabi -DSTM32Cube_DIR=$CI_PROJECT_DIR/STM32CubeF4 -G Ninja ..
+    - cmake --build .
 
 run_tests:
-  extends: .build_test_template
   stage: test
   image: ${CI_DOCKER_REGISTRY}/qemu:esp-develop-20191124
   tags:

+ 23 - 18
CMakeLists.txt

@@ -1,28 +1,33 @@
 cmake_minimum_required(VERSION 3.5)
 
-if (DEFINED ESP_PLATFORM)
+set(srcs src/esp_loader.c
+         src/esp_targets.c
+         src/serial_comm.c
+         src/md5_hash.c
+)
+
 
+if (DEFINED ESP_PLATFORM)
     # Register component to esp-idf build system
-    set(COMPONENT_SRCS
-        src/esp_loader.c
-        src/esp_targets.c
-        src/serial_comm.c
-        src/md5_hash.c
-        port/esp32_port.c)
-    set(COMPONENT_ADD_INCLUDEDIRS "include port")
-    set(COMPONENT_PRIV_INCLUDEDIRS "private_include" )
-    register_component()
-    component_compile_options(-Wstrict-prototypes)
-    set(target ${COMPONENT_LIB})
+    list(APPEND srcs port/esp32_port.c)
+    if ("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "4.0")
+        idf_component_register(SRCS ${srcs}
+                               INCLUDE_DIRS include port
+                               PRIV_INCLUDE_DIRS private_include)
+        set(target ${COMPONENT_LIB})
+        component_compile_options(-Wstrict-prototypes)
+    else()
+        # Remove when dropping support for IDF 3.3
+        set(COMPONENT_SRCS ${srcs})
+        set(COMPONENT_ADD_INCLUDEDIRS include port)
+        set(COMPONENT_PRIV_INCLUDEDIRS private_include)
+        register_component()
+        set(target ${COMPONENT_TARGET})
+    endif()
 
 else()
-
     # Create traditional CMake target
-    add_library(flasher 
-        src/esp_loader.c
-        src/esp_targets.c
-        src/serial_comm.c
-        src/md5_hash.c)
+    add_library(flasher ${srcs})
 
     target_include_directories(flasher PUBLIC include port PRIVATE private_include)
 

+ 19 - 6
examples/esp32_example/main/CMakeLists.txt

@@ -1,9 +1,22 @@
-idf_component_register(SRCS "main.c" "binaries.c" "../../common/example_common.c"
-                       INCLUDE_DIRS "." "../../common")
+set(srcs main.c ../../common/example_common.c)
+set(include_dirs . ../../common)
 
-set_property(SOURCE binaries.c PROPERTY GENERATED 1)
+if ("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "4.0")
+    idf_component_register(SRCS ${srcs}
+                           INCLUDE_DIRS ${include_dirs})
+    set(target ${COMPONENT_LIB})
+else()
+    # remove when dropping IDF 3.3 support
+    set(COMPONENT_SRCS ${srcs})
+    set(COMPONENT_ADD_INCLUDEDIRS ${include_dirs})
+    register_component()
+    set(target ${COMPONENT_TARGET})
+endif()
 
+# Embed binaries into the app.
+# In ESP-IDF this can also be done using EMBED_FILES option of idf_component_register.
+# Here an external tool is used to make file embedding similar with other ports.
 include(${CMAKE_CURRENT_LIST_DIR}/../../common/bin2array.cmake)
-
-create_resources(${CMAKE_CURRENT_LIST_DIR}/../../binaries/Hello-world binaries.c)
-
+create_resources(${CMAKE_CURRENT_LIST_DIR}/../../binaries/Hello-world ${CMAKE_BINARY_DIR}/binaries.c)
+set_property(SOURCE ${CMAKE_BINARY_DIR}/binaries.c PROPERTY GENERATED 1)
+target_sources(${target} PRIVATE ${CMAKE_BINARY_DIR}/binaries.c)

Plik diff jest za duży
+ 0 - 2
examples/esp32_example/main/binaries.c


+ 2 - 2
port/esp32_port.c

@@ -94,11 +94,11 @@ esp_loader_error_t loader_port_esp32_init(const loader_esp32_config_t *config)
     }
 
     // Initialize boot pin selection pins
-    gpio_pad_select_gpio(s_reset_trigger_pin);
+    gpio_reset_pin(s_reset_trigger_pin);
     gpio_set_pull_mode(s_reset_trigger_pin, GPIO_PULLUP_ONLY);
     gpio_set_direction(s_reset_trigger_pin, GPIO_MODE_OUTPUT);
 
-    gpio_pad_select_gpio(s_gpio0_trigger_pin);
+    gpio_reset_pin(s_gpio0_trigger_pin);
     gpio_set_pull_mode(s_gpio0_trigger_pin, GPIO_PULLUP_ONLY);
     gpio_set_direction(s_gpio0_trigger_pin, GPIO_MODE_OUTPUT);
 

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików