AnsweredAssumed Answered

Segmentation fault in accessing Audio data (SGTL5000)

Question asked by Purvi Billore on Jul 1, 2019
Latest reply on Jul 2, 2019 by igorpadykov

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;

    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.