Skip to content

Commit

Permalink
workflows: update github action
Browse files Browse the repository at this point in the history
  • Loading branch information
espressif2022 committed Feb 7, 2024
1 parent af23ee5 commit 3be4bda
Show file tree
Hide file tree
Showing 41 changed files with 130 additions and 1,926 deletions.
61 changes: 22 additions & 39 deletions .github/workflows/build-examples-gh-pages-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ jobs:
'usb_headset',
'watering_demo']
boards: ['sdkconfig.ci.box', 'sdkconfig.ci.box-lite', 'sdkconfig.ci.box-3']
exclude:
- boards: sdkconfig.ci.box-lite
build-dir: usb_camera_lcd_display
- boards: sdkconfig.ci.box
build-dir: usb_camera_lcd_display
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -58,47 +63,24 @@ jobs:
shell: bash
run: |
. $IDF_PATH/export.sh
cd $GITHUB_WORKSPACE/examples/${{matrix.build-dir}}
if [ -e "${{matrix.boards}}" ]; then
rm -rf sdkconfig build sdkconfig.defaults
cp ${{matrix.boards}} sdkconfig.defaults
# idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;${{matrix.boards}}" reconfigure
fi
pip install --upgrade idf-component-manager
pip install "idf_build_apps<2.0"
if [[ ${{matrix.build-dir}} == usb_camera_lcd_display ]]; then
if [[ ${{matrix.boards}} == sdkconfig.ci.box-3 ]]; then
idf.py build
cd build
esptool.py --chip esp32s3 merge_bin -o "$GITHUB_WORKSPACE/images/${{matrix.build-dir}}_${{matrix.boards}}.bin" @flash_args
else
echo "Skipping build for ${{matrix.build-dir}} with ${{matrix.boards}}"
fi
elif [[ ${{matrix.build-dir}} == chatgpt_demo ]]; then
idf.py build
cd $GITHUB_WORKSPACE/examples/${{matrix.build-dir}}
# diff sdkconfig.defaults ${{matrix.boards}} | grep '^>' | sed 's/^> *//' | grep -v '^#' | sed 's/.*/\n&/' >> sdkconfig.defaults
comm -23 <(grep -v '^#' ${{matrix.boards}} | sort) <(grep -v '^#' sdkconfig.defaults | sort) | sed 's/.*/\n&/' >> sdkconfig.defaults
if [[ ${{matrix.build-dir}} == chatgpt_demo ]]; then
cd factory_nvs
rm -rf sdkconfig build sdkconfig.defaults
cp ${{matrix.boards}} sdkconfig.defaults
# idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;${{matrix.boards}}" reconfigure
comm -23 <(grep -v '^#' ${{matrix.boards}} | sort) <(grep -v '^#' sdkconfig.defaults | sort) | sed 's/.*/\n&/' >> sdkconfig.defaults
idf.py build
cd ../
esptool.py --chip ESP32-S3 merge_bin \
-o "$GITHUB_WORKSPACE/images/${{matrix.build-dir}}_${{matrix.boards}}.bin" \
--flash_mode dio --flash_freq 80m --flash_size 16MB \
0x0 build/bootloader/bootloader.bin \
0x8000 build/partition_table/partition-table.bin \
0xd000 build/ota_data_initial.bin \
0x10000 build/chatgpt_demo.bin \
0x900000 build/storage.bin \
0xb00000 build/srmodels/srmodels.bin \
0x700000 factory_nvs/build/factory_nvs.bin
else
idf.py build
cd build
esptool.py --chip esp32s3 merge_bin -o "$GITHUB_WORKSPACE/images/${{matrix.build-dir}}_${{matrix.boards}}.bin" @flash_args
fi
idf.py build
cd build
esptool.py --chip esp32s3 merge_bin -o "$GITHUB_WORKSPACE/images/${{matrix.build-dir}}_${{matrix.boards}}.bin" @flash_args
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
Expand All @@ -107,7 +89,7 @@ jobs:

