持续记录-菜鸟I2S驱动开发

昨天刚拿到RK3288-Reload的开发板,今天正好有时间就来折腾下。
目前的任务是:
以前做了一块FPGA的板子,能够与一块音频编解码的芯片通过I2S做到音频数据流的传输,现在的想法是直接用RK3288的板子来替换音频编码芯片,直接通过I2S总线进行录音。
总体计划:
因为对这个板子不太熟悉,预计一个星期时间,中间可能会遇到一些问题,希望大家多多指教,同时也希望这份记录能为后来人带来点参考。

目前已经给板子上电了,并且切换到了Ubuntu系统^_^

内核和版本都是板子自带的

mkbootimg 工具已经安装完成


获取内核源码和安装交叉编译工具链
直接git下,网速比较慢。

:lol折腾起来吧~

终于git下来完全了

下一步来安装Toolchain

现在有个疑问是:
我把耳机插在了phone孔上,怎么还是用HDMI的外音输出呢?
是不是要进了什么特别的设置?

牛头 发表于 2016-4-16 11:40
折腾起来吧~

:smiley:

不错,写一个系列的教程!


感觉es8323启动中间异常了,有没有firefly的开发过来看下~

xyh666168 发表于 2016-4-16 12:42
不错,写一个系列的教程!

教程谈不上,只是个记录,还希望各路大神过来指教

OK,继续安装Toolchain,我把下载下来的文件解压复制到了/opt/Firefly文件夹下面:Selection_119.png

现在添加进环境变量中:
vim ~/.bashrc

我比较喜欢这种方式添加环境变量
129行那个 $ARM_LINUX是以前玩其他开发板的时候添加的,可以省略
再执行下 source ~/.bashrc 让环境变量生效
设置好后的效果如下:

说明安装成功了

继续来编译内核
现在内核根目录执行下make firefly-rk3288-linux_defconfig

看下默认的配置,如下:

看到使用的是ALSA音频系统,SoC的音频支持已经加入了ESP8323的支持
比较疑惑的是,在ES8323的下面,还有一个ES8323 for PCM modem,
不知道什么意思,求指教!
还有昨天耳机插上不能用,最后查出来ES8323驱动加载正常,只是和HDMI的声音有冲突。
插上HDMI线时,默认使用HDMI播放声音,再插入耳机,耳机也就没有反应了。
这个应该是个bug吧~
怎么见不到开发的人,不来论坛交流嘛(⊙_⊙)?

编译:
masong@hydra:~/Coding/learnUbuntu/firefly-rk3288-kernel$ make ARCH=arm CROSS_COMPILE=arm-eabi- -j8 firefly-rk3288.img

最后出现这样就说明编译成功了
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
Image: kernel.img is ready
Pack to resource.img successed!
Image: resource.img (with firefly-rk3288.dtb logo.bmp) is ready

你提出的es8323问题,我们会去跟进的。

你提出的es8323问题,我们会去跟进的。

moker 发表于 2016-4-16 12:57
感觉es8323启动中间异常了,有没有firefly的开发过来看下~

8323的驱动是android和ubuntu内核共用,create file失败是因为ubuntu没有/data目录,可以在probe中把路径改一下

zouxf 发表于 2016-4-18 09:59
ES8323 和 HDMI 是两个声卡,如果你要验证ES8323是否正常,可以使用aplay来播放wav文件测试。

可以验证es8323驱动是正常的,只是插上HDMI的线,会优先使用HDMI播放声音,当去除掉HDMI线时,耳机声音就正常了。

