KEAZ128 FLASH_Program Cause crash

cancel
Showing results for 
Search instead for 
Did you mean: 

KEAZ128 FLASH_Program Cause crash

Jump to solution
1,158 Views
pg31321
Contributor III

When I using FLASH_Program function.

MCU is stop working.

I try to using J-Link Debugger to oversee.

When MCU is stop working,I find this message:

Shutdown.jpg

I do not know what happen to MCU,I have not enable WDOG.

My program like this:

https://drive.google.com/open?id=1WzlJ7vdKm0MLdq0CDF0shVPksW0lmSMb 

0 Kudos
1 Solution
872 Views
stanish
NXP Employee
NXP Employee

Hi,

I'm able to import your "crash" version and it works just fine on my side.

It suspect you might be debugging an old verison of the elf file or project has not been rebuild for some reason.

Now when you copy all the source files into a new project ->  project is correctly rebuild and this version works ok.

My only suggestion is to clean project it better manualy delete entire output folder and rebuild to make sure elf is ok.

Hope it helps.

Stan

View solution in original post

0 Kudos
12 Replies
873 Views
stanish
NXP Employee
NXP Employee

Hi,

I'm able to import your "crash" version and it works just fine on my side.

It suspect you might be debugging an old verison of the elf file or project has not been rebuild for some reason.

Now when you copy all the source files into a new project ->  project is correctly rebuild and this version works ok.

My only suggestion is to clean project it better manualy delete entire output folder and rebuild to make sure elf is ok.

Hope it helps.

Stan

0 Kudos
872 Views
pg31321
Contributor III

If a new project is created, program will still be crashes after "import" the project.

When the program is running,pull low the PTC1.

The program is crash.

If a new project is created,copy all old .C and .HEX files and overwrite them in the new project.

When the program is running,pull low the PTC1.

The program does not crash.

0 Kudos
872 Views
stanish
NXP Employee
NXP Employee

Hi,

I cannot reproduce this issue any more after suggested chnages.

Please try to figure out which specific instruction is causing this.

If it is a jump instruction check the destination address contains valid code.

Stan

0 Kudos
872 Views
pg31321
Contributor III

Hi,Stanislav Sliva

I have solved the problem.

Before this I found out that when I use variables to define what command related to FLASH.

Program will crash.Like this:

pastedImage_1.png

If I use ordinary constants, there is no problem. Like this:
pastedImage_2.png

I can't understand what is going wrong here.

But,

When I create a new project, I copy all the .C and .HEX files into the new project.

The program works normally with variables .

These are the program project files:

crash: https://drive.google.com/open?id=1nIwEJJpSEMiiuMUJ0KaQi2yTMGwLYF97 

normally : https://drive.google.com/open?id=1zZLAhbXlzpBTZJEMM7u-qw2HVNsANv1j 

I hope that analyzing these two projects will be helpful to you.

0 Kudos
872 Views
pg31321
Contributor III

Hi,Stanislav Sliva

Can you give me other related example programs?Or related programming technology?
I want to try to rewrite the related functions myself to solve this problem.

I just need to be able to save the settings after power off.

0 Kudos
872 Views
pg31321
Contributor III

Hi,Stanislav Sliva

Still have the same problem like video:

https://drive.google.com/open?id=1LLV8IfHT2xhNQRV6xxz3kaD3Tju3USDM 

When it executes FLASH_Program2LongWords(),MCU is crash.

If the problem lies with FLASH_Program2LongWords() subroutine,I try to skip calling the subroutine and run the contents of the subroutine directly.

MCU still stuck in the WDOG_IRQHandler.

My Program like this:

https://drive.google.com/open?id=19Ve0a1u47fDBszDEih5F5akOuy4zsFGR 

0 Kudos
872 Views
stanish
NXP Employee
NXP Employee

Hi,

According to my observations this is not a hardware issue.

The exception is caused by the fact you are trying to execute function FLASH_Program2LongWords() which is located at address 0x0004000+ 

.text.FLASH_Program
 0x00004114 0x194 ./src/flash.o
 0x00004114 FLASH_Program
 .text.FLASH_Program1LongWord
 0x000042a8 0x134 ./src/flash.o
 0x000042a8 FLASH_Program1LongWord
 .text.FLASH_Program2LongWords
 0x000043dc 0x168 ./src/flash.o
 0x000043dc FLASH_Program2LongWords
 .text.FLASH_EraseSector
 0x00004544 0x100 ./src/flash.o
 0x00004544 FLASH_EraseSector

The flash memory sector (0x4000 .. 0x4200)  is erased by  FLASH_EraseSector() in the previous step.

I'd recommend you to alloacate memory section for EEPROM in the linker file so the code does not get erased e.g.:

MEMORY
{
  m_interrupts (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00000100
  m_flash_config (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010
  my_text (RX)  : ORIGIN = 0X00004000, LENGTH = 0X00001000
  m_text (RX)  : ORIGIN = 0X00005000, LENGTH = 0X0001B000   
  m_data (RW)  : ORIGIN = 0x1FFFF000, LENGTH = 0x00004000
}‍‍‍‍‍‍‍‍

Please try to adjust the linker file and check if the problem still appers or not.

Hope it helps.

Stan

0 Kudos
872 Views
pg31321
Contributor III

Hi,Stanislav Sliva

I have to refer to the MAP file.

When I set the memory start address at 0x1000 like this:

pastedImage_1.png

My program uses only up to 0x572c like this:

pastedImage_2.png

I changed the address of erase and write at 0xc800 like this:

pastedImage_3.png

pastedImage_4.png

Still crashes in the same place.

I'm currently trying to reduce the size of the program, which may solve this problem.

P.S. After the above modifications, FLASH_Program2LongWords() address is currently at 0x3744

pastedImage_5.png

0 Kudos
872 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi 維哲,

Please check the value of DISABLE_WDOG.

DISABLE_WDOG.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
872 Views
pg31321
Contributor III

Like picture:

DISABLE_WDOG.jpg

value of DISABLE_WDOG is "1".

I have upload my program on google drive.

You can download to check.

My program  is refer example code witch come from agent :

https://drive.google.com/open?id=1AgpzpBa9TNdCaUYzowPf5juSGUtqpmNI 

Example code have not this problem.

0 Kudos
872 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

I have try to import these two project, I did not encounter similar problems.

I am using the default workspace C:\Users\xxx\workspaceS32DS.ARM.2018.R1

Shutdown

Program Selection.png

Device name.png

Flash_FTMRE

Can't find a source file.png

debug.png

0 Kudos
872 Views
pg31321
Contributor III

Hi,Robin_Shen

I using your debug setting.

It still crash.

I recorded a video of the entire program and marked some notes:

https://drive.google.com/open?id=1Jcr_yiw1yShv4Zs7tOa4H_jkpMnVnT4O 

Program used in this video is :

https://drive.google.com/open?id=1jQnJ2vrI_tJz6nklxrOVvmL3Ui0xz1Ax 

I have no idea to solve this problem for a month.

I urgently need to solve this problem.

Thank you for your assistance.

I guess there might be something wrong with my circuit.

Provide my MCU peripheral circuit diagram.

Shutdown.jpg

P.S. PTI4 R10 is replaced by orange light with 1K resistor in video.

0 Kudos