0
guidol

[Info] FriendlyARM PCM5102A-Hat with NanoPi Neo under mainline 4.x.x

Recommended Posts

I did that on a NanoPi Neo with the FriendlyARM PCM5102A Hat

https://www.friendlyarm.com/index.php?route=product/product&product_id=169 )
using kernel 4.14.87-sunxi and armbian 5.67 (or later would be only 5.65?)
(before that I did use legacy kernel 3.4.x with the PCM510A)


and the armbian-BuildSystem

plus (THANKS to) informations in threads from  @dony71 , @Christos, @Valery Rezvyakov
and the the Reference-Threads you could find above :)

 

----------------------------------------------------------------------------------------------------------------------------------
BACKUP DTB (on NanoPi Neo)
----------------------------------------------------------------------------------------------------------------------------------

cp /boot/dtb/sun8i-h3-nanopi-neo.dtb /boot/dtb/sun8i-h3-nanopi-neo.dtb_org

 

----------------------------------------------------------------------------------------------------------------------------------
CONVERT dtb to dts (on NanoPi Neo)
----------------------------------------------------------------------------------------------------------------------------------

dtc -I dtb -O dts /boot/dtb/sun8i-h3-nanopi-neo.dtb -o /boot/dtb/sun8i-h3-nanopi-neo.dts

 

----------------------------------------------------------------------------------------------------------------------------------
EDIT 
/boot/dtb/sun8i-h3-nanopi-neo.dts
----------------------------------------------------------------------------------------------------------------------------------

nano /boot/dtb/sun8i-h3-nanopi-neo.dts

 

- change: status from "disabled" to "okay"

----------------------------------------------------------------------------------------------------------------------------------
FROM

 

                i2s@1c22000 {
                        #sound-dai-cells = <0x0>;
                        compatible = "allwinner,sun8i-h3-i2s";
                        reg = <0x1c22000 0x400>;
                        interrupts = <0x0 0xd 0x4>;
                        clocks = <0x3 0x38 0x3 0x54>;
                        clock-names = "apb", "mod";
                        dmas = <0x13 0x3 0x13 0x3>;
                        resets = <0x3 0x2b>;
                        dma-names = "rx", "tx";
                        status = "disabled";
                        phandle = <0x4e>;
                };

 


TO
 

                i2s@1c22000 {
                        #sound-dai-cells = <0x0>;
                        compatible = "allwinner,sun8i-h3-i2s";
                        reg = <0x1c22000 0x400>;
                        interrupts = <0x0 0xd 0x4>;
                        clocks = <0x3 0x38 0x3 0x54>;
                        clock-names = "apb", "mod";
                        dmas = <0x13 0x3 0x13 0x3>;
                        resets = <0x3 0x2b>;
                        dma-names = "rx", "tx";
                        status = "okay";
                        phandle = <0x4e>;
                };


----------------------------------------------------------------------------------------------------------------------------------
CONVERT (BACK) dts to dtb (on NanoPi Neo)
----------------------------------------------------------------------------------------------------------------------------------

dtc -I dts -O dtb /boot/dtb/sun8i-h3-nanopi-neo.dts -o /boot/dtb/sun8i-h3-nanopi-neo.dtb_I2S_okay

 

----------------------------------------------------------------------------------------------------------------------------------
COPY new dtb over dtb (on NanoPi Neo)
----------------------------------------------------------------------------------------------------------------------------------

cp /boot/dtb/sun8i-h3-nanopi-neo.dtb_I2S_okay /boot/dtb/sun8i-h3-nanopi-neo.dtb
                
----------------------------------------------------------------------------------------------------------------------------------
COPY sun8i-h3-I2S-out.dts to home (working directory on NanoPi Neo)
----------------------------------------------------------------------------------------------------------------------------------

copy sun8i-h3-I2S-out.dts -->  /home/guido/

 

----------------------------------------------------------------------------------------------------------------------------------
armbian-add-overlay (on NanoPi Neo)

does only work if you got the kernel-headers installed for your actual kernel-version

(at this time the lastest kernel-header are (via armbian-config -> Software -> Install Headers)

Linux kernel headers for 4.14.84-sunxi on armhf - so NOT for kernel 4.19.y)
----------------------------------------------------------------------------------------------------------------------------------

root@npi-neo(192.168.6.24):/home/guido# armbian-add-overlay ./sun8i-h3-I2S-out.dts
Compiling the overlay
Copying the compiled overlay file to /boot/overlay-user/
Reboot is required to apply the changes


----------------------------------------------------------------------------------------------------------------------------------
dtbo is created (on NanoPi Neo)
----------------------------------------------------------------------------------------------------------------------------------

