From ca86cbf56536d4b98343df6a8381abc3171be3a4 Mon Sep 17 00:00:00 2001 From: Thomas Sailer Date: Tue, 27 Mar 2018 16:41:53 +0200 Subject: [PATCH 1/8] Code::Blocks project file exporter --- .../device/TOOLCHAIN_GCC_ARM/NCS36510.ld | 20 +- tools/export/__init__.py | 5 +- tools/export/codeblocks/__init__.py | 152 +++++++++++++++ tools/export/codeblocks/cbp.tmpl | 99 ++++++++++ tools/export/codeblocks/ncs36510addfib.py | 178 ++++++++++++++++++ tools/export/codeblocks/ncs36510fib.c | 93 +++++++++ tools/export/codeblocks/ncs36510trim.c | 86 +++++++++ 7 files changed, 627 insertions(+), 6 deletions(-) create mode 100644 tools/export/codeblocks/__init__.py create mode 100644 tools/export/codeblocks/cbp.tmpl create mode 100755 tools/export/codeblocks/ncs36510addfib.py create mode 100644 tools/export/codeblocks/ncs36510fib.c create mode 100644 tools/export/codeblocks/ncs36510trim.c diff --git a/targets/TARGET_ONSEMI/TARGET_NCS36510/device/TOOLCHAIN_GCC_ARM/NCS36510.ld b/targets/TARGET_ONSEMI/TARGET_NCS36510/device/TOOLCHAIN_GCC_ARM/NCS36510.ld index 1d87e63962..778135fadc 100644 --- a/targets/TARGET_ONSEMI/TARGET_NCS36510/device/TOOLCHAIN_GCC_ARM/NCS36510.ld +++ b/targets/TARGET_ONSEMI/TARGET_NCS36510/device/TOOLCHAIN_GCC_ARM/NCS36510.ld @@ -3,10 +3,12 @@ */ MEMORY { + FIB (rx) : ORIGIN = 0x00002000, LENGTH = 0x00000800 + TRIM (rx) : ORIGIN = 0x00002800, LENGTH = 0x00000800 VECTORS (rx) : ORIGIN = 0x00003000, LENGTH = 0x00000090 - FLASH (rx) : ORIGIN = 0x00003090, LENGTH = 320K - 4K - 0x90 - RAM (rwx) : ORIGIN = 0x3FFF4090, LENGTH = 48K - 0x90 /* 8_byte_aligned(35 vectors * 4 bytes each) = 0x90 */ - } + FLASH (rx) : ORIGIN = 0x00003090, LENGTH = 320K - 4K - 0x90 + RAM (rwx) : ORIGIN = 0x3FFF4090, LENGTH = 48K - 0x90 /* 8_byte_aligned(35 vectors * 4 bytes each) = 0x90 */ +} /* Linker script to place sections and symbol values. Should be used together * with other linker script that defines memory regions FLASH and RAM. @@ -37,7 +39,17 @@ MEMORY { ENTRY(Reset_Handler) SECTIONS { -.isr_vector : + .fib : + { + KEEP(*(.fib)) + } > FIB + + .trim : + { + KEEP(*(.trim)) + } > TRIM + + .isr_vector : { __vector_table = .; KEEP(*(.vector_table)) diff --git a/tools/export/__init__.py b/tools/export/__init__.py index ae0e95a337..567a325f92 100644 --- a/tools/export/__init__.py +++ b/tools/export/__init__.py @@ -30,7 +30,7 @@ from ..toolchains import Resources from ..targets import TARGET_NAMES from . import (lpcxpresso, ds5_5, iar, makefile, embitz, coide, kds, simplicity, atmelstudio, mcuxpresso, sw4stm32, e2studio, zip, cmsis, uvision, - cdt, vscode, gnuarmeclipse, qtcreator, cmake, nb, cces) + cdt, vscode, gnuarmeclipse, qtcreator, cmake, nb, cces, codeblocks) EXPORTERS = { u'uvision5': uvision.Uvision, @@ -61,7 +61,8 @@ EXPORTERS = { u'vscode_iar' : vscode.VSCodeIAR, u'vscode_armc5' : vscode.VSCodeArmc5, u'cmake_gcc_arm': cmake.GccArm, - u'cces' : cces.CCES + u'cces' : cces.CCES, + u'codeblocks': codeblocks.CodeBlocks } ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN = """ diff --git a/tools/export/codeblocks/__init__.py b/tools/export/codeblocks/__init__.py new file mode 100644 index 0000000000..9b05edb232 --- /dev/null +++ b/tools/export/codeblocks/__init__.py @@ -0,0 +1,152 @@ +""" +mbed SDK +Copyright (c) 2014-2017 ARM Limited +Copyright (c) 2018 Code::Blocks + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" +import copy +import os +from os.path import splitext, basename +from os import remove +from shutil import rmtree +from tools.targets import TARGET_MAP +from tools.export.exporters import Exporter +from tools.export.makefile import GccArm + +class CodeBlocks(GccArm): + NAME = 'Code::Blocks' + + DOT_IN_RELATIVE_PATH = True + + MBED_CONFIG_HEADER_SUPPORTED = True + + PREPROCESS_ASM = False + + POST_BINARY_WHITELIST = set([ + "NCS36510TargetCode.ncs36510_addfib" + ]) + + @staticmethod + def filter_dot(str_in): + """ + Remove the './' prefix, if present. + This function assumes that resources.win_to_unix() + replaced all windows backslashes with slashes. + """ + if str_in is None: + return None + if str_in[:2] == './': + return str_in[2:] + return str_in + + def generate(self): + self.resources.win_to_unix() + + comp_flags = [] + debug_flags = [] + next_is_include = False + for f in self.flags['c_flags'] + self.flags['cxx_flags'] + self.flags['common_flags']: + f=f.strip() + if f == "-include": + next_is_include = True + continue + if f == 'c': + continue + if next_is_include: + f = '-include ' + f + next_is_include = False + if f.startswith('-O') or f.startswith('-g'): + debug_flags.append(f) + continue + comp_flags.append(f) + comp_flags = list(set(comp_flags)) + inc_dirs = [self.filter_dot(s) for s in self.resources.inc_dirs]; + inc_dirs = [x for x in inc_dirs if x is not None and x != '' and x != '.' and not x.startswith('bin') and not x.startswith('obj')]; + + c_sources = [self.filter_dot(s) for s in self.resources.c_sources] + targ = TARGET_MAP[self.target] + ncs36510fib = hasattr(targ, 'post_binary_hook') and targ.post_binary_hook['function'] == 'NCS36510TargetCode.ncs36510_addfib' + if ncs36510fib: + c_sources.append('ncs36510fib.c') + c_sources.append('ncs36510trim.c') + + ctx = { + 'project_name': self.project_name, + 'debug_flags': debug_flags, + 'comp_flags': comp_flags, + 'ld_flags': self.flags['ld_flags'], + 'headers': list(set([self.filter_dot(s) for s in self.resources.headers])), + 'c_sources': c_sources, + 's_sources': [self.filter_dot(s) for s in self.resources.s_sources], + 'cpp_sources': [self.filter_dot(s) for s in self.resources.cpp_sources], + 'include_paths': inc_dirs, + 'linker_script': self.filter_dot(self.resources.linker_script), + 'libraries': self.resources.libraries, + 'ncs36510addfib': ncs36510fib, + 'openocdboard': '' + } + + openocd_board = { + 'NCS36510': 'board/ncs36510_axdbg.cfg', + 'DISCO_F429ZI': 'board/stm32f429discovery.cfg', + 'DISCO_F469NI': 'board/stm32f469discovery.cfg', + 'DISCO_L053C8': 'board/stm32l0discovery.cfg', + 'DISCO_L072CZ_LRWAN1': 'board/stm32l0discovery.cfg', + 'DISCO_F769NI': 'board/stm32f7discovery.cfg', + 'DISCO_L475VG_IOT01A': 'board/stm32l4discovery.cfg', + 'DISCO_L476VG': 'board/stm32l4discovery.cfg', + 'NRF51822': 'board/nordic_nrf51822_mkit.cfg', + 'NRF51822_BOOT': 'board/nordic_nrf51822_mkit.cfg', + 'NRF51822_OTA': 'board/nordic_nrf51822_mkit.cfg', + 'NRF51_DK_LEGACY': 'board/nordic_nrf51_dk.cfg', + 'NRF51_DK_BOOT': 'board/nordic_nrf51_dk.cfg', + 'NRF51_DK_OTA': 'board/nordic_nrf51_dk.cfg', + 'NRF51_DK': 'board/nordic_nrf51_dk.cfg' + } + + if self.target in openocd_board: + ctx['openocdboard'] = openocd_board[self.target] + + self.gen_file('codeblocks/cbp.tmpl', ctx, "%s.%s" % (self.project_name, 'cbp')) + + if ncs36510fib: + ctx = { + 'mac_addr_low': 0xFFFFFFFF, + 'mac_addr_high': 0xFFFFFFFF, + 'clk_32k_trim': 0x39, + 'clk_32m_trim': 0x17, + 'rssi': 0x3D, + 'txtune': 0xFFFFFFFF + } + if hasattr(targ, 'config'): + for an, cn in [ ['mac-addr-low', 'mac_addr_low'], ['mac-addr-high', 'mac_addr_high'], + ['32KHz-clk-trim', 'clk_32k_trim'], ['32MHz-clk-trim', 'clk_32m_trim'], + ['rssi-trim', 'rssi'], ['txtune-trim', 'txtune'] ]: + if an in targ.config: + if 'value' in targ.config[an]: + ctx[cn] = int(targ.config[an]['value'], 0) + for f in [ 'ncs36510fib.c', 'ncs36510trim.c' ]: + self.gen_file("codeblocks/%s" % f, ctx, f) + + # finally, generate the project file + super(CodeBlocks, self).generate() + + @staticmethod + def clean(project_name): + for ext in ['cbp', 'depend', 'layout']: + remove("%s.%s" % (project_name, ext)) + for f in ['openocd.log', 'ncs36510fib.c', 'ncs36510trim.c']: + remove(f) + for d in ['bin', 'obj']: + rmtree(d, ignore_errors=True) diff --git a/tools/export/codeblocks/cbp.tmpl b/tools/export/codeblocks/cbp.tmpl new file mode 100644 index 0000000000..c0844b1283 --- /dev/null +++ b/tools/export/codeblocks/cbp.tmpl @@ -0,0 +1,99 @@ + + + + + + diff --git a/tools/export/codeblocks/ncs36510addfib.py b/tools/export/codeblocks/ncs36510addfib.py new file mode 100755 index 0000000000..6b1e0b88ae --- /dev/null +++ b/tools/export/codeblocks/ncs36510addfib.py @@ -0,0 +1,178 @@ +#!/usr/bin/env python + +""" +@copyright (c) 2012-2018 ON Semiconductor. All rights reserved. +ON Semiconductor is supplying this software for use with ON Semiconductor +processor based microcontrollers only. +THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED +OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. +ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, +INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. +""" + +import sys +import itertools +import binascii +import intelhex + +FIB_BASE = 0x2000 +TRIM_BASE = 0x2800 +FLASH_BASE = 0x3000 +FLASHA_SIZE = 0x52000 +FLASHB_BASE = 0x00102000 +FLASHB_SIZE = 0x52000 +FW_REV = 0x01000100 + +def ranges(i): + for _, b in itertools.groupby(enumerate(i), lambda x_y: x_y[1] - x_y[0]): + b = list(b) + yield b[0][1], b[-1][1] + +def add_fib(input_file, output_file): + # Read in hex file + input_hex_file = intelhex.IntelHex() + input_hex_file.loadhex(input_file) + #set padding value to be returned when reading from unspecified address + input_hex_file.padding = 0xFF + # Create new binary data array + output_data = bytearray([0xff]*2048) + + # Get the starting and ending address + addresses = input_hex_file.addresses() + addresses.sort() + start_end_pairs = list(ranges(addresses)) + regions = len(start_end_pairs) + + if regions == 1: + #single range indicating fits within first flash block (<320K) + start, end = start_end_pairs[0] + print("Memory start 0x%08X, end 0x%08X" % (start, end)) + # Compute checksum over the range (don't include data at location of crc) + size = end - start + 1 + data = input_hex_file.tobinarray(start=start, size=size) + crc32 = binascii.crc32(data) & 0xFFFFFFFF + else: + #multiple ranges indicating requires both flash blocks (>320K) + start, end = start_end_pairs[0] + start2, end2 = start_end_pairs[1] + print("Region 1: memory start 0x%08X, end 0x%08X" % (start, end)) + print("Region 2: memory start 0x%08X, end 0x%08X" % (start2, end2)) + # Compute checksum over the range (don't include data at location of crc) + # replace end with end of flash block A + end = FLASHA_SIZE - 1 + size = end - start + 1 + data = input_hex_file.tobinarray(start=start, size=size) + + # replace start2 with base of flash block B + start2 = FLASHB_BASE + size2 = end2 - start2 + 1 + data2 = input_hex_file.tobinarray(start=start2, size=size2) + + #concatenate data and data2 arrays together + data.extend(data2) + crc32 = binascii.crc32(data) & 0xFFFFFFFF + + #replace size with sum of two memory region sizes + size = size + size2 + + assert start >= FLASH_BASE, ("Error - start 0x%x less than begining of user\ + flash area" %start) + + assert regions <= 2, ("Error - more than 2 memory regions found") + + fw_rev = FW_REV + + checksum = (start + size + crc32 + fw_rev) & 0xFFFFFFFF + + print("Writing FIB: base 0x%08X, size 0x%08X, crc32 0x%08X, fw rev 0x%08X,\ + checksum 0x%08X" % (start, size, crc32, fw_rev, checksum)) + +#expected initial values used by daplink to validate that it is a valid bin +#file added as dummy values in this file because the fib area preceeds the +#application area the bootloader will ignore these dummy values +# 00 is stack pointer (RAM address) +# 04 is Reset vector (FLASH address) +# 08 NMI_Handler (FLASH address) +# 0C HardFault_Handler(FLASH address) +# 10 dummy + dummy_sp = 0x3FFFFC00 + dummy_reset_vector = 0x00003625 + dummy_nmi_handler = 0x00003761 + dummy_hardfault_handler = 0x00003691 + dummy_blank = 0x00000000 + +#expected fib structure +#typedef struct fib{ + #uint32_t base; /**< Base offset of firmware, indicating what flash the + # firmware is in. (will never be 0x11111111) */ + #uint32_t size; /**< Size of the firmware */ + #uint32_t crc; /**< CRC32 for firmware correctness check */ + #uint32_t rev; /**< Revision number */ + #uint32_t checksum; /**< Check-sum of information block */ +#}fib_t, *fib_pt; + + # Write FIB to the file in little endian + output_data[0] = (dummy_sp >> 0) & 0xFF + output_data[1] = (dummy_sp >> 8) & 0xFF + output_data[2] = (dummy_sp >> 16) & 0xFF + output_data[3] = (dummy_sp >> 24) & 0xFF + + output_data[4] = (dummy_reset_vector >> 0) & 0xFF + output_data[5] = (dummy_reset_vector >> 8) & 0xFF + output_data[6] = (dummy_reset_vector >> 16) & 0xFF + output_data[7] = (dummy_reset_vector >> 24) & 0xFF + + output_data[8] = (dummy_nmi_handler >> 0) & 0xFF + output_data[9] = (dummy_nmi_handler >> 8) & 0xFF + output_data[10] = (dummy_nmi_handler >> 16) & 0xFF + output_data[11] = (dummy_nmi_handler >> 24) & 0xFF + + output_data[12] = (dummy_hardfault_handler >> 0) & 0xFF + output_data[13] = (dummy_hardfault_handler >> 8) & 0xFF + output_data[14] = (dummy_hardfault_handler >> 16) & 0xFF + output_data[15] = (dummy_hardfault_handler >> 24) & 0xFF + + output_data[16] = (dummy_blank >> 0) & 0xFF + output_data[17] = (dummy_blank >> 8) & 0xFF + output_data[18] = (dummy_blank >> 16) & 0xFF + output_data[19] = (dummy_blank >> 24) & 0xFF + + # Write FIB to the file in little endian + output_data[20] = (start >> 0) & 0xFF + output_data[21] = (start >> 8) & 0xFF + output_data[22] = (start >> 16) & 0xFF + output_data[23] = (start >> 24) & 0xFF + + output_data[24] = (size >> 0) & 0xFF + output_data[25] = (size >> 8) & 0xFF + output_data[26] = (size >> 16) & 0xFF + output_data[27] = (size >> 24) & 0xFF + + output_data[28] = (crc32 >> 0) & 0xFF + output_data[29] = (crc32 >> 8) & 0xFF + output_data[30] = (crc32 >> 16) & 0xFF + output_data[31] = (crc32 >> 24) & 0xFF + + output_data[32] = (fw_rev >> 0) & 0xFF + output_data[33] = (fw_rev >> 8) & 0xFF + output_data[34] = (fw_rev >> 16) & 0xFF + output_data[35] = (fw_rev >> 24) & 0xFF + + output_data[36] = (checksum >> 0) & 0xFF + output_data[37] = (checksum >> 8) & 0xFF + output_data[38] = (checksum >> 16) & 0xFF + output_data[39] = (checksum >> 24) & 0xFF + + f = open(output_file, 'wb') + f.write(output_data) + f.close() + +def main(argv): + if len(argv) < 2: + sys.stderr.write("usage: ncs36510addfib.py input.hex output.bin\n") + sys.exit() + add_fib(argv[0], argv[1]) + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/tools/export/codeblocks/ncs36510fib.c b/tools/export/codeblocks/ncs36510fib.c new file mode 100644 index 0000000000..054b340e61 --- /dev/null +++ b/tools/export/codeblocks/ncs36510fib.c @@ -0,0 +1,93 @@ +#include + +struct ncs36510fib { + uint32_t dummy_sp; + uint32_t dummy_reset_vector; + uint32_t dummy_nmi_handler; + uint32_t dummy_hardfault_handler; + uint32_t dummy_blank; + uint32_t start; + uint32_t size; + uint32_t crc32; + uint32_t fw_rev; + uint32_t checksum; + uint32_t fill[502]; +}; + +static struct ncs36510fib __attribute__((section(".fib,\"a\",%progbits@"), unused)) ncs36510fib = { + 0x3FFFFC00, + 0x00003625, + 0x00003761, + 0x00003691, + 0x00000000, + 0, + 0, + 0, + 0x01000100, + 0, + { + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff + } +}; diff --git a/tools/export/codeblocks/ncs36510trim.c b/tools/export/codeblocks/ncs36510trim.c new file mode 100644 index 0000000000..8a8cd4367f --- /dev/null +++ b/tools/export/codeblocks/ncs36510trim.c @@ -0,0 +1,86 @@ +#include + +struct ncs36510fib { + uint32_t mac_addr_low; + uint32_t mac_addr_high; + uint32_t clk_32k_trim; + uint32_t clk_32m_trim; + uint32_t rssi; + uint32_t txtune; + uint32_t fill[506]; +}; + +static struct ncs36510fib __attribute__((section(".trim,\"a\",%progbits@"), unused)) ncs36510fib = { + {{"0x{:08x}".format(mac_addr_low)}}, + {{"0x{:08x}".format(mac_addr_high)}}, + {{"0x{:08x}".format(clk_32k_trim)}}, + {{"0x{:08x}".format(clk_32m_trim)}}, + {{"0x{:08x}".format(rssi)}}, + {{"0x{:08x}".format(txtune)}}, + { + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff + } +}; From f53154a95e535fd9b811a7ae39f15d662a8e26f2 Mon Sep 17 00:00:00 2001 From: Thomas Sailer Date: Tue, 27 Mar 2018 18:38:18 +0200 Subject: [PATCH 2/8] some modifications from review --- .../TARGET_NCS36510/ncs36510Init.c | 6 ++-- tools/export/codeblocks/__init__.py | 32 +++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/targets/TARGET_ONSEMI/TARGET_NCS36510/ncs36510Init.c b/targets/TARGET_ONSEMI/TARGET_NCS36510/ncs36510Init.c index 8976efe973..f15df426c2 100644 --- a/targets/TARGET_ONSEMI/TARGET_NCS36510/ncs36510Init.c +++ b/targets/TARGET_ONSEMI/TARGET_NCS36510/ncs36510Init.c @@ -147,13 +147,13 @@ void fClockInit() for(Timer = 0; Timer < 10; Timer++); /** - Enable calibration */ - CLOCKREG->CCR.BITS.CAL32M = True; + //CLOCKREG->CCR.BITS.CAL32M = True; /** - Wait calibration to be completed */ - while(CLOCKREG->CSR.BITS.CAL32MDONE == False); /* If you stuck here, issue with internal 32M calibration */ + //while(CLOCKREG->CSR.BITS.CAL32MDONE == False); /* If you stuck here, issue with internal 32M calibration */ /** - Check calibration status */ - while(CLOCKREG->CSR.BITS.CAL32MFAIL == True); /* If you stuck here, issue with internal 32M calibration */ + //while(CLOCKREG->CSR.BITS.CAL32MFAIL == True); /* If you stuck here, issue with internal 32M calibration */ /** - Power down internal 32MHz osc */ PMUREG->CONTROL.BITS.INT32M = 1; diff --git a/tools/export/codeblocks/__init__.py b/tools/export/codeblocks/__init__.py index 9b05edb232..bfc31435a4 100644 --- a/tools/export/codeblocks/__init__.py +++ b/tools/export/codeblocks/__init__.py @@ -57,7 +57,7 @@ class CodeBlocks(GccArm): debug_flags = [] next_is_include = False for f in self.flags['c_flags'] + self.flags['cxx_flags'] + self.flags['common_flags']: - f=f.strip() + f = f.strip() if f == "-include": next_is_include = True continue @@ -68,15 +68,18 @@ class CodeBlocks(GccArm): next_is_include = False if f.startswith('-O') or f.startswith('-g'): debug_flags.append(f) - continue - comp_flags.append(f) + else: + comp_flags.append(f) comp_flags = list(set(comp_flags)) inc_dirs = [self.filter_dot(s) for s in self.resources.inc_dirs]; - inc_dirs = [x for x in inc_dirs if x is not None and x != '' and x != '.' and not x.startswith('bin') and not x.startswith('obj')]; + inc_dirs = [x for x in inc_dirs if (x is not None and + x != '' and x != '.' and + not x.startswith('bin') and + not x.startswith('obj'))]; c_sources = [self.filter_dot(s) for s in self.resources.c_sources] - targ = TARGET_MAP[self.target] - ncs36510fib = hasattr(targ, 'post_binary_hook') and targ.post_binary_hook['function'] == 'NCS36510TargetCode.ncs36510_addfib' + ncs36510fib = (hasattr(self.toolchain.target, 'post_binary_hook') and + self.toolchain.target.post_binary_hook['function'] == 'NCS36510TargetCode.ncs36510_addfib') if ncs36510fib: c_sources.append('ncs36510fib.c') c_sources.append('ncs36510trim.c') @@ -129,13 +132,16 @@ class CodeBlocks(GccArm): 'rssi': 0x3D, 'txtune': 0xFFFFFFFF } - if hasattr(targ, 'config'): - for an, cn in [ ['mac-addr-low', 'mac_addr_low'], ['mac-addr-high', 'mac_addr_high'], - ['32KHz-clk-trim', 'clk_32k_trim'], ['32MHz-clk-trim', 'clk_32m_trim'], - ['rssi-trim', 'rssi'], ['txtune-trim', 'txtune'] ]: - if an in targ.config: - if 'value' in targ.config[an]: - ctx[cn] = int(targ.config[an]['value'], 0) + if hasattr(self.toolchain.target, 'config'): + for an, cn in [ ['mac-addr-low', 'mac_addr_low'], + ['mac-addr-high', 'mac_addr_high'], + ['32KHz-clk-trim', 'clk_32k_trim'], + ['32MHz-clk-trim', 'clk_32m_trim'], + ['rssi-trim', 'rssi'], + ['txtune-trim', 'txtune'] ]: + if an in self.toolchain.target.config: + if 'value' in self.toolchain.target.config[an]: + ctx[cn] = int(self.toolchain.target.config[an]['value'], 0) for f in [ 'ncs36510fib.c', 'ncs36510trim.c' ]: self.gen_file("codeblocks/%s" % f, ctx, f) From 209310c54f45130a183d9f4131878ae91f84431e Mon Sep 17 00:00:00 2001 From: Thomas Sailer Date: Tue, 27 Mar 2018 18:45:18 +0200 Subject: [PATCH 3/8] remove NCS36510 specific changes from this branch --- .../device/TOOLCHAIN_GCC_ARM/NCS36510.ld | 20 +- .../TARGET_NCS36510/ncs36510Init.c | 6 +- tools/export/codeblocks/__init__.py | 30 +-- tools/export/codeblocks/cbp.tmpl | 16 -- tools/export/codeblocks/ncs36510addfib.py | 178 ------------------ tools/export/codeblocks/ncs36510fib.c | 93 --------- tools/export/codeblocks/ncs36510trim.c | 86 --------- 7 files changed, 8 insertions(+), 421 deletions(-) delete mode 100755 tools/export/codeblocks/ncs36510addfib.py delete mode 100644 tools/export/codeblocks/ncs36510fib.c delete mode 100644 tools/export/codeblocks/ncs36510trim.c diff --git a/targets/TARGET_ONSEMI/TARGET_NCS36510/device/TOOLCHAIN_GCC_ARM/NCS36510.ld b/targets/TARGET_ONSEMI/TARGET_NCS36510/device/TOOLCHAIN_GCC_ARM/NCS36510.ld index 778135fadc..1d87e63962 100644 --- a/targets/TARGET_ONSEMI/TARGET_NCS36510/device/TOOLCHAIN_GCC_ARM/NCS36510.ld +++ b/targets/TARGET_ONSEMI/TARGET_NCS36510/device/TOOLCHAIN_GCC_ARM/NCS36510.ld @@ -3,12 +3,10 @@ */ MEMORY { - FIB (rx) : ORIGIN = 0x00002000, LENGTH = 0x00000800 - TRIM (rx) : ORIGIN = 0x00002800, LENGTH = 0x00000800 VECTORS (rx) : ORIGIN = 0x00003000, LENGTH = 0x00000090 - FLASH (rx) : ORIGIN = 0x00003090, LENGTH = 320K - 4K - 0x90 - RAM (rwx) : ORIGIN = 0x3FFF4090, LENGTH = 48K - 0x90 /* 8_byte_aligned(35 vectors * 4 bytes each) = 0x90 */ -} + FLASH (rx) : ORIGIN = 0x00003090, LENGTH = 320K - 4K - 0x90 + RAM (rwx) : ORIGIN = 0x3FFF4090, LENGTH = 48K - 0x90 /* 8_byte_aligned(35 vectors * 4 bytes each) = 0x90 */ + } /* Linker script to place sections and symbol values. Should be used together * with other linker script that defines memory regions FLASH and RAM. @@ -39,17 +37,7 @@ MEMORY { ENTRY(Reset_Handler) SECTIONS { - .fib : - { - KEEP(*(.fib)) - } > FIB - - .trim : - { - KEEP(*(.trim)) - } > TRIM - - .isr_vector : +.isr_vector : { __vector_table = .; KEEP(*(.vector_table)) diff --git a/targets/TARGET_ONSEMI/TARGET_NCS36510/ncs36510Init.c b/targets/TARGET_ONSEMI/TARGET_NCS36510/ncs36510Init.c index f15df426c2..8976efe973 100644 --- a/targets/TARGET_ONSEMI/TARGET_NCS36510/ncs36510Init.c +++ b/targets/TARGET_ONSEMI/TARGET_NCS36510/ncs36510Init.c @@ -147,13 +147,13 @@ void fClockInit() for(Timer = 0; Timer < 10; Timer++); /** - Enable calibration */ - //CLOCKREG->CCR.BITS.CAL32M = True; + CLOCKREG->CCR.BITS.CAL32M = True; /** - Wait calibration to be completed */ - //while(CLOCKREG->CSR.BITS.CAL32MDONE == False); /* If you stuck here, issue with internal 32M calibration */ + while(CLOCKREG->CSR.BITS.CAL32MDONE == False); /* If you stuck here, issue with internal 32M calibration */ /** - Check calibration status */ - //while(CLOCKREG->CSR.BITS.CAL32MFAIL == True); /* If you stuck here, issue with internal 32M calibration */ + while(CLOCKREG->CSR.BITS.CAL32MFAIL == True); /* If you stuck here, issue with internal 32M calibration */ /** - Power down internal 32MHz osc */ PMUREG->CONTROL.BITS.INT32M = 1; diff --git a/tools/export/codeblocks/__init__.py b/tools/export/codeblocks/__init__.py index bfc31435a4..5657df65ee 100644 --- a/tools/export/codeblocks/__init__.py +++ b/tools/export/codeblocks/__init__.py @@ -78,11 +78,6 @@ class CodeBlocks(GccArm): not x.startswith('obj'))]; c_sources = [self.filter_dot(s) for s in self.resources.c_sources] - ncs36510fib = (hasattr(self.toolchain.target, 'post_binary_hook') and - self.toolchain.target.post_binary_hook['function'] == 'NCS36510TargetCode.ncs36510_addfib') - if ncs36510fib: - c_sources.append('ncs36510fib.c') - c_sources.append('ncs36510trim.c') ctx = { 'project_name': self.project_name, @@ -96,7 +91,6 @@ class CodeBlocks(GccArm): 'include_paths': inc_dirs, 'linker_script': self.filter_dot(self.resources.linker_script), 'libraries': self.resources.libraries, - 'ncs36510addfib': ncs36510fib, 'openocdboard': '' } @@ -123,28 +117,6 @@ class CodeBlocks(GccArm): self.gen_file('codeblocks/cbp.tmpl', ctx, "%s.%s" % (self.project_name, 'cbp')) - if ncs36510fib: - ctx = { - 'mac_addr_low': 0xFFFFFFFF, - 'mac_addr_high': 0xFFFFFFFF, - 'clk_32k_trim': 0x39, - 'clk_32m_trim': 0x17, - 'rssi': 0x3D, - 'txtune': 0xFFFFFFFF - } - if hasattr(self.toolchain.target, 'config'): - for an, cn in [ ['mac-addr-low', 'mac_addr_low'], - ['mac-addr-high', 'mac_addr_high'], - ['32KHz-clk-trim', 'clk_32k_trim'], - ['32MHz-clk-trim', 'clk_32m_trim'], - ['rssi-trim', 'rssi'], - ['txtune-trim', 'txtune'] ]: - if an in self.toolchain.target.config: - if 'value' in self.toolchain.target.config[an]: - ctx[cn] = int(self.toolchain.target.config[an]['value'], 0) - for f in [ 'ncs36510fib.c', 'ncs36510trim.c' ]: - self.gen_file("codeblocks/%s" % f, ctx, f) - # finally, generate the project file super(CodeBlocks, self).generate() @@ -152,7 +124,7 @@ class CodeBlocks(GccArm): def clean(project_name): for ext in ['cbp', 'depend', 'layout']: remove("%s.%s" % (project_name, ext)) - for f in ['openocd.log', 'ncs36510fib.c', 'ncs36510trim.c']: + for f in ['openocd.log']: remove(f) for d in ['bin', 'obj']: rmtree(d, ignore_errors=True) diff --git a/tools/export/codeblocks/cbp.tmpl b/tools/export/codeblocks/cbp.tmpl index c0844b1283..2a10ac1d96 100644 --- a/tools/export/codeblocks/cbp.tmpl +++ b/tools/export/codeblocks/cbp.tmpl @@ -20,14 +20,6 @@ - {% if ncs36510addfib -%} - - - - - - - {% endif -%} diff --git a/tools/export/codeblocks/ncs36510addfib.py b/tools/export/codeblocks/ncs36510addfib.py deleted file mode 100755 index 6b1e0b88ae..0000000000 --- a/tools/export/codeblocks/ncs36510addfib.py +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/env python - -""" -@copyright (c) 2012-2018 ON Semiconductor. All rights reserved. -ON Semiconductor is supplying this software for use with ON Semiconductor -processor based microcontrollers only. -THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED -OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. -ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, -INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. -""" - -import sys -import itertools -import binascii -import intelhex - -FIB_BASE = 0x2000 -TRIM_BASE = 0x2800 -FLASH_BASE = 0x3000 -FLASHA_SIZE = 0x52000 -FLASHB_BASE = 0x00102000 -FLASHB_SIZE = 0x52000 -FW_REV = 0x01000100 - -def ranges(i): - for _, b in itertools.groupby(enumerate(i), lambda x_y: x_y[1] - x_y[0]): - b = list(b) - yield b[0][1], b[-1][1] - -def add_fib(input_file, output_file): - # Read in hex file - input_hex_file = intelhex.IntelHex() - input_hex_file.loadhex(input_file) - #set padding value to be returned when reading from unspecified address - input_hex_file.padding = 0xFF - # Create new binary data array - output_data = bytearray([0xff]*2048) - - # Get the starting and ending address - addresses = input_hex_file.addresses() - addresses.sort() - start_end_pairs = list(ranges(addresses)) - regions = len(start_end_pairs) - - if regions == 1: - #single range indicating fits within first flash block (<320K) - start, end = start_end_pairs[0] - print("Memory start 0x%08X, end 0x%08X" % (start, end)) - # Compute checksum over the range (don't include data at location of crc) - size = end - start + 1 - data = input_hex_file.tobinarray(start=start, size=size) - crc32 = binascii.crc32(data) & 0xFFFFFFFF - else: - #multiple ranges indicating requires both flash blocks (>320K) - start, end = start_end_pairs[0] - start2, end2 = start_end_pairs[1] - print("Region 1: memory start 0x%08X, end 0x%08X" % (start, end)) - print("Region 2: memory start 0x%08X, end 0x%08X" % (start2, end2)) - # Compute checksum over the range (don't include data at location of crc) - # replace end with end of flash block A - end = FLASHA_SIZE - 1 - size = end - start + 1 - data = input_hex_file.tobinarray(start=start, size=size) - - # replace start2 with base of flash block B - start2 = FLASHB_BASE - size2 = end2 - start2 + 1 - data2 = input_hex_file.tobinarray(start=start2, size=size2) - - #concatenate data and data2 arrays together - data.extend(data2) - crc32 = binascii.crc32(data) & 0xFFFFFFFF - - #replace size with sum of two memory region sizes - size = size + size2 - - assert start >= FLASH_BASE, ("Error - start 0x%x less than begining of user\ - flash area" %start) - - assert regions <= 2, ("Error - more than 2 memory regions found") - - fw_rev = FW_REV - - checksum = (start + size + crc32 + fw_rev) & 0xFFFFFFFF - - print("Writing FIB: base 0x%08X, size 0x%08X, crc32 0x%08X, fw rev 0x%08X,\ - checksum 0x%08X" % (start, size, crc32, fw_rev, checksum)) - -#expected initial values used by daplink to validate that it is a valid bin -#file added as dummy values in this file because the fib area preceeds the -#application area the bootloader will ignore these dummy values -# 00 is stack pointer (RAM address) -# 04 is Reset vector (FLASH address) -# 08 NMI_Handler (FLASH address) -# 0C HardFault_Handler(FLASH address) -# 10 dummy - dummy_sp = 0x3FFFFC00 - dummy_reset_vector = 0x00003625 - dummy_nmi_handler = 0x00003761 - dummy_hardfault_handler = 0x00003691 - dummy_blank = 0x00000000 - -#expected fib structure -#typedef struct fib{ - #uint32_t base; /**< Base offset of firmware, indicating what flash the - # firmware is in. (will never be 0x11111111) */ - #uint32_t size; /**< Size of the firmware */ - #uint32_t crc; /**< CRC32 for firmware correctness check */ - #uint32_t rev; /**< Revision number */ - #uint32_t checksum; /**< Check-sum of information block */ -#}fib_t, *fib_pt; - - # Write FIB to the file in little endian - output_data[0] = (dummy_sp >> 0) & 0xFF - output_data[1] = (dummy_sp >> 8) & 0xFF - output_data[2] = (dummy_sp >> 16) & 0xFF - output_data[3] = (dummy_sp >> 24) & 0xFF - - output_data[4] = (dummy_reset_vector >> 0) & 0xFF - output_data[5] = (dummy_reset_vector >> 8) & 0xFF - output_data[6] = (dummy_reset_vector >> 16) & 0xFF - output_data[7] = (dummy_reset_vector >> 24) & 0xFF - - output_data[8] = (dummy_nmi_handler >> 0) & 0xFF - output_data[9] = (dummy_nmi_handler >> 8) & 0xFF - output_data[10] = (dummy_nmi_handler >> 16) & 0xFF - output_data[11] = (dummy_nmi_handler >> 24) & 0xFF - - output_data[12] = (dummy_hardfault_handler >> 0) & 0xFF - output_data[13] = (dummy_hardfault_handler >> 8) & 0xFF - output_data[14] = (dummy_hardfault_handler >> 16) & 0xFF - output_data[15] = (dummy_hardfault_handler >> 24) & 0xFF - - output_data[16] = (dummy_blank >> 0) & 0xFF - output_data[17] = (dummy_blank >> 8) & 0xFF - output_data[18] = (dummy_blank >> 16) & 0xFF - output_data[19] = (dummy_blank >> 24) & 0xFF - - # Write FIB to the file in little endian - output_data[20] = (start >> 0) & 0xFF - output_data[21] = (start >> 8) & 0xFF - output_data[22] = (start >> 16) & 0xFF - output_data[23] = (start >> 24) & 0xFF - - output_data[24] = (size >> 0) & 0xFF - output_data[25] = (size >> 8) & 0xFF - output_data[26] = (size >> 16) & 0xFF - output_data[27] = (size >> 24) & 0xFF - - output_data[28] = (crc32 >> 0) & 0xFF - output_data[29] = (crc32 >> 8) & 0xFF - output_data[30] = (crc32 >> 16) & 0xFF - output_data[31] = (crc32 >> 24) & 0xFF - - output_data[32] = (fw_rev >> 0) & 0xFF - output_data[33] = (fw_rev >> 8) & 0xFF - output_data[34] = (fw_rev >> 16) & 0xFF - output_data[35] = (fw_rev >> 24) & 0xFF - - output_data[36] = (checksum >> 0) & 0xFF - output_data[37] = (checksum >> 8) & 0xFF - output_data[38] = (checksum >> 16) & 0xFF - output_data[39] = (checksum >> 24) & 0xFF - - f = open(output_file, 'wb') - f.write(output_data) - f.close() - -def main(argv): - if len(argv) < 2: - sys.stderr.write("usage: ncs36510addfib.py input.hex output.bin\n") - sys.exit() - add_fib(argv[0], argv[1]) - -if __name__ == "__main__": - main(sys.argv[1:]) diff --git a/tools/export/codeblocks/ncs36510fib.c b/tools/export/codeblocks/ncs36510fib.c deleted file mode 100644 index 054b340e61..0000000000 --- a/tools/export/codeblocks/ncs36510fib.c +++ /dev/null @@ -1,93 +0,0 @@ -#include - -struct ncs36510fib { - uint32_t dummy_sp; - uint32_t dummy_reset_vector; - uint32_t dummy_nmi_handler; - uint32_t dummy_hardfault_handler; - uint32_t dummy_blank; - uint32_t start; - uint32_t size; - uint32_t crc32; - uint32_t fw_rev; - uint32_t checksum; - uint32_t fill[502]; -}; - -static struct ncs36510fib __attribute__((section(".fib,\"a\",%progbits@"), unused)) ncs36510fib = { - 0x3FFFFC00, - 0x00003625, - 0x00003761, - 0x00003691, - 0x00000000, - 0, - 0, - 0, - 0x01000100, - 0, - { - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff - } -}; diff --git a/tools/export/codeblocks/ncs36510trim.c b/tools/export/codeblocks/ncs36510trim.c deleted file mode 100644 index 8a8cd4367f..0000000000 --- a/tools/export/codeblocks/ncs36510trim.c +++ /dev/null @@ -1,86 +0,0 @@ -#include - -struct ncs36510fib { - uint32_t mac_addr_low; - uint32_t mac_addr_high; - uint32_t clk_32k_trim; - uint32_t clk_32m_trim; - uint32_t rssi; - uint32_t txtune; - uint32_t fill[506]; -}; - -static struct ncs36510fib __attribute__((section(".trim,\"a\",%progbits@"), unused)) ncs36510fib = { - {{"0x{:08x}".format(mac_addr_low)}}, - {{"0x{:08x}".format(mac_addr_high)}}, - {{"0x{:08x}".format(clk_32k_trim)}}, - {{"0x{:08x}".format(clk_32m_trim)}}, - {{"0x{:08x}".format(rssi)}}, - {{"0x{:08x}".format(txtune)}}, - { - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff - } -}; From 8478ec253a636206aacc6614b310fb1d540c4aca Mon Sep 17 00:00:00 2001 From: Thomas Sailer Date: Wed, 28 Mar 2018 00:09:03 +0200 Subject: [PATCH 4/8] copy ncs36510addfib.py into project root, because it cannot be relied to be accessible in the template directory --- tools/export/codeblocks/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/export/codeblocks/__init__.py b/tools/export/codeblocks/__init__.py index 5657df65ee..c45cfa8454 100644 --- a/tools/export/codeblocks/__init__.py +++ b/tools/export/codeblocks/__init__.py @@ -16,10 +16,11 @@ See the License for the specific language governing permissions and limitations under the License. """ import copy +import stat import os -from os.path import splitext, basename +from os.path import splitext, basename, dirname, abspath from os import remove -from shutil import rmtree +from shutil import rmtree, copyfile from tools.targets import TARGET_MAP from tools.export.exporters import Exporter from tools.export.makefile import GccArm From 84fe7ed5fdac693767d32271b881858209c9e38a Mon Sep 17 00:00:00 2001 From: Thomas Sailer Date: Tue, 3 Apr 2018 18:41:09 +0200 Subject: [PATCH 5/8] skip -c, sort compiler options and file list --- tools/export/codeblocks/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/export/codeblocks/__init__.py b/tools/export/codeblocks/__init__.py index c45cfa8454..4e84deb2df 100644 --- a/tools/export/codeblocks/__init__.py +++ b/tools/export/codeblocks/__init__.py @@ -1,7 +1,7 @@ """ mbed SDK Copyright (c) 2014-2017 ARM Limited -Copyright (c) 2018 Code::Blocks +Copyright (c) 2018 ON Semiconductor Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ class CodeBlocks(GccArm): if f == "-include": next_is_include = True continue - if f == 'c': + if f == '-c': continue if next_is_include: f = '-include ' + f @@ -71,24 +71,24 @@ class CodeBlocks(GccArm): debug_flags.append(f) else: comp_flags.append(f) - comp_flags = list(set(comp_flags)) + comp_flags = sorted(list(set(comp_flags))) inc_dirs = [self.filter_dot(s) for s in self.resources.inc_dirs]; inc_dirs = [x for x in inc_dirs if (x is not None and x != '' and x != '.' and not x.startswith('bin') and not x.startswith('obj'))]; - c_sources = [self.filter_dot(s) for s in self.resources.c_sources] + c_sources = sorted([self.filter_dot(s) for s in self.resources.c_sources]) ctx = { 'project_name': self.project_name, 'debug_flags': debug_flags, 'comp_flags': comp_flags, 'ld_flags': self.flags['ld_flags'], - 'headers': list(set([self.filter_dot(s) for s in self.resources.headers])), + 'headers': sorted(list(set([self.filter_dot(s) for s in self.resources.headers]))), 'c_sources': c_sources, - 's_sources': [self.filter_dot(s) for s in self.resources.s_sources], - 'cpp_sources': [self.filter_dot(s) for s in self.resources.cpp_sources], + 's_sources': sorted([self.filter_dot(s) for s in self.resources.s_sources]), + 'cpp_sources': sorted([self.filter_dot(s) for s in self.resources.cpp_sources]), 'include_paths': inc_dirs, 'linker_script': self.filter_dot(self.resources.linker_script), 'libraries': self.resources.libraries, From 7b7d5fcb910e6cb4874ecfeb0f28c4b9aead25b0 Mon Sep 17 00:00:00 2001 From: Thomas Sailer Date: Wed, 4 Apr 2018 17:49:28 +0200 Subject: [PATCH 6/8] exporter: properly export libraries --- tools/export/codeblocks/__init__.py | 17 ++++++++++++++++- tools/export/codeblocks/cbp.tmpl | 6 +++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/tools/export/codeblocks/__init__.py b/tools/export/codeblocks/__init__.py index 4e84deb2df..33ea2f2a71 100644 --- a/tools/export/codeblocks/__init__.py +++ b/tools/export/codeblocks/__init__.py @@ -51,6 +51,16 @@ class CodeBlocks(GccArm): return str_in[2:] return str_in + @staticmethod + def prepare_lib(libname): + if "lib" == libname[:3]: + libname = libname[3:-2] + return "-l" + libname + + @staticmethod + def prepare_sys_lib(libname): + return "-l" + libname + def generate(self): self.resources.win_to_unix() @@ -79,6 +89,10 @@ class CodeBlocks(GccArm): not x.startswith('obj'))]; c_sources = sorted([self.filter_dot(s) for s in self.resources.c_sources]) + libraries = [self.prepare_lib(basename(lib)) for lib + in self.resources.libraries] + sys_libs = [self.prepare_sys_lib(lib) for lib + in self.toolchain.sys_libs] ctx = { 'project_name': self.project_name, @@ -91,7 +105,8 @@ class CodeBlocks(GccArm): 'cpp_sources': sorted([self.filter_dot(s) for s in self.resources.cpp_sources]), 'include_paths': inc_dirs, 'linker_script': self.filter_dot(self.resources.linker_script), - 'libraries': self.resources.libraries, + 'libraries': libraries, + 'sys_libs': sys_libs, 'openocdboard': '' } diff --git a/tools/export/codeblocks/cbp.tmpl b/tools/export/codeblocks/cbp.tmpl index 2a10ac1d96..ab19e9c072 100644 --- a/tools/export/codeblocks/cbp.tmpl +++ b/tools/export/codeblocks/cbp.tmpl @@ -45,8 +45,12 @@ {% endfor -%} + + {% for f in sys_libs -%} + + {% endfor -%} {% for f in libraries -%} - + {% endfor -%} {% for f in headers -%} From 69d7c530f54d5fc16dc3a2ef22c7305c3f090dd8 Mon Sep 17 00:00:00 2001 From: Thomas Sailer Date: Thu, 5 Apr 2018 16:11:29 +0200 Subject: [PATCH 7/8] proper compile flags for Release target; add fib/trim files to .mbedignore so mbed compile doesn't pick them up --- tools/export/codeblocks/__init__.py | 2 ++ tools/export/codeblocks/cbp.tmpl | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/tools/export/codeblocks/__init__.py b/tools/export/codeblocks/__init__.py index 33ea2f2a71..ec853eddf8 100644 --- a/tools/export/codeblocks/__init__.py +++ b/tools/export/codeblocks/__init__.py @@ -66,6 +66,7 @@ class CodeBlocks(GccArm): comp_flags = [] debug_flags = [] + release_flags = [ '-Os', '-g1' ] next_is_include = False for f in self.flags['c_flags'] + self.flags['cxx_flags'] + self.flags['common_flags']: f = f.strip() @@ -97,6 +98,7 @@ class CodeBlocks(GccArm): ctx = { 'project_name': self.project_name, 'debug_flags': debug_flags, + 'release_flags': release_flags, 'comp_flags': comp_flags, 'ld_flags': self.flags['ld_flags'], 'headers': sorted(list(set([self.filter_dot(s) for s in self.resources.headers]))), diff --git a/tools/export/codeblocks/cbp.tmpl b/tools/export/codeblocks/cbp.tmpl index ab19e9c072..3429693b87 100644 --- a/tools/export/codeblocks/cbp.tmpl +++ b/tools/export/codeblocks/cbp.tmpl @@ -27,6 +27,12 @@