Linux驱动开发环境搭建
1,ubuntu中配置编译环境
设置交叉工具链:
tar -xvf gcc-4.6.4.tar.xz -C ~/Linux_4412/toolchain
设置环境变量:
vim ~/.bashrc 最后面添加
export PATH=$PATH:/home/george/Linux_4412/toolchain/gcc-4.6.4/bin
更新脚本:
source ~/.bashrc
arm-none-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/home/george/Linux_4412/toolchain/gcc-4.6.4/bin/
../libexec/gcc/arm-arm1176jzfssf-linux-gnueabi/4.6.4/lto-wrapper
2,运行开发
a,通过tftp去启动内核
1,将uImage和dtb文件放入到ubuntu中/tftpboot
2,在开发板中设置uboot参数,使其能够去加载内核
set ipaddr 192.168.7.22
set serverip 192.168.7.21
set bootcmd tftp 0x41000000 uImage \; tftp 0x42000000 exynos4412-fs4412.dtb \; bootm 0x41000000 - 0x42000000
save
b,通过nfs去挂载rootfs
1,需要一个跟文件系统目录--rootfs.tar.xz,需要解压到ubuntu
sudo tar -xvf rootfs.tar.xz -C /opt/4412/
2, 配置nfs服务器(需要安装),让/opt/4412/rootfs可以被挂载
sudo vim /etc/exports
/opt/4412/rootfs *(subtree_check,rw,no_root_squash,async)
sudo service nfs-kernel-server restart //重启nfs服务器
测试:
sudo mount -t nfs localhost:/opt/4412/rootfs /mnt
3,在开发中去指定内核要挂载/opt/4412/rootfs--切换到开发操作
set bootargs console=ttySAC2,115200 init=/linuxrc root=/dev/nfs rw nfsroot=192.168.7.21:/opt/4412/rootfs ip=192.168.7.22
save
解释:
bootargs 是uboot传递给内核到启动参数,是一个字符串
console=xxx: 告诉内核启动时候到调试信息是从哪个设备输出
init=xxx: 告诉内核linux到第一个用户进程是什么
root=xxx : 告诉内核根文件系统在哪里
root=/dev/nfs 表示根文件系统在网路远端
nfsroot=ip:path
ip=xxx :告诉内核开机的时候内核的ip地址是多少(静态分配ip)
3,可以开始去编写代码--开发驱动
a, 编译内核
tar -xvf linux-3.14.tar.xz
&n