root@npi-neo(192.168.6.24):/home/guido# ls -l /boot/overlay-user/
insgesamt 4
-rw-r--r-- 1 root root 1323 Dez  7 19:34 sun8i-h3-I2S-out.dtbo

 

----------------------------------------------------------------------------------------------------------------------------------
user-overlay is created in /boot/armbianEnv.txt (on NanoPi Neo)
----------------------------------------------------------------------------------------------------------------------------------

verbosity=1
logo=disabled
console=both
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
overlays=usbhost1 usbhost2
rootdev=UUID=33ca90d6-130b-4d5f-a8f4-95b3b97ef5c0
rootfstype=ext4
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u
user_overlays=sun8i-h3-I2S-out

 

----------------------------------------------------------------------------------------------------------------------------------
now REBOOT (on NanoPi Neo)

----------------------------------------------------------------------------------------------------------------------------------

root@npi-neo(192.168.6.24):~# lsmod|grep i2s

sun4i_i2s              16384  0
snd_soc_core          118784  2 sun4i_i2s,sun8i_codec_analog
snd_pcm                69632  3 sun4i_i2s,snd_pcm_dmaengine,snd_soc_core
 

----------------------------------------------------------------------------------------------------------------------------------
EDIT config-default.conf (on armbian-BuildSystem)
----------------------------------------------------------------------------------------------------------------------------------

cd /home/guido/build
nano ./config-default.conf

replace content /home/guido/build/config-default.conf with attached
config-default.conf_nanopineo

./compile

-> With this conf, script compilation will stop to overwrite kernel source to build patch
-> At that time, overwrite original Kconfig with the one you modified above

(at "Make changes to U-Boot" press ENTER to proceed)

wait for
"Make your changes to /home/guido/build/cache/sources/linux-mainline/linux-4.14.y then press ENTER"
BUT DONT PRESS ENTER YET

 

----------------------------------------------------------------------------------------------------------------------------------
EDIT/SAVE Kconfig in a 2nd shell-Window (on armbian-BuildSystem)
----------------------------------------------------------------------------------------------------------------------------------

nano /home/guido/build/cache/sources/linux-mainline/linux-4.14.y/sound/soc/codecs/Kconfig

 

the part FROM
 

config SND_SOC_PCM5102A
    tristate

TO
 

config SND_SOC_PCM5102A
    tristate "Texas Instruments PCM5102A CODEC - I2S"

 

----------------------------------------------------------------------------------------------------------------------------------
NOW PRESS ENTER in the 1st shell-Windows (.compile.sh) (on armbian-BuildSystem)

----------------------------------------------------------------------------------------------------------------------------------

-> Then script compilation will stop again to ask whether you want to add pcm5102a to compile
-> Default is N, so you need to enter m for module compilation

After compile is complete
 

----------------------------------------------------------------------------------------------------------------------------------
copy (via SCP/FTP?) the .deb's from /home/guido/build/output/debs (on armbian-BuildSystem) 
to /home/guido/ (on the NanoPi Neo)

----------------------------------------------------------------------------------------------------------------------------------

 

----------------------------------------------------------------------------------------------------------------------------------
INSTALL the .deb's (here only header and image - because it was already 5.67 (on NanoPi Neo)
----------------------------------------------------------------------------------------------------------------------------------

cd /home/guido 
dpkg -i ./linux-headers-next-sunxi_5.67_armhf.deb
dpkg -i ./linux-image-next-sunxi_5.67_armhf.deb
(image did include the .ko module for the pcm5102a)

 

----------------------------------------------------------------------------------------------------------------------------------

now REBOOT (on NanoPi Neo)
----------------------------------------------------------------------------------------------------------------------------------

 

=====================================================================================
=====================================================================================

!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ATTENTION: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
After reboot my NanoPi Neo show the following armbian-version:
ARMBIAN 5.65 stable Debian GNU/Linux 9 (stretch) 4.14.84-sunxi
and 2 upgrades for headers&image (without the PCM5102A support)

please keep in mind to freeze the kernel-updates in armbian-config
for not to loose the support (module) for the PCM5120A!
armbian-config -> system -> Freeze Disable kernel upgrades
=====================================================================================
=====================================================================================


----------------------------------------------------------------------------------------------------------------------------------
BE HAPPY about a successful i2s mapping in dmesg (on NanoPi Neo)
----------------------------------------------------------------------------------------------------------------------------------

root@npi-neo(192.168.6.24):~# dmesg|grep -i i2s
[    6.911751] asoc-simple-card sound_i2s: pcm5102a-hifi <-> 1c22000.i2s mapping ok

 

