raspberrypi / linux

Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at https://forums.raspberrypi.com/
Other
11.15k stars 5k forks source link

Possible DWC I2S kernel driver issue for RPi 5 #5747

Closed nodemand closed 11 months ago

nodemand commented 11 months ago

Describe the bug

I'm on a RPi5 4GB running Raspberry Pi OS 64bit Bookworm and my application hangs on ALSA function snd_pcm_readn when I try to read and write from and to the same device. This occurs on an IQAudio Codec Zero sound card and on a HifiBerry DAC+ADC Pro as well. When I select a USB sound card as the output and one of the others described for input everything works like it should.

Here's my code:

#include <alsa/asoundlib.h>
#include <alsa/control.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <algorithm>
#include <iterator>

typedef   signed short  drwav_int16;
typedef   signed int    drwav_int32;

#define PCM_DEVICE_IN "plughw:Zero,0"
#define PCM_DEVICE_OUT "plughw:Zero,0"

int pcm, err, result, n;
unsigned int rate, tmp, i=0;

snd_pcm_t           *play;
snd_pcm_t           *record;
snd_pcm_hw_params_t *playparams;
snd_pcm_hw_params_t *recordparams;
snd_pcm_uframes_t   frames;
snd_pcm_sframes_t   recresult;
snd_pcm_format_t    format = SND_PCM_FORMAT_S16_LE;
static snd_output_t *info = NULL;
int                 block = 0;

int buffer_frames           =   256;
int bits_per_frame          =   16;
const int bits_per_byte     =   8;
int channels                =   2;

int bytesize_per_channel    =   buffer_frames 
                                * bits_per_frame 
                                / bits_per_byte;

int main(int argc, char **argv) {
    if (argc < 3) {
        printf("Usage: %s <sample_rate> <frames>\n", argv[0]);
        return -1;
    }

    rate            = atoi(argv[1]);
    buffer_frames   = atoi(argv[2]);

    bytesize_per_channel    =   buffer_frames 
                                * snd_pcm_format_width(format)  
                                / bits_per_byte;

    drwav_int16 *buffer_in[channels];

    /* Open the PCM device in record mode */
    if ((pcm = snd_pcm_open(&record, PCM_DEVICE_IN, SND_PCM_STREAM_CAPTURE, block)) < 0)
        printf("ERROR: Can't open \"%s\" PCM device. %s\n", PCM_DEVICE_IN, snd_strerror(pcm));

    /* Allocate parameters object and fill it with default values*/
    if ((pcm = snd_pcm_hw_params_malloc(&recordparams)) < 0)
        printf("ERROR: Can't allocate hardware parameter structure. %s\n", snd_strerror(pcm));

    if ((pcm = snd_pcm_hw_params_any(record, recordparams)) < 0)
        printf("ERROR: Can't initialize hardware parameter structure. %s\n", snd_strerror(pcm));

    /* Set parameters */
    if ((pcm = snd_pcm_hw_params_set_access(record, recordparams, SND_PCM_ACCESS_RW_NONINTERLEAVED )) < 0) 
        printf("ERROR: Can't set interleaved mode. %s\n", snd_strerror(pcm));

    if ((pcm = snd_pcm_hw_params_set_format(record, recordparams, format)) < 0)
        printf("ERROR: Can't set format. %s\n", snd_strerror(pcm));

    if ((pcm = snd_pcm_hw_params_set_channels(record, recordparams, channels)) < 0) 
        printf("ERROR: Can't set channels number. %s\n", snd_strerror(pcm));

    if ((pcm = snd_pcm_hw_params_set_rate_near(record, recordparams, &rate, 0)) < 0) 
        printf("ERROR: Can't set sample rate. %s\n", snd_strerror(pcm));

    /* Write parameters */
    if ((pcm = snd_pcm_hw_params(record, recordparams)) < 0)
        printf("ERROR: Can't set hardware parameters. %s\n", snd_strerror(pcm));

    if ((pcm = snd_pcm_prepare(record)) < 0)
        printf("ERROR: Can't prepare audio interface for use. %s\n", snd_strerror(pcm));

    /* Resume information */
    printf("PCM name: '%s'\n", snd_pcm_name(record));

    printf("PCM state: %s\n", snd_pcm_state_name(snd_pcm_state(record)));

    snd_pcm_hw_params_get_channels(recordparams, &tmp);
    printf("channels: %i ", tmp);

    if (tmp == 1)
        printf("(mono)\n");
    else if (tmp == 2)
        printf("(stereo)\n");

    snd_pcm_hw_params_get_rate(recordparams, &tmp, 0);
    printf("sample rate: %d bps\n", tmp);

    /* Open the PCM device in playback mode */
    if ((pcm = snd_pcm_open(&play, PCM_DEVICE_OUT, SND_PCM_STREAM_PLAYBACK, block)) < 0)
        printf("ERROR: Can't open \"%s\" PCM device. %s\n", PCM_DEVICE_OUT, snd_strerror(pcm));

    if ((pcm = snd_pcm_hw_params_malloc(&playparams)) < 0)
        printf("ERROR: Can't allocate hardware parameter structure. %s\n", snd_strerror(pcm));

    if ((pcm = snd_pcm_hw_params_any(play, playparams)) < 0)
        printf("ERROR: Can't initialize hardware parameter structure. %s\n", snd_strerror(pcm));

    /* Set parameters */
    if ((pcm = snd_pcm_hw_params_set_access(play, playparams, SND_PCM_ACCESS_RW_NONINTERLEAVED )) < 0) 
        printf("ERROR: Can't set interleaved mode. %s\n", snd_strerror(pcm));

    if ((pcm = snd_pcm_hw_params_set_format(play, playparams, format)) < 0)
        printf("ERROR: Can't set format. %s\n", snd_strerror(pcm));

    if ((pcm = snd_pcm_hw_params_set_channels(play, playparams, channels)) < 0) 
        printf("ERROR: Can't set channels number. %s\n", snd_strerror(pcm));

    if ((pcm = snd_pcm_hw_params_set_rate_near(play, playparams, &rate, 0)) < 0) 
        printf("ERROR: Can't set sample rate. %s\n", snd_strerror(pcm));

    /* Write parameters */
    if ((pcm = snd_pcm_hw_params(play, playparams)) < 0)
        printf("ERROR: Can't set hardware parameters. %s\n", snd_strerror(pcm));

    if ((pcm = snd_pcm_prepare(play)) < 0)
        printf("ERROR: Can't prepare audio interface for use. %s\n", snd_strerror(pcm));

    /* Resume information */
    printf("PCM name: '%s'\n", snd_pcm_name(play));

    printf("PCM state: %s\n", snd_pcm_state_name(snd_pcm_state(play)));

    snd_pcm_hw_params_get_channels(playparams, &tmp);
    printf("channels: %i ", tmp);

    if (tmp == 1)
        printf("(mono)\n");
    else if (tmp == 2)
        printf("(stereo)\n");

    snd_pcm_hw_params_get_rate(playparams, &tmp, 0);
    printf("sample rate: %d bps\n", tmp);

    // allocate buffers
    buffer_in[0]    = (drwav_int16*) malloc(bytesize_per_channel);
    buffer_in[1]    = (drwav_int16*) malloc(bytesize_per_channel);

    printf("buffers allocated: %d bytes per channel\n", bytesize_per_channel);

    // check accepted configuration
    snd_output_stdio_attach(&info, stderr, 0);
    err = snd_pcm_dump(play, info);
    err = snd_pcm_dump(record, info);

    // start recording device
    if ((pcm = snd_pcm_start(record)) < 0)
        printf("ERROR: Can't start soundcard for recording. %s\n", snd_strerror(pcm));

    // fill buffer before starting playback device
    if ((recresult = snd_pcm_readn(record, (void**) buffer_in, buffer_frames)) < 0) {
         printf ("ERROR. Read from audio interface failed. (%s)\n", snd_strerror(recresult));
        exit(1);
    }

    if ((result = snd_pcm_writen(play, (void**) buffer_in, recresult)) == -EPIPE) {
        printf("XRUN.\n");
        snd_pcm_prepare(play);
    } else if (result < 0) {
        printf("ERROR. Can't write to playback device. %s\n", snd_strerror(result));
        exit(1);
    }

    // start playback device
    if ((pcm = snd_pcm_start(play)) < 0)
        printf("ERROR: Can't start soundcard for playback. %s\n", snd_strerror(pcm));

    // run loop
    while (1)
    {
        if ((recresult = snd_pcm_readn(record, (void**) buffer_in, buffer_frames)) < 0) {
             printf ("ERROR. Read from audio interface failed. (%s)\n", snd_strerror(recresult));
            exit(1);
        }
        n = (int) recresult;
        printf("read %d done, %d frames\n", i, n);

        if ((result = snd_pcm_writen(play, (void**) buffer_in, recresult)) == -EPIPE) {
            printf("XRUN.\n");
            snd_pcm_prepare(play);
        } else if (result < 0) {
            printf("ERROR. Can't write to playback device. %s\n", snd_strerror(result));
            exit(1);
        }
        printf("write %d done\n", i);
        i++;
    }

    snd_pcm_hw_params_free(playparams);
    snd_pcm_hw_params_free(recordparams);
    printf("params freed\n");

    snd_pcm_drain(play);
    snd_pcm_close(play);
    snd_pcm_drain(record);
    snd_pcm_close(record);
    printf("audio interface closed\n");

    free(buffer_in[0]);
    free(buffer_in[1]);
    printf("buffers freed\n");

    return 0;
}

I have the same issue when I switch to PortAudio as an ALSA wrapper. Then my application hangs on Pa_ReadStream. And I'm using one of the basic PortAudio examples (paex_read_write_wire.c) as the basis of my application.

The issue also occurs when using alsaloop or aplay and arecord in 2 different shell sessions.

As soon as I start aplay, arecord exits with a 2221 input/output error and the HW pointer stops moving. This exact behavior is also seen when using a HifiBerry DAC+ADC Pro on the RPi5.

For. more information see the issue I opened in the alsa-lib repo and PortAudio repo. And the raspberry pi forum.

Steps to reproduce the behaviour

Start arecord in one SSH session with: arecord -f S16_LE -r48000 -c2 -D plughw:Zero,0 -F0 --period-size=256 -B0 --buffer-size=4096 test.wav and aplay in another with: aplay test.wav -f S16_LE -r48000 -c2 -D plughw:Zero,0 And a 3rd SSH session where you watch the status of the capture with: watch cat /proc/asound/card0/pcm0c/sub0/status

Device (s)

Other

System

System Information

Raspberry Pi 5 Model B Rev 1.0 PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)"

Raspberry Pi reference 2023-10-10 Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 962bf483c8f326405794827cce8c0313fd5880a8, stage2

Linux pi 6.1.0-rpi4-rpi-2712 #1 SMP PREEMPT Debian 1:6.1.54-1+rpt2 (2023-10-05) aarch64 GNU/Linux Revision : c04170 Serial : f6c71b432ec3d5df Model : Raspberry Pi 5 Model B Rev 1.0 Throttled flag : throttled=0x0 Camera : vc_gencmd_read_response returned -1 error=1 error_msg="Command not registered"

Videocore information

2023/10/30 16:45:10 Copyright (c) 2012 Broadcom version 30de0ba5 (release) (embedded)

vc_gencmd_read_response returned -1 error=1 error_msg="Command not registered"

Filesystem information

Filesystem 1K-blocks Used Available Use% Mounted on udev 1900240 0 1900240 0% /dev tmpfs 414352 7040 407312 2% /run /dev/mmcblk0p2 14732664 3131392 10966348 23% / tmpfs 2071696 0 2071696 0% /dev/shm tmpfs 5120 32 5088 1% /run/lock /dev/mmcblk0p1 522232 63360 458872 13% /boot/firmware tmpfs 414336 0 414336 0% /run/user/1000

Filename Type Size Used Priority /var/swap file 102368 0 -2

Package version information

raspberrypi-ui-mods: Installed: (none) raspberrypi-sys-mods: Installed: 20231003 openbox: Installed: (none) lxpanel: Installed: (none) pcmanfm: Installed: (none) rpd-plym-splash: Installed: (none)

