参考英文版本:https://develop.phytec.com/phycore-am57x/latest/software-development/how-to-guides/create-a-bootable-sd-card
对应BSP版本:PD20.1.2
本文描述了制作一张可以启动phyCORE AM57x 开发板的SD卡的方法。
注意以下操作均在ubuntu的终端中进行操作,除非特殊声明否则不能使用root用户或者sudo来执行。
准备
- SD卡,烧写默认镜像需要最小8GB
- Linux的电脑
- ubuntu 18 64位
- 可访问sd卡读卡器
- 如果需要使用虚拟机,需要注意
- 通过虚拟机访问sd卡可能会有兼容性问题,可能需要准备多个读卡器来测试
- 开通虚拟机访问主机的磁盘会比较方便复制各种文件
- 编译好的镜像
烧写SD卡
准备好烧写需要的4个文件
- MLO
- 第一级bootloader
- 需要注意内存配置与大小需要和文件名中的说明一致,开发板自带的核心板用MLO即可。
- u-boot.img
- tisdk-rootfs-image-am57xx-phycore-kit.tar.xz
- create-sdcard.sh
SD卡分区
为create-sdcard.sh增加可执行权限。
chmod +x create-sdcard.sh
bob@bob-VirtualBox:~/Desktop/am57x$ chmod +x create-sdcard.sh
插入SD卡读卡器,如使用虚拟机需要将优盘通过虚拟机界面选择连接到虚拟机中。
bob@bob-VirtualBox:~/Desktop/am57x$ dmesg | tail
[ 418.015151] usbcore: registered new interface driver uas
[ 419.049030] scsi 3:0:0:0: Direct-Access Sony Card_R/W 1.00 PQ: 0 ANSI: 0 CCS
[ 419.049920] sd 3:0:0:0: Attached scsi generic sg2 type 0
[ 419.684139] sd 3:0:0:0: [sdb] 7626752 512-byte logical blocks: (3.90 GB/3.64 GiB)
[ 419.700829] sd 3:0:0:0: [sdb] Write Protect is off
[ 419.700835] sd 3:0:0:0: [sdb] Mode Sense: 03 00 00 00
[ 419.717431] sd 3:0:0:0: [sdb] No Caching mode page found
[ 419.717442] sd 3:0:0:0: [sdb] Assuming drive cache: write through
[ 419.796731] sdb: sdb1 sdb2
[ 419.865729] sd 3:0:0:0: [sdb] Attached SCSI removable disk
以上确认到SD卡为sdb
执行脚本
bob@bob-VirtualBox:~/Desktop/am57x$ sudo ./create-sdcard.sh
[sudo] password for bob:
################################################################################
This script will create a bootable SD card from custom or pre-built binaries.
The script must be run with root permissions and from the bin directory of
the SDK
Example:
$ sudo ./create-sdcard.sh
Formatting can be skipped if the SD card is already formatted and
partitioned properly.
################################################################################
Available Drives to write images to:
# major minor size name
1: 8 16 3813376 sdb
Enter Device Number or n to exit:
选择刚才确认的sdb,输入1,回车
Enter Device Number or n to exit: 1
sdb was selected
/dev/sdb is an sdx device
Unmounting the sdb drives
unmounted /dev/sdb1
unmounted /dev/sdb2
Current size of sdb1 52724 bytes
Current size of sdb2 825045 bytes
################################################################################
Select 2 partitions if only need boot and rootfs (most users).
Select 3 partitions if need SDK & other content on SD card. This is
usually used by device manufacturers with access to partition tarballs.
****WARNING**** continuing will erase all data on sdb
################################################################################
Number of partitions needed [2/3] :
选择建立2个分区,输入2,回车,此时进行分区,格式化等操作,整个过程大概2分钟。
Number of partitions needed [2/3] : 2
Now partitioning sdb with 2 partitions...
################################################################################
Now making 2 partitions
################################################################################
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 2.88808 s, 363 kB/s
DISK SIZE - 3904897024 bytes
################################################################################
Partitioning Boot
################################################################################
mkfs.fat 3.0.28 (2015-05-16)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
################################################################################
Partitioning rootfs
################################################################################
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 931072 4k blocks and 232928 inodes
Filesystem UUID: 47942c80-4fbc-4dc4-8387-3b2919821b7a
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
################################################################################
Partitioning is now done
Continue to install filesystem or select 'n' to safe exit
**Warning** Continuing will erase files any files in the partitions
################################################################################
Would you like to continue? [y/n] :
输入n,回车,退出。
复制boot文件
建立一个用来挂载SD卡的文件夹
bob@bob-VirtualBox:~/Desktop/am57x$ mkdir sd
挂载SD卡的第一个分区到sd文件夹
bob@bob-VirtualBox:~/Desktop/am57x$ sudo mount /dev/sdb1 sd
复制MLO和u-boot到该分区中
sudo cp MLO u-boot.img sd/
bob@bob-VirtualBox:~/Desktop/am57x$ sudo cp MLO u-boot.img sd/
写入SD卡,并取消挂载
bob@bob-VirtualBox:~/Desktop/am57x$ sync
bob@bob-VirtualBox:~/Desktop/am57x$ sudo umount sd/
解压缩文件系统
挂载sd卡的第二个分区
bob@bob-VirtualBox:~/Desktop/am57x$ sudo mount /dev/sdb2 sd/
解压缩文件系统到SD卡
sudo tar -Jxf tisdk-rootfs-image-am57xx-phycore-kit.tar.xz -C sd/ && sync
bob@bob-VirtualBox:~/Desktop/am57x$ sudo tar -Jxf tisdk-rootfs-image-am57xx-phycore-kit.tar.xz -C sd/ && sync
等烧写完成后,取消挂载
bob@bob-VirtualBox:~/Desktop/am57x$ sudo umount sd/
此时这张卡既可启动开发板,开发板的启动配置请参考硬件手册中的相关内容:https://develop.phytec.com/phycore-am57x/latest/using-peripherals/boot-switch
PD18的烧写报错修复
BSP-Yocto-TISDK-AM57xx-PD18.1.0 Quickstart#Yocto-TISDK-AM57xx-PD18.1.0Quickstart-BootingthePre-builtImages
中的描述,如果出现下面的问题
sfdisk: invalid option -- 'D'
Usage:
sfdisk [options] <dev> [[-N] <part>]
sfdisk [options] <command>
Display or manipulate a disk partition table.
则需要按照下面这个教程来操作。
https://e2e.ti.com/support/arm/sitara_arm/f/791/t/509510