【树莓派学习笔记】树莓派4B上运行uboot并从网络启动linux内核(上)

【树莓派学习笔记】树莓派4B上运行uboot并从网络启动linux内核(上)



参考:https://hechao.li/2021/12/20/Boot-Raspberry-Pi-4-Using-uboot-and-Initramfs/

前言

树莓派的多数教程上,都是将linux系统下载进入SD,并从SD卡启动。但是对于编写linux驱动这种特定场景来说,每次更改都要把改动拷贝进入U盘实在太过繁琐,严重打击学习热情。所以本文通过在树莓派上运行uboot,并通过uboot网络启动linux内核的方式解决上述问题。


1. 硬件需求与软件版本汇总

1.1 硬件需求

  • 树莓派4B(内存大小不限)
  • linux桌面端运行环境,本文使用虚拟机安装ubuntu20.04.
  • SD卡和读卡器
  • CH340 USB转TTL模块(可选)
  • 杜邦线(至少三根)(可选)

1.2 软件版本汇总

2. 前期准备

SD卡仅用来存储树莓派的启动引导文件,uboot的执行文件以及设备树文件。

2.1 查找SD卡的设备名

linux命令如下:

$ dmesg | tail

命令窗口输出如下:

[ 2719.343068] sd 33:0:0:1: [sdc] 60751872 512-byte logical blocks: (31.1 GB/29.0 GiB)
[ 2719.345290] sd 33:0:0:1: [sdc] Write Protect is off
[ 2719.345294] sd 33:0:0:1: [sdc] Mode Sense: 21 00 00 00
[ 2719.353076] sd 33:0:0:1: [sdc] Write cache: disabled, read cache: enabled, doesn’t support DPO or FUA
[ 2719.359180] sd 33:0:0:0: [sdb] Attached SCSI removable disk
[ 2719.587175] sdc: sdc1 sdc2
[ 2719.612387] sd 33:0:0:1: [sdc] Attached SCSI removable disk
[ 2720.761882] FAT-fs (sdc1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[ 2735.040898] EXT4-fs (sdc2): recovery complete
[ 2735.049551] EXT4-fs (sdc2): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.

从上图可知,新插入的SD的卡设备为sdc,接下来我们将对SD卡进行格式化及分区。

2.2 删除原有的分区

2.2.1 fdisk命令如下:
$ sudo fdisk /dev/sdc

注:其中sdc为2.1.1章节中获取的设备名称,需要更换为自己的设备名称
命令窗口输出:

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help):

2.2.2 删除原有分区:
Command (m for help): d

Command (m for help): d
Partition number (1,2, default 2):

2.2.3 直接回车确认

Partition 2 has been deleted.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值