本教程是教如何编译官方uboot到Beaglebon black 上面。
1.格式化sd卡
本人准备一张16g内存卡。
1.把sd卡插入电脑。
2.在命令行下输入以下指令
sudo fdisk /dev/sdb
注意:/请按照系统实际填入磁盘路径,本人电脑ubunut系统下插入sd卡路径为“/dev/sdb”
3.我们查看输入m,则打印help命令
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): m
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
使用命令 sudo fdisk /dev/sdb
管理磁盘:
a
: toggle a bootable flag(设置或取消启动表示)
b
: edit bsd disklabel(编辑 bsd disklabel)
c
: toggle the dos compatibility flag
d
: delete a partition (删除一个分区)
l
: list known partition types (列出已知的分区类型)
m
: print this menu (打印次列表)
n
: add a new partition (增加一个新分区)
o
: create a new empty DOS partition table (建立一个新的空 DOS 分区表)
p
: print the partition table (打印分区表)
q
: quit without saving changes (不保存退出)
s
: create a new empty Sun disklabel
t
: change a partition’s system id
u
: change display/entry units
v
: verify the partition table (验证分区表)
w
: write table to disk and exit (把分区表写入磁盘)
x
: extra functionality (experts only) (额外的功能)
4.我们格式化sd卡,然后打印磁盘信息
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
Command (m for help): w
The partition table has been altered.
Failed to remove partition 1 from system: Device or resource busy
The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.
yates@yates-virtual-machine:~/beagleboard/linux$ sudo fdisk /dev/sdb
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): d
No partition is defined yet!
Command (m for help): p
Disk /dev/sdb: 14.86 GiB, 15931539456 bytes, 31116288 sectors
Disk model: Mass-Storage
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3244345d
Command (m for help):
5.创建一个新的磁盘p,并且把格式定义为“FAT32”
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): d
Selected partition 1
Partition 1 has been deleted.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-31116287, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-31116287, default 31116287):
Created a new partition 1 of type 'Linux' and of size 14.9 GiB.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): c
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.
Command (m for help): a
Selected partition 1
The bootable flag on partition 1 is enabled now.
Command (m for help): p
Disk /dev/sdb: 14.86 GiB, 15931539456 bytes, 31116288 sectors
Disk model: Mass-Storage
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3244345d
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 31116287 31114240 14.9G c W95 FAT32 (LBA)
Command (m for help): w
The partition table has been altered.
Syncing disks.
yates@yates-virtual-machine:~/beagleboard/linu
二.下载源码.
1.下载源码地址是 https://github.com/beagleboard/u-boot
2.下载源码后切换分支 origin/v2021.01-bb.org-am335x-am57xx
3.执行以下命令编译
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x_evm_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
4.编译成功后,把u-boot.img MLO复制到sd卡上,并且创建一个uEnv.txt文件,输入以下参数
console=ttyO0,115200n8
ipaddr=192.168.23.2
serverip=192.168.23.1
rootpath=/exports/rootfs
netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=${ipaddr}:${serverip}:192.168.23.1:255.255.255.0:beaglebone:eth0:none:192.168.23.1
netboot=echo Booting from network ...; tftp ${loadaddr} ${bootfile}; tftp ${fdtaddr} ${fdtfile}; run netargs; bootz ${loadaddr} - ${fdtaddr}
uenvcmd=run netboot
三.设备上电
用串口工具连接板子串口
- J1 = GND (Ground)
- J4 = RXD (Receive Data)
- J5 = TXD (Transmit Data)
把板子上电,可以显示以下信息,说明uboot运行成功
U-Boot SPL 2021.04-dirty (Jul 21 2021 - 16:04:09 +0800)
Trying to boot from MMC1
U-Boot 2021.04-dirty (Jul 21 2021 - 16:04:09 +0800)
CPU : AM335X-GP rev 2.1
Model: TI AM335x BeagleBone Black
DRAM: 512 MiB
WDT: Started with servicing (60s timeout)
NAND: 0 MiB
MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from FAT... OK
Net: eth2: ethernet@4a100000, eth3: usb_ether
Hit any key to stop autoboot: 0
=>
=>