Skip to content

Commit 678d1d1

Browse files
committed
Fixed esp32 builds
1 parent 7533407 commit 678d1d1

File tree

9 files changed

+101
-190
lines changed

9 files changed

+101
-190
lines changed

target/envbuildscripts/EHS_server2server_update_generate_upload.sh

Lines changed: 0 additions & 125 deletions
This file was deleted.

target/envbuildscripts/targetenv.sh

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ set -e
1313
export SPECIFIC_TARGET=$1
1414

1515
source ./scripts/build-function-library/colour.sh
16+
1617
TXT_FG=${TXT_FG_BLUE}
1718

1819
echo "${TXT_FG_GREY}---------------------------------------------------------------------------------------------------------------------------"
@@ -125,12 +126,12 @@ echo "Setting the internal version information file for the build"
125126
./target/envbuildscripts/targetenv_create_version_info.sh $SPECIFIC_TARGET
126127

127128
if [ "${EHS_DEFAULT_APP}" = "NONE" ]; then
128-
echo
129-
echo "${TXT_FG_GREY}---------------------------------------------------------------------------------------------------------------------------"
130-
echo
131-
echo "Installing the default app"
129+
echo
130+
echo "${TXT_FG_GREY}---------------------------------------------------------------------------------------------------------------------------"
131+
echo
132+
echo "Installing the default app"
132133

133-
if [ -z "${EHS_SKIP_REPO_PULL}" ]; then
134+
if [ -z "${EHS_SKIP_REPO_PULL}" ]; then
134135
echo "Checking out the latest PRODUCTION branch of your app repo..."
135136
if [ -d ../apps ]; then
136137
pushd ../apps || exit 1
@@ -166,17 +167,16 @@ if [ -z "${EHS_SKIP_REPO_PULL}" ]; then
166167
git checkout RELEASE-PRODUCTION || exit 1
167168
popd
168169
fi
169-
else
170+
else
170171
warn "Not checking out the latest 'PRODUCTION' branch of your app repo - 'EHS_SKIP_REPO_PULL' is set"
171-
fi
172-
echo
173-
echo "${TXT_FG_GREY}---------------------------------------------------------------------------------------------------------------------------"
174-
echo
172+
fi
173+
echo
174+
echo "${TXT_FG_GREY}---------------------------------------------------------------------------------------------------------------------------"
175+
echo
175176
else
176-
echo "${TXT_FG_GREY}---------------------------------------------------------------------------------------------------------------------------"
177-
echo "${TXT_FG_YELLOW} NOT Installing a default app"
178-
echo "${TXT_FG_GREY}---------------------------------------------------------------------------------------------------------------------------"
179-
177+
echo "${TXT_FG_GREY}---------------------------------------------------------------------------------------------------------------------------"
178+
echo "${TXT_FG_YELLOW} NOT Installing a default app"
179+
echo "${TXT_FG_GREY}---------------------------------------------------------------------------------------------------------------------------"
180180
fi #if [ "${EHS_DEFAULT_APP}" = "NONE" ];
181181

182182
EHS_APP_EXPORT_DIR=export-ert${ERT_SODL_VERSION}
@@ -224,6 +224,9 @@ echo
224224
echo "${TXT_FG_GREY}---------------------------------------------------------------------------------------------------------------------------"
225225
echo
226226

