Skip to content

Add option to build.sh to enable debug in ESP-IDF #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 49 additions & 25 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fi

TARGET="all"
BUILD_TYPE="all"
BUILD_DEBUG="default"
SKIP_ENV=0
COPY_OUT=0
ARCHIVE_OUT=0
Expand All @@ -20,21 +21,22 @@ if [ -z $DEPLOY_OUT ]; then
fi

function print_help() {
echo "Usage: build.sh [-s] [-A <arduino_branch>] [-I <idf_branch>] [-i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|reconfigure|idf_libs|copy_bootloader|mem_variant>] [config ...]"
echo "Usage: build.sh [-s] [-A <arduino_branch>] [-I <idf_branch>] [-D <debug_level>] [-i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|reconfigure|idf_libs|copy_bootloader|mem_variant>] [config ...]"
echo " -s Skip installing/updating of ESP-IDF and all components"
echo " -A Set which branch of arduino-esp32 to be used for compilation"
echo " -I Set which branch of ESP-IDF to be used for compilation"
echo " -i Set which commit of ESP-IDF to be used for compilation"
echo " -e Archive the build to dist"
echo " -d Deploy the build to github arduino-esp32"
echo " -D Debug level to be set to ESP-IDF. One of default,none,error,warning,info,debug or verbose"
echo " -c Set the arduino-esp32 folder to copy the result to. ex. '$HOME/Arduino/hardware/espressif/esp32'"
echo " -t Set the build target(chip). ex. 'esp32s3'"
echo " -b Set the build type. ex. 'build' to build the project and prepare for uploading to a board"
echo " ... Specify additional configs to be applied. ex. 'qio 80m' to compile for QIO Flash@80MHz. Requires -b"
exit 1
}

while getopts ":A:I:i:c:t:b:sde" opt; do
while getopts ":A:I:i:c:t:b:D:sde" opt; do
case ${opt} in
s )
SKIP_ENV=1
Expand All @@ -58,6 +60,9 @@ while getopts ":A:I:i:c:t:b:sde" opt; do
i )
export IDF_COMMIT="$OPTARG"
;;
D )
BUILD_DEBUG="$OPTARG"
;;
t )
TARGET=$OPTARG
;;
Expand Down Expand Up @@ -107,16 +112,16 @@ else
source ./tools/config.sh
fi

if [ -f "./managed_components/espressif__esp-sr/.component_hash" ]; then
rm -rf ./managed_components/espressif__esp-sr/.component_hash
if [ -f "$AR_MANAGED_COMPS/espressif__esp-sr/.component_hash" ]; then
rm -rf $AR_MANAGED_COMPS/espressif__esp-sr/.component_hash
fi

if [ "$BUILD_TYPE" != "all" ]; then
if [ "$TARGET" = "all" ]; then
echo "ERROR: You need to specify target for non-default builds"
print_help
fi
configs="configs/defconfig.common;configs/defconfig.$TARGET"
configs="configs/defconfig.common;configs/defconfig.$TARGET;configs/defconfig.debug_$BUILD_DEBUG"

# Target Features Configs
for target_json in `jq -c '.targets[]' configs/builds.json`; do
Expand All @@ -141,19 +146,7 @@ if [ "$BUILD_TYPE" != "all" ]; then
fi

rm -rf build sdkconfig out

# Add components version info
mkdir -p "$AR_TOOLS/esp32-arduino-libs" && rm -rf version.txt && rm -rf "$AR_TOOLS/esp32-arduino-libs/versions.txt"
component_version="esp-idf: "$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD)" "$(git -C "$IDF_PATH" rev-parse --short HEAD)
echo $component_version >> version.txt && echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt"
for component in `ls "$AR_COMPS"`; do
if [ -d "$AR_COMPS/$component/.git" ] || [ -d "$AR_COMPS/$component/.github" ]; then
component_version="$component: "$(git -C "$AR_COMPS/$component" symbolic-ref --short HEAD || git -C "$AR_COMPS/$component" tag --points-at HEAD)" "$(git -C "$AR_COMPS/$component" rev-parse --short HEAD)
echo $component_version >> version.txt && echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt"
fi
done
component_version="tinyusb: "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" symbolic-ref --short HEAD || git -C "$AR_COMPS/arduino_tinyusb/tinyusb" tag --points-at HEAD)" "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" rev-parse --short HEAD)
echo $component_version >> version.txt && echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt"
mkdir -p "$AR_TOOLS/esp32-arduino-libs"

