Nathan Yonkee
/
Nucleo_sinewave_output_copy
init
mbed-os/tools/targets/NCS.py@10:46a4cf51ee38, 2018-03-02 (annotated)
- Committer:
- Nathan Yonkee
- Date:
- Fri Mar 02 07:16:49 2018 -0700
- Revision:
- 10:46a4cf51ee38
- Parent:
- 9:d58e77ebd769
remove mbed-os
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nathan Yonkee |
9:d58e77ebd769 | 1 | """ |
Nathan Yonkee |
9:d58e77ebd769 | 2 | @copyright (c) 2012 ON Semiconductor. All rights reserved. |
Nathan Yonkee |
9:d58e77ebd769 | 3 | ON Semiconductor is supplying this software for use with ON Semiconductor |
Nathan Yonkee |
9:d58e77ebd769 | 4 | processor based microcontrollers only. |
Nathan Yonkee |
9:d58e77ebd769 | 5 | THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
Nathan Yonkee |
9:d58e77ebd769 | 6 | OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
Nathan Yonkee |
9:d58e77ebd769 | 7 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
Nathan Yonkee |
9:d58e77ebd769 | 8 | ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, |
Nathan Yonkee |
9:d58e77ebd769 | 9 | INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
Nathan Yonkee |
9:d58e77ebd769 | 10 | """ |
Nathan Yonkee |
9:d58e77ebd769 | 11 | |
Nathan Yonkee |
9:d58e77ebd769 | 12 | from __future__ import absolute_import |
Nathan Yonkee |
9:d58e77ebd769 | 13 | from __future__ import print_function |
Nathan Yonkee |
9:d58e77ebd769 | 14 | |
Nathan Yonkee |
9:d58e77ebd769 | 15 | import itertools |
Nathan Yonkee |
9:d58e77ebd769 | 16 | import binascii |
Nathan Yonkee |
9:d58e77ebd769 | 17 | import intelhex |
Nathan Yonkee |
9:d58e77ebd769 | 18 | from tools.config import Config |
Nathan Yonkee |
9:d58e77ebd769 | 19 | |
Nathan Yonkee |
9:d58e77ebd769 | 20 | FIB_BASE = 0x2000 |
Nathan Yonkee |
9:d58e77ebd769 | 21 | TRIM_BASE = 0x2800 |
Nathan Yonkee |
9:d58e77ebd769 | 22 | FLASH_BASE = 0x3000 |
Nathan Yonkee |
9:d58e77ebd769 | 23 | FLASHA_SIZE = 0x52000 |
Nathan Yonkee |
9:d58e77ebd769 | 24 | FLASHB_BASE = 0x00102000 |
Nathan Yonkee |
9:d58e77ebd769 | 25 | FLASHB_SIZE = 0x52000 |
Nathan Yonkee |
9:d58e77ebd769 | 26 | FW_REV = 0x01000100 |
Nathan Yonkee |
9:d58e77ebd769 | 27 | |
Nathan Yonkee |
9:d58e77ebd769 | 28 | def ranges(i): |
Nathan Yonkee |
9:d58e77ebd769 | 29 | for _, b in itertools.groupby(enumerate(i), lambda x_y: x_y[1] - x_y[0]): |
Nathan Yonkee |
9:d58e77ebd769 | 30 | b = list(b) |
Nathan Yonkee |
9:d58e77ebd769 | 31 | yield b[0][1], b[-1][1] |
Nathan Yonkee |
9:d58e77ebd769 | 32 | |
Nathan Yonkee |
9:d58e77ebd769 | 33 | |
Nathan Yonkee |
9:d58e77ebd769 | 34 | def add_fib_at_start(arginput): |
Nathan Yonkee |
9:d58e77ebd769 | 35 | input_file = arginput + ".hex" |
Nathan Yonkee |
9:d58e77ebd769 | 36 | file_name_hex = arginput + ".hex" |
Nathan Yonkee |
9:d58e77ebd769 | 37 | file_name_bin = arginput + ".bin" |
Nathan Yonkee |
9:d58e77ebd769 | 38 | |
Nathan Yonkee |
9:d58e77ebd769 | 39 | # Read in hex file |
Nathan Yonkee |
9:d58e77ebd769 | 40 | input_hex_file = intelhex.IntelHex() |
Nathan Yonkee |
9:d58e77ebd769 | 41 | input_hex_file.loadhex(input_file) |
Nathan Yonkee |
9:d58e77ebd769 | 42 | #set padding value to be returned when reading from unspecified address |
Nathan Yonkee |
9:d58e77ebd769 | 43 | input_hex_file.padding = 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 44 | # Create new hex file |
Nathan Yonkee |
9:d58e77ebd769 | 45 | output_hex_file = intelhex.IntelHex() |
Nathan Yonkee |
9:d58e77ebd769 | 46 | |
Nathan Yonkee |
9:d58e77ebd769 | 47 | # Get the starting and ending address |
Nathan Yonkee |
9:d58e77ebd769 | 48 | addresses = input_hex_file.addresses() |
Nathan Yonkee |
9:d58e77ebd769 | 49 | addresses.sort() |
Nathan Yonkee |
9:d58e77ebd769 | 50 | start_end_pairs = list(ranges(addresses)) |
Nathan Yonkee |
9:d58e77ebd769 | 51 | regions = len(start_end_pairs) |
Nathan Yonkee |
9:d58e77ebd769 | 52 | |
Nathan Yonkee |
9:d58e77ebd769 | 53 | if regions == 1: |
Nathan Yonkee |
9:d58e77ebd769 | 54 | #single range indicating fits within first flash block (<320K) |
Nathan Yonkee |
9:d58e77ebd769 | 55 | start, end = start_end_pairs[0] |
Nathan Yonkee |
9:d58e77ebd769 | 56 | print("Memory start 0x%08X, end 0x%08X" % (start, end)) |
Nathan Yonkee |
9:d58e77ebd769 | 57 | # Compute checksum over the range (don't include data at location of crc) |
Nathan Yonkee |
9:d58e77ebd769 | 58 | size = end - start + 1 |
Nathan Yonkee |
9:d58e77ebd769 | 59 | data = input_hex_file.tobinarray(start=start, size=size) |
Nathan Yonkee |
9:d58e77ebd769 | 60 | crc32 = binascii.crc32(data) & 0xFFFFFFFF |
Nathan Yonkee |
9:d58e77ebd769 | 61 | else: |
Nathan Yonkee |
9:d58e77ebd769 | 62 | #multiple ranges indicating requires both flash blocks (>320K) |
Nathan Yonkee |
9:d58e77ebd769 | 63 | start, end = start_end_pairs[0] |
Nathan Yonkee |
9:d58e77ebd769 | 64 | start2, end2 = start_end_pairs[1] |
Nathan Yonkee |
9:d58e77ebd769 | 65 | print("Region 1: memory start 0x%08X, end 0x%08X" % (start, end)) |
Nathan Yonkee |
9:d58e77ebd769 | 66 | print("Region 2: memory start 0x%08X, end 0x%08X" % (start2, end2)) |
Nathan Yonkee |
9:d58e77ebd769 | 67 | # Compute checksum over the range (don't include data at location of crc) |
Nathan Yonkee |
9:d58e77ebd769 | 68 | # replace end with end of flash block A |
Nathan Yonkee |
9:d58e77ebd769 | 69 | end = FLASHA_SIZE - 1 |
Nathan Yonkee |
9:d58e77ebd769 | 70 | size = end - start + 1 |
Nathan Yonkee |
9:d58e77ebd769 | 71 | data = input_hex_file.tobinarray(start=start, size=size) |
Nathan Yonkee |
9:d58e77ebd769 | 72 | |
Nathan Yonkee |
9:d58e77ebd769 | 73 | # replace start2 with base of flash block B |
Nathan Yonkee |
9:d58e77ebd769 | 74 | start2 = FLASHB_BASE |
Nathan Yonkee |
9:d58e77ebd769 | 75 | size2 = end2 - start2 + 1 |
Nathan Yonkee |
9:d58e77ebd769 | 76 | data2 = input_hex_file.tobinarray(start=start2, size=size2) |
Nathan Yonkee |
9:d58e77ebd769 | 77 | |
Nathan Yonkee |
9:d58e77ebd769 | 78 | #concatenate data and data2 arrays together |
Nathan Yonkee |
9:d58e77ebd769 | 79 | data.extend(data2) |
Nathan Yonkee |
9:d58e77ebd769 | 80 | crc32 = binascii.crc32(data) & 0xFFFFFFFF |
Nathan Yonkee |
9:d58e77ebd769 | 81 | |
Nathan Yonkee |
9:d58e77ebd769 | 82 | #replace size with sum of two memory region sizes |
Nathan Yonkee |
9:d58e77ebd769 | 83 | size = size + size2 |
Nathan Yonkee |
9:d58e77ebd769 | 84 | |
Nathan Yonkee |
9:d58e77ebd769 | 85 | assert start >= FLASH_BASE, ("Error - start 0x%x less than begining of user\ |
Nathan Yonkee |
9:d58e77ebd769 | 86 | flash area" %start) |
Nathan Yonkee |
9:d58e77ebd769 | 87 | |
Nathan Yonkee |
9:d58e77ebd769 | 88 | assert regions <= 2, ("Error - more than 2 memory regions found") |
Nathan Yonkee |
9:d58e77ebd769 | 89 | |
Nathan Yonkee |
9:d58e77ebd769 | 90 | fw_rev = FW_REV |
Nathan Yonkee |
9:d58e77ebd769 | 91 | |
Nathan Yonkee |
9:d58e77ebd769 | 92 | checksum = (start + size + crc32 + fw_rev) & 0xFFFFFFFF |
Nathan Yonkee |
9:d58e77ebd769 | 93 | |
Nathan Yonkee |
9:d58e77ebd769 | 94 | print("Writing FIB: base 0x%08X, size 0x%08X, crc32 0x%08X, fw rev 0x%08X,\ |
Nathan Yonkee |
9:d58e77ebd769 | 95 | checksum 0x%08X" % (start, size, crc32, fw_rev, checksum)) |
Nathan Yonkee |
9:d58e77ebd769 | 96 | |
Nathan Yonkee |
9:d58e77ebd769 | 97 | #expected initial values used by daplink to validate that it is a valid bin |
Nathan Yonkee |
9:d58e77ebd769 | 98 | #file added as dummy values in this file because the fib area preceeds the |
Nathan Yonkee |
9:d58e77ebd769 | 99 | #application area the bootloader will ignore these dummy values |
Nathan Yonkee |
9:d58e77ebd769 | 100 | # 00 is stack pointer (RAM address) |
Nathan Yonkee |
9:d58e77ebd769 | 101 | # 04 is Reset vector (FLASH address) |
Nathan Yonkee |
9:d58e77ebd769 | 102 | # 08 NMI_Handler (FLASH address) |
Nathan Yonkee |
9:d58e77ebd769 | 103 | # 0C HardFault_Handler(FLASH address) |
Nathan Yonkee |
9:d58e77ebd769 | 104 | # 10 dummy |
Nathan Yonkee |
9:d58e77ebd769 | 105 | dummy_sp = 0x3FFFFC00 |
Nathan Yonkee |
9:d58e77ebd769 | 106 | dummy_reset_vector = 0x00003625 |
Nathan Yonkee |
9:d58e77ebd769 | 107 | dummy_nmi_handler = 0x00003761 |
Nathan Yonkee |
9:d58e77ebd769 | 108 | dummy_hardfault_handler = 0x00003691 |
Nathan Yonkee |
9:d58e77ebd769 | 109 | dummy_blank = 0x00000000 |
Nathan Yonkee |
9:d58e77ebd769 | 110 | |
Nathan Yonkee |
9:d58e77ebd769 | 111 | #expected fib structure |
Nathan Yonkee |
9:d58e77ebd769 | 112 | #typedef struct fib{ |
Nathan Yonkee |
9:d58e77ebd769 | 113 | #uint32_t base; /**< Base offset of firmware, indicating what flash the |
Nathan Yonkee |
9:d58e77ebd769 | 114 | # firmware is in. (will never be 0x11111111) */ |
Nathan Yonkee |
9:d58e77ebd769 | 115 | #uint32_t size; /**< Size of the firmware */ |
Nathan Yonkee |
9:d58e77ebd769 | 116 | #uint32_t crc; /**< CRC32 for firmware correctness check */ |
Nathan Yonkee |
9:d58e77ebd769 | 117 | #uint32_t rev; /**< Revision number */ |
Nathan Yonkee |
9:d58e77ebd769 | 118 | #uint32_t checksum; /**< Check-sum of information block */ |
Nathan Yonkee |
9:d58e77ebd769 | 119 | #}fib_t, *fib_pt; |
Nathan Yonkee |
9:d58e77ebd769 | 120 | |
Nathan Yonkee |
9:d58e77ebd769 | 121 | fib_start = FIB_BASE |
Nathan Yonkee |
9:d58e77ebd769 | 122 | dummy_fib_size = 20 |
Nathan Yonkee |
9:d58e77ebd769 | 123 | fib_size = 20 |
Nathan Yonkee |
9:d58e77ebd769 | 124 | trim_size = 24 |
Nathan Yonkee |
9:d58e77ebd769 | 125 | user_code_start = FLASH_BASE |
Nathan Yonkee |
9:d58e77ebd769 | 126 | trim_area_start = TRIM_BASE |
Nathan Yonkee |
9:d58e77ebd769 | 127 | |
Nathan Yonkee |
9:d58e77ebd769 | 128 | # Write FIB to the file in little endian |
Nathan Yonkee |
9:d58e77ebd769 | 129 | output_hex_file[fib_start + 0] = (dummy_sp >> 0) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 130 | output_hex_file[fib_start + 1] = (dummy_sp >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 131 | output_hex_file[fib_start + 2] = (dummy_sp >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 132 | output_hex_file[fib_start + 3] = (dummy_sp >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 133 | |
Nathan Yonkee |
9:d58e77ebd769 | 134 | output_hex_file[fib_start + 4] = (dummy_reset_vector >> 0) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 135 | output_hex_file[fib_start + 5] = (dummy_reset_vector >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 136 | output_hex_file[fib_start + 6] = (dummy_reset_vector >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 137 | output_hex_file[fib_start + 7] = (dummy_reset_vector >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 138 | |
Nathan Yonkee |
9:d58e77ebd769 | 139 | output_hex_file[fib_start + 8] = (dummy_nmi_handler >> 0) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 140 | output_hex_file[fib_start + 9] = (dummy_nmi_handler >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 141 | output_hex_file[fib_start + 10] = (dummy_nmi_handler >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 142 | output_hex_file[fib_start + 11] = (dummy_nmi_handler >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 143 | |
Nathan Yonkee |
9:d58e77ebd769 | 144 | output_hex_file[fib_start + 12] = (dummy_hardfault_handler >> 0) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 145 | output_hex_file[fib_start + 13] = (dummy_hardfault_handler >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 146 | output_hex_file[fib_start + 14] = (dummy_hardfault_handler >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 147 | output_hex_file[fib_start + 15] = (dummy_hardfault_handler >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 148 | |
Nathan Yonkee |
9:d58e77ebd769 | 149 | output_hex_file[fib_start + 16] = (dummy_blank >> 0) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 150 | output_hex_file[fib_start + 17] = (dummy_blank >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 151 | output_hex_file[fib_start + 18] = (dummy_blank >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 152 | output_hex_file[fib_start + 19] = (dummy_blank >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 153 | |
Nathan Yonkee |
9:d58e77ebd769 | 154 | # Write FIB to the file in little endian |
Nathan Yonkee |
9:d58e77ebd769 | 155 | output_hex_file[fib_start + 20] = (start >> 0) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 156 | output_hex_file[fib_start + 21] = (start >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 157 | output_hex_file[fib_start + 22] = (start >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 158 | output_hex_file[fib_start + 23] = (start >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 159 | |
Nathan Yonkee |
9:d58e77ebd769 | 160 | output_hex_file[fib_start + 24] = (size >> 0) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 161 | output_hex_file[fib_start + 25] = (size >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 162 | output_hex_file[fib_start + 26] = (size >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 163 | output_hex_file[fib_start + 27] = (size >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 164 | |
Nathan Yonkee |
9:d58e77ebd769 | 165 | output_hex_file[fib_start + 28] = (crc32 >> 0) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 166 | output_hex_file[fib_start + 29] = (crc32 >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 167 | output_hex_file[fib_start + 30] = (crc32 >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 168 | output_hex_file[fib_start + 31] = (crc32 >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 169 | |
Nathan Yonkee |
9:d58e77ebd769 | 170 | output_hex_file[fib_start + 32] = (fw_rev >> 0) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 171 | output_hex_file[fib_start + 33] = (fw_rev >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 172 | output_hex_file[fib_start + 34] = (fw_rev >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 173 | output_hex_file[fib_start + 35] = (fw_rev >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 174 | |
Nathan Yonkee |
9:d58e77ebd769 | 175 | output_hex_file[fib_start + 36] = (checksum >> 0) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 176 | output_hex_file[fib_start + 37] = (checksum >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 177 | output_hex_file[fib_start + 38] = (checksum >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 178 | output_hex_file[fib_start + 39] = (checksum >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 179 | |
Nathan Yonkee |
9:d58e77ebd769 | 180 | #pad the rest of the file |
Nathan Yonkee |
9:d58e77ebd769 | 181 | for i in range(fib_start + dummy_fib_size + fib_size, trim_area_start): |
Nathan Yonkee |
9:d58e77ebd769 | 182 | output_hex_file[i] = 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 183 | |
Nathan Yonkee |
9:d58e77ebd769 | 184 | # Read in configuration data from the config parameter in targets.json |
Nathan Yonkee |
9:d58e77ebd769 | 185 | configData = Config('NCS36510') |
Nathan Yonkee |
9:d58e77ebd769 | 186 | paramData = configData.get_target_config_data() |
Nathan Yonkee |
9:d58e77ebd769 | 187 | for v in paramData.values(): |
Nathan Yonkee |
9:d58e77ebd769 | 188 | if (v.name == "target.mac-addr-high"): |
Nathan Yonkee |
9:d58e77ebd769 | 189 | mac_addr_high = int(v.value, 16) |
Nathan Yonkee |
9:d58e77ebd769 | 190 | elif (v.name == "target.mac-addr-low"): |
Nathan Yonkee |
9:d58e77ebd769 | 191 | mac_addr_low = int(v.value,16) |
Nathan Yonkee |
9:d58e77ebd769 | 192 | elif (v.name == "target.32KHz-clk-trim"): |
Nathan Yonkee |
9:d58e77ebd769 | 193 | clk_32k_trim = int(v.value,16) |
Nathan Yonkee |
9:d58e77ebd769 | 194 | elif (v.name == "target.32MHz-clk-trim"): |
Nathan Yonkee |
9:d58e77ebd769 | 195 | clk_32m_trim = int(v.value,16) |
Nathan Yonkee |
9:d58e77ebd769 | 196 | elif (v.name == "target.rssi-trim"): |
Nathan Yonkee |
9:d58e77ebd769 | 197 | rssi = int(v.value,16) |
Nathan Yonkee |
9:d58e77ebd769 | 198 | elif (v.name == "target.txtune-trim"): |
Nathan Yonkee |
9:d58e77ebd769 | 199 | txtune = int(v.value,16) |
Nathan Yonkee |
9:d58e77ebd769 | 200 | else: |
Nathan Yonkee |
9:d58e77ebd769 | 201 | print("Not a valid param") |
Nathan Yonkee |
9:d58e77ebd769 | 202 | |
Nathan Yonkee |
9:d58e77ebd769 | 203 | output_hex_file[trim_area_start + 0] = mac_addr_low & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 204 | output_hex_file[trim_area_start + 1] = (mac_addr_low >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 205 | output_hex_file[trim_area_start + 2] = (mac_addr_low >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 206 | output_hex_file[trim_area_start + 3] = (mac_addr_low >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 207 | |
Nathan Yonkee |
9:d58e77ebd769 | 208 | output_hex_file[trim_area_start + 4] = mac_addr_high & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 209 | output_hex_file[trim_area_start + 5] = (mac_addr_high >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 210 | output_hex_file[trim_area_start + 6] = (mac_addr_high >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 211 | output_hex_file[trim_area_start + 7] = (mac_addr_high >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 212 | |
Nathan Yonkee |
9:d58e77ebd769 | 213 | output_hex_file[trim_area_start + 8] = clk_32k_trim & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 214 | output_hex_file[trim_area_start + 9] = (clk_32k_trim >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 215 | output_hex_file[trim_area_start + 10] = (clk_32k_trim >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 216 | output_hex_file[trim_area_start + 11] = (clk_32k_trim >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 217 | |
Nathan Yonkee |
9:d58e77ebd769 | 218 | output_hex_file[trim_area_start + 12] = clk_32m_trim & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 219 | output_hex_file[trim_area_start + 13] = (clk_32m_trim >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 220 | output_hex_file[trim_area_start + 14] = (clk_32m_trim >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 221 | output_hex_file[trim_area_start + 15] = (clk_32m_trim >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 222 | |
Nathan Yonkee |
9:d58e77ebd769 | 223 | output_hex_file[trim_area_start + 16] = rssi & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 224 | output_hex_file[trim_area_start + 17] = (rssi >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 225 | output_hex_file[trim_area_start + 18] = (rssi >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 226 | output_hex_file[trim_area_start + 19] = (rssi >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 227 | |
Nathan Yonkee |
9:d58e77ebd769 | 228 | output_hex_file[trim_area_start + 20] = txtune & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 229 | output_hex_file[trim_area_start + 21] = (txtune >> 8) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 230 | output_hex_file[trim_area_start + 22] = (txtune >> 16) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 231 | output_hex_file[trim_area_start + 23] = (txtune >> 24) & 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 232 | |
Nathan Yonkee |
9:d58e77ebd769 | 233 | # pad the rest of the area with 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 234 | for i in range(trim_area_start + trim_size, user_code_start): |
Nathan Yonkee |
9:d58e77ebd769 | 235 | output_hex_file[i] = 0xFF |
Nathan Yonkee |
9:d58e77ebd769 | 236 | |
Nathan Yonkee |
9:d58e77ebd769 | 237 | #merge two hex files |
Nathan Yonkee |
9:d58e77ebd769 | 238 | output_hex_file.merge(input_hex_file, overlap='error') |
Nathan Yonkee |
9:d58e77ebd769 | 239 | |
Nathan Yonkee |
9:d58e77ebd769 | 240 | # Write out file(s) |
Nathan Yonkee |
9:d58e77ebd769 | 241 | output_hex_file.tofile(file_name_hex, 'hex') |