目錄
1.修改內容 總目錄
1.1 \soc\arm\nxp_imx\rt\soc.c
#ifdef CONFIG_NXP_IMX_RT_BOOT_HEADER
const __imx_boot_data_section BOOT_DATA_T boot_data = {
.start = CONFIG_FLASH_BASE_ADDRESS,
.size = CONFIG_FLASH_SIZE,
.plugin = PLUGIN_FLAG,
.placeholder = 0xFFFFFFFF,
};
const __imx_boot_ivt_section ivt image_vector_table = {
.hdr = IVT_HEADER,
.entry = CONFIG_FLASH_BASE_ADDRESS + CONFIG_TEXT_SECTION_OFFSET,
.reserved1 = IVT_RSVD,
#ifdef CONFIG_DEVICE_CONFIGURATION_DATA
.dcd = (uint32_t) dcd_data,
#else
.dcd = (uint32_t) NULL,
#endif
.boot_data = (uint32_t) &boot_data,
.self = (uint32_t) &image_vector_table,
.csf = (uint32_t)CSF_ADDRESS,
.reserved2 = IVT_RSVD,
};
#endif
1.2 添加 Kconfig
menuconfig NXP_IMX_RT_BOOT_HEADER
bool "Enable the boot header"
help
Enable data structures required by the boot ROM to boot the
application from an external flash device.
if NXP_IMX_RT_BOOT_HEADER
choice BOOT_DEVICE
prompt "Boot device selection"
default BOOT_FLEXSPI_NOR
config BOOT_FLEXSPI_NOR
bool "FlexSPI serial NOR"
endchoice
config IMAGE_VECTOR_TABLE_OFFSET
hex "Image vector table offset"
default 0x1000 if BOOT_FLEXSPI_NOR || BOOT_SEMC_NOR
help
The Image Vector Table (IVT) provides the boot ROM with pointers to
the application entry point and device configuration data. The boot
ROM requires a fixed IVT offset for each type of boot device.
config DEVICE_CONFIGURATION_DATA
bool "Enable device configuration data"
help
Device configuration data (DCD) provides a sequence of commands to
the boot ROM to initialize components such as an SDRAM.
endif # NXP_IMX_RT_BOOT_HEADER
1.3 添加定義 sections
/* Architecture-specific sections */
#if defined(CONFIG_ARM)
#define KINETIS_FLASH_CONFIG kinetis_flash_config
#define TI_CCFG .ti_ccfg
#define _CCM_DATA_SECTION_NAME .ccm_data
#define _CCM_BSS_SECTION_NAME .ccm_bss
#define _CCM_NOINIT_SECTION_NAME .ccm_noinit
#endif
#define IMX_BOOT_CONF .boot_hdr.conf
#define IMX_BOOT_DATA .boot_hdr.data
#define IMX_BOOT_IVT .boot_hdr.ivt
#define IMX_BOOT_DCD .boot_hdr.dcd_data
1.4 添加sections_tags.h
//E:\work\code\zephyr_20190406\include\linker\section_tags.h
#if defined(CONFIG_ARM)
#define __kinetis_flash_config_section __in_section_unique(KINETIS_FLASH_CONFIG)
#define __ti_ccfg_section Z_GENERIC_SECTION(TI_CCFG)
#define __ccm_data_section Z_GENERIC_SECTION(_CCM_DATA_SECTION_NAME)
#define __ccm_bss_section Z_GENERIC_SECTION(_CCM_BSS_SECTION_NAME)
#define __ccm_noinit_section Z_GENERIC_SECTION(_CCM_NOINIT_SECTION_NAME)
#define __imx_boot_conf_section Z_GENERIC_SECTION(IMX_BOOT_CONF) //新增
#define __imx_boot_data_section Z_GENERIC_SECTION(IMX_BOOT_DATA)
#define __imx_boot_ivt_section Z_GENERIC_SECTION(IMX_BOOT_IVT)
#define __imx_boot_dcd_section Z_GENERIC_SECTION(IMX_BOOT_DCD)
#endif /* CONFIG_ARM */
1.4 Linker.ld
GROUP_START(ROMABLE_REGION)
_image_rom_start = ROM_ADDR;
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
{
#ifdef CONFIG_CC3220SF_DEBUG
/* Add CC3220SF flash header to disable flash verification */
. = 0x0;
KEEP(*(.dbghdr))
KEEP(*(".dbghdr.*"))
#endif
#ifdef CONFIG_NXP_IMX_RT_BOOT_HEADER
KEEP(*(.boot_hdr.conf)) //偏移地址0x0000
. = CONFIG_IMAGE_VECTOR_TABLE_OFFSET; //偏移地址0x1000
KEEP(*(.boot_hdr.ivt))
KEEP(*(.boot_hdr.data))
#ifdef CONFIG_DEVICE_CONFIGURATION_DATA
KEEP(*(.boot_hdr.dcd_data))
#endif
#endif
. = CONFIG_TEXT_SECTION_OFFSET; //偏移地址0x2000
1.5 CMakefiles
E:\work\code\zephyr_20190406\ext\hal\nxp\mcux\boards\evkbimxrt1050\CMakeLists.txt
#
# Copyright (c) 2018, NXP
#
# SPDX-License-Identifier: Apache-2.0
#
zephyr_compile_definitions_ifdef(CONFIG_NXP_IMX_RT_BOOT_HEADER XIP_BOOT_HEADER_ENABLE=1)
zephyr_compile_definitions_ifdef(CONFIG_DEVICE_CONFIGURATION_DATA XIP_BOOT_HEADER_DCD_ENABLE=1)
zephyr_sources_ifdef(CONFIG_BOOT_FLEXSPI_NOR evkbimxrt1050_flexspi_nor_config.c)
zephyr_sources_ifdef(CONFIG_DEVICE_CONFIGURATION_DATA evkbimxrt1050_sdram_ini_dcd.c)
1.5.1文件列表關係
$ ls -l ./ext/hal/nxp/mcux/boards/evkbimxrt1050/
total 37
-rw-r--r-- 1 xiao 197121 423 4月 6 11:11 CMakeLists.txt
-rw-r--r-- 1 xiao 197121 2130 4月 6 11:11 evkbimxrt1050_flexspi_nor_config.c
-rw-r--r-- 1 xiao 197121 12701 4月 6 11:11 evkbimxrt1050_flexspi_nor_config.h
-rw-r--r-- 1 xiao 197121 12276 4月 6 11:11 evkbimxrt1050_sdram_ini_dcd.c
-rw-r--r-- 1 xiao 197121 607 4月 6 11:11 evkbimxrt1050_sdram_ini_dcd.h
2. 驗證結果
2.1 map
0x60000000 _image_rom_start = 0x60000000
text 0x60000000 0x22c0
*(SORT(.boot_hdr.conf))
.boot_hdr.conf
0x60000000 0x200 zephyr/libzephyr.a(evkbimxrt1050_flexspi_nor_config.c.obj)
0x60000000 hyperflash_config
0x00001000 . = 0x1000
*fill* 0x60000200 0xe00
*(SORT(.boot_hdr.ivt))
.boot_hdr.ivt 0x60001000 0x20 zephyr/libzephyr.a(soc.c.obj)
0x60001000 image_vector_table
*(SORT(.boot_hdr.data))
.boot_hdr.data
0x60001020 0x10 zephyr/libzephyr.a(soc.c.obj)
0x60001020 boot_data
*(SORT(.boot_hdr.dcd_data))
.boot_hdr.dcd_data
0x60001030 0x430 zephyr/libzephyr.a(evkbimxrt1050_sdram_ini_dcd.c.obj)
0x60001030 dcd_data
0x00002000 . = 0x2000
*fill* 0x60001460 0xba0
0x60002000 _vector_start = .
*(SORT(.exc_vector_table))
*(SORT(.exc_vector_table.*))