Keil Logo

failed (finit(NULL) ) to initialize the SD card and ends at Hardfault

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Author
chakravarthi m
Posted
11-Mar-2017 11:59 GMT
Toolset
ARM
New! failed (finit(NULL) ) to initialize the SD card and ends at Hardfault

hi

i am getting Hardfault when finit(NULL) function is executed in LPC43xx Coretex M4 Flash file system without RTOS. I am using SD card driver as SDIO43xx.c from standard drivers.

why it goes to Hardfault?. i am using FS_CM3.lib to the project. please provide example project if you have already done.

Thanks and regards
Chakravarthi

Author
Andrew Neil
Posted
11-Mar-2017 12:48 GMT
Toolset
ARM
New! RE: why it goes to Hardfault?

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/Cihdjcfc.html

http://www.keil.com/appnotes/files/apnt209.pdf

http://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html

https://blog.feabhas.com/2013/02/developing-a-generic-hard-fault-handler-for-arm-cortex-m3cortex-m4/

https://community.nxp.com/thread/306244

etc, etc, ...

Author
Clive One
Posted
11-Mar-2017 14:31 GMT
Toolset
ARM
New! RE: why it goes to Hardfault?

Check you have a sufficiently large stack allocation in startup_xxx.s, this can frequently cause faults. Check heap if code uses malloc()

Use a hard fault handler like those from Joseph Yiu to be able to quickly pinpoint what instructions and registers are faulting. Look for invalid memory access, wild pointers, executing bad code, etc.

Author
Andrew Neil
Posted
11-Mar-2017 18:29 GMT
Toolset
ARM
New! RE: Joseph Yiu

https://www.elsevier.com/books/the-definitive-guide-to-arm-cortex-m3-and-cortex-m4-processors/yiu/978-0-12-408082-9

Author
Clive One
Posted
11-Mar-2017 21:01 GMT
Toolset
ARM
New! RE: Joseph Yiu

My spin on the Hard Fault Handler in Keil

http://community.st.com/message/8095?commentID=8095#comment-8095

Author
chakravarthi m
Posted
12-Mar-2017 07:41 GMT
Toolset
ARM
New! RE: Joseph Yiu

i am getting Forced Hard fault whenever finit(null) function is executed. i have gone through different posts that they executed the same function successfully but i am not getting hard fault. so,if you have done same code successfully then give me with project configuration options and correct keil memory settings for RAM and ROM

Author
Clive One
Posted
12-Mar-2017 22:35 GMT
Toolset
ARM
New! Debugging?

Sorry, not using your part/configuration. Try debugging it, the Hard Fault is a gross failure, the processor provides specific details about what/where it fails. Understanding how to decipher that will be a good learning experience.

If the CALL causes the fault make sure you aren't linking in 32-bit code. Check if the NULL pointer is an issue, or if some variable or structure contains uninitialized junk.

It is however FAILING on your build, so you're best place to actually debug the reason in your specific circumstances. Try stepping into the assembler code to refine the point of failure better, or review the processor state from the Hard Fault Handler.

Author
chakravarthi m
Posted
13-Mar-2017 10:31 GMT
Toolset
ARM
New! RE: Debugging?

hi sir,

i have used the hard fault handler as you given above links. i have got the memory location of instruction[LDR R0,[R5,#0x04] . but this instruction is written in Library file provided by Keil MDK [FS_CM3.lib]. i am unable to study the code part of library. i am getting USAGE FAULT [INVSTATE bit is set to 1] . after getting memory location of above instrction [LDR] it is located in function MCI_init. so, is there anyone who faced same problem.??

Author
Clive One
Posted
13-Mar-2017 13:12 GMT
Toolset
ARM
New! RE: Debugging?

>>is there anyone who faced same problem??

Developers frequently have similar problems, the chances that someone has an identical set of issues to you would tend to be much smaller. You will need to debug using the resources you have, working backward from the point of failure.

The salient issue here would be the content of R5 and where that came from, which is likely a parameter or structure passed in. This could be an uninitialized structure, heap or stack, or the incorrect target cpu or memory sizes passed to the linker.

Author
chakravarthi m
Posted
13-Mar-2017 14:08 GMT
Toolset
ARM
New! RE: Debugging?

hi

i am using FS_CM3.lib file in my project.so,i dont't have source code to know what value is loaded into R5 register. i have used memorymap file to know the function address at which Hardfault is occuring.so i hope you understand and give me any useful information to identify the bug.

Author
Clive One
Posted
13-Mar-2017 15:09 GMT
Toolset
ARM
New! RE: Debugging?

Perhaps your code consists of more than finit(NULL) ? Or needs too.

The fact you don't have source isn't immediately relevant, what is reported in R5 would be of immediate interest, as a) it might tell you why it faulted, and b) might provide some insight into where it came from. For example if it were like 0x64636241 it could be ASCII in a buffer, of 0xCDCDCDCD some space purposefully initialize to trap bad pointers.

You are the one sitting in front of your computer with the debugger running, you are the one capable of looking at the disassembly, and content of memory and registers. You are the only one with the code and board in this condition, and there is inadequate project specifics for the issue to be replicated.

Author
Zack Havens
Posted
14-Mar-2017 23:21 GMT
Toolset
ARM
New! RE: failed (finit(NULL) ) to initialize the SD card and ends at Hardfault

Hello Chakravarthi,

From the "finit(NULL)", I guess you are trying to use the earlier version of the filesystem, RL-FlashFS.

I recommend starting with an RTOS and the newer File System Component.
There is one example for an SD Card and MCB4300 in the Pack Installer:
http://www.keil.com/support/man/docs/uv4/uv4_ca_packinstaller.htm

The example is titled "File System Demo", and these newer examples are maintained. In MDKv5.22 or later, you also have access to the Event Recorder to get a lot more debug information from the middleware libraries.

Thanks,
Zack

Author
chakravarthi m
Posted
15-Mar-2017 05:29 GMT
Toolset
ARM
New! RE: failed (finit(NULL) ) to initialize the SD card and ends at Hardfault

hi Havens,

i have installed the pack from Pack installer and executed the project (C:\Keil_v5\ARM\Pack\Keil\LPC4300_DFP\2.7.0\Boards\Keil\MCB4300\Middleware\FileSystem\File_Demo) but it is giving Media Error without SD Card and With SD card. Actually ,fmount function should return No Media without SD card but it is giving Media Error for all types of errors and why i am getting Media Error even though i have configured the SD card properly??.

is there any fault with Commands defined the RTOS flash file system. can you help me at function fmount("M0:") why it is giving FSmedia Error ?

Now,i am using Keil MDK Plus v5.22 with Licence.

Author
Andrew Neil
Posted
15-Mar-2017 09:40 GMT
Toolset
ARM
New! Time for a new thread?

So you're now using a different File System Component, and a different MDK version - and getting a different result.

Sounds like it's time for a new thread - with appropriately adjusted title.

You can always put links between the two threads for reference ...

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.