job2:
runs-on: ubuntu-latest
container: espressif/esp-matter:latest
container: espressif/esp-matter:latest_idf_v5.1.1
strategy:
matrix:
build-dir: ['matter_switch']
Expand All @@ -122,11 +104,12 @@ jobs:
run: |
. $IDF_PATH/export.sh
. $ESP_MATTER_PATH/export.sh
pip install --upgrade idf-component-manager
pip install "idf_build_apps<2.0"
cd $GITHUB_WORKSPACE/examples/${{matrix.build-dir}}
comm -23 <(grep -v '^#' ${{matrix.boards}} | sort) <(grep -v '^#' sdkconfig.defaults | sort) | sed 's/.*/\n&/' >> sdkconfig.defaults
rm -rf sdkconfig build sdkconfig.defaults
cp ${{matrix.boards}} sdkconfig.defaults
# idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;${{matrix.boards}}" reconfigure
idf.py set-target esp32s3 build
cd build
esptool.py --chip esp32s3 merge_bin -o "$GITHUB_WORKSPACE/images/${{matrix.build-dir}}_${{matrix.boards}}.bin" @flash_args
Expand Down Expand Up @@ -162,7 +145,7 @@ jobs:
ls
$GITHUB_WORKSPACE/tools/launchpad/rename.sh $GITHUB_WORKSPACE
ls
$GITHUB_WORKSPACE/tools/launchpad/generate_launchpad_config.sh
$GITHUB_WORKSPACE/tools/launchpad/generate_launchpad_config.sh $GITHUB_REPOSITORY
- name: Setup Pages
uses: actions/configure-pages@v2
Expand Down
5 changes: 5 additions & 0 deletions .gitlab/ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ build_example_chatgpt_demo:
- IMAGE: espressif/idf:latest
variables:
EXAMPLE_DIR: examples/chatgpt_demo
NVS_DIR: examples/chatgpt_demo/factory_nvs
before_script:
- pwd
- mkdir ${NVS_DIR}/build
- touch ${NVS_DIR}/build/factory_nvs.bin

build_example_chatgpt_demo_factory_nvs:
extends:
Expand Down
1 change: 1 addition & 0 deletions examples/chatgpt_demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ set(EXTRA_COMPONENT_DIRS
)
add_compile_options(-fdiagnostics-color=always -Wno-ignored-qualifiers)
project(chatgpt_demo)

2 changes: 1 addition & 1 deletion examples/chatgpt_demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ idf.py build
**8. Flash**

```bash
python -m esptool -p /dev/ttyACM0 --chip esp32s3 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 16MB --flash_freq 80m 0x0 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0xd000 build/ota_data_initial.bin 0x10000 build/chatgpt_demo.bin 0x900000 build/storage.bin 0xb00000 build/srmodels/srmodels.bin 0x700000 factory_nvs/build/factory_nvs.bin
idf.py -p PORT flash

```

Expand Down
4 changes: 2 additions & 2 deletions examples/chatgpt_demo/factory_nvs/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ static void uf2_nvs_modified_cb()

void app_main(void)
{
const esp_partition_t *update_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, NULL);
ESP_LOGI(TAG, "Switch to partition OTA_0");
const esp_partition_t *update_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
ESP_LOGI(TAG, "Switch to partition factory");
esp_ota_set_boot_partition(update_partition);
esp_err_t err = ESP_OK;