感觉音频es8323这块的问题好大
昨天查看的启动信息补全,完全的是这样的
root@firefly:~# dmesg |grep 8323
[ 1.190306] ES8323 2-0010: Error applying setting, reverse things back
[ 1.190606] es8323 probe i2c recv ok
[ 1.192087] es8323_probe
[ 1.192175] es8323_probe:register ISR (irq=194)
[ 1.825600] ES8323 2-0010: ASoC: no dapm match for LINPUT1 → NULL → Left Line Mux
[ 1.825623] ES8323 2-0010: ASoC: Failed to add route LINPUT1 → NULL → Left Line Mux
[ 1.825638] ES8323 2-0010: ASoC: no dapm match for LINPUT2 → NULL → Left Line Mux
[ 1.825652] ES8323 2-0010: ASoC: Failed to add route LINPUT2 → NULL → Left Line Mux
[ 1.825666] ES8323 2-0010: ASoC: no dapm match for Left PGA Mux → NULL → Left Line Mux
[ 1.825679] ES8323 2-0010: ASoC: Failed to add route Left PGA Mux → NULL → Left Line Mux
[ 1.825694] ES8323 2-0010: ASoC: no dapm match for RINPUT1 → NULL → Right Line Mux
[ 1.825706] ES8323 2-0010: ASoC: Failed to add route RINPUT1 → NULL → Right Line Mux
[ 1.825720] ES8323 2-0010: ASoC: no dapm match for RINPUT2 → NULL → Right Line Mux
[ 1.825733] ES8323 2-0010: ASoC: Failed to add route RINPUT2 → NULL → Right Line Mux
[ 1.825747] ES8323 2-0010: ASoC: no dapm match for Right PGA Mux → NULL → Right Line Mux
[ 1.825760] ES8323 2-0010: ASoC: Failed to add route Right PGA Mux → NULL → Right Line Mux
[ 1.825775] ES8323 2-0010: ASoC: no dapm match for LINPUT1 → LAMP → Left PGA Mux
[ 1.825787] ES8323 2-0010: ASoC: Failed to add route LINPUT1 → LAMP → Left PGA Mux
[ 1.825801] ES8323 2-0010: ASoC: no dapm match for LINPUT2 → LAMP → Left PGA Mux
[ 1.825814] ES8323 2-0010: ASoC: Failed to add route LINPUT2 → LAMP → Left PGA Mux
[ 1.825829] ES8323 2-0010: ASoC: no dapm match for Differential Mux → LAMP → Left PGA Mux
[ 1.825842] ES8323 2-0010: ASoC: Failed to add route Differential Mux → LAMP → Left PGA Mux
[ 1.825857] ES8323 2-0010: ASoC: no dapm match for RINPUT1 → RAMP → Right PGA Mux
[ 1.825870] ES8323 2-0010: ASoC: Failed to add route RINPUT1 → RAMP → Right PGA Mux
[ 1.825883] ES8323 2-0010: ASoC: no dapm match for RINPUT2 → RAMP → Right PGA Mux
[ 1.825897] ES8323 2-0010: ASoC: Failed to add route RINPUT2 → RAMP → Right PGA Mux
[ 1.825911] ES8323 2-0010: ASoC: no dapm match for Differential Mux → RAMP → Right PGA Mux
[ 1.825924] ES8323 2-0010: ASoC: Failed to add route Differential Mux → RAMP → Right PGA Mux
[ 1.825939] ES8323 2-0010: ASoC: no dapm match for LINPUT1 → LAMP → Differential Mux
[ 1.825952] ES8323 2-0010: ASoC: Failed to add route LINPUT1 → LAMP → Differential Mux
[ 1.825965] ES8323 2-0010: ASoC: no dapm match for RINPUT1 → RAMP → Differential Mux
[ 1.825978] ES8323 2-0010: ASoC: Failed to add route RINPUT1 → RAMP → Differential Mux
[ 1.825993] ES8323 2-0010: ASoC: no dapm match for LINPUT2 → LAMP → Differential Mux
[ 1.826005] ES8323 2-0010: ASoC: Failed to add route LINPUT2 → LAMP → Differential Mux
[ 1.826020] ES8323 2-0010: ASoC: no dapm match for RINPUT2 → RAMP → Differential Mux
[ 1.826032] ES8323 2-0010: ASoC: Failed to add route RINPUT2 → RAMP → Differential Mux
[ 1.826057] ES8323 2-0010: ASoC: no dapm match for LINPUT1 → LAMP → Left Line Mux
[ 1.826070] ES8323 2-0010: ASoC: Failed to add route LINPUT1 → LAMP → Left Line Mux
[ 1.826084] ES8323 2-0010: ASoC: no dapm match for LINPUT2 → LAMP → Left Line Mux
[ 1.826096] ES8323 2-0010: ASoC: Failed to add route LINPUT2 → LAMP → Left Line Mux
[ 1.826112] ES8323 2-0010: ASoC: no dapm match for Left PGA Mux → LAMP → Left Line Mux
[ 1.826124] ES8323 2-0010: ASoC: Failed to add route Left PGA Mux → LAMP → Left Line Mux
[ 1.826139] ES8323 2-0010: ASoC: no dapm match for RINPUT1 → RAMP → Right Line Mux
[ 1.826152] ES8323 2-0010: ASoC: Failed to add route RINPUT1 → RAMP → Right Line Mux
[ 1.826166] ES8323 2-0010: ASoC: no dapm match for RINPUT2 → RAMP → Right Line Mux
[ 1.826178] ES8323 2-0010: ASoC: Failed to add route RINPUT2 → RAMP → Right Line Mux
[ 1.826192] ES8323 2-0010: ASoC: no dapm match for Right PGA Mux → RAMP → Right Line Mux
[ 1.826204] ES8323 2-0010: ASoC: Failed to add route Right PGA Mux → RAMP → Right Line Mux
[ 1.826345] ES8323 2-0010: ASoC: mux Right Line Mux has no paths
[ 1.826360] ES8323 2-0010: ASoC: mux Left Line Mux has no paths
[ 1.826373] ES8323 2-0010: ASoC: mux Right PGA Mux has no paths
[ 1.826386] ES8323 2-0010: ASoC: mux Left PGA Mux has no paths
[ 1.826408] ES8323 2-0010: ASoC: mux Differential Mux has no paths
[ 1.832507] rockchip-es8323 rockchip-es8323.26: ES8323 HiFi ↔ ff890000.rockchip-i2s mapping ok
[ 2.364435] #0: RK_ES8323
[ 9.077320] es8323_create file error

