Writing to the QSPI Flash of i.MX RT1021 using write_image_win.bat

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

Writing to the QSPI Flash of i.MX RT1021 using write_image_win.bat

Jump to solution
1,199 Views
takagi_y
Contributor III

I am using write_image_win.bat to write to the QSPI Flash of i.MX RT1021.

However, writing to a brand new board fails.

The situation is as follows.

・When writing to a brand new board with a bat file, the process that displays "Erase memory before writing image" displays "failed".

・Boards that have already been written to with the SEC tool can be written to with the bat file.

This situation also occurs with i.MX RT1062 and MCXN947.

The following are the questions I would like to ask.

1. Why can't I write to a brand new board with a bat file?

2. Is there something I need to do to write to a brand new board with a bat file?

3. Is there a difference between a board that has already been written to with the SEC tool and a brand new board?

Please answer.

Best regards

Labels (2)
0 Kudos
Reply
1 Solution
1,123 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @takagi_y ,

Yes, your understanding is correct.When executing the ext_memory_setup.bat, the point is to load the flashloader into RAM, and after that, any operations on the flash need to call the instructions in the flashloader.

If you still want to explore the details, it's a good idea to use MCUBootUtility, as it doesn't encapsulate any bat file at all, and what's shown in the log window is the full blhost command, fully exposed to the user.

Best regards,
Gavin

View solution in original post

0 Kudos
Reply
5 Replies
1,164 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @takagi_y ,

Thanks for your interest in NXP MIMXRT series!

When we burn image with the SEC tool, we need to make sure that the board is placed in serial download mode and it needs to match the board's flash.

Please first make sure that your new board is ready to burn image via the SEC tool after performing these preliminary steps.

Then, in the log window of the SEC tool, it points out all the underlying commands executed, and by analyzing them, you can even create your own *.bat scripts.

Best regards,
Gavin

0 Kudos
Reply
1,150 Views
takagi_y
Contributor III

Thank you for your reply.

The board mode is set to serial download mode.

The same Flash is used for the writable board and the new board.

After performing "Test connection" for USB and "Test the configuration" for "FlexSPI NOR - simplified" in the SEC tool, I closed the SEC tool, turned the board back on, and tried writing using the bat file, and writing was successful.

Does the USB and FlexSPI tests perform any processing on the board other than just checking the connection?

Also, is it correct to assume that the FlexSPI test performs the same processing as ext_memory_setup.bat?

If the processing is the same, does this mean that writing can be performed on a new board by running ext_memory_setup.bat and then write_image_win.bat?

Best regards

0 Kudos
Reply
1,124 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @takagi_y ,

Yes, your understanding is correct.When executing the ext_memory_setup.bat, the point is to load the flashloader into RAM, and after that, any operations on the flash need to call the instructions in the flashloader.

If you still want to explore the details, it's a good idea to use MCUBootUtility, as it doesn't encapsulate any bat file at all, and what's shown in the log window is the full blhost command, fully exposed to the user.

Best regards,
Gavin

0 Kudos
Reply
1,115 Views
takagi_y
Contributor III

Thank you for your reply.

I also appreciate your advice.

Could you please explain a bit more about the need to read the flashloader into RAM?

If the power is turned off after the flashloader has been read into RAM, will the flashloader stored in RAM be erased?

If you run ext_memory_setup.bat once, you can write using write_image_win.bat even if you turn the power on and off.

Does this mean that by running ext_memory_setup.bat, the chip is set up so that the flashloader is read into RAM every time the power is turned on?

If so, is the setting something like Flash or something like eFuse?

Best regards

Tags (1)
0 Kudos
Reply
1,093 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @takagi_y ,

If the power is turned off after the flashloader has been read into RAM, will the flashloader stored in RAM be erased?

If you run ext_memory_setup.bat once, you can write using write_image_win.bat even if you turn the power on and off.

After the board is powered down and rebooted, the flashloader running in RAM will disappear, but the step write image will be executed to check the running status of the flashloader, and if it is not running, it will reload the flashloader, which is executed by calling init_flashloader_win.bat. 

You can see the overall flow by deleting the logs in the logs folder, then re-powering up the board and executing only the write image, and then checking the logs file.

To be precise, SEC generates a lot of scripts and corresponding flashloader in this step of testing connection, and these scripts may also call others later.

 