Expand Down
7 changes: 3 additions & 4 deletions examples/chatgpt_demo/factory_nvs/partitions.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, 0x9000, 0x4000,
otadata, data, ota, 0xd000, 0x2000,
phy_init, data, phy, 0xf000, 0x1000,
ota_0, app, ota_0, 0x10000, 6M,
uf2, app, factory, 0x700000, 2M,
otadata, data, ota, 0xd000, 0x2000,
phy_init, data, phy, 0xf000, 0x1000,
ota_0, app, ota_0, 0x700000, 2M,
35 changes: 1 addition & 34 deletions examples/chatgpt_demo/factory_nvs/sdkconfig.ci.box
Original file line number Diff line number Diff line change
@@ -1,35 +1,2 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_BSP_BOARD_ESP32_S3_BOX=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=1024
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=8192
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP32S3_DATA_CACHE_64KB=y
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y
CONFIG_FREERTOS_HZ=1000
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_FONT_FMT_TXT_LARGE=y
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM_SPEED=80
CONFIG_ENABLE_UF2_USB_CONSOLE=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHFREQ="80m"
CONFIG_UF2_VOLUME_LABEL="ESP-BOX"
CONFIG_TUSB_MANUFACTURER="Espressif"
CONFIG_TUSB_PRODUCT="ESP32-S3-BOX"
CONFIG_UF2_SERIAL_NUM="12345678"
# BSP
CONFIG_BSP_BOARD_ESP32_S3_BOX=y
35 changes: 1 addition & 34 deletions examples/chatgpt_demo/factory_nvs/sdkconfig.ci.box-3
Original file line number Diff line number Diff line change
@@ -1,35 +1,2 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_BSP_BOARD_ESP32_S3_BOX=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=1024
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=8192
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP32S3_DATA_CACHE_64KB=y
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y
CONFIG_FREERTOS_HZ=1000
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_FONT_FMT_TXT_LARGE=y
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM_SPEED=80
CONFIG_ENABLE_UF2_USB_CONSOLE=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHFREQ="80m"
CONFIG_UF2_VOLUME_LABEL="ESP-BOX"
CONFIG_TUSB_MANUFACTURER="Espressif"
CONFIG_TUSB_PRODUCT="ESP32-S3-BOX"
CONFIG_UF2_SERIAL_NUM="12345678"
# BSP
CONFIG_BSP_BOARD_ESP32_S3_BOX_3=y
35 changes: 1 addition & 34 deletions examples/chatgpt_demo/factory_nvs/sdkconfig.ci.box-lite
Original file line number Diff line number Diff line change
@@ -1,35 +1,2 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_BSP_BOARD_ESP32_S3_BOX=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=1024
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=8192
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP32S3_DATA_CACHE_64KB=y
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y
CONFIG_FREERTOS_HZ=1000
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
CONFIG_LV_COLOR_16_SWAP=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_MEMCPY_MEMSET_STD=y
CONFIG_LV_FONT_FMT_TXT_LARGE=y
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM_SPEED=80
CONFIG_ENABLE_UF2_USB_CONSOLE=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHFREQ="80m"
CONFIG_UF2_VOLUME_LABEL="ESP-BOX"
CONFIG_TUSB_MANUFACTURER="Espressif"
CONFIG_TUSB_PRODUCT="ESP32-S3-BOX"
CONFIG_UF2_SERIAL_NUM="12345678"
# BSP
CONFIG_BSP_BOARD_ESP32_S3_BOX_Lite=y
29 changes: 29 additions & 0 deletions examples/chatgpt_demo/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,33 @@ idf_component_register(
${APP_DIR}
${SETTINGS_DIR}
)

set(MV_UF2_BIN_EXE ${COMPONENT_PATH}/generateuf2.py)
idf_build_get_property(build_dir BUILD_DIR)
set(nvs_src_file ${PROJECT_DIR}/factory_nvs/build/factory_nvs.bin)
set(nvs_dst_file ${build_dir}/uf2/factory_nvs.bin)

if(NOT EXISTS ${nvs_src_file})
message(FATAL_ERROR "Please ensure that the 'factory_nvs' is built first, and make sure to keep the 'HMI Board Config' consistent.")
endif()

add_custom_command(
OUTPUT ${nvs_dst_file}
COMMENT "Generate factory_nvs..."
COMMAND python ${MV_UF2_BIN_EXE} -d1 ${nvs_src_file} -d2 ${nvs_dst_file}
VERBATIM)

add_custom_target(nvs_uf2_bin ALL DEPENDS ${nvs_dst_file})
add_dependencies(flash nvs_uf2_bin)

