Enable analog audio on A20 Olinuxino Micro

Started by Brettleger, June 10, 2020, 11:41:57 PM

Previous topic - Next topic

Brettleger

Hi,

I own an A20-olinuxino-micro dating back to 2014 (Rev. E) that I want to use as streaming audio client.

I have successfully installed the official Debian buster image from images.olimex.com. Now I am struggling to get the audio output to work. It seems that no soundcard is recognised and neither soundcore nor any other kernel-module for sound is loaded.

dmesg returns:
[...]
[    3.893573] ALSA device list:
[    3.893580]   No soundcards found.
[...]

Consequently there are no devices listed within aplay:
root@olinuxino:~# aplay -l
aplay: device_list:272: no soundcards found...

I stumbled upon this statement in the armbian howto on Olimex.com (https://www.olimex.com/wiki/ArmbianHowTo)
Quote from: undefinedBy default A20 boards manufactured after 01.01.2018 have board IDs stored in the EEPROM memories with automatic detection in mind and these would not require manual board configuration. These "newer" boards get identified and recognized by the information stored on their EEPROMs and proper Linux configuration gets automatically loaded.

I understand that in my old board, no board IDs are stored in the EEPROM so that needs to be manually configured.

dmesg lists one eeprom at 1-0050:
[...]
[   16.003780] at24 1-0050: 2048 byte 24c16 EEPROM, writable, 16 bytes/write
[...]
That doesn't seem to contain much info:
root@olinuxino:~# more /sys/bus/i2c/devices/1-0050/eeprom | od -x
0000000 55ff ffff ffff ffff ffff ffff ffff ffff
0000020 ffff ffff ffff ffff ffff ffff ffff ffff
*
0004000

Can I write the board info to the EEPROM via this way also? What is the data I need to write?

TiA,

Brettleger

LubOlimex

You don't need to do it via I2C. You can set the board and revision with command in u-boot.

Interrupt u-boot (press space repeatedly as soon as board boots), once inside the u-boot type:

olinuxino
to see available commands, then run

olinuxino config list
and when you see your board write down its number and run

olinuxino config write [id] [revision] [serial] [mac]
where serial and mac are optional but I would recommend setting them.

Let me know if that works.
Technical support and documentation manager at Olimex

Brettleger

Unfortunately that doesn't work. I can connect a keyboard and successfully interrupt the boot process, but it seems the HDMI is not configured then and therefore I can't see anything on the screen.

I guess I have to program the EEPROM via i2c.

I figured out I do have a A20-OLinuXino-MICRO-n4GB, so according to this blog-post the type number is 4615 (hex: 0x00001207).

Board major revision is "E", no minor revision (ASCII hex: 0x4500), serial number shall be set to 20140001 (hex: 0x01334FE1)

The current MAC address of the board is 02:04:02:01:80:C0 (ASCII hex: 0x303230343032303138304330), no need to change.

According to the EEPROM content definition on github the EEPROM shall therewith read:
0x4F4CAA55                  [Header, hard coded]
0x00001207                  [ID, denotes the board type]
0x4500                      [revision]
0x000312B9                  [serial number, arbitrarily chosen]
0x4E403000                  [configuration: NAND,4GB-FLASH,1GB-RAM,commercial grade]
0x303230343032303138304330  [MAC-address]

The EEPROM is connected to i2c-bus 1 at line 50, so I think the the following i2ctransfer command line should to the trick
i2ctransfer 1 w30@0x50 0x4F4CAA55000012074500000312B94E403000303230343032303138304330

The EEPROM content definition does not mention anything about the 222 reserved bytes from 0x1E to 0xFB, so I guess leaving them at 0xFF is just fine.

I am wondering about the 4 "checksum" bytes 0xFC to 0xFF. It is not mentioned how the checksum is generated and which input bytes are considered. How do i determine the correct checksum to program into the EEPROM?

Another issue that makes me worry: When using i2ctransfer to read the EEPROM it throws a warning that the device is in use and the return data is fluctuating (look for 0x55):
root@olinuxino:~# i2ctransfer -f 1 r30@0x50
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will send the following messages to device file /dev/i2c-1:
msg 0: addr 0x50, read, len 30
Continue? [y/N] Y
0xff 0x55 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
root@olinuxino:~# i2ctransfer -f 1 r30@0x50
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will send the following messages to device file /dev/i2c-1:
msg 0: addr 0x50, read, len 30
Continue? [y/N] Y
0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
root@olinuxino:~# i2ctransfer -f 1 r30@0x50
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will send the following messages to device file /dev/i2c-1:
msg 0: addr 0x50, read, len 30
Continue? [y/N] y
0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff

I assume this is a critical operation so your advice is greatly appreciated. I prefer to not brick my board.

LubOlimex

#3
QuoteUnfortunately that doesn't work. I can connect a keyboard and successfully interrupt the boot process, but it seems the HDMI is not configured then and therefore I can't see anything on the screen.

This doesn't happen here. Maybe you are using some minimal image that doesn't have HMDI enabled at all. Maybe the problem is in the monitor settings. I tested with "A20-OLinuXino-bionic-base-20200522-210046" - you can see the results in the YouTube video here:

https://www.youtube.com/watch?v=JFS5xNEBn10

If your problem remains my advice is get USB-serial cable so you can have access to the command line interface even if video output is not working. Something similar like this (should be available in every shop that sells Arduino or hobby electronics):

https://www.olimex.com/Products/Components/Cables/USB-Serial-Cable/USB-Serial-Cable-F/

QuoteI guess I have to program the EEPROM via i2c.

Good luck. If that was possible we would have done such a script to use in the kernel. There was a reason it is done in u-boot. Maybe take a look at the sources of u-boot so see how configuration write is done. The check sum is just CRC32 check of the 252 bits before it. It looks like this in the code:

ee->checksum = crc32(0, eeprom_content, 252);
Technical support and documentation manager at Olimex

anverx

Hi, i'm trying to do the exact thing that original poster wanted, a small sound server/player based on a really old micro board (revision F).  I used serial console to catch uboot, and followed the instructions above.  After saving the board id, i checked it with

=> olinuxino config info
ID:    A20-OLinuXino-MICRO Rev.F
SN:    FFFFFFFF
MAC:   02:13:06:C2:43:CC

And that looks correct, and yet the kernel still says

[Sat Sep  4 01:47:51 2021] ALSA device list:
[Sat Sep  4 01:47:51 2021]   No soundcards found.

The image i'm using is:  `Ubuntu 20.04 LTS (GNU/Linux 5.10.47-olimex armv7l)`
I realize it's an old board, but since i have a few of them it would be nice to give them second life, especially since there is a recent kernel for it.


LubOlimex

Ignore that message, it is always printed. Check empirically if you have sound.
Technical support and documentation manager at Olimex

anverx

#6
Oh yeah.  Alasamixer is showing some channels. But still unable to play audio.

~$ aplay -vv  file_example_WAV_1MG.wav
Playing WAVE 'file_example_WAV_1MG.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo
Plug PCM: Hardware PCM card 0 'sun4i-codec' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 8000
  exact rate   : 8000 (8000/1)
  msbits       : 16
  buffer_size  : 4000
  period_size  : 1000
  period_time  : 125000
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 1000
  period_event : 0
  start_threshold  : 4000
  stop_threshold   : 4000
  silence_threshold: 0
  silence_size : 0
  boundary     : 2097152000
  appl_ptr     : 0
  hw_ptr       : 0
######+                                            | 10%aplay: pcm_write:2061: write error: Input/output error

Nothing in dmesg...

`/etc/asound.conf` is set to

pcm.!default {
        type hw
        card 0
}

ctl.!default {
        type hw
        card 0
}