#targets_count=`jq -c '.targets[] | length' configs/builds.json`
for target_json in `jq -c '.targets[]' configs/builds.json`; do
Expand All @@ -175,7 +168,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
echo "* Target: $target"

# Build Main Configs List
main_configs="configs/defconfig.common;configs/defconfig.$target"
main_configs="configs/defconfig.common;configs/defconfig.$target;configs/defconfig.debug_$BUILD_DEBUG"
for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do
main_configs="$main_configs;configs/defconfig.$defconf"
done
Expand All @@ -186,8 +179,8 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
idf_libs_configs="$idf_libs_configs;configs/defconfig.$defconf"
done

if [ -f "./managed_components/espressif__esp-sr/.component_hash" ]; then
rm -rf ./managed_components/espressif__esp-sr/.component_hash
if [ -f "$AR_MANAGED_COMPS/espressif__esp-sr/.component_hash" ]; then
rm -rf $AR_MANAGED_COMPS/espressif__esp-sr/.component_hash
fi

echo "* Build IDF-Libs: $idf_libs_configs"
Expand Down Expand Up @@ -215,8 +208,8 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
bootloader_configs="$bootloader_configs;configs/defconfig.$defconf";
done

if [ -f "./managed_components/espressif__esp-sr/.component_hash" ]; then
rm -rf ./managed_components/espressif__esp-sr/.component_hash
if [ -f "$AR_MANAGED_COMPS/espressif__esp-sr/.component_hash" ]; then
rm -rf $AR_MANAGED_COMPS/espressif__esp-sr/.component_hash
fi

echo "* Build BootLoader: $bootloader_configs"
Expand All @@ -232,8 +225,8 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
mem_configs="$mem_configs;configs/defconfig.$defconf";
done

if [ -f "./managed_components/espressif__esp-sr/.component_hash" ]; then
rm -rf ./managed_components/espressif__esp-sr/.component_hash
if [ -f "$AR_MANAGED_COMPS/espressif__esp-sr/.component_hash" ]; then
rm -rf $AR_MANAGED_COMPS/espressif__esp-sr/.component_hash
fi

echo "* Build Memory Variant: $mem_configs"
Expand All @@ -243,6 +236,37 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
done
done

#
# Add components version info
#
rm -rf "$AR_TOOLS/esp32-arduino-libs/versions.txt"
# The lib-builder version
component_version="lib-builder: "$(git -C "$AR_ROOT" symbolic-ref --short HEAD || git -C "$AR_ROOT" tag --points-at HEAD)" "$(git -C "$AR_ROOT" rev-parse --short HEAD)
echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt"
# ESP-IDF version
component_version="esp-idf: "$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD)" "$(git -C "$IDF_PATH" rev-parse --short HEAD)
echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt"
# components version
for component in `ls "$AR_COMPS"`; do
if [ -d "$AR_COMPS/$component/.git" ]; then
component_version="$component: "$(git -C "$AR_COMPS/$component" symbolic-ref --short HEAD || git -C "$AR_COMPS/$component" tag --points-at HEAD)" "$(git -C "$AR_COMPS/$component" rev-parse --short HEAD)
echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt"
fi
done
# TinyUSB version
component_version="tinyusb: "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" symbolic-ref --short HEAD || git -C "$AR_COMPS/arduino_tinyusb/tinyusb" tag --points-at HEAD)" "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" rev-parse --short HEAD)
echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt"
# managed components version
for component in `ls "$AR_MANAGED_COMPS"`; do
if [ -d "$AR_MANAGED_COMPS/$component/.git" ]; then
component_version="$component: "$(git -C "$AR_MANAGED_COMPS/$component" symbolic-ref --short HEAD || git -C "$AR_MANAGED_COMPS/$component" tag --points-at HEAD)" "$(git -C "$AR_MANAGED_COMPS/$component" rev-parse --short HEAD)
echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt"
elif [ -f "$AR_MANAGED_COMPS/$component/idf_component.yml" ]; then
component_version="$component: "$(cat "$AR_MANAGED_COMPS/$component/idf_component.yml" | grep "^version: " | cut -d ' ' -f 2)
echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt"
fi
done

