martinayotte Posted November 15, 2018 Share Posted November 15, 2018 12 hours ago, dony71 said: However it gives me error below .... what's wrong? did you ran "depmod -a" before "modprobe" ? Link to comment Share on other sites More sharing options...
dony71 Posted November 15, 2018 Share Posted November 15, 2018 5 hours ago, martinayotte said: did you ran "depmod -a" before "modprobe" ? after run "depmod -a", i got "modprobe: ERROR: could not insert 'snd_soc_pcm5102a': Exec format error" dmesg shows "snd_soc_pcm5102a: version magic '4.14.81-sunxi SMP mod_unload ARMv7 thumb2 p2v8 ' should be '4.14.78-sunxi SMP mod_unload ARMv7 thumb2 p2v8 '" so kernel different ... anybody knows how to build specific kernel 4.14.78 ? i'm using this guideline https://docs.armbian.com/Developer-Guide_Build-Preparation/ Link to comment Share on other sites More sharing options...
martinayotte Posted November 15, 2018 Share Posted November 15, 2018 8 minutes ago, dony71 said: snd_soc_pcm5102a: version magic Pretty normal ... kernel modules can only be loaded if it the same magic version of the current kernel. If you have built a new kernel, you need to install it too, not only copied the missing module... EDIT : If you built it using Armbian build process with "u-boot and kernel only" option, the resulting packages are located in output/debs path. You don't need to re-install u-boot, but install package with name like linux-image-next-sunxi_5.67_armhf.deb, copy it into your board and execute "dpkg -i linux-image-next-sunxi_5.67_armhf.deb", it will install newly built kernel+modules. Link to comment Share on other sites More sharing options...
dony71 Posted November 15, 2018 Share Posted November 15, 2018 6 minutes ago, martinayotte said: Pretty normal ... kernel modules can only be loaded if it the same magic version of the current kernel. If you have built a new kernel, you need to install it too, not only copied the missing module... EDIT : If you built it using Armbian build process with "u-boot and kernel only" option, the resulting packages are located in output/debs path. You don't need to re-install u-boot, but install package with name like linux-image-next-sunxi_5.67_armhf.deb, copy it into your board and execute "dpkg -i linux-image-next-sunxi_5.67_armhf.deb", it will install newly built kernel+modules. I already try installing linux-image-next-sunxi_5.67_armhf.deb and linux-dtb-next-sunxi_5.67_armhf.deb The result is black screen which means I need serial console to debug but I don't have it now Link to comment Share on other sites More sharing options...
martinayotte Posted November 15, 2018 Share Posted November 15, 2018 51 minutes ago, dony71 said: The result is black screen Do you mean that with 4.14.78 it was working but not with your freshly built 4.14.81 ? Are you sure you choose the right board in Armbian menu ? BTW, which one is it ? 53 minutes ago, dony71 said: I need serial console to debug but I don't have it now It is really a "must" tool for your toolbox ! Personally, I have more than 10 of those USB-TTL Serial dongle in my lab, they are really useful ... Link to comment Share on other sites More sharing options...
dony71 Posted November 15, 2018 Share Posted November 15, 2018 42 minutes ago, martinayotte said: Do you mean that with 4.14.78 it was working but not with your freshly built 4.14.81 ? Are you sure you choose the right board in Armbian menu ? BTW, which one is it ? It is really a "must" tool for your toolbox ! Personally, I have more than 10 of those USB-TTL Serial dongle in my lab, they are really useful ... download released image from armbian.com for banana-pi-m2-plus has kernel 4.14.78 but that kernel missing pcm5102a driver so i have to compile kernel module which will give freshly built 4.14.81 Link to comment Share on other sites More sharing options...
martinayotte Posted November 16, 2018 Share Posted November 16, 2018 4 hours ago, dony71 said: download released image from armbian.com for banana-pi-m2-plus has kernel 4.14.78 but that kernel missing pcm5102a driver so i have to compile kernel module which will give freshly built 4.14.81 Yes, but as mentioned in the other thread, it is kind of surprise that differences between those two kernel make your screen going blank ... I think you're in hurry to get some USB-TTL Serial dongle, buy more than one, you can find some merchant who offer them as bundle 5x for US$5 ... Link to comment Share on other sites More sharing options...
dony71 Posted November 16, 2018 Share Posted November 16, 2018 34 minutes ago, martinayotte said: Yes, but as mentioned in the other thread, it is kind of surprise that differences between those two kernel make your screen going blank ... I think you're in hurry to get some USB-TTL Serial dongle, buy more than one, you can find some merchant who offer them as bundle 5x for US$5 ... Well, I manage to compile pcm5102a for kernel 4.14.78 I wonder why armbian kernel never include this in Kconfig, so it show none in menuconfig I have to modify Kconfig on-the-fly during compilation, since .config will be overwritten at some point in compilation Implementing "CONFIG_SND_SOC_PCM5102A=m" in userpatches/linux-sunxi-next.config also doesn't work Link to comment Share on other sites More sharing options...
dony71 Posted November 16, 2018 Share Posted November 16, 2018 On 11/13/2017 at 10:24 AM, Christos said: Hi @Valery Rezvyakov Thank you for the hint, I understand that you use the pcm5102a codec which is the same as a dummy linux codec. Yet after I tried it, is again not showing up. The I2S0 is at i2s@01c22000 and that is not shown up in the dmesg although uboot DT is not complaining again with your modified overlay. Again the uboot DT is passing ok without error, dmesg is not showing I2S0 and aplay -l is not showing it I'm attaching the related dmesg. dmesg2.txt @Christos wondering what board are you using with this? I'm surprised that HDMI audio is working with mainline kernel on this allwinner platform? I have Banana-Pi-M2+ (Alllwinner H3) and HDMI audio is still problem according to @Igor Link to comment Share on other sites More sharing options...
dony71 Posted November 19, 2018 Share Posted November 19, 2018 On 11/15/2018 at 5:58 PM, dony71 said: Well, I manage to compile pcm5102a for kernel 4.14.78 I wonder why armbian kernel never include this in Kconfig, so it show none in menuconfig I have to modify Kconfig on-the-fly during compilation, since .config will be overwritten at some point in compilation Implementing "CONFIG_SND_SOC_PCM5102A=m" in userpatches/linux-sunxi-next.config also doesn't work I try to play some music mclk-fs = 128 in overlay and this will give default 96K sampling rate playing 96K music has no issue, but when i try playing 44.1K music, the music speed is double faster anybody knows what could be the problem? maybe some setting in pulseaudio? Link to comment Share on other sites More sharing options...
dony71 Posted November 21, 2018 Share Posted November 21, 2018 On 1/3/2018 at 3:01 AM, nikkov said: I checked your wip i2s driver code with my hardware and simple codec driver for my clock board. In function sun4i_i2s_set_clk_rate calculates lrck value as (clk_rate / rate / oversample_rate)*word_size and we have, eg (22579200 / 44100 / 128) * 16 = 64 of BCLKs within each channel. But in stereo i2s mode lrck value must be equal slot width. In stable version lrck fixed and equal 32. After I replace calculated value lrck to fixed 32 I successfully played 16/24 bit sample. @nikkov I follow codekipper patch https://github.com/codekipper/linux-sunxi/commit/547fb172c31b4c02d1201004056228b3b553896c but after compile and use new sun4i_i2s.ko, i got this error ... anything that i'm missing? aplay -vDhw:0,0 -c 2 --format=S24_LE --rate=192000 paradise.flac Playing raw data 'paradise.flac' : Signed 24 bit Little Endian, Rate 192000 Hz, Stereo aplay: set_params:1299: Sample format non available Available formats: - S16_LE Link to comment Share on other sites More sharing options...
dony71 Posted November 21, 2018 Share Posted November 21, 2018 1 hour ago, dony71 said: @nikkov I follow codekipper patch https://github.com/codekipper/linux-sunxi/commit/547fb172c31b4c02d1201004056228b3b553896c but after compile and use new sun4i_i2s.ko, i got this error ... anything that i'm missing? aplay -vDhw:0,0 -c 2 --format=S24_LE --rate=192000 paradise.flac Playing raw data 'paradise.flac' : Signed 24 bit Little Endian, Rate 192000 Hz, Stereo aplay: set_params:1299: Sample format non available Available formats: - S16_LE after checking, it seems i didn't implement fully patch from my kernel 4.14.78 manage to get it working after applied full source at https://github.com/codekipper/linux-sunxi/blob/sunxi-wip/sound/soc/sunxi/sun4i-i2s.c however now i have problem playing 96K 24-bit music ... any idea? dmesg says [ 409.077119] COOPS sun4i_i2s_hw_params channels is 2, physical width is 32, rate is 96000, period size is 8192 [ 409.079325] sun4i_i2s_oversample_is_valid COOPS i0 is 128 looking for 256 [ 409.079341] sun4i_i2s_oversample_is_valid COOPS i1 is 192 looking for 256 [ 409.079356] sun4i_i2s_oversample_is_valid COOPS i2 is 256 looking for 256 [ 409.079376] sun4i_i2s_get_bclk_div COOPS word size 24 oversample_rate 256 mclk is 24576000 [ 409.079389] sun4i_i2s_get_bclk_div COOPS bdiv 0 div is 5 [ 409.079402] sun4i_i2s_get_bclk_div COOPS bdiv 1 div is 5 [ 409.079415] sun4i_i2s_get_bclk_div COOPS bdiv 2 div is 5 [ 409.079428] sun4i_i2s_get_bclk_div COOPS bdiv 4 div is 5 [ 409.079440] sun4i_i2s_get_bclk_div COOPS bdiv 6 div is 5 [ 409.079453] sun4i_i2s_get_bclk_div COOPS bdiv 8 div is 5 [ 409.079467] sun4i_i2s_get_bclk_div COOPS bdiv 12 div is 5 [ 409.079480] sun4i_i2s_get_bclk_div COOPS bdiv 16 div is 5 [ 409.079493] sun4i_i2s_get_bclk_div COOPS bdiv 24 div is 5 [ 409.079506] sun4i_i2s_get_bclk_div COOPS bdiv 32 div is 5 [ 409.079519] sun4i_i2s_get_bclk_div COOPS bdiv 48 div is 5 [ 409.079532] sun4i_i2s_get_bclk_div COOPS bdiv 64 div is 5 [ 409.079546] sun4i_i2s_get_bclk_div COOPS bdiv 96 div is 5 [ 409.079559] sun4i_i2s_get_bclk_div COOPS bdiv 128 div is 5 [ 409.079572] sun4i_i2s_get_bclk_div COOPS bdiv 176 div is 5 [ 409.079586] sun4i_i2s_get_bclk_div COOPS bdiv 192 div is 5 [ 409.079621] sun4i-i2s 1c22000.i2s: Unsupported BCLK divider: -22 [ 409.079647] sun4i-i2s 1c22000.i2s: ASoC: can't set 1c22000.i2s hw params: -22 Link to comment Share on other sites More sharing options...
codekipper Posted November 21, 2018 Share Posted November 21, 2018 4 hours ago, dony71 said: [ 409.079621] sun4i-i2s 1c22000.i2s: Unsupported BCLK divider: -22 [ 409.079647] sun4i-i2s 1c22000.i2s: ASoC: can't set 1c22000.i2s hw params: -22 This is not possible with your setup, based on the information in the A20 i2s documentation. From what I remember when I worked with the PCM5102A then I needed to provide a 32bit sample(this has also been seen with the HDMI audio), do you have these tdm settings in your dts/overlay? https://github.com/codekipper/linux-sunxi/commit/977b5838a184350fa8e794420a947d31d81c2e54#diff-9fb7f343370c25c84e919e9a8e392b74R200 Link to comment Share on other sites More sharing options...
dony71 Posted November 21, 2018 Share Posted November 21, 2018 41 minutes ago, codekipper said: This is not possible with your setup, based on the information in the A20 i2s documentation. From what I remember when I worked with the PCM5102A then I needed to provide a 32bit sample(this has also been seen with the HDMI audio), do you have these tdm settings in your dts/overlay? https://github.com/codekipper/linux-sunxi/commit/977b5838a184350fa8e794420a947d31d81c2e54#diff-9fb7f343370c25c84e919e9a8e392b74R200 that's the problem !! thank you @codekipper Link to comment Share on other sites More sharing options...
cibernuts Posted December 2, 2018 Share Posted December 2, 2018 Hi guys, I'm trying to connect an Adafruit SPH0645 I2S microphone to a nanopi neo air board. I am new to this and I don't know how to do it. I wanted to know if someone managed to make a tutorial or something on what I have to do to have this working. What are the steps to follow in order to get this mic working on this board? Thanks a lot! Link to comment Share on other sites More sharing options...
felipeduque Posted December 20, 2018 Share Posted December 20, 2018 Hi, @cibernuts. I was struggling to make the same mic (SPH0645 I2S) to work with H3 mainline kernel (4.14.87), on NanoPi Neo Core. After weeks of distress, I finally made it work! Here's what I did: 1- In file sound/soc/sunxi/sun4i-i2s.c, change the following line { SUN8I_I2S_RX_CHAN_SEL_REG, 0x00000000 } to { SUN8I_I2S_RX_CHAN_SEL_REG, 0x00001000 } You may have to download the linux-source package for your kernel version, or you can build your own kernel. I'm not sure if this register can be accessed through an overlay. I tried my best but could not find a way to do it. Please, someone let me know if it's possible to do that, so we can avoid the driver compiling stuff. 2- Compile, generate and load the new sun4i-i2s.ko module. 3- Create a .dts file, sph0645-overlay.dts with the following contents: Spoiler /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target-path = "/"; __overlay__ { adau7002_codec: adau7002_codec { #sound-dai-cells = <0>; compatible = "adi,adau7002"; status = "okay"; }; }; }; fragment@1 { target = <&i2s0>; __overlay__ { status = "okay"; pinctrl-0 = <&i2s0_pins>; sound-dai = <&adau7002_codec>; pinctrl-names = "default"; }; }; fragment@2 { target-path = "/"; __overlay__ { sound_i2s { compatible = "simple-audio-card"; simple-audio-card,format = "i2s"; simple-audio-card,name = "adau7002"; simple-audio-card,bitclock-slave = <&dailink0_slave>; simple-audio-card,frame-slave = <&dailink0_slave>; simple-audio-card,mclk-fs = <512>; simple-audio-card,widgets = "Microphone", "Microphone Jack"; simple-audio-card,routing = "PDM_DAT", "Microphone Jack"; status = "okay"; simple-audio-card,cpu { sound-dai = <&i2s0>; }; dailink0_slave: simple-audio-card,codec { sound-dai = <&adau7002_codec>; }; }; }; }; }; It's almost the same as the one @Valery Rezvyakov showed earlier in this same thread. The only difference is the line with simple-audio-card,mclk-fs = <512>; 4- Compile and add the .dts file. 5- Reboot and test with arecord -f S16_LE -c 2 -r 48000 -D hw:0,0 -v >test.wav Please let me know if it works for you. Maybe I have forgotten something. Link to comment Share on other sites More sharing options...
codekipper Posted December 20, 2018 Share Posted December 20, 2018 I've got this fix in my stack for mainline but I don't think I'll have a chance to push them before the New Year https://github.com/codekipper/linux-sunxi/commit/67d47db0499e08a985fe8fbb2517f26c52e10476 I've not really tested much with capture so I've been a bit reluctant to push. Hopefully New Year and a new attitude to sharing! CK 1 hour ago, felipeduque said: Hi, @cibernuts. I was struggling to make the same mic (SPH0645 I2S) to work with H3 mainline kernel (4.14.87), on NanoPi Neo Core. After weeks of distress, I finally made it work! Here's what I did: 1- In file sound/soc/sunxi/sun4i-i2s.c, change the following line { SUN8I_I2S_RX_CHAN_SEL_REG, 0x00000000 } to { SUN8I_I2S_RX_CHAN_SEL_REG, 0x00001000 } You may have to download the linux-source package for your kernel version, or you can build your own kernel. I'm not sure if this register can be accessed through an overlay. I tried my best but could not find a way to do it. Please, someone let me know if it's possible to do that, so we can avoid the driver compiling stuff. 2- Compile, generate and load the new sun4i-i2s.ko module. 3- Create a .dts file, sph0645-overlay.dts with the following contents: Reveal hidden contents /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target-path = "/"; __overlay__ { adau7002_codec: adau7002_codec { #sound-dai-cells = <0>; compatible = "adi,adau7002"; status = "okay"; }; }; }; fragment@1 { target = <&i2s0>; __overlay__ { status = "okay"; pinctrl-0 = <&i2s0_pins>; sound-dai = <&adau7002_codec>; pinctrl-names = "default"; }; }; fragment@2 { target-path = "/"; __overlay__ { sound_i2s { compatible = "simple-audio-card"; simple-audio-card,format = "i2s"; simple-audio-card,name = "adau7002"; simple-audio-card,bitclock-slave = <&dailink0_slave>; simple-audio-card,frame-slave = <&dailink0_slave>; simple-audio-card,mclk-fs = <512>; simple-audio-card,widgets = "Microphone", "Microphone Jack"; simple-audio-card,routing = "PDM_DAT", "Microphone Jack"; status = "okay"; simple-audio-card,cpu { sound-dai = <&i2s0>; }; dailink0_slave: simple-audio-card,codec { sound-dai = <&adau7002_codec>; }; }; }; }; }; It's almost the same as the one @Valery Rezvyakov showed earlier in this same thread. The only difference is the line with simple-audio-card,mclk-fs = <512>; 4- Compile and add the .dts file. 5- Reboot and test with arecord -f S16_LE -c 2 -r 48000 -D hw:0,0 -v >test.wav Please let me know if it works for you. Maybe I have forgotten something. Link to comment Share on other sites More sharing options...
cibernuts Posted December 26, 2018 Share Posted December 26, 2018 On 12/20/2018 at 9:33 PM, codekipper said: Thanks a lot Felipe, you are the best! I will try and tell you how it went! Link to comment Share on other sites More sharing options...
starsail0r Posted September 16, 2020 Share Posted September 16, 2020 is there an off the shelf recipe for this so far without compiling kernel? can anyone upload a mainline image with i2s support? Link to comment Share on other sites More sharing options...
Recommended Posts