partition_table_get_partition_info(size "--partition-name ota_0" "size")
partition_table_get_partition_info(offset "--partition-name ota_0" "offset")

if("${size}" AND "${offset}")
esptool_py_flash_to_partition(flash "ota_0" "${nvs_dst_file}")
else()
set(message "Failed to find ota_0 in partition table file"
"Please add a line to the partition file.")
endif()

spiffs_create_partition_image(storage ../spiffs FLASH_IN_PROJECT)
13 changes: 7 additions & 6 deletions examples/chatgpt_demo/main/app/app_ui_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "ui.h"
#include "app_ui_ctrl.h"
#include"OpenAI.h"
#include "OpenAI.h"
#include "esp_ota_ops.h"
#include "esp_system.h"
#include "esp_log.h"
Expand All @@ -27,21 +27,22 @@ void EventPanelSleepClickCb(lv_event_t *e)
ESP_LOGI(TAG, "sr start once");
}

static void RestartToFactoryPartition(void){
const esp_partition_t *update_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
static void RestartToFactoryPartition(void)
{
const esp_partition_t *update_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, NULL);
// Set the boot partition to switch to Project 1 using OTA handle
ESP_LOGI(TAG, "Switch to partition OTA_1");
ESP_LOGI(TAG, "Switch to partition UF2");
esp_ota_set_boot_partition(update_partition);
esp_restart();
}

void EventWifiResetConfirmClick(lv_event_t * e)
void EventWifiResetConfirmClick(lv_event_t *e)
{
ESP_LOGI(TAG, "Reboot from WIFI Page to Factory Partition");
RestartToFactoryPartition();
}

void EventResetConfirm(lv_event_t * e)
void EventResetConfirm(lv_event_t *e)
{
ESP_LOGI(TAG, "Reboot from Settings Page to Factory Partition");
RestartToFactoryPartition();
Expand Down
28 changes: 28 additions & 0 deletions examples/chatgpt_demo/main/generateuf2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import io
import os
import argparse
import shutil
import math
import sys

sys.dont_write_bytecode = True

def copy_files(nvs_src_file, nvs_dst_file):
dst_folder = os.path.dirname(nvs_dst_file)

if not os.path.exists(dst_folder):
os.makedirs(dst_folder)

shutil.copyfile(nvs_src_file, nvs_dst_file)
print(f"File copied from {nvs_src_file} to {nvs_dst_file}")

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='move uf2 fw')
parser.add_argument('-d1', '--nvs_src_file')
parser.add_argument('-d2', '--nvs_dst_file')
args = parser.parse_args()

if os.path.exists(args.nvs_src_file):
copy_files(args.nvs_src_file, args.nvs_dst_file)
4 changes: 2 additions & 2 deletions examples/chatgpt_demo/main/settings/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ static sys_param_t g_sys_param = {0};

esp_err_t settings_factory_reset(void)
{
const esp_partition_t *update_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
ESP_LOGI(TAG, "Switch to partition factory");
const esp_partition_t *update_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_0, NULL);
ESP_LOGI(TAG, "Switch to partition UF2");
esp_ota_set_boot_partition(update_partition);
esp_restart();
return ESP_OK;
Expand Down
14 changes: 7 additions & 7 deletions examples/chatgpt_demo/partitions.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, 0x9000, 0x4000,
otadata, data, ota, 0xd000, 0x2000,
phy_init, data, phy, 0xf000, 0x1000,
ota_0, app, ota_0, 0x10000, 6M,
uf2, app, factory, 0x700000, 2M,
storage, data, spiffs, 0x900000, 2M,
model, data, spiffs, 0xb00000, 4000K
nvs, data, nvs, 0x9000, 0x4000,
otadata, data, ota, 0xd000, 0x2000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 6M,
ota_0, app, ota_0, 0x700000, 2M,
storage, data, spiffs, 0x900000, 2M,
model, data, spiffs, 0xb00000, 4000K
Loading

0 comments on commit 3be4bda

Please sign in to comment.