From 780149bc385b2b7670012e6b46bbd172cbbebd65 Mon Sep 17 00:00:00 2001 From: Christian Mauderer Date: Thu, 13 Jul 2023 10:53:34 +0200 Subject: bsps/imsrt: Make flash config more flexible The flash configuration is something very board specific. So move the file to a board specific location. Beneath that, not all controllers and configurations need the flash config right at the address 0 of the flash. For example on the i.MXRT11xx, the config has an offset for some flash types. --- .../boards/evkbimxrt1050/flash-flexspi-config.c | 60 ++++++++++++++++++++++ bsps/arm/imxrt/include/imxrt/memory.h | 4 ++ bsps/arm/imxrt/start/flash-boot-data.c | 2 +- bsps/arm/imxrt/start/flash-flexspi-config.c | 60 ---------------------- bsps/arm/imxrt/start/mpu-config.c | 4 +- 5 files changed, 67 insertions(+), 63 deletions(-) create mode 100644 bsps/arm/imxrt/boards/evkbimxrt1050/flash-flexspi-config.c delete mode 100644 bsps/arm/imxrt/start/flash-flexspi-config.c (limited to 'bsps/arm') diff --git a/bsps/arm/imxrt/boards/evkbimxrt1050/flash-flexspi-config.c b/bsps/arm/imxrt/boards/evkbimxrt1050/flash-flexspi-config.c new file mode 100644 index 0000000000..4aa10344a9 --- /dev/null +++ b/bsps/arm/imxrt/boards/evkbimxrt1050/flash-flexspi-config.c @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/* + * Copyright (C) 2020 embedded brains GmbH & Co. KG + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +const flexspi_nor_config_t imxrt_flexspi_config = { + .memConfig = { + .tag = FLEXSPI_CFG_BLK_TAG, + .version = FLEXSPI_CFG_BLK_VERSION, + .readSampleClkSrc = kFlexSPIReadSampleClk_ExternalInputFromDqsPad, + .csHoldTime = 3u, + .csSetupTime = 3u, + .columnAddressWidth = 3u, + .controllerMiscOption = (1 << kFlexSpiMiscOffset_DdrModeEnable) | + (1 << kFlexSpiMiscOffset_WordAddressableEnable) | + (1 << kFlexSpiMiscOffset_SafeConfigFreqEnable) | + (1 << kFlexSpiMiscOffset_DiffClkEnable), + .deviceType = kFlexSpiDeviceType_SerialRAM, + .sflashPadType = kSerialFlash_8Pads, + .serialClkFreq = kFlexSpiSerialClk_133MHz, + .sflashA1Size = IMXRT_MEMORY_FLASH_SIZE, + .dataValidTime = {16u, 16u}, + .lookupTable = { + FLEXSPI_LUT_SEQ(CMD_DDR, FLEXSPI_8PAD, 0xA0, RADDR_DDR, FLEXSPI_8PAD, 0x18), + FLEXSPI_LUT_SEQ(CADDR_DDR, FLEXSPI_8PAD, 0x10, DUMMY_DDR, FLEXSPI_8PAD, 0x06), + FLEXSPI_LUT_SEQ(READ_DDR, FLEXSPI_8PAD, 0x04, STOP, FLEXSPI_1PAD, 0x0), + }, + .lutCustomSeq = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}, + }, + .pageSize = 0x200, + .sectorSize = 0x40000, + .blockSize = 0x40000, + .isUniformBlockSize = 1, +}; diff --git a/bsps/arm/imxrt/include/imxrt/memory.h b/bsps/arm/imxrt/include/imxrt/memory.h index 3fc8f0bbfa..52163d040f 100644 --- a/bsps/arm/imxrt/include/imxrt/memory.h +++ b/bsps/arm/imxrt/include/imxrt/memory.h @@ -56,6 +56,10 @@ extern char imxrt_memory_peripheral_begin[]; extern char imxrt_memory_peripheral_end[]; extern char imxrt_memory_peripheral_size[]; +extern char imxrt_memory_flash_raw_begin[]; +extern char imxrt_memory_flash_raw_end[]; +extern char imxrt_memory_flash_raw_size[]; + extern char imxrt_memory_flash_config_begin[]; extern char imxrt_memory_flash_config_end[]; extern char imxrt_memory_flash_config_size[]; diff --git a/bsps/arm/imxrt/start/flash-boot-data.c b/bsps/arm/imxrt/start/flash-boot-data.c index 485f91c8ec..2186fc08bf 100644 --- a/bsps/arm/imxrt/start/flash-boot-data.c +++ b/bsps/arm/imxrt/start/flash-boot-data.c @@ -30,7 +30,7 @@ #include const BOOT_DATA_T imxrt_boot_data = { - .start = (uint32_t) imxrt_memory_flash_config_begin, + .start = (uint32_t) imxrt_memory_flash_raw_begin, .size = IMXRT_MEMORY_FLASH_SIZE, .plugin = PLUGIN_FLAG, .placeholder = 0xFFFFFFFF, diff --git a/bsps/arm/imxrt/start/flash-flexspi-config.c b/bsps/arm/imxrt/start/flash-flexspi-config.c deleted file mode 100644 index 4aa10344a9..0000000000 --- a/bsps/arm/imxrt/start/flash-flexspi-config.c +++ /dev/null @@ -1,60 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - -/* - * Copyright (C) 2020 embedded brains GmbH & Co. KG - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -const flexspi_nor_config_t imxrt_flexspi_config = { - .memConfig = { - .tag = FLEXSPI_CFG_BLK_TAG, - .version = FLEXSPI_CFG_BLK_VERSION, - .readSampleClkSrc = kFlexSPIReadSampleClk_ExternalInputFromDqsPad, - .csHoldTime = 3u, - .csSetupTime = 3u, - .columnAddressWidth = 3u, - .controllerMiscOption = (1 << kFlexSpiMiscOffset_DdrModeEnable) | - (1 << kFlexSpiMiscOffset_WordAddressableEnable) | - (1 << kFlexSpiMiscOffset_SafeConfigFreqEnable) | - (1 << kFlexSpiMiscOffset_DiffClkEnable), - .deviceType = kFlexSpiDeviceType_SerialRAM, - .sflashPadType = kSerialFlash_8Pads, - .serialClkFreq = kFlexSpiSerialClk_133MHz, - .sflashA1Size = IMXRT_MEMORY_FLASH_SIZE, - .dataValidTime = {16u, 16u}, - .lookupTable = { - FLEXSPI_LUT_SEQ(CMD_DDR, FLEXSPI_8PAD, 0xA0, RADDR_DDR, FLEXSPI_8PAD, 0x18), - FLEXSPI_LUT_SEQ(CADDR_DDR, FLEXSPI_8PAD, 0x10, DUMMY_DDR, FLEXSPI_8PAD, 0x06), - FLEXSPI_LUT_SEQ(READ_DDR, FLEXSPI_8PAD, 0x04, STOP, FLEXSPI_1PAD, 0x0), - }, - .lutCustomSeq = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}, - }, - .pageSize = 0x200, - .sectorSize = 0x40000, - .blockSize = 0x40000, - .isUniformBlockSize = 1, -}; diff --git a/bsps/arm/imxrt/start/mpu-config.c b/bsps/arm/imxrt/start/mpu-config.c index 8928980445..a8f98f1c81 100644 --- a/bsps/arm/imxrt/start/mpu-config.c +++ b/bsps/arm/imxrt/start/mpu-config.c @@ -44,8 +44,8 @@ BSP_START_DATA_SECTION const ARMV7M_MPU_Region_config | ARMV7M_MPU_RASR_TEX(0x1) | ARMV7M_MPU_RASR_C | ARMV7M_MPU_RASR_B | ARMV7M_MPU_RASR_ENABLE, }, { - .begin = imxrt_memory_flash_config_begin, - .end = imxrt_memory_flash_end, + .begin = imxrt_memory_flash_raw_begin, + .end = imxrt_memory_flash_raw_end, .rasr = ARMV7M_MPU_RASR_AP(0x3) | ARMV7M_MPU_RASR_TEX(0x1) | ARMV7M_MPU_RASR_C | ARMV7M_MPU_RASR_B | ARMV7M_MPU_RASR_ENABLE, -- cgit v1.2.3