写好的东西不能加载进去,直接使用阿sai的hello模块,使用insmod插入提示为:
root@firefly:~/Coding# insmod hello.ko
Segmentation fault

查看了下模块信息如下:
root@firefly:~/Coding# modinfo hello.ko
filename: /root/Coding/hello.ko
license: GPL
description: Firefly hello driver
author: sai <271319925@qq.com>
depends:
intree: Y
vermagic: 3.10.0 SMP preempt mod_unload ARMv7 p2v8

查看了下内核记录如下:
root@firefly:~/Coding# dmesg |grep Hello
[ 809.210801] Hello world 0
[ 810.195044] Hello world 1
[ 811.179216] Hello world 2
[ 812.163363] Hello world 3
[ 813.147510] Hello world 4
[ 814.131688] Hello world 5
[ 815.115862] Hello world 6
[ 816.100016] Hello world 7
[ 817.084153] Hello world 8
[ 818.068297] Hello world 9
[ 819.052436] Hello world 10
成功打印出来了。但是查看了下dmesg的信息,发现是这样的:
[ 809.210801] Hello world 0
[ 810.195044] Hello world 1
[ 811.179216] Hello world 2
[ 812.163363] Hello world 3
[ 813.147510] Hello world 4
[ 814.131688] Hello world 5
[ 815.115862] Hello world 6
[ 816.100016] Hello world 7
[ 817.084153] Hello world 8
[ 818.068297] Hello world 9
[ 819.052436] Hello world 10
[ 820.036660] Unable to handle kernel paging request at virtual address 0131d004
[ 820.043734] pgd = dccec000
[ 820.046331] [0131d004] *pgd=00000000
[ 820.049848] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
[ 820.055031] Modules linked in: hello
[ 820.058527] CPU: 1 PID: 1444 Comm: insmod Not tainted 3.10.0 #17
[ 820.064405] task: dccd1a40 ti: de8ec000 task.ti: de8ec000
[ 820.069752] PC is at module_put+0x38/0x10c
[ 820.073739] LR is at do_init_module+0xf4/0x168
[ 820.078054] pc : [] lr : [] psr: a0070013
[ 820.078054] sp : de8edf28 ip : 00000000 fp : 00000000
[ 820.089306] r10: 00000000 r9 : de8ec000 r8 : c0841a54
[ 820.094424] r7 : 0000017b r6 : b6ef8398 r5 : bf000094 r4 : bf000094
[ 820.100819] r3 : de8ec000 r2 : 00000004 r1 : 0131d000 r0 : bf000094
[ 820.107232] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 820.114209] Control: 10c5387d Table: 1ccec06a DAC: 00000015
[ 820.119843]
[ 820.119843] PC: 0xc0089630:
[ 820.124011] 9630 30d11003 33a03000 e3530000 1a000004 e1a01006 eb07b4ad e3500000 0a000007
[ 820.132028] 9650 ea000003 e3520000 0a000004 e1a01002 eb07be06 e5940000 e3e0500d eb01b187
[ 820.140044] 9670 e1a00005 e8bd8070 e92d41f0 e2505000 e1a0800e 08bd81f0 e1a0200d e3c23d7f
[ 820.148061] 9690 e3c3303f e5932004 e2822001 e5832004 f57ff05a e595216c ee1d1f90 e2822004
[ 820.156077] 96b0 e7910002 e2800001 e7810002 e59f20bc e5921018 e3510000 0a00001c e5931004
[ 820.164093] 96d0 e2811001 e5831004 e5926024 e3560000 0a00000c e2867008 e1a04006 e5943000
[ 820.172109] 96f0 e1a01005 e5940004 e1a02008 e2844008 e12fff33 e0663004 e0833007 e5133008
[ 820.180126] 9710 e3530000 1afffff4 e1a0200d e3c23d7f e3c3303f e5932004 e2422001 e5832004
[ 820.188146]
[ 820.188146] LR: 0xc08419d4:
[ 820.192320] 19d4 ebe121f7 e3a02000 e59f00d4 e3a01003 e1a03002 ea00002e 0a000006 e59f10c4
[ 820.200337] 19f4 e284200c e1a03005 e59f00bc e58d1000 ebfff9f3 eb0024a0 e3a01000 e1a02004
[ 820.208353] 1a14 e5841000 e59f0094 ebe065f3 e1a0200d e3c23d7f e3c3303f e593300c e593300c
[ 820.216370] 1a34 e3130901 0a000000 ebe06a49 e59f007c e3a05000 eb0060e9 e1a00004 ebe11f08
[ 820.224386] 1a54 e1a00004 ebe8df8b e594311c e59410c0 e1a00004 e5843118 e5943114 e5843110
[ 820.232402] 1a74 e5943124 e5843120 ebe121ca e59f003c e58450c0 e58450c8 e58450d8 e58450d0
[ 820.240419] 1a94 eb00603f e59f0018 e3a01003 e1a02005 e1a03005 ebe07404 e1a00005 e8bd807c
[ 820.248435] 1ab4 c0c1ff48 c0c1ff3c c0861c58 c0a4f9f4 c0c1ff24 e1a03000 e59f00d4 e92d40f0
[ 820.256455]
[ 820.256455] SP: 0xde8edea8:
[ 820.260630] dea8 fd640800 c05d39a8 de8edefc 00005dbf 00000006 00000000 c0d8d000 de8ec000
[ 820.268646] dec8 00000000 c00896b0 a0070013 ffffffff de8edf14 c000d598 bf000094 0131d000
[ 820.276663] dee8 00000004 de8ec000 bf000094 bf000094 b6ef8398 0000017b c0841a54 de8ec000
[ 820.284679] df08 00000000 00000000 00000000 de8edf28 c0841a54 c00896b0 a0070013 ffffffff
[ 820.292695] df28 bf000094 00000000 b6ef8398 0000017b c000db84 c0841a54 bf000094 00000000
[ 820.300711] df48 00000000 00000003 b6ef8398 c008b048 e1a31000 00000ca7 e1a314b4 e1a313a1
[ 820.308728] df68 e1a31ba4 000001fc 0000029c 00000000 00000000 00000000 00000017 00000018
[ 820.316744] df88 0000000f 00000000 0000000c 00000000 be9d3504 be9d3684 5f434600 c000da00
[ 820.324764]
[ 820.324764] R3: 0xde8ebf80:
[ 820.328939] bf80 de8ebf80 de8ebf80 00000000 00000000 de8ebf90 de8ebf90 de8ebfac de87bed0
[ 820.336956] bfa0 c0056070 00000000 00000000 c000da98 00000000 00000000 00000000 00000000
[ 820.344972] bfc0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 820.352988] bfe0 00000000 00000000 00000000 00000000 00000013 00000000 ffff5fff f8ffdffd
[ 820.361004] c000 00000000 00000002 00000000 dccd1a40 c0c1c178 00000001 00000015 dccd1a40
[ 820.369021] c020 c1f13cc0 de8ec000 c5b9f340 00000000 000000be de89c980 de8ede8c de8ede08
[ 820.377037] c040 c085aba4 00000000 00000000 00000000 00000000 00000000 01000000 00000000
[ 820.385054] c060 b6efe850 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 820.393070]
[ 820.393070] R8: 0xc08419d4:
[ 820.397249] 19d4 ebe121f7 e3a02000 e59f00d4 e3a01003 e1a03002 ea00002e 0a000006 e59f10c4
[ 820.405265] 19f4 e284200c e1a03005 e59f00bc e58d1000 ebfff9f3 eb0024a0 e3a01000 e1a02004
[ 820.413281] 1a14 e5841000 e59f0094 ebe065f3 e1a0200d e3c23d7f e3c3303f e593300c e593300c
[ 820.421297] 1a34 e3130901 0a000000 ebe06a49 e59f007c e3a05000 eb0060e9 e1a00004 ebe11f08
[ 820.429314] 1a54 e1a00004 ebe8df8b e594311c e59410c0 e1a00004 e5843118 e5943114 e5843110
[ 820.437330] 1a74 e5943124 e5843120 ebe121ca e59f003c e58450c0 e58450c8 e58450d8 e58450d0
[ 820.445347] 1a94 eb00603f e59f0018 e3a01003 e1a02005 e1a03005 ebe07404 e1a00005 e8bd807c
[ 820.453363] 1ab4 c0c1ff48 c0c1ff3c c0861c58 c0a4f9f4 c0c1ff24 e1a03000 e59f00d4 e92d40f0
[ 820.461380]
[ 820.461380] R9: 0xde8ebf80:
[ 820.465558] bf80 de8ebf80 de8ebf80 00000000 00000000 de8ebf90 de8ebf90 de8ebfac de87bed0
[ 820.473574] bfa0 c0056070 00000000 00000000 c000da98 00000000 00000000 00000000 00000000
[ 820.481590] bfc0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 820.489607] bfe0 00000000 00000000 00000000 00000000 00000013 00000000 ffff5fff f8ffdffd
[ 820.497623] c000 00000000 00000002 00000000 dccd1a40 c0c1c178 00000001 00000015 dccd1a40
[ 820.505639] c020 c1f13cc0 de8ec000 c5b9f340 00000000 000000be de89c980 de8ede8c de8ede08
[ 820.513656] c040 c085aba4 00000000 00000000 00000000 00000000 00000000 01000000 00000000
[ 820.521672] c060 b6efe850 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 820.529690] Process insmod (pid: 1444, stack limit = 0xde8ec238)
[ 820.535577] Stack: (0xde8edf28 to 0xde8ee000)
[ 820.539845] df20: bf000094 00000000 b6ef8398 0000017b c000db84 c0841a54
[ 820.547856] df40: bf000094 00000000 00000000 00000003 b6ef8398 c008b048 e1a31000 00000ca7
[ 820.555872] df60: e1a314b4 e1a313a1 e1a31ba4 000001fc 0000029c 00000000 00000000 00000000
[ 820.563888] df80: 00000017 00000018 0000000f 00000000 0000000c 00000000 be9d3504 be9d3684
[ 820.571905] dfa0: 5f434600 c000da00 be9d3504 be9d3684 00000003 b6ef8398 00000000 00000000
[ 820.579921] dfc0: be9d3504 be9d3684 5f434600 0000017b b6f04ea8 00000000 b6ef4b60 00000000
[ 820.587937] dfe0: be9d34b0 be9d34a0 b6eef177 b6e5f982 80070030 00000003 440a2930 72637365
[ 820.595993] [] (module_put+0x38/0x10c) from [] (do_init_module+0xf4/0x168)
[ 820.604427] [] (do_init_module+0xf4/0x168) from [] (SyS_finit_module+0x6c/0x94)
[ 820.613314] [] (SyS_finit_module+0x6c/0x94) from [] (ret_fast_syscall+0x0/0x30)
[ 820.622139] Code: f57ff05a e595216c ee1d1f90 e2822004 (e7910002)
[ 820.628152] —[ end trace a4f74d77999ba5be ]—

谁来帮我解释下,一个printk就快要把我给搞疯掉!!!

.ko你自己编译的吗?不要用现成的.ko,在自己的内核里编译出来。

牛头 发表于 2016-4-19 14:36
.ko你自己编译的吗?不要用现成的.ko,在自己的内核里编译出来。

ko是自己编译起来的,并且我也把编译好的kernel.img下载到开发板里面了