LIME2 sun4i-codec not working in bullseye-base image

Started by zeallin, June 18, 2025, 07:01:25 AM

Previous topic - Next topic

zeallin

Hello,

I want to upgrade the A20 system image to latest A20-OLinuXino-bullseye-base-20241121-172551.img, but the sun4i-codec seems not enabled by default.

I used the cool olinuxino-overlay tool to enabled the lime-audio-codec.dtbo then reset, and can see the device from aplay -l:

**** List of PLAYBACK Hardware Devices ****
card 0: sun4icodec [sun4i-codec], device 0: CDC PCM Codec-0 [CDC PCM Codec-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

However when I try to play a wav file it does not have audio output to speaker, and seems never return, need to use ctrl+c to force quit:
olimex@a20-olinuxino:~$ aplay ready.wav
Playing WAVE 'ready.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
^CAborted by signal Interrupt...
aplay: pcm_write:2058: write error: Interrupted system call

The same board with speaker can play audio using old debian8 image.

Is there anything I need to configure to make the analog codec works?

The test board is T2 Rev.L, it is connected to HDMI screen (but we don't want hdmi audio output since the screen does not have speaker)

Love Olimex A20. Thanks you very much my friends!

LubOlimex

What happens if you try the different options in olinuxino-display? E.g. with HDMI output set, with automatic set, with something else selected? Maybe first run olinuxino-reset and reboot to revert any changes configuration you might have done and forgotten about.
Technical support and documentation manager at Olimex

zeallin

#2
Yeah I've tried following scenario (olinuxino-reset is executed):

1.  run olinuxino-overlay to enable sun4icodec then reset  (HDMI plugged) -> same aplay fail
2.  based on step 1, use olinuxino-display switch to LCD 10' no TS (HDMI unplugged)  -> same aplay fail
3.  based on step 1, use olinuxino-display switch to DISABLE, (HDMI unplugged)  -> same aplay fail

I found when I enabled the sun4icodec then the sun4ihdmi is gone. but when called olinuxino-reset the sun4ihdmi is backed is this expected?

LubOlimex

I am not sure if audio is enabled for the LIME2 since the board has no audio jacks, I think it is not enabled on purpose to have more free GPIOs. Are you using LIME2-SHIELD? Try enabling the overlay for LIME2-SHIELD instead. It might be in olinuxino-overlay. Which variant of the LIME2 board? I will test too.
Technical support and documentation manager at Olimex

zeallin

#4
Thank you very much my friend!

1. I am not using LIME2-SHIELD since we used GPIO-1 with our addon board
2. The overlay of LIME2-SHIELD seems not found in the olinuxino-overlay tool
3. It is the amazing T2-OLinuXino-LIME2-IND, version Rev.L

LubOlimex

So how is the audio output connected then? Do you have drawing or schematic? Is it similar to what we did in A20-OLinuXino-MICRO?
Technical support and documentation manager at Olimex

LubOlimex

#6
Ok here is some empirical info since I tested today with same board T2-OLinuXino-LIME2-IND and LIME2-SHIELD and some wav file. It played just fine (there was also sound on the headphones attached):

root@a20-olinuxino:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sun4icodec [sun4i-codec], device 0: CDC PCM Codec-0 [CDC PCM Codec-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root@a20-olinuxino:~# aplay file_example_WAV_5MG.wav
Playing WAVE 'file_example_WAV_5MG.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

Didn't test before updating the image tho. I first ran apt update and apt upgrade to be sure I have the latest image, then rebooted. Didn't change anything in the overlays or settings.

You can find the wav file I used here:

https://ftp.olimex.com/TEMP/MP3test/file_example_WAV_5MG.wav

This means that audio is supported in the LIME2 images and config even tho it has no audio jacks by default. Here are few ideas to try:

1) Try re-writing a fresh image and running apt update and apt upgrade like me and test again. Maybe some configuration via olinuxino-overlay or other change caused the issue.

2) Maybe check if the board is properly recognized at start of boot, like this is what I got at boot:

"U-Boot 2021.04+olimex-1-20250305.102147 (Mar 05 2025 - 10:22:57 +0000) Allwinner Technology

CPU:  Allwinner A20 (SUN7I)
ID:    T2-OLinuXino-LIME2-IND Rev.N
SN:    00037DXX
MAC:  30:1F:9A:D1:XX:XX
I2C:  ready
DRAM:  1 GiB
MMC:  mmc@1c0f000: 0
"

You should get revision L, of course.

3) Since you are not using LIME2-SHIELD maybe also check the schematic of LIME2-SHIELD and compare with your hardware setup.
Technical support and documentation manager at Olimex

zeallin

Thank you very much my friend!

1. For the audio output, I just have a add-on board which wired the HPOUTL and HPCOM from GPIO-1 to a speaker (mono) , which works before
2. Ohh I will try to do apt update and apt upgrade, and see if the boot info is correct
3. So the steps you used should be (please correct my if I am wrong):
- use a fresh image to boot
- run apt update and apt upgrade, then u-boot-install
- use olinuxino-overlay to turn on sun4icodec

