Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flash issue with RT1024 EVK #231

Open
hathach opened this issue Jul 15, 2022 · 7 comments
Open

Flash issue with RT1024 EVK #231

hathach opened this issue Jul 15, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@hathach
Copy link
Member

hathach commented Jul 15, 2022

Operating System

Linux

INFO_UF2.TXT

TinyUF2 Bootloader 0.10.2-21-g71a89e4-dirty - nxp/mcux-sdk (MCUX_2.10.0-25-ga242602a) tinyusb (0.12.0-203-ga4cfd1c6)
Model: NXP RT1024 EVK
Board-ID: MIMXRT1024-EVK-revA
Date: Jul 15 2022

What happened ?

  • flash-sdp work, bootloader seems to run well on SRAM, and seems to write to flash
  • however when reset, the booROM run again instead of the tinyuf2 even though the boot switch is set to normal 10

This seems to indicate there is some misconfigured in the fcfb that cause bootROM to run instead of loading tinuf2. I have tried to alter several flash_config but does not seem to work.

NOTE: rt1020 evt work well with an 8MB external flash, the rt1024 with built-in qspi flash probably need a bit more testing.

How to reproduce ?

  1. power rt1024 with BOOTSW = 10
  2. make BOARD=imxrt1024_evk LOG=1 flash-sdp
  3. TinyUF2 will show up as RT1024BOOT
  4. press reset
  5. the bootROM will run instead of tinyuf2
[ 7621.815570] usb 3-2: New USB device found, idVendor=1fc9, idProduct=0130, bcdDevice= 1.01
[ 7621.815576] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 7621.815578] usb 3-2: Product: SE Blank RT Family 
[ 7621.815580] usb 3-2: Manufacturer: NXP      SemiConductors Inc 

Debug Log

n/a

Screenshots

No response

@hathach hathach added the bug Something isn't working label Jul 15, 2022
@tannewt
Copy link
Member

tannewt commented Mar 30, 2023

Could this be due to an incorrect address in the IVT? Seems like it should be patched when written to flash. The addresses used in RAM won't work when loaded from flash. In particular, the reset handler will run from flash because it loads everything into ram.

@hathach
Copy link
Member Author

hathach commented Mar 31, 2023

There is a recent pr fixed by other users to tinyusb that fixes the 1024 issue. I will pull out and check this later next week when I get back from vacation.

@gsteiert
Copy link
Collaborator

gsteiert commented Apr 1, 2023

TinyUF2 only writes itself to flash under certain conditions (from board_flash.c):

  // TinyUF2 will copy its image to flash if one of conditions meets:
  // - Boot Mode is '01' i.e Serial Download Mode (BootRom)
  // - Flash FCFB is invalid e.g blank flash
  // - Flash contents does not match running tinyuf2 in SRAM (depending on COMPARE_AND_WRITE_TINYUF2)

Here are four ways to force it to load:

  1. Change BOOTSW to 01
  2. Erase flash before loading to clear FCFB
  3. Drag-n-drop the TinyUF2.uf2 self update image after loading
  4. Change COMPARE_AND_WRITE_TINYUF2 define to 1

@tannewt
Copy link
Member

tannewt commented Apr 3, 2023

I think I got TinyUF2 writing to flash ok.

What I don't understand is that the RAM version is linked to run from the address range of RAM. How does that work when loading/running from flash?

@gsteiert
Copy link
Collaborator

gsteiert commented Apr 3, 2023

One of the entries in the IVT is for the boot data structure.
The boot data includes the start address and image length.
The ROM reads the boot header, and if the start address is in RAM, it copies the image to RAM.

The IVT and boot data structures are in flash_config.c
The definition for BOARD_BOOT_START is in boards.h

@tannewt
Copy link
Member

tannewt commented Apr 3, 2023

@gsteiert Any pointers to where this is documented? How does the RAM address need to relate to the flash address? Does the start of the image start with the boot data?

@gsteiert
Copy link
Collaborator

gsteiert commented Apr 3, 2023

See the program image section of the reference manual (9.7 in RT1010)
The i.MX RT Flashloader Use Case app note also has some additional information:
https://www.nxp.com/docs/en/nxp/application-notes/AN12238.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants