#!/bin/bash ############################################################################## # Copyright (c) 2024 Microsoft Corporation # Copyright (c) 2026 Eclipse ThreadX contributors # # This program and the accompanying materials are made available under the # terms of the MIT License which is available at # https://opensource.org/licenses/MIT. # # 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. # # SPDX-License-Identifier: MIT and CC0-1.0 ############################################################################## set -e cd "$(dirname "$0")" # 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=arm9 reset.S "${CC}" ${TARGET_FLAGS} -c -g -mcpu=arm9 crt0.S "${CC}" ${TARGET_FLAGS} -c -g -mcpu=arm9 tx_initialize_low_level.S "${CC}" ${TARGET_FLAGS} -c -g -mcpu=arm9 -I../../../../common/inc -I../inc sample_threadx.c "${CC}" ${TARGET_FLAGS} -g -nostartfiles -mcpu=arm9 -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