嵌入式Linux(七):linux kernel编译烧写与SD卡和NFS的挂载

前言

折腾了一阵子,终于把东山派壹号的NFS以及SD内存卡的挂载搞定了,原本烧录的系统里,linux kernel没有支持vfat 和 nfs服务。本文将详细讲解,make menuconfig添加配置,kernel的编译烧录。

一 编译Kernel

1 环境配置

编译kernel前需要配置好交叉编译环境,可以参考嵌入式Linux(一):东山派壹号 ubuntu开发环境配置
我这边测试时,win10的ubuntu子系统编译内核会出现错误。所以我直接切换到了ubunt18.04双系统环境中编译,当然你也可以用虚拟机运行ubuntu来编译kernel.
编译环境还需要python2的环境
总结就是:
(1)交叉编译环境
(2)ubuntu18.04
(4)python2.7
(5)源码(可以参考上面文章获取)

2 make menuconfig配置

要想支持vfat和nfs,需要在编译内核前添加相关配置。

//cd 到kernel路径
huss@huss:~/onwork/DongshanPiOne-TAKOYAKI$ cd kernel
huss@huss:~/onwork/DongshanPiOne-TAKOYAKI/kernel$

//添加默认配置
make infinity2m_spinand_ssc011a_s01a_minigui_defconfig;

//进入make menuconfig
make menuconfig

(1) vfat支持

按顺序进入

File systems —>
DOS/FAT/NT Filesystems —>
请添加图片描述

(2) nfs支持

File systems —>
[*] Network File Systems —>

请添加图片描述

3 编译

make clean;
make -j8

编译完
生成image Nand Flash在为下面路径

kernel/arch/arm/boot/uImage.xz

(二)kernel boot烧录

1 SD内存卡

准备一张低于32G的内存卡,将上面的编译出来的kernel image文件移到内存卡中。插入开发板。

2 烧录

(1)启动进入Boot

启动开发板,可以用minicom来连接开发板子可以参考嵌入式Linux(一):东山派壹号 ubuntu开发环境配置里的minicom连接。

按板子上的重启键RESET,然后马上**长按回车(Enter)**就可以进入boot命令行了。

在boot命令行里输入下面命令,烧录kernel

fatload  mmc 0:1  0x21000000 uImage.xz
nand erase.part KERNEL
nand write.e 0x21000000 KERNEL ${filesize}
nand erase.part RECOVERY
nand write.e 0x21000000 RECOVERY ${filesize}

(三)关联SD内存卡

烧录好kernel,重启,就可以使用内存卡了。
操作内存卡前,需要关联以下内存卡,才能进行读写操作

mkdir /mnt/sd
#mount sd card
mount /dev/mmcblk0p1 /mnt/sd

(四)关联NFS

使用Network File System(NFS),需要通过网线连接电脑,同时需要分别配置电脑端和板子端的IP.

1 配置IP

电脑端(ubuntu18.04)

//需要确定号自己的网络端口号,我的是enp2s0
sudo ifconfig enp2s0 192.168.5.9

板子端

sudo ifconfig eth0 192.168.5.10

2 ubuntu安装nfs server 服务

//安装服务
sudo apt-get install nfs-kernel-server
//创建根目录
mkdir /home/huss/rootfs
chmod 777  /home/huss/rootfs
//配置nfs服务,内容为下面的代码块
sudo vim /etc/exports 
# /etc/exports: the access control list for filesystems which may be exported
#		to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/home/huss/rootfs *(rw,sync,no_root_squash)

3 重启nfs server 服务

sudo /etc/init.d/nfs-kernel-server restart

4 关联nfs服务

mkdir /mnt/nfs
#mount nfs
mount -o nolock,proto=tcp -t nfs 192.168.5.9:/home/huss/rootfs /mnt/nfs

后言

上面主要参考
https://dongshanpi.com/DongshanPi-One/07-BuildFlashKernel/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值