Networking Information

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet x.x.x.x netmask x.x.x.x broadcast x.x.x.x inet6 y::y.y.y.y prefixlen 64 scopeid 0x20 ether m.m.m.m txqueuelen 1000 (Ethernet) RX packets 74 bytes 10317 (10.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 126 bytes 22804 (22.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 107

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet x.x.x.x netmask x.x.x.x inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 16 bytes 2893 (2.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 16 bytes 2893 (2.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether m.m.m.m txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

USB Information

/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M /: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/2p, 480M /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/2p, 480M

Display Information

Running (F)KMS, console

/sys/class/drm/card1-HDMI-A-1

/sys/class/drm/card1-HDMI-A-2

/sys/class/drm/card1-Writeback-1

/sys/class/drm/card1-Writeback-2

Connector 0 (32) HDMI-A-1 (connected) Encoder 0 (31) TMDS Connector 1 (42) HDMI-A-2 (disconnected) Encoder 1 (41) TMDS

Connector 0 (32) HDMI-A-1 (connected)

HDMI0: HDMI_HOTPLUG = 0x00000001 HDMI1: HDMI_HOTPLUG = 0x00000000

/sys/kernel/debug/dri/1/state: plane[47]: plane-0 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=0 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[64]: plane-1 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=0 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[78]: plane-2 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=0 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[89]: plane-3 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=0 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[100]: plane-4 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=1 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[110]: plane-5 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=2 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[120]: plane-6 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=3 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[130]: plane-7 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=4 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[140]: plane-8 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=5 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[150]: plane-9 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=6 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[160]: plane-10 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=7 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[170]: plane-11 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=8 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[180]: plane-12 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=9 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[190]: plane-13 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=a color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[200]: plane-14 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=b color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[210]: plane-15 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=c color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[220]: plane-16 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=d color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[230]: plane-17 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=e color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[240]: plane-18 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=f color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[250]: plane-19 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=10 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[260]: plane-20 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=11 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[270]: plane-21 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=11 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[280]: plane-22 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=11 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range plane[290]: plane-23 crtc=(null) fb=0 crtc-pos=0x0+0+0 src-pos=0.000000x0.000000+0.000000+0.000000 rotation=1 normalized-zpos=11 color-encoding=ITU-R BT.709 YCbCr color-range=YCbCr limited range crtc[57]: mop enable=0 active=0 self_refresh_active=0 planes_changed=0 mode_changed=0 active_changed=0 connectors_changed=0 color_mgmt_changed=0 plane_mask=0 connector_mask=0 encoder_mask=0 mode: "": 0 0 0 0 0 0 0 0 0 0 0x0 0x0 crtc[74]: moplet enable=0 active=0 self_refresh_active=0 planes_changed=0 mode_changed=0 active_changed=0 connectors_changed=0 color_mgmt_changed=0 plane_mask=0 connector_mask=0 encoder_mask=0 mode: "": 0 0 0 0 0 0 0 0 0 0 0x0 0x0 crtc[88]: crtc-2 enable=0 active=0 self_refresh_active=0 planes_changed=0 mode_changed=0 active_changed=0 connectors_changed=0 color_mgmt_changed=0 plane_mask=0 connector_mask=0 encoder_mask=0 mode: "": 0 0 0 0 0 0 0 0 0 0 0x0 0x0 crtc[99]: crtc-3 enable=0 active=0 self_refresh_active=0 planes_changed=0 mode_changed=0 active_changed=0 connectors_changed=0 color_mgmt_changed=0 plane_mask=0 connector_mask=0 encoder_mask=0 mode: "": 0 0 0 0 0 0 0 0 0 0 0x0 0x0 connector[32]: HDMI-A-1 crtc=(null) self_refresh_aware=0 max_requested_bpc=8 connector[42]: HDMI-A-2 crtc=(null) self_refresh_aware=0 max_requested_bpc=8 connector[63]: Writeback-1 crtc=(null) self_refresh_aware=0 max_requested_bpc=0 connector[77]: Writeback-2 crtc=(null) self_refresh_aware=0 max_requested_bpc=0

config.txt

arm_64bit=1 arm_boost=1 arm_freq=2400 arm_freq_min=1000 arm_peri_high=1 audio_pwm_mode=2 auto_initramfs=1 avs_temp=38929 camera_auto_detect=1 core_freq=910 core_freq_min=500 disable_commandline_tags=2 disable_fw_kms_setup=1 disable_l2cache=1 disable_overscan=1 display_auto_detect=1 display_default_lcd=-1 display_hdmi_rotate=-1 display_lcd_rotate=-1 dvfs=4 enable_gic=1 enable_uart=-1 force_eeprom_read=1 force_pwm_open=1 framebuffer_depth=16 framebuffer_ignore_alpha=1 framebuffer_swap=1 gpu_freq_min=500 hdmi_enable_4kp60=1 hevc_freq=910 hevc_freq_min=500 ignore_lcd=-1 init_uart_clock=0x2dc6c00 isp_freq=910 isp_freq_min=500 mask_gpu_interrupt1=16418 max_framebuffers=2 over_voltage_avs=0x169b8 pause_burst_frames=1 pciex4_reset=1 program_serial_random=1 total_mem=4096 usb_max_current_enable=1 v3d_freq=960 v3d_freq_min=500 vpred=8526 hdmi_force_cec_address:0=65535 hdmi_force_cec_address:1=65535 device_tree=- overlay_prefix=overlays/ hdmi_cvt:0= hdmi_cvt:1= hdmi_edid_filename:0= hdmi_edid_filename:1= hdmi_timings:0= hdmi_timings:1=

cmdline.txt

coherent_pool=1M 8250.nr_uarts=1 pci=pcie_bus_safe snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 smsc95xx.macaddr=D8:3A:DD:AB:74:70 vc_mem.mem_base=0x3fc00000 vc_mem.mem_size=0x40000000 console=ttyAMA10,115200 console=tty1 root=PARTUUID=d6564e59-02 rootfstype=ext4 fsck.repair=yes rootwait

pin configuration

0: ip pu | hi // ID_SD/GPIO0 = input 1: ip pu | hi // ID_SC/GPIO1 = input 2: a3 pu | hi // PIN3/GPIO2 = SDA1 3: a3 pu | hi // PIN5/GPIO3 = SCL1 4: no pu | lo // PIN7/GPIO4 = none 5: no pu | lo // PIN29/GPIO5 = none 6: no pu | lo // PIN31/GPIO6 = none 7: no pu | lo // PIN26/GPIO7 = none 8: no pu | lo // PIN24/GPIO8 = none 9: no pd | lo // PIN21/GPIO9 = none 10: no pd | lo // PIN19/GPIO10 = none 11: no pd | lo // PIN23/GPIO11 = none 12: no pd | lo // PIN32/GPIO12 = none 13: no pd | lo // PIN33/GPIO13 = none 14: no pd | lo // PIN8/GPIO14 = none 15: no pd | lo // PIN10/GPIO15 = none 16: no pd | lo // PIN36/GPIO16 = none 17: no pd | lo // PIN11/GPIO17 = none 18: a4 pn | lo // PIN12/GPIO18 = I2S1_SCLK 19: a4 pn | lo // PIN35/GPIO19 = I2S1_WS 20: a4 pn | lo // PIN38/GPIO20 = I2S1_SDI0 21: a4 pn | lo // PIN40/GPIO21 = I2S1_SDO0 22: no pd | lo // PIN15/GPIO22 = none 23: ip pd | lo // PIN16/GPIO23 = input 24: ip pd | lo // PIN18/GPIO24 = input 25: no pd | lo // PIN22/GPIO25 = none 26: no pd | lo // PIN37/GPIO26 = none 27: ip pd | hi // PIN13/GPIO27 = input 28: no pd | lo // PCIE_RP1_WAKE/GPIO28 = none 29: no pu | hi // FAN_TACH/GPIO29 = none 30: no pu | lo // HOST_SDA/GPIO30 = none 31: no pu | lo // HOST_SCL/GPIO31 = none 32: op dh pd | hi // ETH_RST_N/GPIO32 = output 33: no pd | lo // GPIO33 = none 34: op dl pd | lo // CD0_IO0_MICCLK/GPIO34 = output 35: no pd | lo // CD0_IO0_MICDAT0/GPIO35 = none 36: no pd | lo // RP1_PCIE_CLKREQ_N/GPIO36 = none 37: no pd | lo // GPIO37 = none 38: ip pd | hi // CD0_SDA/GPIO38 = input 39: ip pd | hi // CD0_SCL/GPIO39 = input 40: ip pd | hi // CD1_SDA/GPIO40 = input 41: ip pd | hi // CD1_SCL/GPIO41 = input 42: a2 pd | hi // USB_VBUS_EN/GPIO42 = VBUS_EN1 43: a2 pu | hi // USB_OC_N/GPIO43 = VBUS_OC1 44: op dh pd | hi // RP1_STAT_LED/GPIO44 = output 45: a0 pd | hi // FAN_PWM/GPIO45 = PWM1_CHAN3 46: op dl pd | lo // CD1_IO0_MICCLK/GPIO46 = output 47: no pd | lo // 2712_WAKE/GPIO47 = none 48: no pd | lo // CD1_IO1_MICDAT1/GPIO48 = none 49: op dh pd | hi // EN_MAX_USB_CUR/GPIO49 = output 50: no pd | lo // GPIO50 = none 51: no pd | lo // GPIO51 = none 52: no pu | lo // GPIO52 = none 53: no pu | hi // GPIO53 = none 100: ip pd | lo // GPIO0 = input 101: op dh pu | hi // 2712_BOOT_CS_N/GPIO1 = output 102: a6 pn | hi // 2712_BOOT_MISO/GPIO2 = VC_SPI0_MISO 103: a5 pn | hi // 2712_BOOT_MOSI/GPIO3 = VC_SPI0_MOSI 104: a6 pn | lo // 2712_BOOT_SCLK/GPIO4 = VC_SPI0_SCLK 105: ip pd | lo // GPIO5 = input 106: ip pd | lo // GPIO6 = input 107: ip pd | lo // GPIO7 = input 108: ip pd | lo // GPIO8 = input 109: ip pd | lo // GPIO9 = input 110: ip pd | lo // GPIO10 = input 111: ip pd | lo // GPIO11 = input 112: ip pd | lo // GPIO12 = input 113: ip pd | lo // GPIO13 = input 114: a1 pd | lo // PCIE_SDA/GPIO14 = SPI_S_MOSI_OR_BSC_S_SDA 115: a1 pd | lo // PCIE_SCL/GPIO15 = SPI_S_SCK_OR_BSC_S_SCL 116: ip pd | lo // GPIO16 = input 117: ip pd | lo // GPIO17 = input 118: ip pd | lo // GPIO18 = input 119: ip pd | lo // GPIO19 = input 120: ip pu | hi // PWR_GPIO/GPIO20 = input 121: ip pd | lo // 2712_G21_FS/GPIO21 = input 122: ip pd | lo // GPIO22 = input 123: ip pd | lo // GPIO23 = input 124: a3 pn | lo // BT_RTS/GPIO24 = UART_RTS_0 125: a4 pu | lo // BT_CTS/GPIO25 = UART_CTS_0 126: a4 pn | hi // BT_TXD/GPIO26 = UART_TXD_0 127: a4 pu | hi // BT_RXD/GPIO27 = UART_RXD_0 128: op dh pd | hi // WL_ON/GPIO28 = output 129: op dh pd | hi // BT_ON/GPIO29 = output 130: a4 pn | lo // WIFI_SDIO_CLK/GPIO30 = SD2_CLK 131: a4 pu | hi // WIFI_SDIO_CMD/GPIO31 = SD2_CMD 132: a4 pd | hi // WIFI_SDIO_D0/GPIO32 = SD2_DAT0 133: a3 pu | hi // WIFI_SDIO_D1/GPIO33 = SD2_DAT1 134: a4 pn | hi // WIFI_SDIO_D2/GPIO34 = SD2_DAT2 135: a3 pn | hi // WIFI_SDIO_D3/GPIO35 = SD2_DAT3 200: ip pd | hi // RP1_SDA/AON_GPIO0 = input 201: ip pd | hi // RP1_SCL/AON_GPIO1 = input 202: op dh pd | hi // RP1_RUN/AON_GPIO2 = output 203: op dh pd | hi // SD_IOVDD_SEL/AON_GPIO3 = output 204: op dh pd | hi // SD_PWR_ON/AON_GPIO4 = output 205: a6 pu | lo // SD_CDET_N/AON_GPIO5 = SD_CARD_PRES_G 206: ip pd | hi // SD_FLG_N/AON_GPIO6 = input 207: ip pd | lo // AON_GPIO7 = input 208: ip pd | lo // 2712_WAKE/AON_GPIO8 = input 209: op dh pd | hi // 2712_STAT_LED/AON_GPIO9 = output 210: ip pd | lo // AON_GPIO10 = input 211: ip pd | lo // AON_GPIO11 = input 212: ip pd | lo // PMIC_INT/AON_GPIO12 = input 213: a3 pu | hi // UART_TX_FS/AON_GPIO13 = VC_TXD0 214: a3 pu | hi // UART_RX_FS/AON_GPIO14 = VC_RXD0 215: ip pd | lo // AON_GPIO15 = input 216: ip pu | hi // AON_GPIO16 = input 232: a1 -- | hi // HDMI0_SCL/AON_SGPIO0 = HDMI_TX0_BSC_SCL 233: a1 -- | hi // HDMI0_SDA/AON_SGPIO1 = HDMI_TX0_BSC_SDA 234: a1 -- | hi // HDMI1_SCL/AON_SGPIO2 = HDMI_TX1_BSC_SCL 235: a1 -- | hi // HDMI1_SDA/AON_SGPIO3 = HDMI_TX1_BSC_SDA 236: a2 -- | hi // PMIC_SCL/AON_SGPIO4 = BSC_M2_SCL 237: a2 -- | hi // PMIC_SDA/AON_SGPIO5 = BSC_M2_SDA

vcdbg log messages

004157.677: Initial voltage 800000 temp 38379 004355.116: avs_2712: AVS pred 8526 852600 temp 38929 004355.127: vpred 852 mV +0 004981.364: FB framebuffer_swap 1 005009.458: Select resolution HDMI0/2 hotplug 1 max_mode 2 005009.650: BSC_A no ACK 005009.840: BSC_A no ACK 005009.851: HDMI0: Unable to read EDID block 0 005009.864: Select resolution HDMI1/2 hotplug 0 max_mode 2 005606.490: dtb_file 'bcm2712-rpi-5-b.dtb' 007775.758: Starting OS 7775 ms 007778.396: 00000040: -> 00000480 007778.412: 00000030: -> 00100080 007778.428: 00000034: -> 00100080 007778.444: 00000038: -> 00100080 007778.459: 0000003c: -> 00100080

Logs

No response

Additional context

No response

pelwell commented 11 months ago

I can reproduce your findings.

pelwell commented 11 months ago

There was a bug in the DMA configuration, which I had to add to the 6.1 driver. Things have changed significantly in newer kernels so I need to review my changes in rpi-6.6.y etc. (and possibly back-port some of it), but for now #5757 should fix rpi-6.1.y.

Wait about an hour for the auto-builds to complete, then you'll be able to install a trial kernel by running sudo rpi-update pulls/5757.

nodemand commented 11 months ago

Thank you so much!

gtrainavicius commented 11 months ago

The full duplex playback and recording on Pisound works with pulls/5757.

nodemand commented 11 months ago

@pelwell I'm getting the following error in the output when executing sudo rpi-update pulls/5757:

 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** Performing self-update
 *** Relaunching after update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
FW_REV:
 *** We're running for the first time
 *** Backing up files (this will take a few minutes)
 *** Remove old firmware backup
 *** Backing up firmware
 *** Remove old modules backup
 *** Backing up modules 6.1.0-rpi4-rpi-2712
WANT_32BIT:0 WANT_64BIT:1 WANT_PI4:1 WANT_PI5:1
 *** Downloading specific artifact revision (this will take a few minutes)
curl  -L https://builds.raspberrypi.com/github/linux/778cd12aef3b18c92a78dae93059acef0feab354/bcmrpi | zcat | tar xf - -C //root/.rpi-firmware --strip-components=2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0

gzip: stdin: unexpected end of file
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
Invalid artifact specified. Response: 404.
pelwell commented 11 months ago

Give it a while - 20 minutes, say - I pushed an update in response to a comment on the previous version of the patch.

nodemand commented 11 months ago

okay!

pelwell commented 11 months ago

I was too pessimistic - it should be ready now.

nodemand commented 11 months ago

Well, I'm not getting any errors, but where there was sound before when starting aplay test.wav -f S16_LE -r48000 -c2 -D plughw:Zero,0 there is nothing now....no sound.

EDIT: Then I played back the file test.wav, that was recorded with arecord -f S16_LE -r48000 -c2 -D plughw:Zero,0 -F0 --period-size=256 -B0 --buffer-size=4096 test.wav on my Mac, but there is only silence...

pelwell commented 11 months ago

Is that because you've overwritten your test.wav with silence recorded by arecord?

nodemand commented 11 months ago

Yes, I have overwritten it. And I checked. There is sound coming out of the audio source I used as input for arecord.... So why is there silence?

pelwell commented 11 months ago

Did you try playing another file? Have you used the same soundcard and configuration on an older Pi and had valid recordings?

nodemand commented 11 months ago

I just tried another wav and it won't play back with aplay and mplayer says: Audio device got stuck! And no, I don't have an older working config and neither do I have a decent older Pi; only a Model B+ ;-). But I will try and re-install Raspberry OS now...

pelwell commented 11 months ago

Is this new behaviour? Has playback ever worked before? sudo rpi-update will revert to a kernel without the trial patch.

nodemand commented 11 months ago

Yes it is. It worked right before the patch, just not recording and playback simultaneously...

pelwell commented 11 months ago

Which Codec Zero alsactl configuration file are you using, the one that used to give you good recordings?

nodemand commented 11 months ago

hahaha, yes that is exactly the thing I did not run because it generates an error with me and I thought it did not work because of that so I did not run it anymore...

nodemand commented 11 months ago

it works now! Sorry my bad...

pelwell commented 11 months ago

Excellent. I'm merging the patch, and it will appear in future releases.

Thanks for the clear and accurate report.

nodemand commented 11 months ago

Only one more thing. I cannot run my application because it depends on libasound2 and libasound-dev and portaudio19-dev. And I'm trying to install libasound-dev, but it tells me:

sudo apt-get install libasound-dev

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'libasound2-dev' instead of 'libasound-dev'
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libasound2-dev : Depends: libasound2 (= 1.2.8-1+b1) but 1.2.8-1+rpt1 is to be installed

This used to work. Is this as a result of the patch? Not sure what to do now...

EDIT: Also:

sudo apt-get install portaudio19-dev

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libasound2-dev : Depends: libasound2 (= 1.2.8-1+b1) but 1.2.8-1+rpt1 is to be installed
E: Unable to correct problems, you have held broken packages.
pelwell commented 11 months ago

Is this as a result of the patch?

No, it really can't be, therefore this is not the place for your question.

Are you sure that libasound2-dev doesn't work?

Try updating your packages:

pi@raspberrypi:~$ apt info libasound2-dev
Package: libasound2-dev
Version: 1.2.8-1+rpt1
Priority: optional
Section: libdevel
Source: alsa-lib
Maintainer: Debian ALSA Maintainers <pkg-alsa-devel@lists.alioth.debian.org>
Installed-Size: 676 kB
Provides: libasound-dev
Depends: libasound2 (= 1.2.8-1+rpt1)
Suggests: libasound2-doc
Homepage: https://www.alsa-project.org/
Download-Size: 110 kB
APT-Manual-Installed: yes
APT-Sources: http://buildbot.pitowers.org:3143 bookworm/main arm64 Packages
Description: shared library for ALSA applications -- development files
 This package contains files required for developing software
 that makes use of libasound2, the ALSA library.
 .
 ALSA is the Advanced Linux Sound Architecture.
nodemand commented 11 months ago
apt info libasound2-dev
Package: libasound2-dev
Version: 1.2.8-1+b1
Priority: optional
Section: libdevel
Source: alsa-lib (1.2.8-1)
Maintainer: Debian ALSA Maintainers <pkg-alsa-devel@lists.alioth.debian.org>
Installed-Size: 677 kB
Provides: libasound-dev
Depends: libasound2 (= 1.2.8-1+b1)
Suggests: libasound2-doc
Homepage: https://www.alsa-project.org/
Tag: devel::library, role::devel-lib, works-with::audio
Download-Size: 110 kB
APT-Sources: http://deb.debian.org/debian bookworm/main arm64 Packages
Description: shared library for ALSA applications -- development files
 This package contains files required for developing software
 that makes use of libasound2, the ALSA library.
 .
 ALSA is the Advanced Linux Sound Architecture.
nodemand commented 11 months ago

okay, I really thought I had updated everything. I had not. It must be time to stop now... Thank you sooo much!

nodemand commented 11 months ago

My application WORKSSSS!!!!

pelwell commented 11 months ago

Woot!