Skip to content

Commit 4439839

Browse files
committed
Build C and ASM demo for specified target
1 parent 76b69b5 commit 4439839

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

samples/asmhello/build.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
TARGET=${1:-thumbv6m-none-eabi}
6+
7+
if [ "$TARGET" == "thumbv6m-none-eabi" ]; then
8+
CPU="cortex-m0plus"
9+
elif [ "$TARGET" == "thumbv7m-none-eabi" ]; then
10+
CPU="cortex-m3"
11+
elif [ "$TARGET" == "thumbv7em-none-eabi" ]; then
12+
CPU="cortex-m4"
13+
else
14+
echo "Unknown target"
15+
exit 1
16+
fi
17+
218
arm-none-eabi-gcc \
319
-nostartfiles \
420
-ffreestanding \
5-
-mcpu=cortex-m0plus \
21+
-mcpu=$CPU \
622
-Wl,-T../neotron-cortex-m.ld \
723
-o asmhello.elf \
824
asmhello.S \

samples/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ echo "Building for ${TARGET}"
2525
cargo build --target ${TARGET} --release
2626

2727
pushd chello
28-
./build.sh
28+
./build.sh ${TARGET}
2929
popd
3030

3131
pushd asmhello
32-
./build.sh
32+
./build.sh ${TARGET}
3333
popd
3434

3535
for program in panic hello fault input-test; do

samples/chello/build.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
TARGET=${1:-thumbv6m-none-eabi}
6+
7+
if [ "$TARGET" == "thumbv6m-none-eabi" ]; then
8+
CPU="cortex-m0plus"
9+
elif [ "$TARGET" == "thumbv7m-none-eabi" ]; then
10+
CPU="cortex-m3"
11+
elif [ "$TARGET" == "thumbv7em-none-eabi" ]; then
12+
CPU="cortex-m4"
13+
else
14+
echo "Unknown target"
15+
exit 1
16+
fi
217

318
arm-none-eabi-gcc \
419
-fdata-sections \
520
-ffreestanding \
621
-ffunction-sections \
722
-flto \
8-
-mcpu=cortex-m0 \
23+
-mcpu=$CPU \
924
-nostartfiles \
1025
-Os \
1126
-Wall \

0 commit comments

Comments
 (0)