mirror of https://github.com/ARMmbed/mbed-os.git
Code::Blocks project file exporter
parent
1529ad62c2
commit
ca86cbf565
|
@ -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))
|
||||
|
|
|
@ -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 = """
|
||||
|
|
|
@ -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)
|
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="{{project_name}}" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="arm-elf-gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="bin/Debug/{{project_name}}.elf" prefix_auto="1" extension_auto="0" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="arm-elf-gcc" />
|
||||
<Option use_console_runner="0" />
|
||||
<Compiler>
|
||||
{% for f in debug_flags -%}
|
||||
<Add option="{{f}}" />
|
||||
{% endfor -%}
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option='-Wl,-Map,"bin/Debug/{{project_name}}.map"' />
|
||||
</Linker>
|
||||
{% if ncs36510addfib -%}
|
||||
<ExtraCommands>
|
||||
<Add after="arm-none-eabi-objcopy -O ihex -R .fib -R .trim bin/Debug/{{project_name}}.elf bin/Debug/{{project_name}}.hex" />
|
||||
<Add after="mbed-os/tools/export/codeblocks/ncs36510addfib.py bin/Debug/{{project_name}}.hex bin/Debug/{{project_name}}.fib" />
|
||||
<Add after="arm-none-eabi-objcopy --update-section .fib=bin/Debug/{{project_name}}.fib bin/Debug/{{project_name}}.elf" />
|
||||
<Add after="arm-none-eabi-objcopy -O ihex bin/Debug/{{project_name}}.elf bin/Debug/{{project_name}}.hex" />
|
||||
</ExtraCommands>
|
||||
{% endif -%}
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="bin/Release/{{project_name}}.elf" prefix_auto="1" extension_auto="0" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="arm-elf-gcc" />
|
||||
<Option use_console_runner="0" />
|
||||
<Linker>
|
||||
<Add option='-Wl,-Map,"bin/Release/{{project_name}}.map"' />
|
||||
</Linker>
|
||||
{% if ncs36510addfib -%}
|
||||
<ExtraCommands>
|
||||
<Add after="arm-none-eabi-objcopy -O ihex -R .fib -R .trim bin/Release/{{project_name}}.elf bin/Release/{{project_name}}.hex" />
|
||||
<Add after="mbed-os/tools/export/codeblocks/ncs36510addfib.py bin/Release/{{project_name}}.hex bin/Release/{{project_name}}.fib" />
|
||||
<Add after="arm-none-eabi-objcopy --update-section .fib=bin/Release/{{project_name}}.fib bin/Release/{{project_name}}.elf" />
|
||||
<Add after="arm-none-eabi-objcopy -O ihex bin/Release/{{project_name}}.elf bin/Release/{{project_name}}.hex" />
|
||||
</ExtraCommands>
|
||||
{% endif -%}
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
{% for f in comp_flags -%}
|
||||
<Add option="{{f}}" />
|
||||
{% endfor -%}
|
||||
{% for f in include_paths -%}
|
||||
<Add directory="{{f}}" />
|
||||
{% endfor -%}
|
||||
</Compiler>
|
||||
<Linker>
|
||||
{% for f in ld_flags -%}
|
||||
<Add option="{{f}}" />
|
||||
{% endfor -%}
|
||||
<Add option="-T {{linker_script}}" />
|
||||
{% for f in libraries -%}
|
||||
<Add library="{{f}}" />
|
||||
{% endfor -%}
|
||||
</Linker>
|
||||
{% for f in headers -%}
|
||||
<Unit filename="{{f}}"/>
|
||||
{% endfor -%}
|
||||
{% for f in c_sources -%}
|
||||
<Unit filename="{{f}}">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
{% endfor -%}
|
||||
{% for f in s_sources -%}
|
||||
<Unit filename="{{f}}">
|
||||
<Option compilerVar="CPP" />
|
||||
</Unit>
|
||||
{% endfor -%}
|
||||
{% for f in cpp_sources -%}
|
||||
<Unit filename="{{f}}">
|
||||
<Option compilerVar="CPP" />
|
||||
</Unit>
|
||||
{% endfor -%}
|
||||
<Extensions>
|
||||
{% if openocdboard != '' -%}
|
||||
<debugger>
|
||||
<remote_debugging target="Release">
|
||||
<options conn_type="3" serial_baud="115200" pipe_command="openocd -p -l openocd.log -f {{openocdboard}}" additional_cmds='monitor reset halt
monitor flash write_image erase "bin/Release/{{project_name}}.elf"
file "bin/Release/{{project_name}}.elf"
monitor reset halt
' extended_remote="1" />
|
||||
</remote_debugging>
|
||||
<remote_debugging target="Debug">
|
||||
<options conn_type="3" serial_baud="115200" pipe_command="openocd -p -l openocd.log -f {{openocdboard}}" additional_cmds='monitor reset halt
monitor flash write_image erase "bin/Debug/{{project_name}}.elf"
file "bin/Debug/{{project_name}}.elf"
monitor reset halt
' extended_remote="1" />
|
||||
</remote_debugging>
|
||||
</debugger>
|
||||
{% endif -%}
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
|
@ -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:])
|
|
@ -0,0 +1,93 @@
|
|||
#include <stdint.h>
|
||||
|
||||
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
|
||||
}
|
||||
};
|
|
@ -0,0 +1,86 @@
|
|||
#include <stdint.h>
|
||||
|
||||
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
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue