diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/xip')
3 files changed, 182 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/xip/driver_xip_device.cmake b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/xip/driver_xip_device.cmake new file mode 100644 index 000000000..14fde5e26 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/xip/driver_xip_device.cmake | |||
@@ -0,0 +1,16 @@ | |||
1 | if(NOT DRIVER_XIP_DEVICE_INCLUDED) | ||
2 | |||
3 | set(DRIVER_XIP_DEVICE_INCLUDED true CACHE BOOL "driver_xip_device component is included.") | ||
4 | |||
5 | target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE | ||
6 | ${CMAKE_CURRENT_LIST_DIR}/fsl_flexspi_nor_boot.c | ||
7 | ) | ||
8 | |||
9 | target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE | ||
10 | ${CMAKE_CURRENT_LIST_DIR}/. | ||
11 | ) | ||
12 | |||
13 | |||
14 | include(driver_common) | ||
15 | |||
16 | endif() \ No newline at end of file | ||
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/xip/fsl_flexspi_nor_boot.c b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/xip/fsl_flexspi_nor_boot.c new file mode 100644 index 000000000..2b52e5a3c --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/xip/fsl_flexspi_nor_boot.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * Copyright 2017-2020 NXP | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * SPDX-License-Identifier: BSD-3-Clause | ||
6 | */ | ||
7 | |||
8 | #include "fsl_flexspi_nor_boot.h" | ||
9 | |||
10 | /* Component ID definition, used by tools. */ | ||
11 | #ifndef FSL_COMPONENT_ID | ||
12 | #define FSL_COMPONENT_ID "platform.drivers.xip_device" | ||
13 | #endif | ||
14 | |||
15 | #if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1) | ||
16 | #if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) | ||
17 | __attribute__((section(".boot_hdr.ivt"), used)) | ||
18 | #elif defined(__ICCARM__) | ||
19 | #pragma location = ".boot_hdr.ivt" | ||
20 | #endif | ||
21 | /************************************* | ||
22 | * IVT Data | ||
23 | *************************************/ | ||
24 | const ivt image_vector_table = { | ||
25 | IVT_HEADER, /* IVT Header */ | ||
26 | IMAGE_ENTRY_ADDRESS, /* Image Entry Function */ | ||
27 | IVT_RSVD, /* Reserved = 0 */ | ||
28 | (uint32_t)DCD_ADDRESS, /* Address where DCD information is stored */ | ||
29 | (uint32_t)BOOT_DATA_ADDRESS, /* Address where BOOT Data Structure is stored */ | ||
30 | (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ | ||
31 | (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ | ||
32 | IVT_RSVD /* Reserved = 0 */ | ||
33 | }; | ||
34 | |||
35 | #if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__) | ||
36 | __attribute__((section(".boot_hdr.boot_data"), used)) | ||
37 | #elif defined(__ICCARM__) | ||
38 | #pragma location = ".boot_hdr.boot_data" | ||
39 | #endif | ||
40 | /************************************* | ||
41 | * Boot Data | ||
42 | *************************************/ | ||
43 | const BOOT_DATA_T boot_data = { | ||
44 | FLASH_BASE, /* boot start location */ | ||
45 | FLASH_SIZE, /* size */ | ||
46 | PLUGIN_FLAG, /* Plugin flag*/ | ||
47 | 0xFFFFFFFFU /* empty - extra data word */ | ||
48 | }; | ||
49 | #endif | ||
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/xip/fsl_flexspi_nor_boot.h b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/xip/fsl_flexspi_nor_boot.h new file mode 100644 index 000000000..6a76c29da --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1064/xip/fsl_flexspi_nor_boot.h | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | * Copyright 2017-2020 NXP | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * SPDX-License-Identifier: BSD-3-Clause | ||
6 | */ | ||
7 | |||
8 | #ifndef __FLEXSPI_NOR_BOOT_H__ | ||
9 | #define __FLEXSPI_NOR_BOOT_H__ | ||
10 | |||
11 | #include <stdint.h> | ||
12 | #include "board.h" | ||
13 | #include "fsl_common.h" | ||
14 | |||
15 | /*! @name Driver version */ | ||
16 | /*@{*/ | ||
17 | /*! @brief XIP_DEVICE driver version 2.0.2. */ | ||
18 | #define FSL_XIP_DEVICE_DRIVER_VERSION (MAKE_VERSION(2, 0, 2)) | ||
19 | /*@}*/ | ||
20 | |||
21 | /************************************* | ||
22 | * IVT Data | ||
23 | *************************************/ | ||
24 | typedef struct _ivt_ | ||
25 | { | ||
26 | /** @ref hdr with tag #HAB_TAG_IVT, length and HAB version fields | ||
27 | * (see @ref data) | ||
28 | */ | ||
29 | uint32_t hdr; | ||
30 | /** Absolute address of the first instruction to execute from the | ||
31 | * image | ||
32 | */ | ||
33 | uint32_t entry; | ||
34 | /** Reserved in this version of HAB: should be NULL. */ | ||
35 | uint32_t reserved1; | ||
36 | /** Absolute address of the image DCD: may be NULL. */ | ||
37 | uint32_t dcd; | ||
38 | /** Absolute address of the Boot Data: may be NULL, but not interpreted | ||
39 | * any further by HAB | ||
40 | */ | ||
41 | uint32_t boot_data; | ||
42 | /** Absolute address of the IVT.*/ | ||
43 | uint32_t self; | ||
44 | /** Absolute address of the image CSF.*/ | ||
45 | uint32_t csf; | ||
46 | /** Reserved in this version of HAB: should be zero. */ | ||
47 | uint32_t reserved2; | ||
48 | } ivt; | ||
49 | |||
50 | #define IVT_MAJOR_VERSION 0x4 | ||
51 | #define IVT_MAJOR_VERSION_SHIFT 0x4 | ||
52 | #define IVT_MAJOR_VERSION_MASK 0xF | ||
53 | #define IVT_MINOR_VERSION 0x1 | ||
54 | #define IVT_MINOR_VERSION_SHIFT 0x0 | ||
55 | #define IVT_MINOR_VERSION_MASK 0xF | ||
56 | |||
57 | #define IVT_VERSION(major, minor) \ | ||
58 | ((((major)&IVT_MAJOR_VERSION_MASK) << IVT_MAJOR_VERSION_SHIFT) | \ | ||
59 | (((minor)&IVT_MINOR_VERSION_MASK) << IVT_MINOR_VERSION_SHIFT)) | ||
60 | |||
61 | /* IVT header */ | ||
62 | #define IVT_TAG_HEADER 0xD1 /**< Image Vector Table */ | ||
63 | #define IVT_SIZE 0x2000 | ||
64 | #define IVT_PAR IVT_VERSION(IVT_MAJOR_VERSION, IVT_MINOR_VERSION) | ||
65 | #define IVT_HEADER (IVT_TAG_HEADER | (IVT_SIZE << 8) | (IVT_PAR << 24)) | ||
66 | |||
67 | /* Set resume entry */ | ||
68 | #if defined(__CC_ARM) || defined(__ARMCC_VERSION) | ||
69 | extern uint32_t __Vectors[]; | ||
70 | #define IMAGE_ENTRY_ADDRESS ((uint32_t)__Vectors) | ||
71 | #elif defined(__MCUXPRESSO) | ||
72 | extern uint32_t __Vectors[]; | ||
73 | #define IMAGE_ENTRY_ADDRESS ((uint32_t)__Vectors) | ||
74 | #elif defined(__ICCARM__) | ||
75 | extern uint32_t __VECTOR_TABLE[]; | ||
76 | #define IMAGE_ENTRY_ADDRESS ((uint32_t)__VECTOR_TABLE) | ||
77 | #elif defined(__GNUC__) | ||
78 | extern uint32_t __VECTOR_TABLE[]; | ||
79 | #define IMAGE_ENTRY_ADDRESS ((uint32_t)__VECTOR_TABLE) | ||
80 | #endif | ||
81 | |||
82 | #if defined(XIP_BOOT_HEADER_DCD_ENABLE) && (1 == XIP_BOOT_HEADER_DCD_ENABLE) | ||
83 | #define DCD_ADDRESS dcd_data | ||
84 | #else | ||
85 | #define DCD_ADDRESS 0 | ||
86 | #endif | ||
87 | |||
88 | #define BOOT_DATA_ADDRESS &boot_data | ||
89 | #define CSF_ADDRESS 0 | ||
90 | #define IVT_RSVD (uint32_t)(0x00000000) | ||
91 | |||
92 | /************************************* | ||
93 | * Boot Data | ||
94 | *************************************/ | ||
95 | typedef struct _boot_data_ | ||
96 | { | ||
97 | uint32_t start; /* boot start location */ | ||
98 | uint32_t size; /* size */ | ||
99 | uint32_t plugin; /* plugin flag - 1 if downloaded application is plugin */ | ||
100 | uint32_t placeholder; /* placehoder to make even 0x10 size */ | ||
101 | } BOOT_DATA_T; | ||
102 | |||
103 | #define FLASH_BASE FlexSPI2_AMBA_BASE | ||
104 | #if defined(BOARD_FLASH_SIZE) | ||
105 | #define FLASH_SIZE BOARD_FLASH_SIZE | ||
106 | #else | ||
107 | #error "Please define macro BOARD_FLASH_SIZE" | ||
108 | #endif | ||
109 | #define PLUGIN_FLAG (uint32_t)0 | ||
110 | |||
111 | /* External Variables */ | ||
112 | const BOOT_DATA_T boot_data; | ||
113 | #if defined(XIP_BOOT_HEADER_DCD_ENABLE) && (1 == XIP_BOOT_HEADER_DCD_ENABLE) | ||
114 | extern const uint8_t dcd_data[]; | ||
115 | #endif | ||
116 | |||
117 | #endif /* __FLEXSPI_NOR_BOOT_H__ */ | ||