《5.linux驱动开发-第2部分-5.2.字符设备驱动基础》5.2.5.用开发板来调试模块

1.  首先 开发板 可以运行 Uboot

2. Ubuntu 安装好了 t f t p(启动内核zImage)  和   NFS (挂载 根文件系统)

3. 提前 制作好了 根文件系统(2022年做的,早就忘记 怎么做了)

4.内核 需要设置 nfs 作为根文件系统 启动 (内核下 make menuconfig)

 更改 Makefile !  这个 Makefile 是最终的运行效果

KERN_DIR = /root/driver/kernel  我们编译的 内核 x210 路径

cp *.ko /root/rootfs/rootfs/driver_test 

这个是把 我们在 ubuntu下编译好的module_test.o 放到 我们提前制作好的 根文件系统的目录下

根文件系统 路径:/root/rootfs/rootfs/driver_test 

#ubuntu的内核源码树,如果要编译在ubuntu中安装的模块就打开这2个
#KERN_VER = $(shell uname -r)
#KERN_DIR = /lib/modules/$(KERN_VER)/build	

		
# 开发板的linux内核的源码树目录  
KERN_DIR = /root/driver/kernel

obj-m	+= module_test.o

all:
	make -C $(KERN_DIR) M=`pwd` modules 

cp:
	cp *.ko /root/rootfs/rootfs/driver_test 

.PHONY: clean	
clean:
	make -C $(KERN_DIR) M=`pwd` modules clean
	

5.2.5.用开发板来调试模块
5.2.5.1、设置bootcmd使开发板通过tftp下载自己建立的内核源码树编译得到的zImage
set bootcmd 'tftp 0x30008000 zImage;bootm 0x30008000'

1.  ubuntu网络配置
 

 

 

 把 开发板 的 网线 插到了 路由器上,没有 做其他的更改,tftp 启动内核成功

2. 在 ubooot 环境下 更改 如下 配置

set serverip 192.168.1.100  这个是ubuntu 下的服务器IP
set gatewayip 192.168.1.1  
set netmask 255.255.255.0

从 tftp 启动内核
set bootcmd 'tftp 0x30008000 zImage;bootm 0x30008000'

x210 # print
mtdpart=80000 400000 3000000
bootdelay=3
baudrate=115200
ethaddr=00:40:5c:26:0a:5b
ipaddr=192.168.1.20
bootargs=console=ttySAC2,115200 root=/dev/mmcblk0p2 rw init=/linuxrc rootfstype=ext2
serverip=192.168.1.100
gatewayip=192.168.1.1
netmask=255.255.255.0
bootcmd=tftp 0x30008000 zImage;bootm 0x30008000



4.1、配置网络部分,主要是使能CONFIG_IP_PNP以在2中能够看到Root file system on NFS选项
内核  make menuconfig
Networking support 
	Networking options 
		TCP/IP networking
				IP: kernel level autoconfiguration
					[*] IP: DHCP support
					[*] IP: BOOTP support
					
2、配置开启nfs服务
File systems  --->	
	Network File Systems  --->
		<*> NFS client support 
		[*] NFS client support for NFS version 3                                  [*] NFS client support for the NFSv3 ACL protocol extension 
		[*] NFS client support for NFS version 4 (EXPERIMENTAL) 
		[*] NFS client support for NFSv4.1 (DEVELOPER ONLY) 
		[*] Root file system on NFS  



5. 设置bootargs使开发板从nfs去挂载rootfs(内核配置记得打开使能nfs形式的rootfs)
setenv bootargs root=/dev/nfs nfsroot=192.168.1.100:/root/rootfs/rootfs ip=192.168.1.20:192.168.1.100:192.168.1.1:255.255.255.0::eth0:off  init=/linuxrc console=ttySAC2,115200 

root=/dev/nfs 从 nfs 挂载文件系统

nfsroot=192.168.1.100 这个 IP 是我们 Ubuntu的IP (ifconfig)

/root/rootfs/rootfs  文件系统的 路径 

ip=192.168.1.20:192.168.1.100:192.168.1.1:255.255.255.0  开发板 IP

init=/linuxrc  执行根文件系统

console=ttySAC2,115200  串口 2 ,  115200





 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大漠飞鹰6666

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值