bsteinsbo / DE1-SoC-Sound

GNU Lesser General Public License v2.1
17 stars 16 forks source link

De1 Soc Audio Test #3

Closed larryjol closed 8 years ago

larryjol commented 8 years ago

Dear Bsteinsbo,

I am begginer in SoC system, i want to test your DE1 Alsa Project in my DE1-SoC, Could you explain me the steps for run the project?...

Thanks,

Larry

bsteinsbo commented 8 years ago

Hi,

Could you please elaborate? I'm not sure I understand what your real question is. The DE1_SOC_Linux_Audio directory contains a Quantum project, using IP cores in the cores/i2s directory. This project can be synthesized using Quartus, generating a bitsteam that be can loaded to the FPGA by u-boot before u-boot starts the Linux kernel. This bitstream will implement an i2s interface in the FPGA fabric. You will also find a device tree file describing the hardware; the compiled device tree is also loaded by u-boot before booting the Linux kernel. Linux will use the device tree to start the correct drivers for this FPGA design. The last part is a Linux driver that must be compiled and loaded by the Linux kernel. The driver will allow standard ALSA programs to play sound using the codec on the DE1-SoC board.

Does that help?

larryjol commented 8 years ago

yes, thanks..so the board must be configurated as HPS-FPGA by the dipswitch? and only save the boot files in sd card l?

Thanks

bsteinsbo commented 8 years ago

Yes, I have set the SW10 to all zero and loaded the bitstream from u-boot, but I don't that's critical. I have also been running Linux with u-boot on SD-card, and everything else over the network on TFTP/NFS, but again, this should not be critical to run the design.

scshepard commented 8 years ago

Hi all,I am very intrigued by this discussion; won't have time to try running audio on the Linaro linux system; what version of Linux are you running? Mine is quantal. These pages might help, but if they are run, please help me fix them.Thanks! http://terasic.yubacollegecompsci.com/

Date: Fri, 13 May 2016 20:58:55 -0700 From: notifications@github.com To: DE1-SoC-Sound@noreply.github.com CC: Subject: Re: [bsteinsbo/DE1-SoC-Sound] De1 Soc Audio Test (#3)

Yes, I have set the SW10 to all zero and loaded the bitstream from u-boot, but I don't that's critical. I have also been running Linux with u-boot on SD-card, and everything else over the network on TFTP/NFS, but again, this should not be critical to run the design.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

larryjol commented 8 years ago

i try to test the project but when load the soc_system.qsys (in the qsys), i get "the component i2s_clkctrl_api 1.7 and the component i2s_output_apb 1.4 not found (no is in the library)" error.

bsteinsbo commented 8 years ago

I'm sorry, but I'm not able to provide detailed support on user issues. The cores you mention (I presume you mean i2s_clkctrl_apb) are present in the "cores/i2s" directory, so you need to add that directory to Quartus search path or something.

Bjarne

sunjiangbo commented 8 years ago

Hi, Is your device tree correct ? I have generated .rbf file with your project , and copy this file to SD card. Put your .dts in my kernel source tree, and I get a .dtb file too. when i boot my linux system, insmod i2s and snd-soc-de1 audio driver , use mpg123 to play a mp3 file for test , but no sound . i don't know why your driver code only support 96000 sample rate? Thanks.

bsteinsbo commented 8 years ago

Hi,

My device tree file obviously worked when I tested this a year ago. Take notice of what it says in the README file about enabling the interface between the ARM DMA controller and the FPGA, and also about the electrical interface on i2c.

Why do you say the driver code only supports 96000 sample rate?

        .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000
            | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000
            | SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000,

To be honest, I haven't tested all of these, but I did test the most common ones, including 192000.

Best regards,

sunjiangbo commented 8 years ago

Dear Bsteinsbo, In the codec driver of sound/soc/codec/wm8731.c , there is a statement ,

define WM8731_RATES SNDRV_PCM_RATE_8000_96000

When the i2s platform drvier what you wrote match this codec driver,only 96000 sample rate can be matched .My socfpga linux version is 3.17 , i patch the wm8731.c failed ,so i do it mannally. would you like pull your wm8731.c to github . Thank you for giving me advice about ARM DMA controller, but i still do not know how to enable the interface between the ARM DMA controller and the FPGA , could you give me more details or steps?

Many thanks

bsteinsbo commented 8 years ago

Hi,

The original wm8731.c file that I patched can be found at https://github.com/altera-opensource/linux-socfpga/blob/socfpga-3.17/sound/soc/codecs/wm8731.c

SNDRV_PCM_RATE_8000_96000 means everything from 8000 to 96000. I probably remembered incorrectly when I wrote that I had tested 192000, but I'm certain I tested standard CD (44100) and 96000, both for actual sound output and for register contents in the clock divider. I'm not sure what's happening in your case, but I had no problems using different sample rates.

Enabling the DMA interface to the FPGA fabric can be done either using the Altera tools (in the EDS?) to create a new u-boot SPL (based on the Quartus design where these DMA requests have been enabled, the correct initialization code will be added to SPL) or alternatively by setting some register (in u-boot) to the correct value BEFORE starting the kernel. Ummm.. Took me some digging to find the register I was talking about.. It's called "per2modrst" at address 0xFFD05018, and you should be able to read the description at http://wl.altera.com/literature/hb/cyclone-v/hps.html#topic/sfo1410067767358.html (search for per2modrst).

Bjarne

sunjiangbo commented 8 years ago

Dear Bsteinsbo, Thanks for your reply. According to what you said, i wrote a simple code of applicaion layer for test in linux . In this code , i force per2modrst value from 0xff to 0x00 for enabling the DMA controller between HPS and FPGA farbic. and i am sure the value of this register is 0x00 after the programme finished. but i stiil can not hear the sound .What shall i do?

include

include

include

include

include <sys/mman.h>

define REG_BASE (0xFFD05000)

define MAP_SIZE 0xFF

static int dev_fd; int main(int argc, char **argv) {

    dev_fd = open("/dev/mem", O_RDWR | O_NDELAY);

    if (dev_fd < 0)
    {
            printf("open(/dev/mem) failed.");
            return 0;
    }

    unsigned char *map_base=(unsigned char * )mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, dev_fd, REG_BASE );

    printf("%x \n", *(volatile unsigned int *)(map_base+0x18)); // Print the original value of  per2modrst 

    *(volatile unsigned int *)(map_base + 0x18) = 0x00000000; //Forece per2modrst to 0 for enablling HPS DMA controller.

    if(dev_fd)
            close(dev_fd);
    munmap(map_base,MAP_SIZE);

    return 0;

}

I2S driver and mechine driver work fine ,The board is OK, still no sound .

Best Regards

bsteinsbo commented 8 years ago

Hi, First of all, I think perhaps you need to set that register before the kernel takes the DMA controller out of reset, i.e. in SPL or u-boot. See u-boot's "mw" command if you don't want to make a new SPL. Setting it in Linux might be too late.

Secondly, it's of course important to un-mute the output. See "alsamixer" command in Linux.

Thirdly, if you still have no sound, it's time to start tracing the Linux driver (see https://www.kernel.org/doc/Documentation/dynamic-debug-howto.txt) , and adding a SignalTap in the design to see where it stops.

-br

sunjiangbo commented 8 years ago

Dear Bsteinsbo, Thank you very much! I'm so excited to tell you that i have solved the problem.
The default value of 'Output Mixer HiFi Playback Switch' is off ,so i can not playback. I set it to on.

amixer cset numid=14,iface=MIXER,name='Output Mixer HiFi Playback Switch' on

aplay mytest.wav

I can hear the sound . Thanks.

Best Regards

bsteinsbo commented 8 years ago

Hi,

That's good to hear!

-br