----------------------------------------------------------------------------------------------------------------------------------
I enabled also ananlog-Codec (on NanoPi Neo)
----------------------------------------------------------------------------------------------------------------------------------

root@npi-neo(192.168.6.24):/home/guido# aplay -l
**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 0: Codec [H3 Audio Codec], Gerät 0: CDC PCM Codec-0 []
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0
Karte 1: I2Smaster [I2S-master], Gerät 0: 1c22000.i2s-pcm5102a-hifi pcm5102a-hifi-0 []
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0


----------------------------------------------------------------------------------------------------------------------------------
/etc/asound.conf (on NanoPi Neo) - later I2S did switch automatically to card 0 :(
----------------------------------------------------------------------------------------------------------------------------------

 

pcm.!default {
    type hw
    card 1
    device 0
}

ctl.!default {
    type hw
    card 1
}


 

----------------------------------------------------------------------------------------------------------------------------------
Reference-Threads
----------------------------------------------------------------------------------------------------------------------------------

 

config-default.conf.mod_nanopineo

sun8i-h3-I2S-out.dts

Share this post


Link to post
Share on other sites

Yesterday I did read on twitter about a new 4.19.y armbian for the Neo - so I did try that with my PCM5102A-Hat:
 

Quote

Added polished, minimal and top performant #Bionic or #Stretch based images with optimised @linuxfoundation K4.19.y, @armbian hardware configurator and @armbian software installer for @AllwinnerTech #H3 powered #nanopineo https://www.armbian.com/nanopi-neo

 

I did try it like in my instructions above in this thread, but failed (again) with the armbian-add-overlay part.

armbian-add-overlay told me that it cant compile a overlay-dts.

I did found the information that this is because of the missing kernel-headers - the older dtc did told this "secret".

 

OK - I did try to install the kernel-headers via armbian-config -> software, BUT this will not install the kernel-headers for the current kernel-version :(

It will only install the latest available as kernel-header-package.

 

Latest available was 4.14.87 and I did use the new "next" 4.19

 

So I had to use at first the armbian-build-system to create the following .deb's for me :
 

-rw-r--r-- 1 root root   173380 Jan 11 21:43 linux-dtb-next-sunxi_5.70_armhf.deb
-rw-r--r-- 1 root root 10608812 Jan 11 21:43 linux-headers-next-sunxi_5.70_armhf.deb
-rw-r--r-- 1 root root 19933808 Jan 11 21:43 linux-image-next-sunxi_5.70_armhf.deb
-rw-r--r-- 1 root root   171212 Jan 11 20:39 linux-u-boot-next-nanopineo_5.70_armhf.deb

While editing the Kconfig file I did see the name/path has changed

from 

/home/guido/build/cache/sources/linux-mainline/linux-4.14.y/sound/soc/codecs/Kconfig

to 

/home/guido/build/cache/sources/linux-mainline/orange-pi-4.19/sound/soc/codecs/Kconfig

but there was nothing to change because it was already

( @dony71 did you also see that there isnt to change anything? I am not sure about the menu-driven screen after selecting m for Module,
  but it did work and create the module)

config SND_SOC_PCM5102A
    tristate "Texas Instruments PCM5102A CODEC - I2S"

 

After installing the .deb's I hadnt no problem anymore with armbian-add-overlay - because now I had the right kernel-headers for my kernel :)

 

Later I converted the .dtb to .dts, edited the .dts and converted it back to .dtb

 

Now the PCM5102A-Hat is running under

ARMBIAN 5.69 stable Debian GNU/Linux 9 (stretch) 4.19.13-sunxi

Linux npi-neo 4.19.13-sunxi #5.70 SMP Fri Jan 11 21:40:58 +03 2019 armv7l GNU/Linux

 

dmesg|grep -i i2s
 

[    8.524723] asoc-simple-card sound_i2s: pcm5102a-hifi <-> 1c22000.i2s mapping ok

aplay -l
 

**** List of PLAYBACK Hardware Devices ****
card 0: Codec [H3 Audio Codec], device 0: CDC PCM Codec-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: I2Smaster [I2S-master], device 0: 1c22000.i2s-pcm5102a-hifi pcm5102a-hifi-0 []
  Subdevices: 0/1
  Subdevice #0: subdevice #0


FOR SURE: I did freeze the kernel/updates in armbian-config to keep my PCM5102A working after updating in the future ;)

 

Share this post


Link to post
Share on other sites

Awesome!  I was reminded on my site that not only is my writeup for the 3.x kernel, but I also have older revision boards than current.  :lol:

Share this post


Link to post
Share on other sites
0