Alsa configuration (I2S4) Jetson Nano

Hi all

I’m having trouble setting up alsa configuration

I’m currently working with Jetson nano DevKit, so I’ve enabled pin usage via sudo /opt/nvidia/jetson-io/jetson-io.py

Next I configured alsa via alsamixer -c 1

my configuration worked and saw the clk on the oscilloscope and could even play the sound

but after rebooting the device
I started receiving messages like this when I turned on the recording:

arecord: pcm_read:2103: read error: Input/output error

And I stopped seeing any sync sequences on the oscilloscope

Perhaps I need to setting up something else?
Perhaps there is a list of default settings for managing I2S4 in alsa?
what could be the reason for this error because the device just rebooted

Regards,
Georgiy

Have you check NVIDIA Jetson Linux Developer Guide : Audio Setup and Development | NVIDIA Docs to see if any help?

Hi Kayccc, is there something specific to this issue in there? I would love to follow the docs better.

for example I found this:

Device Tree Configuration for a Custom Audio Card

To support a custom audio card or other external audio device, you may need to add or update various device tree nodes such as clocks and power supplies.

this:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/sound/sgtl5000.txt?h=v5.2-rc3

and this:

Populate Codec Node

To enable the codec, you must add the codec under the device tree node of the device that is used to access the codec. Most codecs use either I2C or SPI for access. In the example below, the codec uses I2C for its control interface, and so is added to the appropriate I2C node.

i2c@ {

sgtl5000: sgtl5000@0a {

compatible = “fsl,sgtl5000”;

reg = <0x0a>;

clocks = <&sgtl5000_mclk>;

micbias-resistor-k-ohms = <2>;

micbias-voltage-m-volts = <3000>;

VDDA-supply = <&vdd_3v3>;

VDDIO-supply = <&vdd_3v3>;

status = “okay”;

};

};

See the device tree binding documentation to determine what properties must be populated for the codec and how to configure them.

Make sure that the relevant control interface (I2C, SPI, etc.) is enabled in the platform’s device tree. The 40-pin GPIO expansion header exposes an I2C controller; the table below shows the address of the I2C controller exposed on each Jetson platform.

Hi @kayccc

I have read the recommendations in this document
and this is what I got:

$ dmesg | grep "ASoC"
[   19.058532] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[   19.065536] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S4 DAP Receive event failed: -22
[   19.313592] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[   19.320627] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S4 DAP Receive event failed: -22
[   19.486063] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[   19.493066] tegra-asoc: sound: ASoC: PRE_PMU: I2S4 DAP Transmit-x Playback event failed: -22
[   19.753159] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[   19.760236] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S4 DAP Receive event failed: -22
[   19.776332] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[   19.783338] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S4 DAP Receive event failed: -22
[   19.800098] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[   19.807096] tegra-asoc: sound: ASoC: PRE_PMU: I2S4 DAP Transmit-x Playback event failed: -22
[   19.930798] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[   19.937990] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S4 DAP Receive event failed: -22
[   19.953980] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[   19.960995] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S4 DAP Receive event failed: -22
[   19.990221] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[   19.997246] tegra-asoc: sound: ASoC: PRE_PMU: I2S4 DAP Transmit-x Playback event failed: -22
[   20.136205] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[   20.143209] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S4 DAP Receive event failed: -22
[  559.198508] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[  559.205935] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S4 DAP Receive event failed: -22
[  622.449396] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[  622.456414] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S4 DAP Receive event failed: -22
[  673.800598] tegra210-i2s tegra210-i2s.3: ASoC: can't set DAP hw params: -22
[  673.807832] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S4 DAP Receive event failed: -22

I guess the problem is in the initialization of I2S4, because I received this list and do not see I2S4 there

$ sudo cat /sys/kernel/debug/asoc/codecs
tegra210-ope.1
tegra210-ope.0
tegra210-mvc.1
tegra210-mvc.0
tegra210-afc.5
tegra210-afc.4
tegra210-afc.3
tegra210-afc.2
tegra210-afc.1
tegra210-afc.0
tegra210-sfc.3
tegra210-sfc.2
tegra210-sfc.1
tegra210-sfc.0
tegra210-mixer
tegra210-adx.1
tegra210-adx.0
tegra210-amx.1
tegra210-amx.0
tegra210-dmic.1
tegra210-dmic.0
tegra210-i2s.3
tegra210-i2s.2
tegra210-admaif
tegra210-axbar
7.spdif-dit.7
6.spdif-dit.6
5.spdif-dit.5
4.spdif-dit.4
3.spdif-dit.3
2.spdif-dit.2
1.spdif-dit.1
0.spdif-dit.0
snd-soc-dummy

or in my case I2S4 will correspond to tegra210-i2s tegra210-i2s.3?

Regards,
Georgiy

Hello @kayccc

Here is a list of settings for alsamixer:

