Can't program external flash

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

Can't program external flash

1,690 Views
thomas1234
Contributor II

Hello,

I can't successfully program my external flash.

I'm using:

  • IMXrt633S MCU
  • MX66UM1G45G 1Gb Spi Nor Flash
  • On a custom PCB

The flash is connected to the FlexSPI Port B, just as seen in the IMXRT685S Evaluation Board.

 

I did:

  1. Create a new empty project for the RT633S
  2. Add flash_config folder, copy flash_config.c/h from RT685S examples, change flash size.
  3. Create a flash memory and add an appropriate driver in MCU settings
  4. In Symbols, add "BOOT_HEADER_ENABLE=1"

I dont know if it is important for flashing, too, but I also set the ISP Boot Pins to:
ISP0 = 0
ISP1 = 1
ISP2 = 0

Which is the config to boot from external flash connected to FlexSPI Port B.

 

However, with the above steps I'm unable to program my external flash.
When trying, I get the following error:

****** Error: Failed to prepare RAMCode using RAM
Error while determining flash info (Bank @ 0x08000000)
Unspecified error -1
Script processing completed.
Unable to perform operation!
Command failed with exit code 1

 

I really need your help with this.

 

Thanks a lot,
Thomas

0 Kudos
8 Replies

1,629 Views
thomas1234
Contributor II

Hi Kerry and thanks once again for your help!

Yes, I can erase, write and readback the flash using the MCU Bootutil.
I was looking also at the example project you've mentioned. But to be honest, I thought the issue must be much much simpler. So I was checking a lot of stuff, like the blhost commands and here I found the actual binary data that is written to the Flash.

This can be found in "MCU-BOOTUTILITY\gen\bootable_image\bt_<imagename>.bin" and is generated by the boot utility.
This file does not contain an ELF-Header at all. Further it looks as the binary data I am able to read back.

This means that I have just been confused about the MCUBootUtil writing a different file than the .axf to the flash memory. I was reading some "headless" binary back and was thinking, something has been cutoff. As I cannot boot, this seemed to be the logical consequence for me.
I am totally sorry. It was just the bt_*.bin format.

 

So in conclusion, the flashing works as expected.
Now I'm going to work on the boot process.

 

Again, thank you so much for all your help the last couple of days. This is great!

 

All the best,
Thomas

0 Kudos

1,613 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @thomas1234 ,

  If the ISP mode, you can use the MCUbootutility tool write and erase code, your external flash connection works OK.

 So, now, when you switch to the PORTB boot: ISP0 = 0 ISP1 = 1 ISP2 = 0.

 Maybe, these issues:

APP code is not matched your RT633.

 I have a suggestion, can you use the debugger download the RAM code? eg, the led_blinky code, when the RAM code works, then you generate the .s19 file, then add to the mcubootutility, and download it to the flash. you can try it.

Normally, I will try this one in the tool:led_blinky_0x0001c000.srec

You can use your own app, which works with RAM in debug mode. Note, RAM, not the flash debugger.

About your questions:This can be found in "MCU-BOOTUTILITY\gen\bootable_image\bt_<imagename>.bin" 

This is OK, as the tool will convert the elf to the bin, then download it. Tool will add the header.

If you have the MIMXRT685-EVK, you also can check the related bt, that will be same and it can work.

About the boot, I suggest you use your own app.srec which is confirmed working in the RAM debugger.

 

Any updated information.

Best Regards,

Kerry

 

 

 

 

0 Kudos

1,650 Views
thomas1234
Contributor II

a

0 Kudos

1,673 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @thomas1234 

  Do you use the IDE and the debugger to download the code to your external image?

  What's the debugger and IDE you are using?

  As the RT600 is default using the octal flash, so the IDE will use the octal flashdriver in default.

  So, to the IDE download, you also need to change the flashdriver.

  I suggest you try the MCUBootUtility tool at first, enter the ISP mode, then select the QSPI flash, whether you can connect it or not?

https://github.com/JayHeng/NXP-MCUBootUtility/archive/refs/tags/v3.3.0.zip
the related user manual is:
https://github.com/JayHeng/NXP-MCUBootUtility

 

Best Regards,

Kerry

1,664 Views
thomas1234
Contributor II

Hi Kerry,

thanks a lot for your reply.

I am using the J-Link debug probe and the MCUXPresso IDE.

 

When using the MCUBoot-Utility I can successfully program the Flash, even though it is a bit strange:

  • I cannot use tha actual MX66XXXXX flash, then the IDE freezes and crashes after some time
  • I can however use the same flash that is used on the Development Board for the RT685S. The flash is a different series but same vendor (Macronix).

I guess, this works due to the fact that my setup as well as the Development Board are both using Macronix Flashes on FLEXSPI Port B.

 

Even though I can program, erase and read back the flash, I am still unable to boot from it.
I was able to download my program, read it back and disassemble it.
When disassembling e.g. the ELF header is missing. It seems like the whole image begins before I am actually reading it back with the tool. The main is also not contained, a lot of other functions are contained though.
This might be due to different flashes/different flash sizes.

 

Can you tell me the needed steps to program my external flash from within the MCUXpresso-IDE by using the Segger J-Link debug probe? In the future I would also have to debug my firmware which is why I want to use the IDE.

 

Thanks for your help,
Thomas

0 Kudos

1,657 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @thomas1234 ,

   If you use the MCUbootUtility dowload, then whether it can boot or not after you configure the correct ISP pins?

  About the debugger, it should be caused by the JLINK flashdriver, as you know, the RT685 default one is the octal flash, so if you want to change it to the QSPI flash, you need to modify the JLINK flashdriver, normally, it can be added in the .xml in the JLINK driver, as the IDE also calls that related files. You need to change the JLINK RT600 flashdriver to the QSPI flash driver.

Best Regard,

Kerry

1,650 Views
thomas1234
Contributor II

Hi Kerry, great to hear from you again.

The problem is that I cannot boot, neither by flashing with the MCUBootUtility nor by flashing via J-Link Debug probe from within MCUXpresso.
I am able to flash with both methods now. But booting afterwards is not possible. The ISP pins are correctly set, so this cannot be the issue.

When reading back the image from flash, there is a whole lot of stuff missing, like e.g. the ELF header at the beginning. The read-back firmware image just starts in the middle of the binary, so to say. I just do not understand, why this is the case.

Have you maybe encountered this before? Any ideas?

 

All the best,
Thomas

0 Kudos

1,636 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @thomas1234 ,

   If download with the MCUBootUtility can't boot, whether your connection, erase or write works OK or not?

   I think you may need to run some QSPI testing code in the RAM with the debugger.

   Do you know how to modify the QSPI code?

   You can modify this SDK code:

SDK_2_10_0_EVK-MIMXRT685\boards\evkmimxrt685\driver_examples\flexspi\octal\polling_transfer

Change the flexSPI related pins to your QSPI pins, the LUT and configuration to the QSPI.

You also can refer to the RT1060 related code, as that chip is using the QSPI memory.

Please note, this code should run in the internal RAM, it will run code in RAM and to check the external memory read, erase, write function.

As the MIMXRT685-EVK just with the octal flash, so I have limit to test the QSPI flash situation.

You can test it, and give me the updated information.

Best Regards,

Kerry