LubOlimex

Just the first two + reboot. I didn't use olinuxino-overlay, audio was already enabled without running anything. I didn't use olinuxino-overlay at all.

About the hardware we connect both right and left channels but I guess for mono just one is ok, as long as it is setup properly in the alsamixer settings. We have resistors and capacitors in series to ground tho, to filter. This is the excerpt from the MICRO board that comes with headphones output:

https://imgur.com/a/CmWlsZv

Technical support and documentation manager at Olimex

zeallin

Hello my friend,

I tried just use first two steps (clean image + apt update, apt upgrade, u-boot-install), but seems no luck:

1. aplay -l have no soundcard found
olimex@a20-olinuxino:~$ aplay -l
aplay: device_list:274: no soundcards found...

2. However, I check the boot information, it seems not correct. I wonder if this is the problem:

U-Boot 2021.04+olimex-1-20250305.102147 (Mar 05 2025 - 10:22:57 +0000) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
ID:    A20-OLinuXino-LIME Rev.A
SN:    00000000
MAC:   FF:FF:FF:FF:FF:FF
I2C:   ready
DRAM:  1 GiB
MMC:   mmc1:0c0f000: 0
Loading Environment from EXT4... *** Warning - bad CRC, using default environment

Loading Environment from FAT... ** No device specified **
HDMI connected: Setting up a 1920x1080 hdmi console (overscan 0x0)
In:    serial
Out:   vga
Err:   vga
Allwinner mUSB OTG (Peripheral)
Net:   eth0: ethernet@1c50000, eth1: usb_ether
starting USB...
Bus usb0c14000: USB EHCI 1.00
Bus usb1c14400: USB OHCI 1.0
Bus usb1c1c000: USB EHCI 1.00
Bus usb1c1c400: USB OHCI 1.0
       scanning bus usb0c14000 for devices... 7 USB Device(s) found
       scanning bus usb1c14400 for devices... 1 USB Device(s) found
       scanning bus usb1c1c000 for devices... 2 USB Device(s) found
       scanning bus usb1c1c400 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
Hit any key to stop autoboot:  0
https://ibb.co/pGc5HHJ

3. How can I make the board properly recognized at start of boot?

Thank you very much for your help!

LubOlimex

Yes, the fail to recognize the board properly is the problem! When this happens the Olimex loads settings for that specific board and revision, and the hardware of the real board would not work properly.

Why did this happen? Well, the ID for the board is stored on the EEPROM memory and either EEPROM got wiped or overwritten and the boot can't find the ID so it loads the default fallback configuration.

How to fix it? Re-configure the EEPROM with proper information. This can be done via software means. You need to interrupt the boot early - where it says in your log "Hit any key to stop autoboot:  0" just mash some key after power up. Then you'd end up in the u-boot. Then you manually set the board and revision by using commands, type:

olinuxino

to see help, then type

olinuxino config list

to see all IDs for each board and then:

olinuxino config write [id] [revision] [serial] [mac]

where ID is taken from the olinuxino config list and should match your board variant and then hardware revision.

Once done, type:

saveenv

and finally reset the board with:

reset

Observe if the new and proper values are stored and displayed at the start of boot.

For more info refer to the Olimage guide document, page 20, chapter "7.1 U-boot tools":

https://github.com/OLIMEX/OLINUXINO/blob/master/DOCUMENTS/OLIMAGE/Olimage-guide.pdf

Best regards,
Lub/OLIMEX

Technical support and documentation manager at Olimex

zeallin

Hello my friend,

Your suggestion is awesome! I followed the steps you provided and now the board is recognized properly!

1. The sun4icodec is turned on automatically!

**** List of PLAYBACK Hardware Devices ****
card 0: sun4icodec [sun4i-codec], device 0: CDC PCM Codec-0 [CDC PCM Codec-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

2. The aplay seems works properly (it finish in time) but no audio output (no sound from the speaker).

olimex@a20-olinuxino:~/tool-audio$ aplay -Dhw:0,0 launch.wav
Playing WAVE 'launch.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
olimex@a20-olinuxino:~/tool-audio$

3. I checked the alsamixer and unmute all playback items

https://ibb.co/sdWJQnWK

Just wonder what is missing...

Thank you very much my friend!

LubOlimex

No idea. My hardware setup is different - I used regular stereo output and I didn't change anything in alsa mixer. You only have one channel connected and mono source, I think you need to change the input the output to mono and either left or right channel as input somewhere. Not sure if unmutting all is the correct approach.

Maybe also try with the audio file I linked above "file_example_WAV_5MG.wav".
Technical support and documentation manager at Olimex

zeallin

Hello my friend,

Since I think the system should be alright, I change the wire from HPOUTL + HPCOM to HPOUTR + HPCOM, and the mono audio works!

Thank you very very much for your support, you are the best!

LubOlimex

Thank you for the update! Glad it worked in the end.
Technical support and documentation manager at Olimex