|
21 | 21 |
|
22 | 22 | source venv/bin/activate
|
23 | 23 |
|
24 |
| -rm -rf build |
| 24 | +ZEPHYR_BASE=$(west topdir)/zephyr |
| 25 | + |
| 26 | +# Get the variant name (NORMALIZED_BOARD_TARGET in Zephyr) |
| 27 | +tmpdir=$(mktemp -d) |
| 28 | +variant=$(cmake -DBOARD=$board -S loader -DMODULES=boards -B${tmpdir} -P ${ZEPHYR_BASE}/cmake/package_helper.cmake -R $(pwd)/extra/get_variant_name.cmake | grep 'VARIANT=' | cut -d '=' -f 2) |
| 29 | +rm -rf ${tmpdir} |
| 30 | + |
| 31 | +if [ -z "${variant}" ] ; then |
| 32 | + echo "Failed to get variant name from '$board'" |
| 33 | + exit 1 |
| 34 | +fi |
25 | 35 |
|
26 | 36 | echo && echo && echo
|
| 37 | +echo ${variant} |
| 38 | +echo ${variant} | sed -e 's/./=/g' |
| 39 | +echo |
27 | 40 |
|
28 |
| -west build loader -b $board -t llext-edk $* |
29 |
| -tar xfp build/zephyr/llext-edk.tar.Z |
30 |
| -variant=$(cat llext-edk/Makefile.cflags | grep BOARD_TARGET | cut -d'=' -f2 | tr -d '" ') |
| 41 | +# Build the loader |
| 42 | +BUILD_DIR=build/${variant} |
| 43 | +VARIANT_DIR=variants/${variant} |
| 44 | +rm -rf ${BUILD_DIR} |
| 45 | +west build -d ${BUILD_DIR} -b ${board} loader -t llext-edk $* |
| 46 | + |
| 47 | +# Extract the generated EDK tarball and copy it to the variant directory |
| 48 | +mkdir -p ${VARIANT_DIR} firmwares |
| 49 | +(set -e ; cd ${BUILD_DIR} && rm -rf llext-edk && tar xf zephyr/llext-edk.tar.Z) |
| 50 | +rsync -a --delete ${BUILD_DIR}/llext-edk ${VARIANT_DIR}/ |
31 | 51 |
|
32 | 52 | # remove all inline comments in macro definitions
|
33 | 53 | # (especially from devicetree_generated.h and sys/util_internal.h)
|
34 | 54 | line_preproc_ok='^\s*#\s*(if|else|elif|endif)' # match conditional preproc lines
|
35 | 55 | line_comment_only='^\s*\/\*' # match lines starting with comment
|
36 | 56 | line_continuation='\\$' # match lines ending with '\'
|
37 | 57 | c_comment='\s*\/\*.*?\*\/' # match C-style comments and any preceding space
|
38 |
| -perl -i -pe "s/${c_comment}//gs unless /${line_preproc_ok}/ || (/${line_comment_only}/ && !/${line_continuation}/)" $(find llext-edk/include/ -type f) |
39 |
| - |
40 |
| -mkdir -p firmwares variants/$variant |
41 |
| -rm -rf variants/$variant/llext-edk |
42 |
| -mv llext-edk variants/$variant/ |
| 58 | +perl -i -pe "s/${c_comment}//gs unless /${line_preproc_ok}/ || (/${line_comment_only}/ && !/${line_continuation}/)" $(find ${VARIANT_DIR}/llext-edk/include/ -type f) |
43 | 59 | for ext in elf bin hex; do
|
44 |
| - rm -f build/zephyr/zephyr-$variant.$ext |
45 |
| - if [ -f build/zephyr/zephyr.$ext ]; then |
46 |
| - cp build/zephyr/zephyr.$ext firmwares/zephyr-$variant.$ext |
| 60 | + rm -f firmwares/zephyr-$variant.$ext |
| 61 | + if [ -f ${BUILD_DIR}/zephyr/zephyr.$ext ]; then |
| 62 | + cp ${BUILD_DIR}/zephyr/zephyr.$ext firmwares/zephyr-$variant.$ext |
47 | 63 | fi
|
48 | 64 | done
|
49 | 65 |
|
50 | 66 | # Generate the provides.ld file for linked builds
|
51 | 67 | echo "Exporting provides.ld"
|
52 | 68 | READELF=${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin/arm-zephyr-eabi-readelf
|
53 |
| -$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep FUNC | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' > variants/$variant/provides.ld |
54 |
| -$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> variants/$variant/provides.ld |
55 |
| -$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE(kheap_llext_heap_size = "$3");"}' >> variants/$variant/provides.ld |
56 |
| -$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> variants/$variant/provides.ld |
57 |
| -$READELF --wide -s build/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE(kheap__system_heap_size = "$3");"}' >> variants/$variant/provides.ld |
58 |
| -cat build/zephyr/zephyr.map | grep __device_dts_ord | grep -v rodata | grep -v llext_const_symbol | awk -F' ' '{print "PROVIDE("$2" = "$1");"}' >> variants/$variant/provides.ld |
| 69 | +$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep FUNC | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' > ${VARIANT_DIR}/provides.ld |
| 70 | +$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> ${VARIANT_DIR}/provides.ld |
| 71 | +$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap_llext_heap | awk -F' ' '{print "PROVIDE(kheap_llext_heap_size = "$3");"}' >> ${VARIANT_DIR}/provides.ld |
| 72 | +$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE("$8" = 0x"$2");"}' >> ${VARIANT_DIR}/provides.ld |
| 73 | +$READELF --wide -s ${BUILD_DIR}/zephyr/zephyr.elf | c++filt | grep kheap__system_heap | awk -F' ' '{print "PROVIDE(kheap__system_heap_size = "$3");"}' >> ${VARIANT_DIR}/provides.ld |
| 74 | +cat ${BUILD_DIR}/zephyr/zephyr.map | grep __device_dts_ord | grep -v rodata | grep -v llext_const_symbol | awk -F' ' '{print "PROVIDE("$2" = "$1");"}' >> ${VARIANT_DIR}/provides.ld |
59 | 75 | TEXT_START=`cat loader/boards/$variant.overlay | grep user_sketch: | cut -f2 -d"@" | cut -f1 -d"{"`
|
60 |
| -echo "PROVIDE(_sketch_start = 0x$TEXT_START);" >> variants/$variant/provides.ld |
| 76 | +echo "PROVIDE(_sketch_start = 0x$TEXT_START);" >> ${VARIANT_DIR}/provides.ld |
61 | 77 |
|
62 |
| -sed -i 's/PROVIDE(malloc =/PROVIDE(__wrap_malloc =/g' variants/$variant/provides.ld |
63 |
| -sed -i 's/PROVIDE(free =/PROVIDE(__wrap_free =/g' variants/$variant/provides.ld |
64 |
| -sed -i 's/PROVIDE(realloc =/PROVIDE(__wrap_realloc =/g' variants/$variant/provides.ld |
65 |
| -sed -i 's/PROVIDE(calloc =/PROVIDE(__wrap_calloc =/g' variants/$variant/provides.ld |
66 |
| -sed -i 's/PROVIDE(random =/PROVIDE(__wrap_random =/g' variants/$variant/provides.ld |
| 78 | +sed -i 's/PROVIDE(malloc =/PROVIDE(__wrap_malloc =/g' ${VARIANT_DIR}/provides.ld |
| 79 | +sed -i 's/PROVIDE(free =/PROVIDE(__wrap_free =/g' ${VARIANT_DIR}/provides.ld |
| 80 | +sed -i 's/PROVIDE(realloc =/PROVIDE(__wrap_realloc =/g' ${VARIANT_DIR}/provides.ld |
| 81 | +sed -i 's/PROVIDE(calloc =/PROVIDE(__wrap_calloc =/g' ${VARIANT_DIR}/provides.ld |
| 82 | +sed -i 's/PROVIDE(random =/PROVIDE(__wrap_random =/g' ${VARIANT_DIR}/provides.ld |
67 | 83 |
|
68 | 84 | cmake -P extra/gen_arduino_files.cmake $variant
|
0 commit comments