Skip to content

Conversation

@APIUM
Copy link
Contributor

@APIUM APIUM commented Dec 16, 2025

Checklist

By completing this PR sufficiently, you help us to review this Pull Request quicker and also help improve the quality of Release Notes

  • Please provide specific title of the PR describing the change
  • Please provide related links (eg. Issue which will be closed by this Pull Request)
  • If you are adding an new boards, please make sure
    • Provide link to your allocated VID/PID if applicable
    • UF2_BOARD_ID in your board.h follow correct format from uf2 specs

Could we get a PID for the 1170 evkb please? I have put one in this change but will update it on assignment.


Description of Change

Add support for MIMXRT1176. We are using this on an 1176 custom board, but I've added support for the 1170EVKB eval board as well. These are the changes I needed/used to get it working correctly.

I did this with XIP, as with the 1176 the memory layout is complex with the M4/M7 split and there were clock/power state differences running in SDP vs booting from flash, so this made it much easier to build in support.

I haven't tested on any other boards (as I don't have any on hand) but there shouldn't be any changes that would negatively affect them. There is a fix in here that should affect all imxrt boards though, we were calling SCB_InvalidateDCache_by_Addr with the offset, which could have been leaving stale data in the cache.

I think all the copyright headers are correct.

Thanks for reviewing the change.

@APIUM APIUM force-pushed the feature/mimxrt1176-flash-support branch 2 times, most recently from c8b31f5 to f559018 Compare December 16, 2025 01:06
Add support for MIMXRT1176 including direct flash boot (XIP) mode.

Build system:
- Add FLASH_BUILD=1 option for flash-resident builds
- Fix UF2_MIMXRT1176_ADDR to 0x30000400 (FCFB at 0x400 offset)
- Use MCU-specific memory.ld for MIMXRT1176

Linker scripts:
- Add MIMXRT1176_flash.ld for XIP boot configuration
- Update MIMXRT1176_memory.ld to support both RAM and flash builds

Flash operations:
- Fix SCB_InvalidateDCache_by_Addr to use absolute address instead of
  offset (was causing cache corruption on Cortex-M7)
- Add XIP detection to skip FlexSPI re-init when running from flash
- Add ROM_API_Init() call required for MIMXRT1176

USB support:
- Add optional USB_PWR_PINMUX for boards with USB power control
- Fix USB PHY PLL reference clock for RT1176 (24MHz, not 480MHz)

Board support:
- Add imxrt1170_evk board with clock configuration supporting both
  RAM (SDP) and flash (XIP) boot modes

Other fixes:
- Fix CFG_TUSB_MEM_ALIGN to 32 bytes for M7 DCache compatibility
- Add MIMXRT1176-specific sources to family.cmake
- Update README with RT1170-EVK and FLASH_BUILD documentation
@APIUM APIUM force-pushed the feature/mimxrt1176-flash-support branch from f559018 to 46ba35e Compare December 16, 2025 03:17
@APIUM APIUM force-pushed the feature/mimxrt1176-flash-support branch 4 times, most recently from 560c8e9 to 65a8643 Compare December 19, 2025 02:00
Add automated two-stage flashing via `make flash-sdp` for RT1170/RT1176:
- Uses blhost from NXP SPSDK (pip install spsdk)
- Loads NXP flashloader, then programs TinyUF2 to external flash
- Supports both FLASH_BUILD=1 (two-stage) and RAM builds (direct load)
- Configurable FLASHLOADER path for custom flashloader binaries

Usage:
  make BOARD=imxrt1170_evk FLASH_BUILD=1 flash-sdp FLASHLOADER=/path/to/ivt_flashloader.bin

Also updates README with detailed RT1170 flashing instructions and uses
runtime is_running_from_flash() check in board_flash.c for self-flash.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for the MIMXRT1176 (i.MX RT1170) microcontroller with flash boot capability (XIP - Execute In Place). The implementation differs from other RT10xx chips by supporting both RAM-based SDP loading and direct flash boot, using a two-stage flashloader approach with blhost instead of sdphost. The PR includes support for the MIMXRT1170-EVKB evaluation board and fixes a cache invalidation bug affecting all IMXRT boards.

Key Changes:

  • Added MIMXRT1176 linker scripts for both RAM (_ram.ld) and flash (_flash.ld) boot modes
  • Implemented XIP detection to prevent FlexSPI re-initialization when running from flash
  • Fixed cache invalidation bug by using absolute addresses instead of offsets

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ports/mimxrt10xx/tusb_config.h Changed USB memory alignment from 4-byte to 32-byte for DCache compatibility
ports/mimxrt10xx/linker/MIMXRT1176_ram.ld New RAM boot linker script with adjusted memory regions for SDP loading
ports/mimxrt10xx/linker/MIMXRT1176_memory.ld New memory layout file defining MIMXRT1176-specific memory regions and offsets
ports/mimxrt10xx/linker/MIMXRT1176_flash.ld New flash boot linker script for XIP operation with 0x400 FCFB offset
ports/mimxrt10xx/family.cmake Added conditional compilation for MIMXRT1176-specific SDK files and drivers
ports/mimxrt10xx/boards/imxrt1170_evk/flash_config.c New FlexSPI NOR flash configuration for IS25WP128 flash on RT1170-EVK
ports/mimxrt10xx/boards/imxrt1170_evk/clock_config.h New clock configuration header for RT1170 dual-core support
ports/mimxrt10xx/boards/imxrt1170_evk/clock_config.c New clock initialization with XIP vs SDP detection and minimal OSC-based config
ports/mimxrt10xx/boards/imxrt1170_evk/board.mk New board makefile defining MCU variant and flash targets
ports/mimxrt10xx/boards/imxrt1170_evk/board.h New board configuration with LED, button, USB, and UART pin definitions
ports/mimxrt10xx/boards/imxrt1170_evk/board.cmake New CMake board configuration for RT1170-EVK
ports/mimxrt10xx/boards.c Added MIMXRT1176-specific USB PHY PLL initialization and board-configurable PHY calibration
ports/mimxrt10xx/board_flash.c Added XIP detection, ROM_API_Init call, and fixed cache invalidation bug
ports/mimxrt10xx/README.md Added comprehensive RT1170 documentation including build instructions and flashing guide
ports/mimxrt10xx/Makefile Added FLASH_BUILD support and blhost-based flash-sdp target for RT1176

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +54 to +56
#define SKIP_DCDC_ADJUSTMENT 1
#define SKIP_FBB_ENABLE 1
#define SKIP_LDO_ADJUSTMENT 1
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macros SKIP_DCDC_ADJUSTMENT, SKIP_FBB_ENABLE, and SKIP_LDO_ADJUSTMENT are defined but never used anywhere in this file. If these are meant to be conditional compilation flags for code that was removed or not yet implemented, they should either be removed or the relevant conditional code should be added.

