Skip to content

Commit 793b94c

Browse files
committed
Checkpoint
1 parent 68f8485 commit 793b94c

File tree

2 files changed

+46
-18
lines changed

2 files changed

+46
-18
lines changed

firmware/lockfiles/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
I This directory holds dependencies.lock.<chip> files generated by CMake via idf_build_set_property.
2+
It may be empty initially; files will be created during the first successful build.
3+

scripts/build_and_check.sh

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
set -e
44

5+
# Determine repository root (one level up from this script's directory)
6+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
7+
58
# Print/speak build completion on exit (whether successful or not)
69
function finish {
710
echo "Build complete for board ${BOARD}"
811
if [[ "$OSTYPE" == "darwin"* ]]; then
9-
say "Finished building"
12+
say "Finished building" || true
1013
else
1114
echo "Build complete"
1215
fi
@@ -17,14 +20,16 @@ BOARD=${1:-MICROLITE}
1720
IDF_VERSION=${IDF_VERSION:-v5.4.2}
1821

1922
# Define the absolute path to the micropython folder
20-
export MICROPYTHON_PATH="$(pwd)/third_party/micropython"
23+
export MICROPYTHON_PATH="${ROOT_DIR}/third_party/micropython"
2124

2225
# Update submodules required for build
23-
if [ ! -d third_party/micropython ]; then
24-
echo "Micropython submodule missing" >&2
26+
if [ ! -d "${MICROPYTHON_PATH}" ]; then
27+
echo "Micropython submodule missing at ${MICROPYTHON_PATH}" >&2
2528
exit 1
2629
fi
2730

31+
pushd "${ROOT_DIR}" >/dev/null
32+
2833
git submodule update --init --recursive
2934
pushd third_party/micropython >/dev/null
3035
# ensure required nested submodules
@@ -41,38 +46,58 @@ pushd esp-idf >/dev/null
4146
popd >/dev/null
4247

4348
# Source esp-idf environment
49+
# shellcheck disable=SC1091
4450
source ./esp-idf/export.sh
4551

4652
pip3 install pyelftools
4753
pip3 install ar
4854
# Ensure uf2conv.py is importable by setting PYTHONPATH
49-
export PYTHONPATH="$(pwd)/third_party/micropython/tools${PYTHONPATH:+:$PYTHONPATH}"
55+
export PYTHONPATH="${MICROPYTHON_PATH}/tools${PYTHONPATH:+:$PYTHONPATH}"
5056

5157
# Build micropython cross compiler
52-
pushd "$MICROPYTHON_PATH" >/dev/null
58+
pushd "${MICROPYTHON_PATH}" >/dev/null
5359
make -C mpy-cross V=1 clean all
5460
popd >/dev/null
5561

5662
# Build firmware for the selected board
57-
pushd firmware/boards/${BOARD} >/dev/null
63+
# We intentionally cd into the board directory so each board keeps an isolated build/ directory.
64+
# NOTE: Relative references must go back to ROOT_DIR (three levels up from here) not two.
65+
BOARD_DIR="${ROOT_DIR}/firmware/boards/${BOARD}"
66+
if [ ! -d "${BOARD_DIR}" ]; then
67+
echo "Board directory does not exist: ${BOARD_DIR}" >&2
68+
exit 1
69+
fi
70+
pushd "${BOARD_DIR}" >/dev/null
5871
rm -rf build
5972

60-
6173
# Inject flags so that:
6274
# • C builds drop -Werror=stringop-overflow
6375
# • C++ builds retain -fno-rtti
6476
idf.py clean
65-
#idf.py build -DCMAKE_C_FLAGS="-Wno-error=stringop-overflow -Wno-stringop-overflow" \
66-
# -DCMAKE_CXX_FLAGS="-fno-rtti"
6777

78+
idf.py build \
79+
-DMICROPY_BOARD=${BOARD} \
80+
-DMICROPY_BOARD_VARIANT=SPIRAM_OCT \
81+
-DCMAKE_C_FLAGS="-Wno-error=stringop-overflow -Wno-stringop-overflow" \
82+
-DCMAKE_CXX_FLAGS="-fno-rtti" \
83+
-DMICROPY_USER_FROZEN_MANIFEST="${MICROPYTHON_PATH}/ports/esp32/boards/manifest.py"
84+
85+
# Assemble unified image (corrected path usage)
86+
ASSEMBLE_SCRIPT="${ROOT_DIR}/scripts/assemble-unified-image-esp.sh"
87+
if [ ! -x "${ASSEMBLE_SCRIPT}" ]; then
88+
chmod +x "${ASSEMBLE_SCRIPT}" || true
89+
fi
90+
if [ ! -f "${ASSEMBLE_SCRIPT}" ]; then
91+
echo "Assemble script missing: ${ASSEMBLE_SCRIPT}" >&2
92+
exit 1
93+
fi
6894

69-
# -DCMAKE_EXE_LINKER_FLAGS="-Wl,--gc-sections -Wl,--print-gc-sections" \
70-
idf.py build -DMICROPY_BOARD=ESP32_GENERIC_S3 \
71-
-DMICROPY_BOARD_VARIANT=SPIRAM_OCT \
72-
-DCMAKE_C_FLAGS="-Wno-error=stringop-overflow -Wno-stringop-overflow" \
73-
-DCMAKE_CXX_FLAGS="-fno-rtti" \
74-
-DMICROPY_USER_FROZEN_MANIFEST="${MICROPYTHON_PATH}/ports/esp32/boards/manifest.py"
95+
MP_PORTS_PATH="${MICROPYTHON_PATH}/ports/esp32"
96+
if [ ! -d "${MP_PORTS_PATH}" ]; then
97+
echo "Micropython ports directory missing: ${MP_PORTS_PATH}" >&2
98+
exit 1
99+
fi
75100

76-
chmod +x ../../scripts/assemble-unified-image-esp.sh
77-
../../scripts/assemble-unified-image-esp.sh ../../third_party/micropython/ports/esp32
101+
"${ASSEMBLE_SCRIPT}" "${MP_PORTS_PATH}"
102+
popd >/dev/null
78103
popd >/dev/null

0 commit comments

Comments
 (0)