# update package_esp32_index.template.json
if [ "$BUILD_TYPE" = "all" ]; then
python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -j "$AR_COMPS/arduino/package/package_esp32_index.template.json" -o "$AR_OUT/"
Expand Down
2 changes: 0 additions & 2 deletions configs/defconfig.common
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
CONFIG_AUTOSTART_ARDUINO=y
# CONFIG_WS2812_LED_ENABLE is not set
CONFIG_ARDUHAL_ESP_LOG=y
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
CONFIG_BT_ENABLED=y
Expand Down Expand Up @@ -46,7 +45,6 @@ CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1024
CONFIG_HEAP_POISONING_LIGHT=y
CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
CONFIG_HTTPD_WS_SUPPORT=y
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
# CONFIG_LOG_COLORS is not set
CONFIG_LWIP_ETHARP_TRUST_IP_MAC=y
# CONFIG_LWIP_DHCP_DOES_ARP_CHECK is not set
Expand Down
2 changes: 2 additions & 0 deletions configs/defconfig.debug_debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
2 changes: 2 additions & 0 deletions configs/defconfig.debug_default
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
2 changes: 2 additions & 0 deletions configs/defconfig.debug_error
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
2 changes: 2 additions & 0 deletions configs/defconfig.debug_info
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
2 changes: 2 additions & 0 deletions configs/defconfig.debug_none
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
2 changes: 2 additions & 0 deletions configs/defconfig.debug_verbose
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y
CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y
2 changes: 2 additions & 0 deletions configs/defconfig.debug_warning
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
CONFIG_LOG_DEFAULT_LEVEL_WARN=y
11 changes: 2 additions & 9 deletions tools/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fi

AR_ROOT="$PWD"
AR_COMPS="$AR_ROOT/components"
AR_MANAGED_COMPS="$AR_ROOT/managed_components"
AR_OUT="$AR_ROOT/out"
AR_TOOLS="$AR_OUT/tools"
AR_PLATFORM_TXT="$AR_OUT/platform.txt"
Expand Down Expand Up @@ -152,15 +153,7 @@ function git_create_pr(){ # git_create_pr <branch> <title>
local pr_title="$2"
local pr_target="$3"
local pr_body=""
pr_body+="esp-idf: "$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD)" "$(git -C "$IDF_PATH" rev-parse --short HEAD)"\r\n"
for component in `ls "$AR_COMPS"`; do
if [ ! $component == "arduino" ]; then
if [ -d "$AR_COMPS/$component/.git" ] || [ -d "$AR_COMPS/$component/.github" ]; then
pr_body+="$component: "$(git -C "$AR_COMPS/$component" symbolic-ref --short HEAD || git -C "$AR_COMPS/$component" tag --points-at HEAD)" "$(git -C "$AR_COMPS/$component" rev-parse --short HEAD)"\r\n"
fi
fi
done
pr_body+="tinyusb: "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" symbolic-ref --short HEAD || git -C "$AR_COMPS/arduino_tinyusb/tinyusb" tag --points-at HEAD)" "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" rev-parse --short HEAD)"\r\n"
pr_body+=$(cat "$AR_TOOLS/esp32-arduino-libs/versions.txt")"\r\n"
local pr_data="{\"title\": \"$pr_title\", \"body\": \"$pr_body\", \"head\": \"$AR_USER:$pr_branch\", \"base\": \"$pr_target\"}"
git_create_pr_res=`echo "$pr_data" | curl -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" --data @- "https://api.github.com/repos/$AR_REPO/pulls"`
local done_pr=`echo "$git_create_pr_res" | jq -r '.title'`
Expand Down
3 changes: 3 additions & 0 deletions tools/copy-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@ fi
# sdkconfig
cp -f "sdkconfig" "$AR_SDK/sdkconfig"