Suggested change
#define SKIP_DCDC_ADJUSTMENT 1
#define SKIP_FBB_ENABLE 1
#define SKIP_LDO_ADJUSTMENT 1

Copilot uses AI. Check for mistakes.
@hathach hathach force-pushed the feature/mimxrt1176-flash-support branch from d2f8b5e to 47c841b Compare December 26, 2025 16:22
Copy link
Member

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@APIUM exellent work, thank you very much of the PR. I refactor and update PR to get SRAM version working as well. Binary is flashable via either jlink and/or sdp using blhost. For BLhost we need to create image with ivt at zero address there for need to cook the ivt header (boot start + size). Also when loaded by blhost, fcfb is not part of the image, therefore I added an fcfb copy and ivt/boot copy so that we can re-create those section.

I think we should only keep the flash-store ram-executed version only of tinyuf2, there is no benefit for the flash XIP (FLASH_BUILD) verion. It is not only slower, but is not self upgradable. Let me know what you think if that makes sense, we will just remove the FLASH_BUILD related code.

PS: LED for evkb is not working due to hard coded pinmux, I will fix this in follow up PR later.

@APIUM
Copy link
Contributor Author

APIUM commented Dec 26, 2025

@APIUM exellent work, thank you very much of the PR. I refactor and update PR to get SRAM version working as well. Binary is flashable via either jlink and/or sdp using blhost. For BLhost we need to create image with ivt at zero address there for need to cook the ivt header (boot start + size). Also when loaded by blhost, fcfb is not part of the image, therefore I added an fcfb copy and ivt/boot copy so that we can re-create those section.

Thanks for the changes and explanation, I’m on phone only so have only given a cursory look but they look good.

I think we should only keep the flash-store ram-executed version only of tinyuf2, there is no benefit for the flash XIP (FLASH_BUILD) verion. It is not only slower, but is not self upgradable. Let me know what you think if that makes sense, we will just remove the FLASH_BUILD related code.

Sounds reasonable to me, I’m happy to do this, but I’m away and not back until early Jan so if you have time before then and want it done no worries

PS: LED for evkb is not working due to hard coded pinmux, I will fix this in follow up PR later.

Ah yes I noticed this but didn’t look into it - makes sense

@hathach
Copy link
Member

hathach commented Dec 27, 2025

@APIUM great, I am glad that makes sense to you. Jan is OK, though I would be busy with other works so I think I will just do it now while having all the imxrt evk from 1011 to 1170 on my desk now.

@hathach hathach changed the title Add MIMXRT1176 (i.MX RT1170) support with flash boot Add MIMXRT1176 (i.MX RT1170) support Dec 27, 2025
Copy link
Member

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you very much for your PR. I have wrap up the rt117x support with flash stored, ram executed like other rt10xx. blhost and cooked ivt0 give me a bit of troubleshooting, but it is on running OK now. I would expect newer imxrt would use blhost instead of sdphost, so it is great to get it supported. @APIUM should there is any issue when you get back to your pc. Let me know, we can fix it with follow up pr.

@hathach hathach merged commit bbd3e39 into adafruit:master Dec 27, 2025
158 checks passed
@APIUM
Copy link
Contributor Author

APIUM commented Dec 27, 2025

thank you very much for your PR. I have wrap up the rt117x support with flash stored, ram executed like other rt10xx. blhost and cooked ivt0 give me a bit of troubleshooting, but it is on running OK now. I would expect newer imxrt would use blhost instead of sdphost, so it is great to get it supported. @APIUM should there is any issue when you get back to your pc. Let me know, we can fix it with follow up pr.

Great to have this merged, thanks for your help and follow up work @hathach. I will let you know if I have any issues.

@hathach
Copy link
Member

hathach commented Dec 29, 2025

@APIUM I made an follow up PR to fix rt1170 evk LED and also refactor to use the .mex (mcux pinconfig tool) to make it easier to config pin/clock. Though I found that rt1170 run with very low cpu frequency i.e. 24MH comparing to other smaller chip with 600Mhz. I tried to tweak it to its nominal freq at 900mhz, although tinyuf2 can boot, but jumping to app e.g blinky does not work. Not sure what is wrong but If you could find time to fix it, it would be great thank you.

PS: pr is #469

@APIUM
Copy link
Contributor Author

APIUM commented Jan 6, 2026

@hathach was able to have a look at this today, does this change fix it for you? I could only test on my customboard so not 100% it sorts it out on the EVK but I'm not sure why it wouldn't.

#470

Still does initial SDP flash at 24MHz, but as soon as it's on flash it's full speed and working well for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants