RT685 SD card boot - loading image on SD card corrupts SD card FAT32 formatting

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RT685 SD card boot - loading image on SD card corrupts SD card FAT32 formatting

Jump to solution
1,369 Views
dash
Contributor II

With support from NXP, I was able to obtain instructions to program an SD card for SD card boot mode and then boot from the SD card.

The issue is those steps corrupt the SD card's FAT32 formatting. I am not an expert on SD card FAT32 formatting but I found a utility that allows me to select a FAT32 sector size of 4KB.

4KB is relevant because the boot ROM was carefully designed to boot the image from SD card address 4K (0x1000) to leave space for a boot table.

Still, it seems, the steps to use blhost to write the image to 0x1000 on the SD card still results in the SD card no longer being recognized when I plug it back into my Windows 10 PC.

  1. Format the SD card for fat32, 4KB sectors
  2. Build a RAM application, I chose Hello World 
  3. Plug in SD card to RT685 EVK
  4. Set DIP switch to ISP mode (001), connect USB to J7 (power up reset)
  5. blhost -u 0x1fc9,0x0020 get-property 1
  6. blhost -u 0x1fc9,0x0020 -- fill-memory 0x1c000 4 0xd0080000
  7. blhost -u 0x1fc9,0x0020 -- configure-memory 0x120 0x1c000
  8. blhost -u 0x1fc9,0x0020 -t 100000 -- flash-erase-region 0x0 0x100000 0x120
    this step maybe should change the start address 0x1000 from 0x0, but SD boot does not work with that modification
  9. blhost -u 0x1fc9,0x0020 -- write-memory 0x1000 evkmimxrt685_hello_world.bin 0x120
  10. Change DIP switch to SD boot mode (110), connect USB to J5
  11. Start Teraterm or similar to COM port of the board
    be sure SDK_DEBUGCONSOLE=1 in MCUExpresso build settings for COM port terminal output
  12. Start JLink commander connect to MIMRT685, SWD, default speed
  13. At Jlink prompt type "w4 0x40130188 0x21" - program JLink OTP shadow register to select SD card vs eMMC
  14. Press reset button to see "Hello world" in the terminal output
  15. Unplugging, plugging USB J5 will lose the setting in step 13 unless the actual OTP bit is programmed (versus the shadow register)
  16. Once you have had enough fun with that, remove the SD card and plug into your PC. You will see it is no longer recognized as fat32 and Windows prompts you to reformat it.

I need a set of instructions that allows me to load an image, block that the area starting at 0x1000 for the size of the image, but still retain the ability to use the SD card with the SDK fatfs library functions.

Labels (1)
0 Kudos
1 Solution
1,352 Views
tsi-chung_liew
NXP Employee
NXP Employee

In BLHost, the erase region should not start at 0. That will erase the partition table, starts at 4k (0x1000) to start of filesystem partition. (see below how to assign un-allocate region)

The BLHost flash-erase-region end address must not exceed the filesystem partition created using diskpart

$BLHOST -t 100000 -- flash-erase-region 0x1000 0x200000 0x120

 

If you have windows OS (Win 8 – Win 10), use diskpart command in command prompt (administrator).

***** NOTE: Be VERY EXTREMELY careful when you select the drive, accidently select the wrong drive will not be NXP responsibility!!! *****

 

tsichung_liew_0-1635258982124.jpeg

 

I have a 4GB standard SD card to USB adapter connects to PC. Type list disk to list all the drives.

tsichung_liew_1-1635258982127.jpeg

 

Type select disk # to select the disk you want to work on.

tsichung_liew_2-1635258982127.png

 

Type list disk again, you will see ‘ * “ next to the disk. That means the disk is selected.

tsichung_liew_3-1635258982128.png

 

Type clean will delete the partition

tsichung_liew_4-1635258982128.png

 

Provide offset when create the partition. The filesystem is defined when format is used.

tsichung_liew_5-1635258982130.png

tsichung_liew_6-1635258982132.png

Another example: 4MB offset

tsichung_liew_7-1635258982132.png

tsichung_liew_8-1635258982133.png

The partition is not formatted, it needs to be assigned a file system (FAT32/exFAT/NTFS) by formating it using the following methods:

tsichung_liew_9-1635259359396.png

tsichung_liew_10-1635259499802.pngtsichung_liew_11-1635259516270.png

 

View solution in original post

0 Kudos
2 Replies
1,353 Views
tsi-chung_liew
NXP Employee
NXP Employee

In BLHost, the erase region should not start at 0. That will erase the partition table, starts at 4k (0x1000) to start of filesystem partition. (see below how to assign un-allocate region)

The BLHost flash-erase-region end address must not exceed the filesystem partition created using diskpart

$BLHOST -t 100000 -- flash-erase-region 0x1000 0x200000 0x120

 

If you have windows OS (Win 8 – Win 10), use diskpart command in command prompt (administrator).

***** NOTE: Be VERY EXTREMELY careful when you select the drive, accidently select the wrong drive will not be NXP responsibility!!! *****

 

tsichung_liew_0-1635258982124.jpeg

 

I have a 4GB standard SD card to USB adapter connects to PC. Type list disk to list all the drives.

tsichung_liew_1-1635258982127.jpeg

 

Type select disk # to select the disk you want to work on.

tsichung_liew_2-1635258982127.png

 

Type list disk again, you will see ‘ * “ next to the disk. That means the disk is selected.

tsichung_liew_3-1635258982128.png

 

Type clean will delete the partition

tsichung_liew_4-1635258982128.png

 

Provide offset when create the partition. The filesystem is defined when format is used.

tsichung_liew_5-1635258982130.png

tsichung_liew_6-1635258982132.png

Another example: 4MB offset

tsichung_liew_7-1635258982132.png

tsichung_liew_8-1635258982133.png

The partition is not formatted, it needs to be assigned a file system (FAT32/exFAT/NTFS) by formating it using the following methods:

tsichung_liew_9-1635259359396.png

tsichung_liew_10-1635259499802.pngtsichung_liew_11-1635259516270.png

 

0 Kudos
1,360 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dash ,

   So, now, your download to the SD card and boot app from sd card all works, just the sd card can't be detect directly by the PC, right?

   Seems your SD card MBR is broken.

  Please try to modify the erase range:

blhost -u 0x1fc9,0x0020 -t 100000 -- flash-erase-region 0x0 0x100000 0x120

  Please don't erase from the 0X0, as that area put the MBR, you can try to modify from 0X400, which is the FCB area, then test it again, whether it is OK or not?

  Any updated information, please kindly let me know.

Best Regards,

Kerry

 

 

0 Kudos