227+
# This function populated the Devman Server information if the patform is using Devman
228+
# We probably want to put this in it's own utility script rather than having in the general targetenv script in the future.
229+
227230
function SetDevmanServer() {
228231
local DEVMAN_SERVER_DOMAIN=$1
229232
local DEVMAN_SERVER_DOMAIN_DEFAULT=$2
@@ -302,7 +305,6 @@ function SetDevmanServer() {
302305
else
303306
warn "You have specified DEVMAN_SERVER_PROTOCOL = mqtts, but a CLIENT cert is not found at '${CLIENT_CERT_FILE}'"
304307
fi
305-
306308
CLIENT_KEY_FILE=../DevmanSecurity/${DEVMAN_SERVER_DOMAIN}/mqtt_broker/client.key
307309
if [ -f "${CLIENT_KEY_FILE}" ]; then
308310
cp -f ${CLIENT_KEY_FILE} ${TGT_CERT_DIR}/client.key
@@ -375,7 +377,6 @@ function SetDevmanServer() {
375377
if [ "$DEVMAN_SERVER_DOMAIN" != "" ]; then
376378
echo "Setting 'DEVMAN_SERVER_DOMAIN' (default)"
377379
SetDevmanServer ${DEVMAN_SERVER_DOMAIN} "default"
378-
379380
# check the second certificate domain
380381
if [ "$DEVMAN_SERVER_DOMAIN_1" != "" ]; then
381382
echo "Setting 'DEVMAN_SERVER_DOMAIN_1'"

target/envbuildscripts/targetenv_esp32.sh

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
# the host's make system.
88
####################################################################################################
99

10+
# TODO 2026 have esp tools run from both the venv and then sometimes also directly. This is just a mess of course.
11+
# We should check for a python venv and use this preferentially as teh esp tool path and if it's not there we can fall back
12+
# to the host pythoin environment (assuming this has been setu) and use the tools in the ert-build-support.
13+
1014
set -e
1115

1216
#If this is called as a docker command we wont have the exported environment variables, so read them from the paramaters
@@ -54,19 +58,37 @@ export EHS_ROOT=`pwd` # assuming we're in the ehs project root
5458
pushd ${EHS_ROOT}/..
5559
export REPOSITORY_ROOT=`pwd`
5660
popd
57-
#Check if we are alr
61+
62+
# Note we can use the ates esptool for all versions of esp,buyt allowing for an override
63+
if [ "${EHS_ESPTOOL_VERSION_OVERRIDE}" = "5.1.0" ] ; then
64+
#These are probably not necessary for any IDF version, but is not supported in 4.4.1.
65+
EXTRA_ESPTOOL_ARGS="-min-rev-full 0 --max-rev-full 9999 "
66+
export TOOLCHAIN_VERSION="xtensa-esp32-elf-5.1.0"
67+
else
68+
#default for anything else
69+
EXTRA_ESPTOOL_ARGS=
70+
export TOOLCHAIN_VERSION="xtensa-esp32-elf-4.4.1"
71+
fi
72+
73+
# These tools haven't changed, so we can just use the 4.4.4 for all versions of IDF apparently
74+
75+
export TEMP_PWD=${PWD}
76+
INX_HOST_ARCH=$(uname -m)
77+
TOOLCHAIN_PATH="${TEMP_PWD}/../ert-build-support/toolchains/${INX_HOST_ARCH}/${TOOLCHAIN_VERSION}"
78+
79+
export IDF_PYTHON_ENV_BASE="../../TARGET_TREES/esp32_venv/"
80+
export IDF_ESPTOOL_BASE="${TOOLCHAIN_PATH}/${TOOLCHAIN_FLASHING_VERSION}/tools"
81+
82+
#Check if we are in docker sowe don't try to install IDF's grim python tools again
5883
if [ -f /.dockerenv ]; then
5984
echo "Already running in Docker continuing"
6085
export PATH="/opt/python_env/bin:$PATH"
6186
else
62-
#todo Do we need to do this really?
63-
# Presumably this is attempting to create the python environment on the host?
87+
# If for some reason we don't have a python venv environment we can try and run the host
88+
# TODO see above note on this being an agregation of of mind-farts.
89+
6490
# The following would be better picked from config.mk rather than hardwired, but would need to passed in for Docker builds.
6591

66-
export TOOLCHAIN_VERSION="xtensa-esp32-elf-4.4.4"
67-
export TEMP_PWD=${PWD}
68-
INX_HOST_ARCH=$(uname -m)
69-
TOOLCHAIN_PATH="${TEMP_PWD}/../ert-build-support/toolchains/${INX_HOST_ARCH}/${TOOLCHAIN_VERSION}"
7092
_PATH="${TOOLCHAIN_PATH}/bin"
7193

7294
## Create python virtual environment, install requirements and export it to PATH
@@ -76,19 +98,18 @@ else
7698
# todo-we should consider if we need a nother temporary directory for tools that are built per host machine (TARHGET_TREES is not very descriptive)
7799
# Note there is also a venv that might be built into /opt/python_env - this is typically only generated for workstaions that flash devices.
78100

79-
export IDF_PYTHON_ENV_BASE="../../TARGET_TREES/esp32_venv/"
80101
python3 -m venv ${IDF_PYTHON_ENV_BASE} > /dev/null
81102
export IDF_PYTHON_ENV_PATH="${IDF_PYTHON_ENV_BASE}/bin"
82-
103+
83104
#Set path to the python and toolchain.
84105
_PATH="${TOOLCHAIN_PATH}/bin"
85-
_PATH="${_PATH:+${_PATH}:}${TOOLCHAIN_PATH}/${TOOLCHAIN_FLASHING_VERSION}/tools/openocd-esp32/v0.11.0-esp32-20211220/openocd-esp32/bin"
106+
_PATH="${_PATH:+${_PATH}:}${IDF_ESPTOOL_BASE}/openocd-esp32/v0.11.0-esp32-20211220/openocd-esp32/bin"
86107
_PATH="${_PATH:+${_PATH}:}${IDF_PYTHON_ENV_PATH}"
87-
_PATH="${_PATH:+${_PATH}:}${TOOLCHAIN_PATH}/${TOOLCHAIN_FLASHING_VERSION}/tools/esptool_py/esptool"
88-
_PATH="${_PATH:+${_PATH}:}${TOOLCHAIN_PATH}/${TOOLCHAIN_FLASHING_VERSION}/tools/espcoredump"
89-
_PATH="${_PATH:+${_PATH}:}${TOOLCHAIN_PATH}/${TOOLCHAIN_FLASHING_VERSION}/tools/partition_table"
90-
_PATH="${_PATH:+${_PATH}:}${TOOLCHAIN_PATH}/${TOOLCHAIN_FLASHING_VERSION}/tools/app_update"
91-
_PATH="${_PATH:+${_PATH}:}${TOOLCHAIN_PATH}/${TOOLCHAIN_FLASHING_VERSION}/tools/additional_tools"
108+
_PATH="${_PATH:+${_PATH}:}${IDF_ESPTOOL_BASE}/esptool_py/esptool"
109+
_PATH="${_PATH:+${_PATH}:}${IDF_ESPTOOL_BASE}/espcoredump"
110+
_PATH="${_PATH:+${_PATH}:}${IDF_ESPTOOL_BASE}/partition_table"
111+
_PATH="${_PATH:+${_PATH}:}${IDF_ESPTOOL_BASE}/app_update"
112+
_PATH="${_PATH:+${_PATH}:}${IDF_ESPTOOL_BASE}/additional_tools"
92113
export PATH="${_PATH}${PATH:+:${PATH}}"
93114
# Start the python virutal environment.
94115
sudo python3 -m venv /opt/python_env
@@ -108,25 +129,24 @@ echo "### Building .bin file for esp32 from .elf file "
108129
echo " Location of the elf file:"
109130
echo " ehs_esp32s3_freertos-xtensa-base.elf # or use this: $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.exe"
110131
echo "---------------------------------------------------------------------------------------------------------------------------"
111-
# what was this?? e --flash_mode "dio" --flash_freq "40m" --flash_size "4MB" --elf-sha256-offset 0xb0 ehs_esp32s3_freertos-xtensor-base.elf -o $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.bin
112-
# Older toolchains don't support all arguements
113-
if [ "${TOOLCHAIN_NAME}" = "xtensa-esp32-elf-4.4.1" ] ; then
114-
EXTRA_ESPTOOL_ARGS=
115-
else
116-
EXTRA_ESPTOOL_ARGS=-min-rev-full 0 --max-rev-full 9999
117-
fi
118132

119-
#if python3 ../ert-contrib-middleware/contrib/esp-idf/${CONTRIB_MIDDLWARE_FLASHINGTOOLS_VERSION}/components/esptool_py/esptool/esptool.py --chip esp32 elf2imag
120133

121-
if python3 ../ert-contrib-middleware/contrib/esp-idf/${CONTRIB_MIDDLWARE_FLASHINGTOOLS_VERSION}/components/esptool_py/esptool/esptool.py --chip esp32s3 elf2image ${EXTRA_ESPTOOL_ARGS} -ff 80m -fm qio -fs 8MB -o $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.bin $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.exe
134+
135+
# Building the bootable binary from ehs.exe elf file
136+
137+
if python3 ${IDF_ESPTOOL_BASE}/esptool_py/esptool/esptool.py --chip esp32s3 elf2image ${EXTRA_ESPTOOL_ARGS} -ff 80m -fm qio -fs 8MB -o $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.bin $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.exe
122138
then
123139
echo "### Copied ehs.bin file generated in $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/"
124140
else
125-
echo "!!! ERROR: COULD NOT GENERATE ehs.bin !!!"
141+
echo "!!! ERROR: COULD NOT GENERATE ehs.bin !!!"
142+
exit 1
126143
fi
144+
127145
echo "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
146+
echo "Building the full flashable image from bootloader.bin, partition_table and any other partitions (file sytems and OTA etc)"
128147
ls -l "$PWD/../ert-contrib-middleware/target_libs/${COMPONENT_BASE_TECHNOLOGIES}/build/lib/"
129148
echo "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
149+
130150
if test -f "$PWD/../ert-contrib-middleware/target_libs/${COMPONENT_BASE_TECHNOLOGIES}/build/lib/bootloader.bin"
131151
then
132152
echo "### Copied the pre build bootloader binary (bootloader.bin) into TARGET_TREES ###"
@@ -135,7 +155,7 @@ else
135155
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
136156
echo "!!! ERROR: COuld not find bootloader.bin in $PWD/../ert-contrib-middleware/target_libs/${COMPONENT_BASE_TECHNOLOGIES}/build/lib/bootloader.bin !!!"
137157
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
138-
exit
158+
exit 1
139159
fi
140160

141161
# previously know as? "$PWD/../ert-contrib-middleware/contrib/esp-idf/esp-idf-4.4.1/build/partitions.bin"
@@ -147,7 +167,7 @@ else
147167
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
148168
echo "!!! ERROR: COuld not find partition table (partition-table.bin)) in $PWD/../ert-contrib-middleware/target_libs/${COMPONENT_BASE_TECHNOLOGIES}/build/lib/ !!!"
149169
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
150-
exit
170+
exit 1
151171
fi
152172

153173
# Convert the application folder to binary image
@@ -165,12 +185,14 @@ fi
165185
fi
166186
done
167187

168-
/opt/python_env/bin/littlefs-python create -v --block-size 4096 --fs-size 1572864 --name-max 64 --image $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/data.bin $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/data_partition/
188+
# TODO See comments in head of this document, why we are using the venv scripts here
189+
#todo Presumably we wantthe hardwired sies etc in here to be paramterised so they can be set for speciic platform builds
190+
/opt/python_env/bin/littlefs-python create -v --block-size 4096 --fs-size 1572864 --name-max 64 --image $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/data.bin $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/data_partition/ || exit
169191

170192
#Lets build the binary (todo2023 - we should do this in a packer target in the future?? )
171193
echo "Converting the elf file to binary image.... (This is usually done by make targetenv_esp32s3)"
172194
#python3 ../ert-contrib-middleware/contrib/esp-idf/CONTRIB_MIDDLWARE_FLASHINGTOOLS_VERSION/components/esptool_py/esptool/esptool.py --chip esp32s3 merge_bin -o $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.img --flash_mode dio --flash_size 8MB 0x0 $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/bootloader.bin 0x9000 ../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/partition-table.bin 0x10000 $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.bin 0x410000 $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/data.bin
173-
python3 ../ert-contrib-middleware/contrib/esp-idf/${CONTRIB_MIDDLWARE_FLASHINGTOOLS_VERSION}/components/esptool_py/esptool/esptool.py --chip esp32s3 merge_bin -o $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.img --flash_mode dio --flash_size 8MB 0x0 $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/bootloader.bin 0x9000 ../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/partition-table.bin 0x20000 $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.bin 0x67c000 $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/data.bin 0x5ff000 $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/app_data.bin
195+
python3 ${IDF_ESPTOOL_BASE}/esptool_py/esptool/esptool.py --chip esp32s3 merge_bin -o $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.img --flash_mode dio --flash_size 8MB 0x0 $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/bootloader.bin 0x9000 ../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/partition-table.bin 0x20000 $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/ehs.bin 0x67c000 $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/data.bin 0x5ff000 $PWD/../TARGET_TREES/ehs_env-$SPECIFIC_TARGET/bin/app_data.bin ||exit 1
174196

175197
echo "---------------------------------------------------------------------------------------------------------------------------"
176198
echo "All Done!"

0 commit comments

Comments
 (0)