# dependencies.lock
cp -f "dependencies.lock" "$AR_SDK/dependencies.lock"

# gen_esp32part.py
# cp "$IDF_PATH/components/partition_table/gen_esp32part.py" "$AR_GEN_PART_PY"

Expand Down
114 changes: 6 additions & 108 deletions tools/update-components.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,118 +2,16 @@

source ./tools/config.sh

CAMERA_REPO_URL="https://github.com/espressif/esp32-camera.git"
DL_REPO_URL="https://github.com/espressif/esp-dl.git"
SR_REPO_URL="https://github.com/espressif/esp-sr.git"
RMAKER_REPO_URL="https://github.com/espressif/esp-rainmaker.git"
LITTLEFS_REPO_URL="https://github.com/joltwallet/esp_littlefs.git"
TINYUSB_REPO_URL="https://github.com/hathach/tinyusb.git"
TFLITE_REPO_URL="https://github.com/espressif/tflite-micro-esp-examples.git"

#
# CLONE/UPDATE ESP32-CAMERA
#
#echo "Updating ESP32 Camera..."
#if [ ! -d "$AR_COMPS/esp32-camera" ]; then
# git clone $CAMERA_REPO_URL "$AR_COMPS/esp32-camera"
#else
# git -C "$AR_COMPS/esp32-camera" fetch && \
# git -C "$AR_COMPS/esp32-camera" pull --ff-only
#fi
#if [ $? -ne 0 ]; then exit 1; fi

#
# CLONE/UPDATE ESP-DL
#
#echo "Updating ESP-DL..."
#if [ ! -d "$AR_COMPS/esp-dl" ]; then
# git clone $DL_REPO_URL "$AR_COMPS/esp-dl"
#this is a temp measure to fix build issue
# mv "$AR_COMPS/esp-dl/CMakeLists.txt" "$AR_COMPS/esp-dl/CMakeListsOld.txt"
# echo "idf_build_get_property(target IDF_TARGET)" > "$AR_COMPS/esp-dl/CMakeLists.txt"
# echo "if(NOT \${IDF_TARGET} STREQUAL \"esp32c6\" AND NOT \${IDF_TARGET} STREQUAL \"esp32h2\")" >> "$AR_COMPS/esp-dl/CMakeLists.txt"
# cat "$AR_COMPS/esp-dl/CMakeListsOld.txt" >> "$AR_COMPS/esp-dl/CMakeLists.txt"
# echo "endif()" >> "$AR_COMPS/esp-dl/CMakeLists.txt"
# rm -rf "$AR_COMPS/esp-dl/CMakeListsOld.txt"
#else
# git -C "$AR_COMPS/esp-dl" fetch && \
# git -C "$AR_COMPS/esp-dl" pull --ff-only
#fi
#if [ $? -ne 0 ]; then exit 1; fi
#this is a temp measure to fix build issue
#if [ -f "$AR_COMPS/esp-dl/idf_component.yml" ]; then
# rm -rf "$AR_COMPS/esp-dl/idf_component.yml"
#fi

#
# CLONE/UPDATE ESP-SR
#
#echo "Updating ESP-SR..."
#if [ ! -d "$AR_COMPS/esp-sr" ]; then
# git clone $SR_REPO_URL "$AR_COMPS/esp-sr"
#else
# git -C "$AR_COMPS/esp-sr" fetch && \
# git -C "$AR_COMPS/esp-sr" pull --ff-only
#fi
#if [ $? -ne 0 ]; then exit 1; fi

