summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@gmail.com>2013-11-29 10:09:55 -0300
committerClaudio Takahasi <claudio.takahasi@gmail.com>2013-12-23 11:36:14 -0300
commit0506c86e58a6d5b606ab5b24a87e65d13884fd05 (patch)
treeafb9fdcdf00810a4558fd5d43e861222bc301bc7
parent7e3fe131156a1f0c9e9975eace473f453c32a26c (diff)
build: Add build files for NRF platform
This patch adds the initial Makefiles and autotools files to build a hello world example. Initial configure options was added to allow selecting different platforms. Usage example: ./bootstrap-configure.nrf --with-sdkdir=/osd/work/iot/nrf51-sdk.git
-rw-r--r--Makefile.am26
-rw-r--r--Makefile.nrf41
-rw-r--r--Makefile.ubertooth7
-rw-r--r--Makefile.x8613
-rw-r--r--acinclude.m443
-rwxr-xr-xbootstrap-configure10
-rwxr-xr-xbootstrap-configure.nrf31
-rwxr-xr-xbootstrap-configure.ubertooth16
-rw-r--r--configure.nrf36
-rw-r--r--configure.ubertooth (renamed from configure.ac)6
-rw-r--r--examples/platform/nrf51822/helloworld/main.c (renamed from examples/platform/nrf51822/helloworld/hello.c)3
11 files changed, 187 insertions, 45 deletions
diff --git a/Makefile.am b/Makefile.am
index 9e1fa01..1e6b70b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,22 +1,16 @@
AM_MAKEFLAGS = --no-print-directory
+AM_CPPFLAGS =
-bin_PROGRAMS =
-libexec_PROGRAMS =
+STACK_SOURCE_FILES = stack/ll.c stack/bci.c
-builtin_modules =
-builtin_sources =
-builtin_nodist =
+STACK_OBJECT_FILES = $(STACK_SOURCE_FILES:.c=.o)
-stack_sources = stack/ll.h stack/ll.c \
- stack/bci.h stack/bci.c
+AM_CPPFLAGS += -Istack
-builtin_sources += examples/platform/nrf51822/helloworld/hello.c
-libexec_PROGRAMS += examples/platform/nrf51822/helloworld/hello
+if PLATFORM_NRF
+include Makefile.nrf
+endif
-INCLUDES = -I$(builddir)/stack
-
-CLEANFILES =
-
-MAINTAINERCLEANFILES = Makefile.in \
- aclocal.m4 configure config.h.in config.sub config.guess \
- ltmain.sh depcomp missing install-sh mkinstalldirs
+if PLATFORM_UBERTOOTH
+include Makefile.ubertooth
+endif
diff --git a/Makefile.nrf b/Makefile.nrf
new file mode 100644
index 0000000..df59203
--- /dev/null
+++ b/Makefile.nrf
@@ -0,0 +1,41 @@
+PLATFORM_SOURCE_FILES = $(SDK_DIR)/Nordic/nrf51822/Source/templates/system_nrf51.c
+PLATFORM_ASM_FILES = $(SDK_DIR)/Nordic/nrf51822/Source/templates/gcc/gcc_startup_nrf51.s
+PROJECT_SOURCE_FILES = examples/platform/nrf51822/helloworld/main.c
+
+AM_CPPFLAGS += -I$(SDK_DIR)/Nordic/nrf51822/Include
+AM_CPPFLAGS += -I$(SDK_DIR)/Nordic/nrf51822/Include/gcc
+
+LDFLAGS += -T$(SDK_DIR)/Nordic/nrf51822/Source/templates/gcc/gcc_nrf51_blank_xxaa.ld
+LDFLAGS += -L$(SDK_DIR)/Nordic/nrf51822/Source/templates/gcc
+LDFLAGS += -mabi=aapcs --specs=nano.specs -Xlinker -Map=$(BUILD_DIR)/nrf.map
+
+PLATFORM_OBJECT_FILES = $(PLATFORM_SOURCE_FILES:.c=.o)
+ASM_OBJECT_FILES = $(PLATFORM_ASM_FILES:.s=.o)
+PROJECT_OBJECT_FILES = $(PROJECT_SOURCE_FILES:.c=.o)
+
+all: $(BUILD_DIR) $(BUILD_DIR)/helloworld.bin
+
+$(BUILD_DIR)/helloworld.bin: $(BUILD_DIR)/helloworld.out
+ $(OBJCOPY) -Obinary $(BUILD_DIR)/helloworld.out $@
+
+$(BUILD_DIR)/helloworld.out: $(PROJECT_OBJECT_FILES) $(STACK_OBJECT_FILES) \
+ $(PLATFORM_OBJECT_FILES) $(ASM_OBJECT_FILES)
+ $(CC) $(LDFLAGS) $(ASM_OBJECT_FILES) $(PROJECT_OBJECT_FILES) \
+ $(PLATFORM_OBJECT_FILES) $(STACK_OBJECT_FILES) -o $@
+ $(OBJDUMP) -h $(BUILD_DIR)/helloworld.out
+
+# Build object files from C source files
+%.o: %.c
+ $(CC) -c $(CFLAGS) $(AM_CPPFLAGS) $(AM_CPPFLAGS) -o $@ $<
+
+# Build object files from ASM source files
+%.o: %.s
+ $(CC) -c $(ASMFLAGS) $(AM_CPPFLAGS) -o $@ $<
+
+$(BUILD_DIR):
+ mkdir $@
+
+clean:
+ rm -rf $(BUILD_DIR) *.log
+ rm $(PROJECT_OBJECT_FILES) $(PLATFORM_OBJECT_FILES) \
+ $(ASM_OBJECT_FILES) $(STACK_OBJECT_FILES)
diff --git a/Makefile.ubertooth b/Makefile.ubertooth
new file mode 100644
index 0000000..50ed059
--- /dev/null
+++ b/Makefile.ubertooth
@@ -0,0 +1,7 @@
+all: $(BUILD_DIR)
+
+$(BUILD_DIR):
+ mkdir $@
+
+clean:
+ rm -rf $(BUILD_PATH) *.log
diff --git a/Makefile.x86 b/Makefile.x86
new file mode 100644
index 0000000..2ab66d0
--- /dev/null
+++ b/Makefile.x86
@@ -0,0 +1,13 @@
+bin_PROGRAMS =
+libexec_PROGRAMS =
+
+noinst_LTLIBRARIES =
+
+noinst_LTLIBRARIES += stack/libblestack.la
+
+stack_libblestack_la_SOURCES = stack/ll.h stack/ll.c \
+ stack/bci.h stack/bci.c
+
+libexec_PROGRAMS += examples/platform/nrf51822/helloworld/hello
+examples_platform_nrf51822_helloworld_hello_SOURCES = stack/libblestack.la \
+ examples/platform/nrf51822/helloworld/hello.c
diff --git a/acinclude.m4 b/acinclude.m4
index 842d526..2a3340a 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,15 +1,3 @@
-AC_DEFUN([AC_PROG_CC_PIE], [
- AC_CACHE_CHECK([whether ${CC-cc} accepts -fPIE], ac_cv_prog_cc_pie, [
- echo 'void f(){}' > conftest.c
- if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then
- ac_cv_prog_cc_pie=yes
- else
- ac_cv_prog_cc_pie=no
- fi
- rm -rf conftest*
- ])
-])
-
AC_DEFUN([COMPILER_FLAGS], [
if (test "${CFLAGS}" = ""); then
CFLAGS="-Wall"
@@ -40,6 +28,37 @@ AC_DEFUN([AC_ARG_BLESTACK], [
optimization_enable=${enableval}
])
+ AC_ARG_WITH([sdkdir], AC_HELP_STRING([--with-sdkdir=DIR],
+ [path to NRF SDK directory]), [path_sdkdir=${withval}])
+
+ if (test -z "${path_sdkdir}"); then
+ AC_MSG_ERROR([NRF SDK directory is required])
+ fi
+
+ AC_SUBST(SDK_DIR, [${path_sdkdir}])
+
+ AC_ARG_WITH([builddir], AC_HELP_STRING([--with-builddir=DIR],
+ [path to build directory]), [path_builddir=${withval}])
+
+ if (test "${path_builddir}"); then
+ AC_SUBST(BUILD_DIR, [${path_builddir}])
+ else
+ AC_SUBST(BUILD_DIR, "build")
+ fi
+
+ AC_ARG_WITH([platform], AC_HELP_STRING([--with-platform=nrf|ubertooth],
+ [Select target platform]), [platform_val=${withval}])
+
+ if (test "${platform_val}" == "nrf"); then
+ AM_CONDITIONAL(PLATFORM_NRF, true)
+ AM_CONDITIONAL(PLATFORM_UBERTOOTH, false)
+ elif (test "${platform_val}" == "ubertooth"); then
+ AM_CONDITIONAL(PLATFORM_NRF, false)
+ AM_CONDITIONAL(PLATFORM_UBERTOOTH, true)
+ else
+ AC_MSG_ERROR([Platform is required])
+ fi
+
if (test "${debug_enable}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then
CFLAGS="-g $CFLAGS"
fi
diff --git a/bootstrap-configure b/bootstrap-configure
deleted file mode 100755
index 4ff0865..0000000
--- a/bootstrap-configure
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-if [ -f config.status ]; then
- make maintainer-clean
-fi
-
-./bootstrap && \
- ./configure --enable-maintainer-mode \
- --enable-debug \
- --disable-optimization $*
diff --git a/bootstrap-configure.nrf b/bootstrap-configure.nrf
new file mode 100755
index 0000000..606c7e2
--- /dev/null
+++ b/bootstrap-configure.nrf
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# environment variables
+export CC="arm-none-eabi-gcc"
+export LD="arm-none-eabi-ld"
+export NM="arm-none-eabi-nm -B"
+export AR="arm-none-eabi-ar"
+export RANLIB="arm-none-eabi-ranlib"
+export LN_S="ln -s"
+export OBJCOPY="arm-none-eabi-objcopy"
+export OBJDUMP="arm-none-eabi-objdump"
+
+export CFLAGS="-mcpu=cortex-m0 -mthumb -mfloat-abi=soft -DNRF51 -DNRF51822_QFAA_CA -DBOARD_PCA10001 --std=gnu99"
+export ASMFLAGS="-x assembler-with-cpp -D__HEAP_SIZE=0 -D__STACK_SIZE=1024"
+export CROSS_COMPILE=1
+
+if [ -f config.status ]; then
+ make maintainer-clean
+fi
+
+if [ -f configure.ac ]; then
+ rm configure.ac
+fi
+ln -s configure.nrf configure.ac
+
+./bootstrap &&
+ ./configure \
+ --enable-maintainer-mode \
+ --enable-debug \
+ --disable-optimization \
+ --with-platform=nrf $*
diff --git a/bootstrap-configure.ubertooth b/bootstrap-configure.ubertooth
new file mode 100755
index 0000000..3044f1a
--- /dev/null
+++ b/bootstrap-configure.ubertooth
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+if [ -f config.status ]; then
+ make maintainer-clean
+fi
+
+if [ -f configure.ac ]; then
+ rm configure.ac
+fi
+ln -s configure.ubertooth configure.ac
+
+./bootstrap && \
+ ./configure --enable-maintainer-mode \
+ --enable-debug \
+ --disable-optimization \
+ --with-platform=ubertooth $*
diff --git a/configure.nrf b/configure.nrf
new file mode 100644
index 0000000..eaeb546
--- /dev/null
+++ b/configure.nrf
@@ -0,0 +1,36 @@
+AC_PREREQ(2.60)
+AC_INIT(blestack, 0.0.1)
+AC_SUBST(PROJECT,[HelloWorld])
+
+AM_INIT_AUTOMAKE([foreign subdir-objects])
+
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+AM_MAINTAINER_MODE
+
+COMPILER_FLAGS
+
+AC_INIT_BLESTACK
+AC_ARG_BLESTACK
+
+AC_NO_EXECUTABLES
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+AC_PROG_CC
+AC_CHECK_TOOL(AS, as, as)
+AM_PROG_AS
+AC_PROG_RANLIB
+AC_CHECK_TOOL(AR, ar, ar)
+AC_CHECK_TOOL(OBJCOPY, objcopy, objcopy)
+AC_CHECK_TOOL(SIZE, size, size)
+AC_CHECK_TOOL(OBJDUMP, objdump, objdump)
+AC_SUBST(ARCH, ${ARCH})
+AC_SUBST(DEVICE, ${DEVICE})
+AC_SUBST(PGM_START, ${PGM_START})
+AC_SUBST(RAM_START, ${RAM_START})
+AC_SUBST(RAM_SIZE, ${RAM_SIZE})
+AC_SUBST(TYPE, ${TYPE})
+
+AM_CONFIG_HEADER(config.h)
+
+AC_OUTPUT(Makefile)
diff --git a/configure.ac b/configure.ubertooth
index 9f4d430..c2fd466 100644
--- a/configure.ac
+++ b/configure.ubertooth
@@ -8,6 +8,8 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AM_MAINTAINER_MODE
+AC_ARG_BLESTACK
+
PKG_PROG_PKG_CONFIG
COMPILER_FLAGS
@@ -17,12 +19,8 @@ AC_INIT_BLESTACK
AC_LANG_C
AC_PROG_CC
-AC_PROG_CC_PIE
-AC_PROG_INSTALL
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
-AC_ARG_BLESTACK
-
AC_OUTPUT(Makefile)
diff --git a/examples/platform/nrf51822/helloworld/hello.c b/examples/platform/nrf51822/helloworld/main.c
index d86d5ee..21db609 100644
--- a/examples/platform/nrf51822/helloworld/hello.c
+++ b/examples/platform/nrf51822/helloworld/main.c
@@ -24,10 +24,7 @@
* SOFTWARE.
*/
-#include <stdio.h>
-
int main(void)
{
- printf("Hello World!\n");
return 0;
}