summaryrefslogtreecommitdiff
path: root/ports/arm11/gnu/example_build/build_threadx_sample.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ports/arm11/gnu/example_build/build_threadx_sample.sh')
-rwxr-xr-xports/arm11/gnu/example_build/build_threadx_sample.sh47
1 files changed, 42 insertions, 5 deletions
diff --git a/ports/arm11/gnu/example_build/build_threadx_sample.sh b/ports/arm11/gnu/example_build/build_threadx_sample.sh
index c342ce5a..97a3a1c5 100755
--- a/ports/arm11/gnu/example_build/build_threadx_sample.sh
+++ b/ports/arm11/gnu/example_build/build_threadx_sample.sh
@@ -10,6 +10,7 @@
# SPDX-License-Identifier: MIT
#
# AI Disclosure: This file was largely AI-generated by Copilot (Claude Sonnet 4.6).
+# Portions of this file were generated with AI assistance.
# The AI-generated portions may be considered public domain (CC0-1.0)
# and not subject to the project's licence. The human contributor has
# reviewed and verified that the code is correct.
@@ -20,9 +21,45 @@
set -e
cd "$(dirname "$0")"
-arm-none-eabi-gcc -c -g -mcpu=arm1136j-s reset.S
-arm-none-eabi-gcc -c -g -mcpu=arm1136j-s crt0.S
-arm-none-eabi-gcc -c -g -mcpu=arm1136j-s tx_initialize_low_level.S
-arm-none-eabi-gcc -c -g -mcpu=arm1136j-s -I../../../../common/inc -I../inc sample_threadx.c
-arm-none-eabi-ld -A arm1136j-s -T sample_threadx.ld reset.o crt0.o tx_initialize_low_level.o sample_threadx.o tx.a libc.a libnosys.a libgcc.a -o sample_threadx.out -M > sample_threadx.map
+# Toolchain selection. The default is the GNU toolchain, so an existing
+# invocation of this script behaves exactly as before. Set TOOLCHAIN=atfe to
+# build with Arm Toolchain for Embedded, which is LLVM based and is the
+# successor to Arm Compiler 6:
+#
+# TOOLCHAIN=atfe ATFE_CLANG=/path/to/clang ./build_threadx_sample.sh
+#
+: "${TOOLCHAIN:=gnu}"
+case "${TOOLCHAIN}" in
+ gnu)
+ CC="arm-none-eabi-gcc"
+ AR="arm-none-eabi-ar"
+ TARGET_FLAGS=""
+ ENTRY_FLAG="-ereset_handler"
+ SYSCALL_LIB="--specs=nosys.specs"
+ ;;
+ atfe)
+ CC="${ATFE_CLANG:-clang}"
+ # llvm-ar ships beside clang in the toolchain.
+ case "${CC}" in
+ */*) AR="$(dirname "${CC}")/llvm-ar" ;;
+ *) AR="llvm-ar" ;;
+ esac
+ TARGET_FLAGS="--target=arm-none-eabi"
+ ENTRY_FLAG="-Wl,--entry=reset_handler"
+ # picolibc leaves _exit to the application; the toolchain's own
+ # semihosting library supplies it, which suits an example that runs on
+ # a model.
+ SYSCALL_LIB="-lsemihost"
+ ;;
+ *)
+ echo "Unknown TOOLCHAIN '${TOOLCHAIN}'; expected gnu or atfe" >&2
+ exit 1
+ ;;
+esac
+
+"${CC}" ${TARGET_FLAGS} -c -g -mcpu=arm1136j-s reset.S
+"${CC}" ${TARGET_FLAGS} -c -g -mcpu=arm1136j-s crt0.S
+"${CC}" ${TARGET_FLAGS} -c -g -mcpu=arm1136j-s tx_initialize_low_level.S
+"${CC}" ${TARGET_FLAGS} -c -g -mcpu=arm1136j-s -I../../../../common/inc -I../inc sample_threadx.c
+"${CC}" ${TARGET_FLAGS} -g -nostartfiles -mcpu=arm1136j-s -T sample_threadx.ld ${SYSCALL_LIB} -o sample_threadx.out -Wl,-Map=sample_threadx.map reset.o crt0.o tx_initialize_low_level.o sample_threadx.o tx.a