#
# CLONE/UPDATE ESP-RAINMAKER
#
#echo "Updating ESP-RainMaker..."
#if [ ! -d "$AR_COMPS/esp-rainmaker" ]; then
# git clone $RMAKER_REPO_URL "$AR_COMPS/esp-rainmaker" && \
# git -C "$AR_COMPS/esp-rainmaker" reset --hard d8e93454f495bd8a414829ec5e86842b373ff555 && \
# git -C "$AR_COMPS/esp-rainmaker" submodule update --init --recursive
# else
# git -C "$AR_COMPS/esp-rainmaker" fetch && \
# git -C "$AR_COMPS/esp-rainmaker" pull --ff-only && \
# git -C "$AR_COMPS/esp-rainmaker" submodule update --init --recursive
#fi
#if [ $? -ne 0 ]; then exit 1; fi

#this is a temp measure to fix build issue
#if [ -f "$AR_COMPS/esp-rainmaker/components/esp-insights/components/esp_insights/scripts/get_projbuild_gitconfig.py" ] && [ `cat "$AR_COMPS/esp-rainmaker/components/esp-insights/components/esp_insights/scripts/get_projbuild_gitconfig.py" | grep esp32c6 | wc -l` == "0" ]; then
# echo "Overwriting 'get_projbuild_gitconfig.py'"
# cp -f "tools/get_projbuild_gitconfig.py" "$AR_COMPS/esp-rainmaker/components/esp-insights/components/esp_insights/scripts/get_projbuild_gitconfig.py"
#fi

#
# CLONE/UPDATE ESP-LITTLEFS
#
#echo "Updating ESP-LITTLEFS..."
#if [ ! -d "$AR_COMPS/esp_littlefs" ]; then
# git clone $LITTLEFS_REPO_URL "$AR_COMPS/esp_littlefs" && \
# git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive
#else
# git -C "$AR_COMPS/esp_littlefs" fetch && \
# git -C "$AR_COMPS/esp_littlefs" pull --ff-only && \
# git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive
#fi
#if [ $? -ne 0 ]; then exit 1; fi

#
# CLONE/UPDATE TINYUSB
#
echo "Updating TinyUSB..."
if [ ! -d "$AR_COMPS/arduino_tinyusb/tinyusb" ]; then
git clone $TINYUSB_REPO_URL "$AR_COMPS/arduino_tinyusb/tinyusb"
TINYUSB_REPO_URL="https://github.com/hathach/tinyusb.git"
TINYUSB_REPO_DIR="$AR_COMPS/arduino_tinyusb/tinyusb"
if [ ! -d "$TINYUSB_REPO_DIR" ]; then
git clone "$TINYUSB_REPO_URL" "$TINYUSB_REPO_DIR"
else
git -C "$AR_COMPS/arduino_tinyusb/tinyusb" fetch && \
git -C "$AR_COMPS/arduino_tinyusb/tinyusb" pull --ff-only
git -C "$TINYUSB_REPO_DIR" fetch && \
git -C "$TINYUSB_REPO_DIR" pull --ff-only
fi
if [ $? -ne 0 ]; then exit 1; fi

#
# CLONE/UPDATE TFLITE MICRO
#
#echo "Updating TFLite Micro..."
#if [ ! -d "$AR_COMPS/tflite-micro" ]; then
# git clone $TFLITE_REPO_URL "$AR_COMPS/tflite-micro"
# git -C "$AR_COMPS/tflite-micro" submodule update --init --recursive
#else
# git -C "$AR_COMPS/tflite-micro" fetch && \
# git -C "$AR_COMPS/tflite-micro" pull --ff-only
# git -C "$AR_COMPS/tflite-micro" submodule update --init --recursive
#fi
#if [ $? -ne 0 ]; then exit 1; fi