S32K344 C40 IP Hardware Fault Problem

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

S32K344 C40 IP Hardware Fault Problem

Jump to solution
14,716 Views
mesutkilicmak
Contributor II

Hi All,

I am trying to create custom bootloader app. I reserved 256KB space both bootloader app and parameters from the beginnig of the flash. I need to store boot parameters on the same block with the bootloader code. I tried to use C40 ip but, I am always getting HardFault error. As I learned from "AN13388-S32K3 Memories Guide" I can not write or erase same block while reading(code executing).

I tried some technics like ramcode and ITCM but, I could not be successful.

I do not want to use Data flash. Because HSE firmware uses all of it. 

What is the proper way to do that? Is there any example?

Tags (2)
0 Kudos
Reply
1 Solution
14,698 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @mesutkilicmak,

The below API functions have to be placed into SRAM (".ramcode" section), as show below.

  • C40_Ip_MainInterfaceSectorErase
  • C40_Ip_MainInterfaceSectorEraseStatus
  • C40_Ip_MainInterfaceWrite
  • C40_Ip_MainInterfaceWriteStatus

Then, the core must not access the block from interrupts. The interrupts must be either masked (PRIMASK = 1), or the vector table as well as the ISR() functions and the data the ISR() access must not be in the block.


C40_Ip.h.

Before the declaration:

#if ( 1 == C40_RAM_CODE_ENABLE
/* ram code start */
#define FLS_STOP_SEC_CODE
#include "Fls_MemMap.h"
#define FLS_START_SEC_RAMCODE
#include "Fls_MemMap.h"
#endif

After the declaration.

#if ( 1 == C40_RAM_CODE_ENABLE )
/* ram code end */
#define FLS_STOP_SEC_RAMCODE
#include "Fls_MemMap.h"
#define FLS_START_SEC_CODE
#include "Fls_MemMap.h"
#endif

if #define C40_RAM_CODE_ENABLE 1, the above four flash API functions are placed in the ".ramcode" section.

 

Regards,

Daniel

 

View solution in original post

9 Replies
14,688 Views
mesutkilicmak
Contributor II

Hi @danielmartynek 

Thank you for your answer. Your solution is worked for me.

In addition to your solution I also need to edit this function prototype too.

  • C40_Ip_MainInterfaceHVJobStatus

This function static in C40_Ip.c

I tried on C40 example. It worked fine but, does not worked my app. 

I removed the tick from "Fls Timeout Supervision Enabled" in C40_Ip. Because of the "OsIf_GetElapsed" function used.

I also need to move my functions that uses write and and erase to ramcode.

Regards,

Mesut

14,699 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @mesutkilicmak,

The below API functions have to be placed into SRAM (".ramcode" section), as show below.

  • C40_Ip_MainInterfaceSectorErase
  • C40_Ip_MainInterfaceSectorEraseStatus
  • C40_Ip_MainInterfaceWrite
  • C40_Ip_MainInterfaceWriteStatus

Then, the core must not access the block from interrupts. The interrupts must be either masked (PRIMASK = 1), or the vector table as well as the ISR() functions and the data the ISR() access must not be in the block.


C40_Ip.h.

Before the declaration:

#if ( 1 == C40_RAM_CODE_ENABLE
/* ram code start */
#define FLS_STOP_SEC_CODE
#include "Fls_MemMap.h"
#define FLS_START_SEC_RAMCODE
#include "Fls_MemMap.h"
#endif

After the declaration.

#if ( 1 == C40_RAM_CODE_ENABLE )
/* ram code end */
#define FLS_STOP_SEC_RAMCODE
#include "Fls_MemMap.h"
#define FLS_START_SEC_CODE
#include "Fls_MemMap.h"
#endif

if #define C40_RAM_CODE_ENABLE 1, the above four flash API functions are placed in the ".ramcode" section.

 

Regards,

Daniel

 

7,657 Views
Ali22
Contributor III

Hi, Danielmartynek

What dose"Then, the core must not access the block from interrupts. The interrupts must be either masked (PRIMASK = 1), or the vector table as well as the ISR() functions and the data the ISR() access must not be in the block." mean? Do you mean that vector table and ISR() functions and the data can't be place in the same block with BOOTLOADER and APP, if yes where should vector table and ISR() be place, in the RAM?

Tags (1)
0 Kudos
Reply
7,650 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @Ali22,

While the flash controller is programming/erasing some data in a certain block, the block must not be accessed. I don't know how to explain it differently. Search for RWW Read-while-write in the RM.

 

0 Kudos
Reply
2,072 Views
francescovico
Contributor III

Hello Daniel,

I'm working on a Bootloader that reside in Code Flash Block 0 (From 0x400000 to 0x4FFFFF).

Any erase/write inside this block cause an Hard Fault.

Only erase/write in Code Flash Block 1 or 2 or 3 it's allowed.

My Application must reside in  Block 1 ?

The residual code flash Block 0 it's lost?

Regards, Francesco.

