Segmentation fault in accessing Audio data (SGTL5000)

cancel
Showing results for 
Search instead for 
Did you mean: 

Segmentation fault in accessing Audio data (SGTL5000)

50 Views
Contributor III

Hello ,

I am working on SGTL5000 Audio Codec and sending audio data from processor and writing it to FPGA (register). In alsa utilities source code for recording and playing audio data(aplay and arecord) ,the data is stored in file and played through same file.

I want to access data directly through buffer and write it to FPGA registers(removing the concept of file).

In alsa code for aplay,the data is captured and then pcm_read into audiobuf(whose size is dynamically allocated),and this data from audiobuf is written to a file descriptor in the code shown below:

static ssize_t xwrite(int fd, const void *buf, size_t count)
{

    ssize_t written;
    size_t offset = 0;
    while (offset < count) {
        written = write(fd, buf + offset, count - offset);
        if (written <= 0)
            return written;
        offset += written;
                fclose(fileptr);
    };

    return offset;
}

I am trying to access the (buf+offset) and then sending it to a register (at FPGA side), but the code is showing segmentation fault. I also tried to store the value of (buf+offset) into an array and then send to FPGA , but the code is showing the same error.

I need to know whether the data i am trying to access is correct or not, and if it is correct then how can i remove the segmentation fault and send the data serially.

Any help is appreciated.

Thanks,

Purvi.

Labels (2)
Tags (2)
0 Kudos
1 Reply

4 Views
NXP TechSupport
NXP TechSupport

Hi Purvi

segmentation fault may be caused by incorrect memory mapping,

one can look at linux documentation and examples

mmap(2) - Linux manual page 

use mmap in C to write into memory. - Stack Overflow 

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

0 Kudos