Best regards,
Gavin

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2083229%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EWriting%20to%20the%20QSPI%20Flash%20of%20i.MX%20RT1021%20using%20write_image_win.bat%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2083229%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20am%20using%20write_image_win.bat%20to%20write%20to%20the%20QSPI%20Flash%20of%20i.MX%20RT1021.%3C%2FP%3E%3CP%3EHowever%2C%20writing%20to%20a%20brand%20new%20board%20fails.%3C%2FP%3E%3CP%3EThe%20situation%20is%20as%20follows.%3C%2FP%3E%3CP%3E%E3%83%BBWhen%20writing%20to%20a%20brand%20new%20board%20with%20a%20bat%20file%2C%20the%20process%20that%20displays%20%22Erase%20memory%20before%20writing%20image%22%20displays%20%22failed%22.%3C%2FP%3E%3CP%3E%E3%83%BBBoards%20that%20have%20already%20been%20written%20to%20with%20the%20SEC%20tool%20can%20be%20written%20to%20with%20the%20bat%20file.%3C%2FP%3E%3CP%3EThis%20situation%20also%20occurs%20with%20i.MX%20RT1062%20and%20MCXN947.%3C%2FP%3E%3CP%3EThe%20following%20are%20the%20questions%20I%20would%20like%20to%20ask.%3C%2FP%3E%3CP%3E1.%20Why%20can't%20I%20write%20to%20a%20brand%20new%20board%20with%20a%20bat%20file%3F%3C%2FP%3E%3CP%3E2.%20Is%20there%20something%20I%20need%20to%20do%20to%20write%20to%20a%20brand%20new%20board%20with%20a%20bat%20file%3F%3C%2FP%3E%3CP%3E3.%20Is%20there%20a%20difference%20between%20a%20board%20that%20has%20already%20been%20written%20to%20with%20the%20SEC%20tool%20and%20a%20brand%20new%20board%3F%3C%2FP%3E%3CP%3EPlease%20answer.%3C%2FP%3E%3CP%3EBest%20regards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2083229%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MXRT%20102x%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ei.MXRT%20106x%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2085167%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Writing%20to%20the%20QSPI%20Flash%20of%20i.MX%20RT1021%20using%20write_image_win.bat%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2085167%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F247126%22%20target%3D%22_blank%22%3E%40takagi_y%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3EIf%20the%20power%20is%20turned%20off%20after%20the%20flashloader%20has%20been%20read%20into%20RAM%2C%20will%20the%20flashloader%20stored%20in%20RAM%20be%20erased%3F%3C%2FP%3E%0A%3CP%3EIf%20you%20run%20ext_memory_setup.bat%20once%2C%20you%20can%20write%20using%20write_image_win.bat%20even%20if%20you%20turn%20the%20power%20on%20and%20off.%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3EAfter%20the%20board%20is%20powered%20down%20and%20rebooted%2C%20the%20flashloader%20running%20in%20RAM%20will%20disappear%2C%20but%20the%20step%20write%20image%20will%20be%20executed%20to%20check%20the%20running%20status%20of%20the%20flashloader%2C%20and%20if%20it%20is%20not%20running%2C%20it%20will%20reload%20the%20flashloader%2C%20which%20is%20executed%20by%20calling%20init_flashloader_win.bat.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20see%20the%20overall%20flow%20by%20deleting%20the%20logs%20in%20the%20logs%20folder%2C%20then%20re-powering%20up%20the%20board%20and%20executing%20only%20the%20write%20image%2C%20and%20then%20checking%20the%20logs%20file.%3C%2FP%3E%0A%3CP%3ETo%20be%20precise%2C%20SEC%20generates%20a%20lot%20of%20scripts%20and%20corresponding%20flashloader%20in%20this%20step%20of%20testing%20connection%2C%20and%20these%20scripts%20may%20also%20call%20others%20later.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBest%20regards%2C%3CBR%20%2F%3EGavin%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2084481%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Writing%20to%20the%20QSPI%20Flash%20of%20i.MX%20RT1021%20using%20write_image_win.bat%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2084481%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20for%20your%20reply.%3C%2FP%3E%3CP%3EI%20also%20appreciate%20your%20advice.%3C%2FP%3E%3CP%3ECould%20you%20please%20explain%20a%20bit%20more%20about%20the%20need%20to%20read%20the%20flashloader%20into%20RAM%3F%3C%2FP%3E%3CP%3EIf%20the%20power%20is%20turned%20off%20after%20the%20flashloader%20has%20been%20read%20into%20RAM%2C%20will%20the%20flashloader%20stored%20in%20RAM%20be%20erased%3F%3C%2FP%3E%3CP%3EIf%20you%20run%20ext_memory_setup.bat%20once%2C%20you%20can%20write%20using%20write_image_win.bat%20even%20if%20you%20turn%20the%20power%20on%20and%20off.%3C%2FP%3E%3CP%3EDoes%20this%20mean%20that%20by%20running%20ext_memory_setup.bat%2C%20the%20chip%20is%20set%20up%20so%20that%20the%20flashloader%20is%20read%20into%20RAM%20every%20time%20the%20power%20is%20turned%20on%3F%3C%2FP%3E%3CP%3EIf%20so%2C%20is%20the%20setting%20something%20like%20Flash%20or%20something%20like%20eFuse%3F%3C%2FP%3E%3CP%3EBest%20regards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2084394%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Writing%20to%20the%20QSPI%20Flash%20of%20i.MX%20RT1021%20using%20write_image_win.bat%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2084394%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F247126%22%20target%3D%22_blank%22%3E%40takagi_y%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EYes%2C%20your%20understanding%20is%20correct.When%20executing%20the%20ext_memory_setup.bat%2C%20the%20point%20is%20to%20load%20the%20flashloader%20into%20RAM%2C%20and%20after%20that%2C%20any%20operations%20on%20the%20flash%20need%20to%20call%20the%20instructions%20in%20the%20flashloader.%3C%2FP%3E%0A%3CP%3EIf%20you%20still%20want%20to%20explore%20the%20details%2C%20it's%20a%20good%20idea%20to%20use%20MCUBootUtility%2C%20as%20it%20doesn't%20encapsulate%20any%20bat%20file%20at%20all%2C%20and%20what's%20shown%20in%20the%20log%20window%20is%20the%20full%20blhost%20command%2C%20fully%20exposed%20to%20the%20user.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3CBR%20%2F%3EGavin%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2083737%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Writing%20to%20the%20QSPI%20Flash%20of%20i.MX%20RT1021%20using%20write_image_win.bat%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2083737%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20for%20your%20reply.%3C%2FP%3E%3CP%3EThe%20board%20mode%20is%20set%20to%20serial%20download%20mode.%3C%2FP%3E%3CP%3EThe%20same%20Flash%20is%20used%20for%20the%20writable%20board%20and%20the%20new%20board.%3C%2FP%3E%3CP%3EAfter%20performing%20%22Test%20connection%22%20for%20USB%20and%20%22Test%20the%20configuration%22%20for%20%22FlexSPI%20NOR%20-%20simplified%22%20in%20the%20SEC%20tool%2C%20I%20closed%20the%20SEC%20tool%2C%20turned%20the%20board%20back%20on%2C%20and%20tried%20writing%20using%20the%20bat%20file%2C%20and%20writing%20was%20successful.%3C%2FP%3E%3CP%3EDoes%20the%20USB%20and%20FlexSPI%20tests%20perform%20any%20processing%20on%20the%20board%20other%20than%20just%20checking%20the%20connection%3F%3C%2FP%3E%3CP%3EAlso%2C%20is%20it%20correct%20to%20assume%20that%20the%20FlexSPI%20test%20performs%20the%20same%20processing%20as%20ext_memory_setup.bat%3F%3C%2FP%3E%3CP%3EIf%20the%20processing%20is%20the%20same%2C%20does%20this%20mean%20that%20writing%20can%20be%20performed%20on%20a%20new%20board%20by%20running%20ext_memory_setup.bat%20and%20then%20write_image_win.bat%3F%3C%2FP%3E%3CP%3EBest%20regards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2083633%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Writing%20to%20the%20QSPI%20Flash%20of%20i.MX%20RT1021%20using%20write_image_win.bat%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2083633%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F247126%22%20target%3D%22_blank%22%3E%40takagi_y%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EThanks%20for%20your%20interest%20in%20NXP%20MIMXRT%20series!%3C%2FP%3E%0A%3CP%3EWhen%20we%20burn%20image%20with%20the%20SEC%20tool%2C%20we%20need%20to%20make%20sure%20that%20the%20board%20is%20placed%20in%20serial%20download%20mode%20and%20it%20needs%20to%20match%20the%20board's%20flash.%3C%2FP%3E%0A%3CP%3EPlease%20first%20make%20sure%20that%20your%20new%20board%20is%20ready%20to%20burn%20image%20via%20the%20SEC%20tool%20after%20performing%20these%20preliminary%20steps.%3C%2FP%3E%0A%3CP%3EThen%2C%20in%20the%20log%20window%20of%20the%20SEC%20tool%2C%20it%20points%20out%20all%20the%20underlying%20commands%20executed%2C%20and%20by%20analyzing%20them%2C%20you%20can%20even%20create%20your%20own%20*.bat%20scripts.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3CBR%20%2F%3EGavin%3C%2FP%3E%3C%2FLINGO-BODY%3E