0 Kudos
Reply
2,056 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @francescovico,

Please create a new thread.

It does not have to be in Block1, the flash driver can be in SRAM.

 

Regards,

Daniel

0 Kudos
Reply
9,475 Views
Emguy
Contributor I

Please show sampel code how to place in c40 ip.h

 

0 Kudos
Reply
14,532 Views
WangLeiDevelopment
Contributor I

I find Bootloader project(unified_bootloader_demo_V2.1.exe) use C40_IP driver alsways run to hardware Falut . Then you uart for debug ,find program stoke at erase and write status (specific is inside  C40_Ip_Compare function is C40_Ip_SynchronizeCache)

0 Kudos
Reply
14,507 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @WangLeiDevelopment,

Can you create a new thread for this issue?

 

Thanks,

BR, Daniel

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1697432%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K344%20C40%20IP%20Hardware%20Fault%20Problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1697432%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20All%2C%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20create%20custom%20bootloader%20app.%20I%20reserved%20256KB%20space%20both%20bootloader%20app%20and%20parameters%20from%20the%20beginnig%20of%20the%20flash.%20I%20need%20to%20store%20boot%20parameters%20on%20the%20same%20block%20with%20the%20bootloader%20code.%20I%20tried%20to%20use%20C40%20ip%20but%2C%20I%20am%20always%20getting%20HardFault%20error.%20As%20I%20learned%20from%20%22AN13388-S32K3%20Memories%20Guide%22%20I%20can%20not%20write%20or%20erase%20same%20block%20while%20reading(code%20executing).%3C%2FP%3E%3CP%3EI%20tried%20some%20technics%20like%20ramcode%20and%20ITCM%20but%2C%20I%20could%20not%20be%20successful.%3C%2FP%3E%3CP%3EI%20do%20not%20want%20to%20use%20Data%20flash.%20Because%20HSE%20firmware%20uses%20all%20of%20it.%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20is%20the%20proper%20way%20to%20do%20that%3F%20Is%20there%20any%20example%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2174254%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K344%20C40%20IP%20Hardware%20Fault%20Problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2174254%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%2F153065%22%20target%3D%22_blank%22%3E%40francescovico%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EPlease%20create%20a%20new%20thread.%3C%2FP%3E%0A%3CP%3EIt%20does%20not%20have%20to%20be%20in%20Block1%2C%20the%20flash%20driver%20can%20be%20in%20SRAM.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2174129%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K344%20C40%20IP%20Hardware%20Fault%20Problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2174129%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20Daniel%2C%3C%2FP%3E%3CP%3EI'm%20working%20on%20a%20Bootloader%20that%20reside%20in%20Code%20Flash%20Block%200%20(From%200x400000%20to%200x4FFFFF).%3C%2FP%3E%3CP%3EAny%20erase%2Fwrite%20inside%20this%20block%20cause%20an%20Hard%20Fault.%3C%2FP%3E%3CP%3EOnly%20erase%2Fwrite%20in%26nbsp%3BCode%20Flash%20Block%201%20or%202%20or%203%20it's%20allowed.%3C%2FP%3E%3CP%3EMy%20Application%20must%20reside%20in%26nbsp%3B%20Block%201%20%3F%3C%2FP%3E%3CP%3EThe%20residual%20code%20flash%20Block%200%20it's%20lost%3F%3C%2FP%3E%3CP%3ERegards%2C%20Francesco.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1998910%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K344%20C40%20IP%20Hardware%20Fault%20Problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1998910%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F241216%22%20target%3D%22_blank%22%3E%40Ali22%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EWhile%20the%20flash%20controller%20is%20programming%2Ferasing%20some%20data%20in%20a%20certain%20block%2C%20the%20block%20must%20not%20be%20accessed.%20I%20don't%20know%20how%20to%20explain%20it%20differently.%20Search%20for%20RWW%20Read-while-write%20in%20the%20RM.%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1998519%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K344%20C40%20IP%20Hardware%20Fault%20Problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1998519%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%20Danielmartynek%3C%2FP%3E%3CP%3EWhat%20dose%22%3CSPAN%3EThen%2C%20the%20core%20must%20not%20access%20the%20block%20from%20interrupts.%20The%20interrupts%20must%20be%20either%20masked%20(PRIMASK%20%3D%201)%2C%20or%20the%20vector%20table%20as%20well%20as%20the%20ISR()%20functions%20and%20the%20data%20the%20ISR()%20access%20must%20not%20be%20in%20the%20block.%22%20mean%3F%20Do%20you%20mean%20that%20vector%20table%20and%20ISR()%20functions%26nbsp%3Band%20the%20data%20can't%20be%20place%20in%20the%20same%20block%20with%20BOOTLOADER%20and%20APP%2C%20if%20yes%20where%20should%26nbsp%3Bvector%20table%20and%20ISR()%20be%20place%2C%20in%20the%20RAM%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1892068%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K344%20C40%20IP%20Hardware%20Fault%20Problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1892068%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EPlease%20show%20sampel%20code%20how%20to%20place%20in%20c40%20ip.h%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1712001%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K344%20C40%20IP%20Hardware%20Fault%20Problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1712001%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F219503%22%20target%3D%22_blank%22%3E%40WangLeiDevelopment%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3ECan%20you%20create%20a%20new%20thread%20for%20this%20issue%3F%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThanks%2C%3C%2FP%3E%0A%3CP%3EBR%2C%20Daniel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1711353%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K344%20C40%20IP%20Hardware%20Fault%20Problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1711353%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20find%20Bootloader%20project(unified_bootloader_demo_V2.1.exe)%20use%20C40_IP%20driver%20alsways%20run%20to%20hardware%20Falut%20.%20Then%20you%20uart%20for%20debug%20%EF%BC%8Cfind%20program%20stoke%20at%20erase%20and%20write%20status%20%EF%BC%88specific%20is%20inside%26nbsp%3B%20C40_Ip_Compare%20function%20is%20C40_Ip_SynchronizeCache%EF%BC%89%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1698676%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K344%20C40%20IP%20Hardware%20Fault%20Problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1698676%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%2F160001%22%20target%3D%22_blank%22%3E%40danielmartynek%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20answer.%20Your%20solution%20is%20worked%20for%20me.%3C%2FP%3E%3CP%3EIn%20addition%20to%20your%20solution%20I%20also%20need%20to%20edit%20this%20function%20prototype%20too.%3C%2FP%3E%3CUL%3E%3CLI%3EC40_Ip_MainInterfaceHVJobStatus%3C%2FLI%3E%3C%2FUL%3E%3CP%3EThis%20function%20static%20in%26nbsp%3B%3CSPAN%3EC40_Ip.c%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20tried%20on%20C40%20example.%20It%20worked%20fine%20but%2C%20does%20not%20worked%20my%20app.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20removed%20the%20tick%20from%20%22Fls%20Timeout%20Supervision%20Enabled%22%20in%20C40_Ip.%20Because%20of%20the%20%22OsIf_GetElapsed%22%20function%20used.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20also%20need%20to%20move%20my%20functions%20that%20uses%20write%20and%20and%20erase%20to%20ramcode.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ERegards%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EMesut%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1698520%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K344%20C40%20IP%20Hardware%20Fault%20Problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1698520%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F219090%22%20target%3D%22_blank%22%3E%40mesutkilicmak%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EThe%20below%20API%20functions%20have%20to%20be%20placed%20into%20SRAM%20(%22.ramcode%22%20section)%2C%20as%20show%20below.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EC40_Ip_MainInterfaceSectorErase%3C%2FLI%3E%0A%3CLI%3EC40_Ip_MainInterfaceSectorEraseStatus%3C%2FLI%3E%0A%3CLI%3EC40_Ip_MainInterfaceWrite%3C%2FLI%3E%0A%3CLI%3EC40_Ip_MainInterfaceWriteStatus%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThen%2C%20the%20core%20must%20not%20access%20the%20block%20from%20interrupts.%20The%20interrupts%20must%20be%20either%20masked%20(PRIMASK%20%3D%201)%2C%20or%20the%20vector%20table%20as%20well%20as%20the%20ISR()%20functions%20and%20the%20data%20the%20ISR()%20access%20must%20not%20be%20in%20the%20block.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EC40_Ip.h.%3C%2FP%3E%0A%3CP%3EBefore%20the%20declaration%3A%3C%2FP%3E%0A%3CP%3E%23if%20(%201%20%3D%3D%20C40_RAM_CODE_ENABLE%3CBR%20%2F%3E%2F*%20ram%20code%20start%20*%2F%3CBR%20%2F%3E%23define%20FLS_STOP_SEC_CODE%3CBR%20%2F%3E%23include%20%22Fls_MemMap.h%22%3CBR%20%2F%3E%23define%20FLS_START_SEC_RAMCODE%3CBR%20%2F%3E%23include%20%22Fls_MemMap.h%22%3CBR%20%2F%3E%23endif%3C%2FP%3E%0A%3CP%3EAfter%20the%20declaration.%3C%2FP%3E%0A%3CP%3E%23if%20(%201%20%3D%3D%20C40_RAM_CODE_ENABLE%20)%3CBR%20%2F%3E%2F*%20ram%20code%20end%20*%2F%3CBR%20%2F%3E%23define%20FLS_STOP_SEC_RAMCODE%3CBR%20%2F%3E%23include%20%22Fls_MemMap.h%22%3CBR%20%2F%3E%23define%20FLS_START_SEC_CODE%3CBR%20%2F%3E%23include%20%22Fls_MemMap.h%22%3CBR%20%2F%3E%23endif%3C%2FP%3E%0A%3CP%3Eif%20%23define%20C40_RAM_CODE_ENABLE%201%2C%20the%20above%20four%20flash%20API%20functions%20are%20placed%20in%20the%20%22.ramcode%22%20section.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E