Unable to integrate NOR FLASH SDK example into my C++ project

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

Unable to integrate NOR FLASH SDK example into my C++ project

Jump to solution
1,018 Views
bp1979
Senior Contributor I

Hi,

I am using the imx rt 1020 EVK board. I can run the NOR FLASH SDK example without issues. 

When I try to integrate the NOR FLASH SDK example in my own C++ project, I keep running into weird issues. Bus errors, Imprecise data bus errors, null pointer exceptions in the Flex SPI interrupt handler.

I created a new fresh new imx rt 1020 EVK C++ project, and started to integrate the SDK example. With minimal changes applied, I can reproduce the problem in my small C++ project.

The steps I took:

- New project, choose evk 1020, C++

- in Drivers selection add, choose cache, flexspi

- in Abstraction Layer, choose nor_flash-common, nor_flash-controller-flexpi

- Click finish, generate the project.

In the newly generated C++ project, I added the initialization code 

 

Nor_Flash_Initialization(&norConfig, &norHandle);

 

(and I also added the initialization of config and handle).

The problem occurs when this function gets executed:

bp1979_0-1628589306730.png

 

bp1979_1-1628589328866.png

I added the complete project to this post as zip.

I am completely blocked by this, I have no clue what to do. 

Some help/tips would be greatly appreciated!

 

 

0 Kudos
1 Solution
991 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @bp1979 

  The SDK project already copy the related files to the internal RAM, do you do it?

kerryzhou_0-1628666116033.png

You can the debug result, the API in the internal RAM:

kerryzhou_1-1628666134454.png

Wish it helps you!

Best Regards,

Kerry

 

 

 

View solution in original post

5 Replies
1,003 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @bp1979 

 I smiply checked your code, why you do the Nor_flash_initalization in the app code?

  Do you try the sample one, no flash operation, just do the printf or the led_blinky, whether that method C++ project works or not?

  Let me tell you, your code is running in the external flash, as you know, the external QSPI flash is not the RWW chip, so you can't run the code, and do the flash operation at the same time.

  If you need to do the external flash operation, you need to copy the code to the internal RAM intead of running in the external flash.

  So, your issues should not be caused by the C++, just your functions, you can test the simple project at first, whehter that works or not?

Best Regards,

kerry

0 Kudos
996 Views
bp1979
Senior Contributor I

Hi @kerryzhou 

Thanks for taking the time to look at my project!  

The simple blink / printf stuff will work (haven't tried, but I already have an entire application running on my board). I am trying to start making my bootloader, hence I need to be able to write my downloaded firmware.bin to some portion in flash.

You state:

Let me tell you, your code is running in the external flash, as you know, the external QSPI flash is not the RWW chip, so you can't run the code, and do the flash operation at the same time.

 Can you then please explain why this works fine in the SDK example? 

Screenshot of code in flash_component_nor SDK example:

bp1979_0-1628665091573.png

Why is the SDK example not suffering from the fact that external flash is not RWW? What am I still missing here?

 

Many thanks!

0 Kudos
992 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @bp1979 

  The SDK project already copy the related files to the internal RAM, do you do it?

kerryzhou_0-1628666116033.png

You can the debug result, the API in the internal RAM:

kerryzhou_1-1628666134454.png

Wish it helps you!

Best Regards,

Kerry

 

 

 

984 Views
bp1979
Senior Contributor I

Ahaaa so that explains everything! No I haven't done that. I also didn't pay attention to the linker file template things in the SDK example.

One question about that if I may:

how does the linker file generation works? Will it magically pick up any file in my workspace with extension ".ldt" and use it as a template to generate the linker files? 

I can see these three in the SDK example

bp1979_0-1628687799546.png

 

but I can't find where they are "used" / referred. 

0 Kudos
978 Views
bp1979
Senior Contributor I

I fixed it, still don't know how the linker file generation works, but when I simply copy the template files into my project, and change the names to the corresponding object files, it works.

 

Many thanks for your help and pointers!

0 Kudos