-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcompile
executable file
·59 lines (41 loc) · 1.92 KB
/
compile
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
#!/bin/sh
# Hugh O'Brien, [email protected] 2013-06-02
# Shell script to compile for the nrf51822, i.e. avoid 'make'
# This folder is contained within nrf51_sdk_v5_2_0_39364.zip (or later).
sdk="/home/hugh/nrf/nrf51822"
# https://launchpad.net/gcc-arm-embedded
gcc_dir="/home/hugh/nrf/gcc-arm-none-eabi-4_8-2014q1"
[ ! -d "$sdk" ] && echo "Set SDK directory" && exit
[ ! -d "$gcc_dir" ] && echo "Set GCC directory" && exit
compiler="$gcc_dir/bin/arm-none-eabi-gcc"
objcopy="$gcc_dir/bin/arm-none-eabi-objcopy"
compiler_version=$($compiler -dumpversion)
# The m0 only supports thumb instructions, see:
# http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/index.html
# ABI definition:
# http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf
# GCC ARM options:
#http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
# Optimisations like -Os (size) can be set here
compiler_args="-mcpu=cortex-m0 -mthumb -mabi=aapcs -Wall"
sdk_includes="-I$sdk/Include -I$sdk/Include/gcc \
-I$sdk/Include/ble -I$sdk/Include/ble/ble_services \
-I$sdk/Include/s110 -I$sdk/Include/app_common \
-I$sdk/Include/sd_common"
system_nrf51="$sdk/Source/templates/system_nrf51.c"
gcc_startup="$sdk/Source/templates/gcc/gcc_startup_nrf51.s"
nrf_delay="$sdk/Source/nrf_delay/nrf_delay.c"
# Required by Include/nrf.h
sdk_flags="-DNRF51 -DBOARD_PCA10001"
linker_script="-T$sdk/Source/templates/gcc/gcc_nrf51_s110_xxaa.ld"
linker_includes="-L$sdk/Source/templates/gcc \
-L$gcc_dir/arm-none-eabi/lib/armv6-m \
-L$gcc_dir/lib/gcc/arm-none-eabi/$compiler_version/armv6-m"
rm *.out *.hex *.o 2>/dev/null #clean any existing object files
# -c specifies compilation only (no linking)
$compiler -c $compiler_args $sdk_includes $sdk_flags \
$system_nrf51 $gcc_startup $nrf_delay *.c
# link (create a.out in ELF form)
$compiler $compiler_args $linker_includes $linker_script *.o
# create ihex for flashing
$objcopy --output-target=ihex a.out a.hex