amixer -c tegrasndt210ref sset 'I2S4 Mux' 'ADMAIF1'
amixer -c tegrasndt210ref sset 'ADMAIF1 Mux' 'I2S4'
amixer -c tegrasndt210ref sset 'I2S4 codec bit format' '16'
amixer -c tegrasndt210ref sset 'I2S4 codec master mode' 'cbm-cfm'
amixer -c tegrasndt210ref sset 'I2S4 BCLK ratio' '64'
amixer -c tegrasndt210ref sset 'I2S4 codec frame mode' 'i2s'
amixer -c tegrasndt210ref sset 'I2S4 fsync width' 15
amixer -c tegrasndt210ref sset "I2S4 Loopback" off
amixer -c tegrasndt210ref sset "I2S4 Sample Rate" 44100
amixer -c tegrasndt210ref sset "I2S4 Channels" 1

Regards,
Georgiy

hi @kayccc is there any update to this.

@kayccc this is what i’ve come across. is it true that you can’t persist the mixer across reboots?
Would these solutions work?

The behavior you’re observing is typical. The ALSA mixer settings are not persistent across reboots. They reset to default values when the system restarts.

To make your amixer configurations persistent across reboots, you can consider the following methods:

  1. Startup Script: This is one of the most straightforward methods.

    • For a system using systemd, you can create a custom service that will run your script at startup.
    • Alternatively, if your distribution supports it, you can place your amixer commands in the /etc/rc.local file, ensuring that it’s executable.
  2. ALSA State Save/Restore: Use alsactl to save and restore the ALSA mixer state.

    • After you’ve made your configurations using amixer, you can save the current state with sudo alsactl store.
    • Ensure the saved state is loaded at boot. Some systems do this automatically, but if yours doesn’t, you can add sudo alsactl restore to your startup script or /etc/rc.local.
  3. Custom ALSA Configuration: Set default behaviors in /etc/asound.conf or ~/.asoundrc. This method doesn’t replace the amixer commands but can be used to set default behaviors.

Here’s a quick guide to set up a systemd service for your needs:

  1. Create a script containing your amixer commands:
echo -e "#!/bin/bash\n
amixer -c tegrasndt210ref sset 'I2S4 Mux' 'ADMAIF1'\n
amixer -c tegrasndt210ref sset 'ADMAIF1 Mux' 'I2S4'\n
... (rest of your amixer commands)
" > /usr/local/bin/alsa_setup.sh
  1. Make it executable: sudo chmod +x /usr/local/bin/alsa_setup.sh

  2. Create a systemd service for it:

echo -e "[Unit]\n
Description=Set custom ALSA configurations\n\n
[Service]\n
Type=oneshot\n
ExecStart=/usr/local/bin/alsa_setup.sh\n\n
[Install]\n
WantedBy=multi-user.target
" > /etc/systemd/system/alsa-setup.service
  1. Enable and start the service:
sudo systemctl enable alsa-setup.service
sudo systemctl start alsa-setup.service

Now, every time the system boots up, the systemd service should set your custom amixer configurations.

also @georgiy.lutsenko is reporting that the configuration is there after reboot but it is just not working.

If the configuration was saved and applied during boot but is not working as expected, there might be a couple of potential reasons:

  1. Race Condition: It’s possible that your script is running before the sound modules or services have been fully initialized, leading to a race condition. In this scenario, the settings might not apply correctly.

  2. Overwritten Settings: Another service or system routine may be overwriting your settings after they’re applied during boot.

Let’s address these potential issues:

1. Delay the Execution

You can modify the systemd service to wait for the sound system to be fully initialized. You can achieve this by making your service depend on the sound.target:

Edit the /etc/systemd/system/alsa-setup.service file:

sudo nano /etc/systemd/system/alsa-setup.service

Add After=sound.target under the [Unit] section:

[Unit]
Description=Set custom ALSA configurations
After=sound.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/alsa_setup.sh

[Install]
WantedBy=multi-user.target

Then reload the systemd configuration:

sudo systemctl daemon-reload

And restart the service:

sudo systemctl restart alsa-setup.service

2. Check Other Sound Services

If you’re using a desktop environment like GNOME or KDE, they might have their own sound services or daemons that are overwriting your settings. You might need to check their documentation or settings to ensure they’re not interfering.

3. Diagnostic Steps

  • Check Logs: After reboot, check system logs to see if there’s any relevant information:

    sudo journalctl -u alsa-setup.service
    

    This will give you the logs specific to the alsa-setup service. Look for any errors or warnings.

  • Manually Run After Boot: After reboot, if the settings aren’t working, try manually executing your script:

    sudo /usr/local/bin/alsa_setup.sh
    

    See if manually running the script after boot makes a difference. If it does, it’s a strong indicator of a timing issue during the boot process.

These steps should give you more insight into what might be going wrong. If the issue persists, you may need to dig deeper into the specific behavior of the Jetson Nano’s sound system or other system components that could be interacting with your ALSA settings.

Hi xtianus,
Just trying to understand, whether this query is same as Persist Alsa configuration (I2S4) in Jetson Nano doesn’t apply upon reboot - Jetson & Embedded Systems / Jetson Nano - NVIDIA Developer Forums?

If so we can track in single query for better tracking. FYI. ALSA conf files are present to apply mixer controls during the boot. I don’t see need for separate scripts. But I will work with you to sort out the issues.

Yes, this is the same query and the above was an GPT query response.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.