tinyuf2 icon indicating copy to clipboard operation
tinyuf2 copied to clipboard

Flash issue with RT1024 EVK

Open hathach opened this issue 3 years ago • 7 comments

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 avatar Jul 15 '22 17:07 hathach

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.

tannewt avatar Mar 30 '23 16:03 tannewt

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.

hathach avatar Mar 31 '23 03:03 hathach

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

gsteiert avatar Apr 01 '23 14:04 gsteiert

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?

tannewt avatar Apr 03 '23 16:04 tannewt

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

gsteiert avatar Apr 03 '23 18:04 gsteiert

@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?

tannewt avatar Apr 03 '23 18:04 tannewt

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

gsteiert avatar Apr 03 '23 19:04 gsteiert