Add support for NXP MR-VMU-Tropic board (#25845)

* rt106x: Use platform SPI hal layer

* rt106x: Add romapi support and reboot to isp/bootloader

* bootloader: imxrt_common: Add rt106x support

* NXP MR-Tropic initial commit

* Add missing file for mr-tropic bootloader

* nxp-mr-tropic:Bootloader Alow Assertion debugging & Keep Ram Vectors

* nxp-mr-tropic: Firmware Boot from bootloader

* nxp-mr-tropic:Add Bootloader bin file

* mr-tropic: Update config and linker

Fixes enet issues with write-back and some code cleanup.
Furthermore increase NOR LittleFS to 256kB to reflect on linker

* Update NuttX

* mr-tropic: fix itcm apping and add mr-tropic to itcm check

---------

Co-authored-by: David Sidrane <David.Sidrane@NscDg.com>
This commit is contained in:
Peter van der Perk
2025-11-05 11:48:26 -05:00
committed by GitHub
co-authored by David Sidrane
parent 5f0d222e1b
commit 1250563ed1
55 changed files with 5972 additions and 30 deletions
@@ -9,9 +9,19 @@
#include "hw_config.h"
#include <px4_arch/imxrt_flexspi_nor_flash.h>
#include <px4_arch/imxrt_romapi.h>
#include <hardware/rt117x/imxrt117x_ocotp.h>
#include <hardware/rt117x/imxrt117x_anadig.h>
#include <hardware/rt117x/imxrt117x_snvs.h>
#ifdef CONFIG_ARCH_FAMILY_IMXRT117x
# include <hardware/rt117x/imxrt117x_ocotp.h>
# include <hardware/rt117x/imxrt117x_anadig.h>
# include <hardware/rt117x/imxrt117x_snvs.h>
#else
# include <chip.h>
# include <hardware/imxrt_usb_analog.h>
# include <hardware/imxrt_snvs.h>
# include <hardware/imxrt_ocotp.h>
# include "hardware/imxrt_ccm.h"
# include "imxrt_periphclks.h"
# define SNVS_LPCR_GPR_Z_DIS (1 << 24) /* Bit 24: General Purpose Registers Zeroization Disable */
#endif
#include <hardware/imxrt_usb_analog.h>
#include "imxrt_clockconfig.h"
@@ -30,14 +40,31 @@
#define APP_SIZE_MAX (BOARD_FLASH_SIZE - (BOOTLOADER_RESERVATION_SIZE + APP_RESERVATION_SIZE))
#ifdef CONFIG_ARCH_FAMILY_IMXRT117x
#define CHIP_TAG "i.MX RT11?0,r??"
#define CHIP_TAG_LEN sizeof(CHIP_TAG)-1
#define SI_REV(n) ((n & 0x7000000) >> 24)
#define DIFPROG_TYPE(n) ((n & 0xF000) >> 12)
#define DIFPROG_REV_MAJOR(n) ((n & 0xF0) >> 4)
#define DIFPROG_REV_MINOR(n) ((n & 0xF))
#elif defined(CONFIG_ARCH_FAMILY_IMXRT106x)
#define CHIP_TAG "i.MX RT10?? r?.?"
#define DIGPROG_MINOR_SHIFT 0
#define DIGPROG_MINOR_MASK (0xff << DIGPROG_MINOR_SHIFT)
#define DIGPROG_MINOR(info) (((info) & DIGPROG_MINOR_MASK) >> DIGPROG_MINOR_SHIFT)
#define DIGPROG_MAJOR_LOWER_SHIFT 8
#define DIGPROG_MAJOR_LOWER_MASK (0xff << DIGPROG_MAJOR_LOWER_SHIFT)
#define DIGPROG_MAJOR_LOWER(info) (((info) & DIGPROG_MAJOR_LOWER_MASK) >> DIGPROG_MAJOR_LOWER_SHIFT)
#define DIGPROG_MAJOR_UPPER_SHIFT 16
#define DIGPROG_MAJOR_UPPER_MASK (0xff << DIGPROG_MAJOR_UPPER_SHIFT)
#define DIGPROG_MAJOR_UPPER(info) (((info) & DIGPROG_MAJOR_UPPER_MASK) >> DIGPROG_MAJOR_UPPER_SHIFT)
#endif
#define CHIP_TAG_LEN sizeof(CHIP_TAG)-1
#ifdef CONFIG_ARCH_FAMILY_IMXRT117x
#define FLASH_BASE IMXRT_FLEXSPI1_CIPHER_BASE
#elif defined(CONFIG_ARCH_CHIP_MIMXRT1064DVL6A)
#define FLASH_BASE IMXRT_FLEX2CIPHER_BASE
#endif
/* context passed to cinit */
#if INTERFACE_USART
@@ -287,6 +314,27 @@ board_deinit(void)
px4_arch_configgpio(MK_GPIO_INPUT(BOARD_PIN_LED_BOOTLOADER));
#endif
#ifdef CONFIG_ARCH_FAMILY_IMXRT106x
// Restore CCM registers to ROM state
putreg32(0x00000001, IMXRT_CCM_CACRR);
putreg32(0x000A8200, IMXRT_CCM_CBCDR);
putreg32(0x06490B03, IMXRT_CCM_CSCDR1);
putreg32(0x75AE8104, IMXRT_CCM_CBCMR);
putreg32(0x67930001, IMXRT_CCM_CSCMR1);
imxrt_clockoff_lpuart3();
imxrt_clockoff_usboh3();
imxrt_clockoff_timer3();
imxrt_clockoff_xbar1();
imxrt_clockoff_xbar3();
up_disable_icache();
up_disable_dcache();
#endif
#ifdef CONFIG_ARCH_FAMILY_IMXRT117x
const uint32_t dnfw[] = {
CCM_CR_M7,
CCM_CR_BUS,
@@ -309,6 +357,8 @@ board_deinit(void)
putreg32(CCM_CR_CTRL_OFF, IMXRT_CCM_CR_CTRL(i));
}
}
#endif
}
inline void arch_systic_init(void)
@@ -365,7 +415,7 @@ ssize_t arch_flash_write(uintptr_t address, const void *buffer, size_t buflen)
j++;
}
uintptr_t offset = ((uintptr_t) address) - IMXRT_FLEXSPI1_CIPHER_BASE;
uintptr_t offset = ((uintptr_t) address) - FLASH_BASE;
volatile uint32_t status = ROM_FLEXSPI_NorFlash_ProgramPage(1, pConfig, offset, (const uint32_t *)buffer);
up_invalidate_dcache((uintptr_t)address,
@@ -400,7 +450,7 @@ flash_func_sector_size(unsigned sector)
ssize_t up_progmem_ispageerased(unsigned sector)
{
const uint32_t bytes_per_sector = flash_func_sector_size(sector);
uint32_t *address = (uint32_t *)(IMXRT_FLEXSPI1_CIPHER_BASE + (sector * bytes_per_sector));
uint32_t *address = (uint32_t *)(FLASH_BASE + (sector * bytes_per_sector));
const uint32_t uint32_per_sector = bytes_per_sector / sizeof(*address);
int blank = 0; /* Assume it is Bank */
@@ -437,9 +487,9 @@ flash_func_erase_sector(unsigned sector, bool force)
struct flexspi_nor_config_s *pConfig = &g_bootConfig;
const uint32_t bytes_per_sector = flash_func_sector_size(sector);
uint32_t *address = (uint32_t *)(IMXRT_FLEXSPI1_CIPHER_BASE + (sector * bytes_per_sector));
uint32_t *address = (uint32_t *)(FLASH_BASE + (sector * bytes_per_sector));
uintptr_t offset = ((uintptr_t) address) - IMXRT_FLEXSPI1_CIPHER_BASE;
uintptr_t offset = ((uintptr_t) address) - FLASH_BASE;
irqstate_t flags;
flags = enter_critical_section();
volatile uint32_t status = ROM_FLEXSPI_NorFlash_Erase(1, pConfig, (uintptr_t) offset, bytes_per_sector);
@@ -473,6 +523,8 @@ flash_func_read_otp(uintptr_t address)
return 0;
}
#ifdef CONFIG_ARCH_FAMILY_IMXRT117x
uint32_t get_mcu_id(void)
{
// ??? is DEBUGMCU get able
@@ -499,6 +551,36 @@ int get_mcu_desc(int max, uint8_t *revstr)
return strp - revstr;
}
#elif defined(CONFIG_ARCH_FAMILY_IMXRT106x)
uint32_t get_mcu_id(void)
{
return getreg32(IMXRT_OCOTP_UNIQUE_ID_LSB);
}
int get_mcu_desc(int max, uint8_t *revstr)
{
uint32_t info = getreg32(IMXRT_USB_ANALOG_DIGPROG);
// CHIP_TAG "i.MX RT10?? r?.?"
static uint8_t chip[sizeof(CHIP_TAG) + 1] = CHIP_TAG;
chip[CHIP_TAG_LEN - 1] = '0' + DIGPROG_MINOR(info);
chip[CHIP_TAG_LEN - 3] = '1' + DIGPROG_MAJOR_LOWER(info);
chip[CHIP_TAG_LEN - 6] = getreg32(0x401F867C) == 0x10 ? '4' : '2';
chip[CHIP_TAG_LEN - 7] = DIGPROG_MAJOR_UPPER(info) == 0x6a ? '5' : '6';
uint8_t *endp = &revstr[max - 1];
uint8_t *strp = revstr;
uint8_t *des = chip;
while (strp < endp && *des) {
*strp++ = *des++;
}
return strp - revstr;
}
#endif
int check_silicon(void)
{
@@ -717,6 +799,7 @@ bootloader_main(void)
* Returns - 0 if connected.
*
************************************************************************************/
#ifdef CONFIG_ARCH_FAMILY_IMXRT117x
#undef IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT
#define USB1_VBUS_DET_STAT_OFFSET 0xd0
#define IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT (IMXRT_USBPHY1_BASE + USB1_VBUS_DET_STAT_OFFSET)
@@ -727,6 +810,17 @@ bootloader_main(void)
try_boot = false;
}
#elif defined(CONFIG_ARCH_FAMILY_IMXRT106x)
#undef IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT
#define IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT (IMXRT_ANATOP_BASE + IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT_OFFSET)
if ((getreg32(IMXRT_USB_ANALOG_USB1_VBUS_DETECT_STAT) & USB_ANALOG_USB_VBUS_DETECT_STAT_VBUS_VALID) != 0) {
usb_connected = true;
/* don't try booting before we set up the bootloader */
try_boot = false;
}
#endif
#endif
#if INTERFACE_USART
@@ -0,0 +1,34 @@
############################################################################
#
# Copyright (c) 2023 PX4 Development Team. All rights reserved.
#
# 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.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# 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.
#
############################################################################
add_subdirectory(../imxrt_common arch_bootloader)