diff --git a/tools/export/nb/Makefile.tmpl b/tools/export/nb/Makefile.tmpl index 05de621e85..a7254417b1 100644 --- a/tools/export/nb/Makefile.tmpl +++ b/tools/export/nb/Makefile.tmpl @@ -49,6 +49,11 @@ MKDIR=mkdir CP=cp CCADMIN=CCadmin +BUILDDIR = BUILD +PLATFORM = {{target}} +ELF2BIN = 'arm-none-eabi-objcopy' +TARGET = ${CND_DISTDIR}/${CONF}/${CND_PLATFORM}/{{name}} + # build build: .build-post @@ -58,7 +63,10 @@ build: .build-post .build-post: .build-impl # Add your post 'build' code here... - + $(ELF2BIN) -O binary ${TARGET}.elf ${TARGET}.bin + +@echo "===== bin file ready to flash: $(TARGET).bin =====" + $(ELF2BIN) -O ihex ${TARGET}.elf ${TARGET}.hex + cp ${TARGET}.* ${CND_BUILDDIR}/${CONF}/${CND_PLATFORM} # clean clean: .clean-post @@ -126,3 +134,6 @@ include nbproject/Makefile-impl.mk # include project make variables include nbproject/Makefile-variables.mk + +CND_BUILDDIR = ${BUILDDIR} +CND_PLATFORM = ${PLATFORM} diff --git a/tools/export/nb/__init__.py b/tools/export/nb/__init__.py index 2a3357d986..0b797a79b1 100644 --- a/tools/export/nb/__init__.py +++ b/tools/export/nb/__init__.py @@ -28,6 +28,10 @@ class GNUARMNetbeans(Exporter): return apply_supported_whitelist( cls.TOOLCHAIN, POST_BINARY_WHITELIST, target) + @staticmethod + def prepare_sys_lib(libname): + return "-l" + libname + def toolchain_flags(self, toolchain): """Returns a dictionary of toolchain flags. Keys of the dictionary are: @@ -207,11 +211,19 @@ class GNUARMNetbeans(Exporter): sources = [self.filter_dot(field) for field in sources] include_paths = [self.filter_dot(field) for field in self.resources.inc_dirs] + sys_libs = [self.prepare_sys_lib(lib) for lib + in self.toolchain.sys_libs] + preproc = " ".join([part for part + in ([basename(self.toolchain.preproc[0])] + + self.toolchain.preproc[1:] + + self.toolchain.ld[1:])]) + if 'nbproject' in include_paths: include_paths.remove('nbproject') jinja_ctx = { 'name': self.project_name, + 'target': self.toolchain.target.name, 'elf_location': join('BUILD', self.project_name) + '.elf', 'c_symbols': self.toolchain.get_symbols(), 'asm_symbols': self.toolchain.get_symbols(True), @@ -233,6 +245,8 @@ class GNUARMNetbeans(Exporter): 'c_std': self.get_netbeans_c_std(c_std), 'cpp_std': self.get_netbeans_cpp_std(cpp_std), 'linker_script': self.ld_script, + 'linker_libs': sys_libs, + 'pp_cmd': preproc } return jinja_ctx diff --git a/tools/export/nb/configurations.tmpl b/tools/export/nb/configurations.tmpl index 6f0c69992c..8eeeac258d 100644 --- a/tools/export/nb/configurations.tmpl +++ b/tools/export/nb/configurations.tmpl @@ -131,8 +131,10 @@ + ${CND_DISTDIR}/${CND_CONF}/{{target}}/{{name}}.elf + ${CND_BUILDDIR}/${CND_CONF}/{{target}}/.link_script.ld arm-none-eabi-gcc - {%- for symbol in opts['ld'] -%}{{ symbol+" "}}{%- endfor -%} + -T ${CND_BUILDDIR}/${CND_CONF}/{{target}}/.link_script.ld {%- for symbol in opts['ld'] -%}{{" "+symbol}}{%- endfor -%} {%- for item in linker_libs -%}{{" "+item}}{%- endfor -%} {% for h in headers -%} @@ -156,6 +158,11 @@ {% endfor -%} + + {{pp_cmd}} -o $@ $< + Create ELF File using Link Script + ${CND_BUILDDIR}/${CND_CONF}/{{target}}/.link_script.ld +