Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: XIP from external memory on 4.1?

  1. #1
    Member
    Join Date
    Sep 2019
    Location
    United States
    Posts
    30

    XIP from external memory on 4.1?

    Hi,
    I'm considering what I guess would be a non-standard memory map; but it depends on
    the ability to run XIP from the add-on memory (PSRAM &| FLASH) on the Teesny4.1.
    I see that they are hooked up to the FlexSPI interface on the chip, and the 1060 does support
    XIP from FlexSPI, so is there any reason why I wouldn't be able to run XIP (execute in place)
    from either of those devices?

    As a follow-on question (assuming I can run XIP from those external devices); does the HalfKay
    bootloader support writing to the external Flash memory space?
    Thanks,

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,250
    Quote Originally Posted by edsut View Post
    so is there any reason why I wouldn't be able to run XIP (execute in place)
    from either of those devices?
    Yes, the MPU would be 1 reason...

    By default the memory ranges not normally used for code are configured with NOEXEC. It's meant as a security precaution. So you would need to edit this code in startup.c:

    Code:
            SCB_MPU_RBAR = 0x70000000 | REGION(i++); // FlexSPI2
            SCB_MPU_RASR = MEM_CACHE_WBWA | READONLY | NOEXEC | SIZE_256M;
    
            SCB_MPU_RBAR = 0x70000000 | REGION(i++); // FlexSPI2
            SCB_MPU_RASR = MEM_CACHE_WBWA | READWRITE | NOEXEC | SIZE_16M;
    If you delete NOEXEC, then it should become possible to execute code from those memory ranges.


    does the HalfKay bootloader support writing to the external Flash memory space?
    No, definitely not. You will need to arrange for putting the code into that memory. The bootloader only knows how to write to the main flash memory. The bootloader also does not erase that memory, so each time you wish to change that code, you'll need to erase it before writing new data. But the good news is once you've build special code and gone though the trouble to write it there, it will remain intact in that extra flash memory chip as you do normal loading of the main flash memory.

    You also need the linker to create code meant to execute from the address where you will place it. The compiler can do that, but at the very least you will need to create a special linker script.

  3. #3
    Member
    Join Date
    Sep 2019
    Location
    United States
    Posts
    30
    I'm back to transitioning from an eval board to Teensy4.1 and I'm having some trouble getting my image booted with HalfKay,
    so I just wanna make sure I'm doing things correctly...
    Am I correct to assume that as long as I limit the addresses in the .hex file (fed to teensy_loader_cli) to space within
    the main flash memory, then HalfKay will program that space... Correct?
    (i.e. there is no off-limits area in the main flash memory, correct?)
    Thanks,

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,250
    The top 256K of the 8M flash chip on Teensy 4.1 is reserved. Teensy Loader will complain if your .hex file has data beyond the first 7936K. The "imxrt1062_t41.ld" linker file we use in Teensyduino also restricts the compiler to use only 7936K of the 8192K flash. But if you edit the linker file or build with another system, Teensy Loader will not allow you to load code into that top 256K.

    In the reserved space, 252K is used for eeprom emulation. Data you have stored in the emulated eeprom is meant to persist between uploads, which is the reason you can't load code into that memory.

    The top 4K is a copy of the LED blink example. When you hold the pushbutton for 15 seconds for a complete wipe of all non-volatile memory, that little program is copied to the beginning of the flash so your Teensy reboots to a known-good program. The top 4K is permanently hardware locked. It can never be erased or altered.

  5. #5
    Member
    Join Date
    Sep 2019
    Location
    United States
    Posts
    30
    Ok, good to know. I'll just allocate that upper 256K for the same purpose.
    Tx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •