Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.
Upstream: https://github.com/ARMmbed/DAPLink
docs/PORT_TARGET_FAMILY.md@0:01f31e923fe2, 2020-04-07 (annotated)
- Committer:
- Pawel Zarembski
- Date:
- Tue Apr 07 12:55:42 2020 +0200
- Revision:
- 0:01f31e923fe2
hani: DAPLink with reset workaround
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pawel Zarembski |
0:01f31e923fe2 | 1 | # Adding A New Target Family |
Pawel Zarembski |
0:01f31e923fe2 | 2 | Adding new target family support requires creating a flash algo blob and the implementation for target family api. Target support is added to the `source/family/<mfg>/<target>` directory. At minimum, 3 files are needed. The first is `source/target/<mfg>/target_reset.c` |
Pawel Zarembski |
0:01f31e923fe2 | 3 | |
Pawel Zarembski |
0:01f31e923fe2 | 4 | ```c |
Pawel Zarembski |
0:01f31e923fe2 | 5 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 6 | * @file target_reset.c |
Pawel Zarembski |
0:01f31e923fe2 | 7 | * @brief Target reset for the new target |
Pawel Zarembski |
0:01f31e923fe2 | 8 | * |
Pawel Zarembski |
0:01f31e923fe2 | 9 | * DAPLink Interface Firmware |
Pawel Zarembski |
0:01f31e923fe2 | 10 | * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved |
Pawel Zarembski |
0:01f31e923fe2 | 11 | * SPDX-License-Identifier: Apache-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 12 | * |
Pawel Zarembski |
0:01f31e923fe2 | 13 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Pawel Zarembski |
0:01f31e923fe2 | 14 | * not use this file except in compliance with the License. |
Pawel Zarembski |
0:01f31e923fe2 | 15 | * You may obtain a copy of the License at |
Pawel Zarembski |
0:01f31e923fe2 | 16 | * |
Pawel Zarembski |
0:01f31e923fe2 | 17 | * http://www.apache.org/licenses/LICENSE-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 18 | * |
Pawel Zarembski |
0:01f31e923fe2 | 19 | * Unless required by applicable law or agreed to in writing, software |
Pawel Zarembski |
0:01f31e923fe2 | 20 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Pawel Zarembski |
0:01f31e923fe2 | 21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Pawel Zarembski |
0:01f31e923fe2 | 22 | * See the License for the specific language governing permissions and |
Pawel Zarembski |
0:01f31e923fe2 | 23 | * limitations under the License. |
Pawel Zarembski |
0:01f31e923fe2 | 24 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 25 | |
Pawel Zarembski |
0:01f31e923fe2 | 26 | #include "target_reset.h" |
Pawel Zarembski |
0:01f31e923fe2 | 27 | #include "swd_host.h" |
Pawel Zarembski |
0:01f31e923fe2 | 28 | #include "target_family.h" |
Pawel Zarembski |
0:01f31e923fe2 | 29 | |
Pawel Zarembski |
0:01f31e923fe2 | 30 | static void target_before_init_debug(void) |
Pawel Zarembski |
0:01f31e923fe2 | 31 | { |
Pawel Zarembski |
0:01f31e923fe2 | 32 | // any target specific sequences needed before attaching |
Pawel Zarembski |
0:01f31e923fe2 | 33 | // to the DAP across JTAG or SWD |
Pawel Zarembski |
0:01f31e923fe2 | 34 | return; |
Pawel Zarembski |
0:01f31e923fe2 | 35 | } |
Pawel Zarembski |
0:01f31e923fe2 | 36 | |
Pawel Zarembski |
0:01f31e923fe2 | 37 | static uint8_t target_unlock_sequence(void) |
Pawel Zarembski |
0:01f31e923fe2 | 38 | { |
Pawel Zarembski |
0:01f31e923fe2 | 39 | // if the device can secure the flash and there is a way to |
Pawel Zarembski |
0:01f31e923fe2 | 40 | // erase all it should be implemented here. |
Pawel Zarembski |
0:01f31e923fe2 | 41 | return 1; |
Pawel Zarembski |
0:01f31e923fe2 | 42 | } |
Pawel Zarembski |
0:01f31e923fe2 | 43 | |
Pawel Zarembski |
0:01f31e923fe2 | 44 | static uint8_t target_set_state(TARGET_RESET_STATE state) |
Pawel Zarembski |
0:01f31e923fe2 | 45 | { |
Pawel Zarembski |
0:01f31e923fe2 | 46 | // if a custom state machine is needed to set the TARGET_RESET_STATE state |
Pawel Zarembski |
0:01f31e923fe2 | 47 | return 1; |
Pawel Zarembski |
0:01f31e923fe2 | 48 | } |
Pawel Zarembski |
0:01f31e923fe2 | 49 | |
Pawel Zarembski |
0:01f31e923fe2 | 50 | static uint8_t security_bits_set(uint32_t addr, uint8_t *data, uint32_t size) |
Pawel Zarembski |
0:01f31e923fe2 | 51 | { |
Pawel Zarembski |
0:01f31e923fe2 | 52 | // if there are security bits in the programmable flash region |
Pawel Zarembski |
0:01f31e923fe2 | 53 | // a check should be performed. This method is used when programming |
Pawel Zarembski |
0:01f31e923fe2 | 54 | // by drag-n-drop and should refuse to program an image requesting |
Pawel Zarembski |
0:01f31e923fe2 | 55 | // to set the device security. This can be performed with the debug channel |
Pawel Zarembski |
0:01f31e923fe2 | 56 | // if needed. |
Pawel Zarembski |
0:01f31e923fe2 | 57 | return 0; |
Pawel Zarembski |
0:01f31e923fe2 | 58 | } |
Pawel Zarembski |
0:01f31e923fe2 | 59 | |
Pawel Zarembski |
0:01f31e923fe2 | 60 | const target_family_descriptor_t g_target_family = { |
Pawel Zarembski |
0:01f31e923fe2 | 61 | .family_id = myFamilyID, |
Pawel Zarembski |
0:01f31e923fe2 | 62 | .default_reset_type = kHardwareReset, |
Pawel Zarembski |
0:01f31e923fe2 | 63 | .target_before_init_debug = target_before_init_debug, |
Pawel Zarembski |
0:01f31e923fe2 | 64 | .target_unlock_sequence = target_unlock_sequence, |
Pawel Zarembski |
0:01f31e923fe2 | 65 | .target_set_state = target_set_state, |
Pawel Zarembski |
0:01f31e923fe2 | 66 | .security_bits_set = security_bits_set, |
Pawel Zarembski |
0:01f31e923fe2 | 67 | }; |
Pawel Zarembski |
0:01f31e923fe2 | 68 | ``` |
Pawel Zarembski |
0:01f31e923fe2 | 69 | |
Pawel Zarembski |
0:01f31e923fe2 | 70 | The target family api is located in `source/target/target_family.h` and target_reset file can customize the function apis according to the family specification. Family id is a combination of vendor id and an incrementing id. There are predefined family id stubs that can be used for generic reset types; kStub_HWReset_FamilyID, kStub_SWVectReset_FamilyID and kStub_SWSysReset_FamilyID. |
Pawel Zarembski |
0:01f31e923fe2 | 71 | |
Pawel Zarembski |
0:01f31e923fe2 | 72 | ```c |
Pawel Zarembski |
0:01f31e923fe2 | 73 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 74 | * @file target_family.h |
Pawel Zarembski |
0:01f31e923fe2 | 75 | * @brief |
Pawel Zarembski |
0:01f31e923fe2 | 76 | * |
Pawel Zarembski |
0:01f31e923fe2 | 77 | * DAPLink Interface Firmware |
Pawel Zarembski |
0:01f31e923fe2 | 78 | * Copyright (c) 2018-2019, ARM Limited, All Rights Reserved |
Pawel Zarembski |
0:01f31e923fe2 | 79 | * SPDX-License-Identifier: Apache-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 80 | * |
Pawel Zarembski |
0:01f31e923fe2 | 81 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Pawel Zarembski |
0:01f31e923fe2 | 82 | * not use this file except in compliance with the License. |
Pawel Zarembski |
0:01f31e923fe2 | 83 | * You may obtain a copy of the License at |
Pawel Zarembski |
0:01f31e923fe2 | 84 | * |
Pawel Zarembski |
0:01f31e923fe2 | 85 | * http://www.apache.org/licenses/LICENSE-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 86 | * |
Pawel Zarembski |
0:01f31e923fe2 | 87 | * Unless required by applicable law or agreed to in writing, software |
Pawel Zarembski |
0:01f31e923fe2 | 88 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Pawel Zarembski |
0:01f31e923fe2 | 89 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Pawel Zarembski |
0:01f31e923fe2 | 90 | * See the License for the specific language governing permissions and |
Pawel Zarembski |
0:01f31e923fe2 | 91 | * limitations under the License. |
Pawel Zarembski |
0:01f31e923fe2 | 92 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 93 | |
Pawel Zarembski |
0:01f31e923fe2 | 94 | #ifndef TARGET_FAMILY_H |
Pawel Zarembski |
0:01f31e923fe2 | 95 | #define TARGET_FAMILY_H |
Pawel Zarembski |
0:01f31e923fe2 | 96 | |
Pawel Zarembski |
0:01f31e923fe2 | 97 | #include <stdint.h> |
Pawel Zarembski |
0:01f31e923fe2 | 98 | #include <string.h> |
Pawel Zarembski |
0:01f31e923fe2 | 99 | #include "target_reset.h" |
Pawel Zarembski |
0:01f31e923fe2 | 100 | |
Pawel Zarembski |
0:01f31e923fe2 | 101 | #define VENDOR_TO_FAMILY(x, y) (x<<8 | y) |
Pawel Zarembski |
0:01f31e923fe2 | 102 | |
Pawel Zarembski |
0:01f31e923fe2 | 103 | typedef enum _reset_type { |
Pawel Zarembski |
0:01f31e923fe2 | 104 | kHardwareReset=1, |
Pawel Zarembski |
0:01f31e923fe2 | 105 | kSoftwareReset, |
Pawel Zarembski |
0:01f31e923fe2 | 106 | } reset_type_t; |
Pawel Zarembski |
0:01f31e923fe2 | 107 | |
Pawel Zarembski |
0:01f31e923fe2 | 108 | enum _vendor_ids { |
Pawel Zarembski |
0:01f31e923fe2 | 109 | kStub_VendorID = 0, |
Pawel Zarembski |
0:01f31e923fe2 | 110 | kNXP_VendorID = 11, |
Pawel Zarembski |
0:01f31e923fe2 | 111 | kTI_VendorID = 16, |
Pawel Zarembski |
0:01f31e923fe2 | 112 | kNordic_VendorID = 54, |
Pawel Zarembski |
0:01f31e923fe2 | 113 | kToshiba_VendorID = 92, |
Pawel Zarembski |
0:01f31e923fe2 | 114 | kRenesas_VendorID = 117, |
Pawel Zarembski |
0:01f31e923fe2 | 115 | kWiznet_VendorID = 122, |
Pawel Zarembski |
0:01f31e923fe2 | 116 | kRealtek_VendorID = 124, |
Pawel Zarembski |
0:01f31e923fe2 | 117 | }; |
Pawel Zarembski |
0:01f31e923fe2 | 118 | |
Pawel Zarembski |
0:01f31e923fe2 | 119 | typedef enum _family_id { |
Pawel Zarembski |
0:01f31e923fe2 | 120 | kStub_HWReset_FamilyID = VENDOR_TO_FAMILY(kStub_VendorID, 1), |
Pawel Zarembski |
0:01f31e923fe2 | 121 | kStub_SWVectReset_FamilyID = VENDOR_TO_FAMILY(kStub_VendorID, 2), |
Pawel Zarembski |
0:01f31e923fe2 | 122 | kStub_SWSysReset_FamilyID = VENDOR_TO_FAMILY(kStub_VendorID, 3), |
Pawel Zarembski |
0:01f31e923fe2 | 123 | kNXP_KinetisK_FamilyID = VENDOR_TO_FAMILY(kNXP_VendorID, 1), |
Pawel Zarembski |
0:01f31e923fe2 | 124 | kNXP_KinetisL_FamilyID = VENDOR_TO_FAMILY(kNXP_VendorID, 2), |
Pawel Zarembski |
0:01f31e923fe2 | 125 | kNXP_Mimxrt_FamilyID = VENDOR_TO_FAMILY(kNXP_VendorID, 3), |
Pawel Zarembski |
0:01f31e923fe2 | 126 | kNXP_RapidIot_FamilyID = VENDOR_TO_FAMILY(kNXP_VendorID, 4), |
Pawel Zarembski |
0:01f31e923fe2 | 127 | kNXP_KinetisK32W_FamilyID = VENDOR_TO_FAMILY(kNXP_VendorID, 5), |
Pawel Zarembski |
0:01f31e923fe2 | 128 | kNordic_Nrf51_FamilyID = VENDOR_TO_FAMILY(kNordic_VendorID, 1), |
Pawel Zarembski |
0:01f31e923fe2 | 129 | kNordic_Nrf52_FamilyID = VENDOR_TO_FAMILY(kNordic_VendorID, 2), |
Pawel Zarembski |
0:01f31e923fe2 | 130 | kRealtek_Rtl8195am_FamilyID = VENDOR_TO_FAMILY(kRealtek_VendorID, 1), |
Pawel Zarembski |
0:01f31e923fe2 | 131 | kTI_Cc3220sf_FamilyID = VENDOR_TO_FAMILY(kTI_VendorID, 1), |
Pawel Zarembski |
0:01f31e923fe2 | 132 | kToshiba_Tz_FamilyID = VENDOR_TO_FAMILY(kToshiba_VendorID, 1), |
Pawel Zarembski |
0:01f31e923fe2 | 133 | kWiznet_W7500_FamilyID = VENDOR_TO_FAMILY(kWiznet_VendorID, 1), |
Pawel Zarembski |
0:01f31e923fe2 | 134 | kRenesas_FamilyID = VENDOR_TO_FAMILY(kRenesas_VendorID, 1), |
Pawel Zarembski |
0:01f31e923fe2 | 135 | } family_id_t; |
Pawel Zarembski |
0:01f31e923fe2 | 136 | |
Pawel Zarembski |
0:01f31e923fe2 | 137 | typedef struct target_family_descriptor { |
Pawel Zarembski |
0:01f31e923fe2 | 138 | uint16_t family_id; /*!< Use to select or identify target family from defined target family or custom ones */ |
Pawel Zarembski |
0:01f31e923fe2 | 139 | reset_type_t default_reset_type; /*!< Target family can select predefined reset from kHardwareReset and kSoftwareReset */ |
Pawel Zarembski |
0:01f31e923fe2 | 140 | uint32_t soft_reset_type; /*!< Families can override software reset type to VECTRESET or SYSRESETREQ */ |
Pawel Zarembski |
0:01f31e923fe2 | 141 | void (*target_before_init_debug)(void); /*!< Target dependant function before debug initialization */ |
Pawel Zarembski |
0:01f31e923fe2 | 142 | void (*prerun_target_config)(void); /*!< Target specific initialization */ |
Pawel Zarembski |
0:01f31e923fe2 | 143 | uint8_t (*target_unlock_sequence)(void); /*!< Unlock targets that can enter lock state */ |
Pawel Zarembski |
0:01f31e923fe2 | 144 | uint8_t (*security_bits_set)(uint32_t addr, uint8_t *data, uint32_t size); /*!< Check security bits in the programmable flash region */ |
Pawel Zarembski |
0:01f31e923fe2 | 145 | uint8_t (*target_set_state)(TARGET_RESET_STATE state); /*!< Families can customize target debug states in target_reset.h */ |
Pawel Zarembski |
0:01f31e923fe2 | 146 | void (*swd_set_target_reset)(uint8_t asserted); /*!< Families can customize how to send reset to the target */ |
Pawel Zarembski |
0:01f31e923fe2 | 147 | uint8_t (*validate_bin_nvic)(const uint8_t *buf); /*!< Validate a bin file to be flash by drag and drop */ |
Pawel Zarembski |
0:01f31e923fe2 | 148 | uint8_t (*validate_hexfile)(const uint8_t *buf); /*!< Validate a hex file to be flash by drag and drop */ |
Pawel Zarembski |
0:01f31e923fe2 | 149 | } target_family_descriptor_t; |
Pawel Zarembski |
0:01f31e923fe2 | 150 | |
Pawel Zarembski |
0:01f31e923fe2 | 151 | extern const target_family_descriptor_t *g_target_family; |
Pawel Zarembski |
0:01f31e923fe2 | 152 | |
Pawel Zarembski |
0:01f31e923fe2 | 153 | #ifdef __cplusplus |
Pawel Zarembski |
0:01f31e923fe2 | 154 | extern "C" { |
Pawel Zarembski |
0:01f31e923fe2 | 155 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 156 | |
Pawel Zarembski |
0:01f31e923fe2 | 157 | void init_family(void); |
Pawel Zarembski |
0:01f31e923fe2 | 158 | uint8_t target_family_valid(void); |
Pawel Zarembski |
0:01f31e923fe2 | 159 | uint8_t target_set_state(TARGET_RESET_STATE state); |
Pawel Zarembski |
0:01f31e923fe2 | 160 | void swd_set_target_reset(uint8_t asserted); |
Pawel Zarembski |
0:01f31e923fe2 | 161 | |
Pawel Zarembski |
0:01f31e923fe2 | 162 | #ifdef __cplusplus |
Pawel Zarembski |
0:01f31e923fe2 | 163 | } |
Pawel Zarembski |
0:01f31e923fe2 | 164 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 165 | |
Pawel Zarembski |
0:01f31e923fe2 | 166 | #endif |
Pawel Zarembski |
0:01f31e923fe2 | 167 | ``` |
Pawel Zarembski |
0:01f31e923fe2 | 168 | |
Pawel Zarembski |
0:01f31e923fe2 | 169 | A flash algorithm blob is needed to program the target MCUs internal (or external) flash memory. This blob contains position independent functions for erasing, reading and writing to the flash controller. Flash algorithm blobs are created from the [FlashAlgo project.](https://github.com/mbedmicro/FlashAlgo) An example blob is shown below and would be added to `source/family/<mfg>/<targetname>/flash_blob.c` |
Pawel Zarembski |
0:01f31e923fe2 | 170 | |
Pawel Zarembski |
0:01f31e923fe2 | 171 | ```c |
Pawel Zarembski |
0:01f31e923fe2 | 172 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 173 | * @file flash_blob.c |
Pawel Zarembski |
0:01f31e923fe2 | 174 | * @brief Flash algorithm for the new target MCU |
Pawel Zarembski |
0:01f31e923fe2 | 175 | * |
Pawel Zarembski |
0:01f31e923fe2 | 176 | * DAPLink Interface Firmware |
Pawel Zarembski |
0:01f31e923fe2 | 177 | * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved |
Pawel Zarembski |
0:01f31e923fe2 | 178 | * SPDX-License-Identifier: Apache-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 179 | * |
Pawel Zarembski |
0:01f31e923fe2 | 180 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Pawel Zarembski |
0:01f31e923fe2 | 181 | * not use this file except in compliance with the License. |
Pawel Zarembski |
0:01f31e923fe2 | 182 | * You may obtain a copy of the License at |
Pawel Zarembski |
0:01f31e923fe2 | 183 | * |
Pawel Zarembski |
0:01f31e923fe2 | 184 | * http://www.apache.org/licenses/LICENSE-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 185 | * |
Pawel Zarembski |
0:01f31e923fe2 | 186 | * Unless required by applicable law or agreed to in writing, software |
Pawel Zarembski |
0:01f31e923fe2 | 187 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Pawel Zarembski |
0:01f31e923fe2 | 188 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Pawel Zarembski |
0:01f31e923fe2 | 189 | * See the License for the specific language governing permissions and |
Pawel Zarembski |
0:01f31e923fe2 | 190 | * limitations under the License. |
Pawel Zarembski |
0:01f31e923fe2 | 191 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 192 | |
Pawel Zarembski |
0:01f31e923fe2 | 193 | #include "flash_blob.h" |
Pawel Zarembski |
0:01f31e923fe2 | 194 | |
Pawel Zarembski |
0:01f31e923fe2 | 195 | static const uint32_t targetname_blob[] = { |
Pawel Zarembski |
0:01f31e923fe2 | 196 | 0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2, |
Pawel Zarembski |
0:01f31e923fe2 | 197 | 0x4770ba40, 0x4770bac0, 0x4c0cb510, 0xf04068a0, 0x60a00001, 0x301af246, 0xf44f6560, 0x60e07040, |
Pawel Zarembski |
0:01f31e923fe2 | 198 | 0x20012100, 0xf83ef000, 0x65612100, 0xf02168a1, 0x60a10101, 0xbf182800, 0xbd102001, 0x400c0000, |
Pawel Zarembski |
0:01f31e923fe2 | 199 | 0x4684b510, 0xf44f2300, 0xf8505180, 0x1f092b04, 0x1c52d002, 0xe001d0f9, 0xd0131c50, 0x68a04c0c, |
Pawel Zarembski |
0:01f31e923fe2 | 200 | 0x0001f040, 0xf8c460a0, 0x2001c010, 0x200260e0, 0x210060e0, 0xf0002001, 0x4603f815, 0xf02068a0, |
Pawel Zarembski |
0:01f31e923fe2 | 201 | 0x60a00001, 0xbf142b00, 0x20002001, 0x0000bd10, 0x400c0000, 0xf6414902, 0x63c83071, 0x47702000, |
Pawel Zarembski |
0:01f31e923fe2 | 202 | 0x400c0000, 0x4b14b410, 0xc050f8df, 0x201cf8dc, 0x0f16f012, 0xf8dcd014, 0xf0200008, 0xf8cc0005, |
Pawel Zarembski |
0:01f31e923fe2 | 203 | 0xf0120008, 0xbf1e0f02, 0x0001f06f, 0x4770bc10, 0x0f04f012, 0xf04fbf1e, 0xbc1030ff, 0xe0074770, |
Pawel Zarembski |
0:01f31e923fe2 | 204 | 0x428a4002, 0xbc10d102, 0x47702000, 0xd1dd1e5b, 0xf06fbc10, 0x47700002, 0x00989680, 0x400c0000, |
Pawel Zarembski |
0:01f31e923fe2 | 205 | 0x4df0e92d, 0x1cc84604, 0x0603f020, 0x46904859, 0xf0416881, 0x60810101, 0xd9732e07, 0x0f07f014, |
Pawel Zarembski |
0:01f31e923fe2 | 206 | 0xf8d8d011, 0x61041000, 0x60c22201, 0x21086181, 0x210060c1, 0xf7ff4610, 0x2800ffb5, 0x1d24d17e, |
Pawel Zarembski |
0:01f31e923fe2 | 207 | 0x0810f108, 0x484b1f36, 0xf0416881, 0x60810104, 0xbf882e07, 0x0a02f06f, 0xf504d966, 0x46015080, |
Pawel Zarembski |
0:01f31e923fe2 | 208 | 0x010bf36f, 0x42b11b09, 0x4635bf8e, 0x000bf36f, 0xf0151b05, 0xbf180f04, 0x46471f2d, 0x20012100, |
Pawel Zarembski |
0:01f31e923fe2 | 209 | 0xff90f7ff, 0xd13b2800, 0xe0e8f8df, 0x4010f8ce, 0xf8ce2001, 0xf857000c, 0xf8ce0b04, 0xf8570018, |
Pawel Zarembski |
0:01f31e923fe2 | 210 | 0xf8ce0b04, 0x20080018, 0x000cf8ce, 0x0208f1a5, 0xd9332a07, 0x0b08f04f, 0x46dc482f, 0x101cf8de, |
Pawel Zarembski |
0:01f31e923fe2 | 211 | 0x0f16f011, 0xf8ded012, 0xf0200008, 0xf8ce0005, 0xf0110008, 0xbf180f02, 0x0001f06f, 0xf011d10f, |
Pawel Zarembski |
0:01f31e923fe2 | 212 | 0xbf180f04, 0x30fff04f, 0xe007d109, 0x010bea01, 0xd1014561, 0xe0022000, 0xd1df1e40, 0xb1104650, |
Pawel Zarembski |
0:01f31e923fe2 | 213 | 0xe00bb9e0, 0xf857e01c, 0xf8ce0b04, 0xf8570018, 0xf8ce0b04, 0x3a080018, 0xd8cb2a07, 0xeb081b76, |
Pawel Zarembski |
0:01f31e923fe2 | 214 | 0x442c0885, 0xd8982e07, 0x20012100, 0xff3af7ff, 0x4810b920, 0xf0216881, 0xe0000104, 0x6081e00f, |
Pawel Zarembski |
0:01f31e923fe2 | 215 | 0x480cb186, 0x1000f8d8, 0x22016104, 0x618160c2, 0x60c12108, 0x46102100, 0xff24f7ff, 0x2001b110, |
Pawel Zarembski |
0:01f31e923fe2 | 216 | 0x8df0e8bd, 0x68814803, 0x0101f021, 0x20006081, 0x8df0e8bd, 0x400c0000, 0x00989680, 0x68814803, |
Pawel Zarembski |
0:01f31e923fe2 | 217 | 0x0105f021, 0x20006081, 0x00004770, 0x400c0000, 0x00000000, |
Pawel Zarembski |
0:01f31e923fe2 | 218 | }; |
Pawel Zarembski |
0:01f31e923fe2 | 219 | |
Pawel Zarembski |
0:01f31e923fe2 | 220 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 221 | * List of start and size for each size of flash sector |
Pawel Zarembski |
0:01f31e923fe2 | 222 | * The size will apply to all sectors between the listed address and the next address |
Pawel Zarembski |
0:01f31e923fe2 | 223 | * in the list. |
Pawel Zarembski |
0:01f31e923fe2 | 224 | * The last pair in the list will have sectors starting at that address and ending |
Pawel Zarembski |
0:01f31e923fe2 | 225 | * at address start + size. |
Pawel Zarembski |
0:01f31e923fe2 | 226 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 227 | static const sector_info_t sectors_info[] = { |
Pawel Zarembski |
0:01f31e923fe2 | 228 | {0x00000000, 0x00001000}, |
Pawel Zarembski |
0:01f31e923fe2 | 229 | }; |
Pawel Zarembski |
0:01f31e923fe2 | 230 | |
Pawel Zarembski |
0:01f31e923fe2 | 231 | static const program_target_t flash = { |
Pawel Zarembski |
0:01f31e923fe2 | 232 | 0x200000B5, // Init |
Pawel Zarembski |
0:01f31e923fe2 | 233 | 0x2000029D, // UnInit |
Pawel Zarembski |
0:01f31e923fe2 | 234 | 0x20000029, // EraseChip |
Pawel Zarembski |
0:01f31e923fe2 | 235 | 0x20000061, // EraseSector |
Pawel Zarembski |
0:01f31e923fe2 | 236 | 0x20000121, // ProgramPage |
Pawel Zarembski |
0:01f31e923fe2 | 237 | |
Pawel Zarembski |
0:01f31e923fe2 | 238 | // BKPT : start of blob + 1 |
Pawel Zarembski |
0:01f31e923fe2 | 239 | // RSB : blob start + header + rw data offset |
Pawel Zarembski |
0:01f31e923fe2 | 240 | // RSP : stack pointer |
Pawel Zarembski |
0:01f31e923fe2 | 241 | { |
Pawel Zarembski |
0:01f31e923fe2 | 242 | 0x20000000 + 0x00000001, |
Pawel Zarembski |
0:01f31e923fe2 | 243 | 0x20000000 + 0x00000020 + 0x00000290, |
Pawel Zarembski |
0:01f31e923fe2 | 244 | 0x20000800 |
Pawel Zarembski |
0:01f31e923fe2 | 245 | }, |
Pawel Zarembski |
0:01f31e923fe2 | 246 | |
Pawel Zarembski |
0:01f31e923fe2 | 247 | 0x20000000 + 0x00000A00, // mem buffer location |
Pawel Zarembski |
0:01f31e923fe2 | 248 | 0x20000000, // location to write prog_blob in target RAM |
Pawel Zarembski |
0:01f31e923fe2 | 249 | sizeof(targetname_blob), // prog_blob size |
Pawel Zarembski |
0:01f31e923fe2 | 250 | targetname_blob, // address of prog_blob |
Pawel Zarembski |
0:01f31e923fe2 | 251 | 0x00000200 // program_buffer_size, largest size that can be written in a single call to program page |
Pawel Zarembski |
0:01f31e923fe2 | 252 | }; |
Pawel Zarembski |
0:01f31e923fe2 | 253 | |
Pawel Zarembski |
0:01f31e923fe2 | 254 | ``` |
Pawel Zarembski |
0:01f31e923fe2 | 255 | |
Pawel Zarembski |
0:01f31e923fe2 | 256 | The last required file is the target MCU description file `source/family/<mfg>/<targetname>/target.c` This file contains information about the size of ROM, RAM and sector operations needed to be performed on the target MCU while programming an image across the drag-n-drop channel. |
Pawel Zarembski |
0:01f31e923fe2 | 257 | |
Pawel Zarembski |
0:01f31e923fe2 | 258 | ```c |
Pawel Zarembski |
0:01f31e923fe2 | 259 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 260 | * @file target.c |
Pawel Zarembski |
0:01f31e923fe2 | 261 | * @brief Target information for the target MCU |
Pawel Zarembski |
0:01f31e923fe2 | 262 | * |
Pawel Zarembski |
0:01f31e923fe2 | 263 | * DAPLink Interface Firmware |
Pawel Zarembski |
0:01f31e923fe2 | 264 | * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved |
Pawel Zarembski |
0:01f31e923fe2 | 265 | * SPDX-License-Identifier: Apache-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 266 | * |
Pawel Zarembski |
0:01f31e923fe2 | 267 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Pawel Zarembski |
0:01f31e923fe2 | 268 | * not use this file except in compliance with the License. |
Pawel Zarembski |
0:01f31e923fe2 | 269 | * You may obtain a copy of the License at |
Pawel Zarembski |
0:01f31e923fe2 | 270 | * |
Pawel Zarembski |
0:01f31e923fe2 | 271 | * http://www.apache.org/licenses/LICENSE-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 272 | * |
Pawel Zarembski |
0:01f31e923fe2 | 273 | * Unless required by applicable law or agreed to in writing, software |
Pawel Zarembski |
0:01f31e923fe2 | 274 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Pawel Zarembski |
0:01f31e923fe2 | 275 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Pawel Zarembski |
0:01f31e923fe2 | 276 | * See the License for the specific language governing permissions and |
Pawel Zarembski |
0:01f31e923fe2 | 277 | * limitations under the License. |
Pawel Zarembski |
0:01f31e923fe2 | 278 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 279 | |
Pawel Zarembski |
0:01f31e923fe2 | 280 | #include "target_config.h" |
Pawel Zarembski |
0:01f31e923fe2 | 281 | |
Pawel Zarembski |
0:01f31e923fe2 | 282 | // The file flash_blob.c must only be included in target.c |
Pawel Zarembski |
0:01f31e923fe2 | 283 | #include "flash_blob.c" |
Pawel Zarembski |
0:01f31e923fe2 | 284 | |
Pawel Zarembski |
0:01f31e923fe2 | 285 | target_cfg_t target_device = { |
Pawel Zarembski |
0:01f31e923fe2 | 286 | .sectors_info = sectors_info, |
Pawel Zarembski |
0:01f31e923fe2 | 287 | .sector_info_length = (sizeof(sectors_info))/(sizeof(sector_info_t)), |
Pawel Zarembski |
0:01f31e923fe2 | 288 | .flash_regions[0].start = 0x00000000, |
Pawel Zarembski |
0:01f31e923fe2 | 289 | .flash_regions[0].end = 0x00200000, |
Pawel Zarembski |
0:01f31e923fe2 | 290 | .flash_regions[0].flags = kRegionIsDefault, |
Pawel Zarembski |
0:01f31e923fe2 | 291 | .flash_regions[0].flash_algo = (program_target_t *) &flash, |
Pawel Zarembski |
0:01f31e923fe2 | 292 | .ram_regions[0].start = 0x1fff0000, |
Pawel Zarembski |
0:01f31e923fe2 | 293 | .ram_regions[0].end = 0x20030000, |
Pawel Zarembski |
0:01f31e923fe2 | 294 | }; |
Pawel Zarembski |
0:01f31e923fe2 | 295 | ``` |
Pawel Zarembski |
0:01f31e923fe2 | 296 | Complete target configuration api is located in `source/target/target_config.h` |
Pawel Zarembski |
0:01f31e923fe2 | 297 | ```c |
Pawel Zarembski |
0:01f31e923fe2 | 298 | enum _region_flags { |
Pawel Zarembski |
0:01f31e923fe2 | 299 | kRegionIsDefault = (1 << 0), //out of bounds regions will use the same flash algo if this is set |
Pawel Zarembski |
0:01f31e923fe2 | 300 | kRegionIsSecure = (1 << 1) |
Pawel Zarembski |
0:01f31e923fe2 | 301 | }; |
Pawel Zarembski |
0:01f31e923fe2 | 302 | |
Pawel Zarembski |
0:01f31e923fe2 | 303 | |
Pawel Zarembski |
0:01f31e923fe2 | 304 | typedef struct region_info { |
Pawel Zarembski |
0:01f31e923fe2 | 305 | uint32_t start; |
Pawel Zarembski |
0:01f31e923fe2 | 306 | uint32_t end; |
Pawel Zarembski |
0:01f31e923fe2 | 307 | uint32_t flags; |
Pawel Zarembski |
0:01f31e923fe2 | 308 | uint8_t alias_index; /*!<use with flags; will point to a different index if there is an alias region */ |
Pawel Zarembski |
0:01f31e923fe2 | 309 | program_target_t *flash_algo; /*!< A pointer to the flash algorithm structure */ |
Pawel Zarembski |
0:01f31e923fe2 | 310 | } region_info_t; |
Pawel Zarembski |
0:01f31e923fe2 | 311 | |
Pawel Zarembski |
0:01f31e923fe2 | 312 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 313 | @struct target_cfg_t |
Pawel Zarembski |
0:01f31e923fe2 | 314 | @brief The firmware configuration struct has unique about the chip its running on. |
Pawel Zarembski |
0:01f31e923fe2 | 315 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 316 | typedef struct target_cfg { |
Pawel Zarembski |
0:01f31e923fe2 | 317 | uint32_t version; /*!< Target configuration version */ |
Pawel Zarembski |
0:01f31e923fe2 | 318 | const sector_info_t* sectors_info; /*!< Sector start and length list */ |
Pawel Zarembski |
0:01f31e923fe2 | 319 | int sector_info_length; /*!< Sector start and length list total */ |
Pawel Zarembski |
0:01f31e923fe2 | 320 | region_info_t flash_regions[MAX_EXTRA_FLASH_REGION]; /*!< Flash regions */ |
Pawel Zarembski |
0:01f31e923fe2 | 321 | region_info_t ram_regions[MAX_EXTRA_RAM_REGION]; /*!< RAM regions */ |
Pawel Zarembski |
0:01f31e923fe2 | 322 | uint8_t erase_reset; /*!< Reset after performing an erase */ |
Pawel Zarembski |
0:01f31e923fe2 | 323 | const char *rt_board_id; /*!< If assigned, this is a flexible board ID */ |
Pawel Zarembski |
0:01f31e923fe2 | 324 | uint16_t rt_family_id; /*!< If assigned, this is a flexible board ID */ |
Pawel Zarembski |
0:01f31e923fe2 | 325 | } target_cfg_t; |
Pawel Zarembski |
0:01f31e923fe2 | 326 | ``` |
Pawel Zarembski |
0:01f31e923fe2 | 327 | At this point these target specific files could be added to a board build and developed. |
Pawel Zarembski |
0:01f31e923fe2 | 328 | |
Pawel Zarembski |
0:01f31e923fe2 | 329 | # Supported Target Families |
Pawel Zarembski |
0:01f31e923fe2 | 330 | A HIC can target all supported families available and a post build script can modify a board's family id to point to the correct family. See [Porting board guide](PORT_BOARD.md) |