Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Segmentation fault problem in Embedded system

Status
Not open for further replies.

Shreehari

Member level 4
Joined
Jun 18, 2010
Messages
68
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
mangalore
Activity points
1,735
Hello

I had written a code to read the digital output of my embedded system.and compiled i through the GDB.and executed in target system.But it gives Segmentation fault error.My program is simple and is written below...


the value is a file located in do5 file.
-----------------------------------------------------------------------------------------
#include<stdio.h>

main()
{

FILE *file =fopen("/sys/class/sbc2800/d05/value","wt");
fprintf(file,"1");
fclose(file);

}
----------------------------------------------------------------------------------------

Pls rply ..I am using ARM 9 processor.and logged as root. and also please tell me how to generate the executable in tiny model(like compact,small,medium,tiny).


Regards
 

But several documents says supports "t" mode.I had seen some documents in internet.Your link doesn't work.
Also the Embedded system manual also tells the same.
 

ok I will work with simple "w" mode and let me tell you the result.

Added after 3 hours 33 minutes:

I had written 'w' inplace of 'wt ',but still segmentation fault comes...
 

Try to know which line gives the segmentation fault, in order to remove the error.
Add some printf or use a debugger.
--
Amr
 

    Shreehari

    Points: 2
    Helpful Answer Positive Rating
Do not assume that the file was successfully opened. If fp is NULL, you will get segmentation fault. You need something like:

FILE *file =fopen("/sys/class/sbc2800/d05/value","wt");
if(file) fprintf(file,"1");
if(file) fclose(file);

Try this. Does it still give segmentation fault or does it complete ?

Kennedy
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top