让NanoPi2支持USB声卡

首先必须修改内核,因为目前官方默认的内核是不带USB声卡驱动的。修改内核就必须先编译uboot中的mkimage。所以先编译mkimage:

1
2
3
4
5
6
7
sudo apt-get install git
git clone https://github.com/friendlyarm/uboot_nanopi2.git
cd uboot_nanopi2
git checkout nanopi2-lollipop-mr1
make CROSS_COMPILE=arm-linux- tools
sudo mkdir -p /usr/local/sbin && sudo cp -v tools/mkimage /usr/local/sbin

然后下载内核源码并开始配置:

1
2
3
4
5
git clone https://github.com/friendlyarm/linux-3.4.y.git
cd linux-3.4.y
git checkout nanopi2-lollipop-mr1
make nanopi2_linux_defconfig
make menuconfig
我们需要在Device Drivers > Sound card support > Advanced Linux Sound Architecture > USB sound devices中选择,我不知道我的设备是什么,所以我全选了。
1
2
3
4
Device Drivers -->
Sound card support -->
Advanced Linux Sound Architecture -->
USB sound devices

然后保存配置,编译uImage:

1
2
touch .scmversion
make uImage
然后将此内核传到NanoPi2上,并覆盖原来的内核(下面的代码仅供参考):
1
scp /home/ypw/Desktop/linux-3.4.y/arch/arm/boot/uImage root@192.168.2.22:/media/fa/boot2/uImage.hdmi
当然,使用读卡器直接覆盖也是可以的。

注意:此处由于我并没有接LCD,所以我直接覆盖的hdmi内核,需要接LCD的话,还需要这样修改内核:

1
2
3
4
5
6
make menuconfig
Device Drivers -->
Graphics support -->
Nexell Graphics -->
[*] LCD
[ ] HDMI
内核装好了之后,我们上传一个音乐文件到NanoPi2上,然后使用mplayer播放:
1
2
3
scp /Users/ypw/Desktop/周杰伦\ -\ 青花瓷.mp3 root@192.168.2.22:/home/fa/Desktop/qinghuaci.mp3
ssh root@192.168.2.22
mplayer /home/fa/Desktop/qinghuaci.mp3

当然,也可以在vnc中播放音乐