-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·73 lines (61 loc) · 1.51 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
if [ -f "toolpath" ]; then
toolPath=$(cat toolpath)
PATH="$toolPath:$PATH"
fi
sources="\
libc.S \
libc.c \
LPC11U00.c \
LPC11U00API.c \
USBAPI.c \
USBCDC.c \
main.c \
"
linkerFile="LPC11U24.x"
mkdir -p obj
rm obj/*
objs=""
count=0
for s in $sources; do
ext=$(echo $s | sed -E 's/^.*\.([a-zA-Z]+)$/\1/')
case $ext in
c )
lang="c -std=c99"
;;
cpp )
lang="c++"
;;
s )
lang=assembler
;;
S )
lang=assembler-with-cpp
;;
esac
f=$(basename $s | sed -E 's/(^.*)\.[a-zA-Z]+$/\1/')
o="obj/$count-$f.o"
count=$(($count + 1))
echo "Building $s"
arm-none-eabi-gcc -Wall -Wextra -Wno-switch -nostdlib -nodefaultlibs -fno-exceptions \
-g -Os -mthumb -march=armv6-m -mcpu=cortex-m0 -Wno-attributes \
-I . \
-o $o -x $lang -c $s
if [ $? -ne 0 ]; then
exit -1
fi
objs="$objs $o"
done
echo Linking...
arm-none-eabi-gcc -Wall -Wextra -nostdlib -nodefaultlibs -fno-exceptions \
-g -Os -mthumb -march=armv6-m -mcpu=cortex-m0 \
-T $linkerFile -o obj/test.elf $objs
if [ $? == 0 ]; then
echo "addr length F name" > obj/test.elf.memmap.txt
echo "---- -------- - -------------------------------" >> obj/test.elf.memmap.txt
arm-none-eabi-nm -Sn obj/test.elf | grep -E "^1000" | arm-none-eabi-c++filt >> obj/test.elf.memmap.txt
arm-none-eabi-objcopy -j .text -j .data -O binary obj/test.elf obj/unsigned.bin
/usr/local/bin/node cortex-checksum.js < obj/unsigned.bin > obj/test.bin
arm-none-eabi-objdump -d obj/test.elf > obj/test.elf.disasm.txt
arm-none-eabi-size obj/test.elf
fi