-03-PetaLinux starts through eMMC [Xilinx-Petalinux learning]

As mentioned earlier, there is an eMMC chip on my hardware, the model is MTFC4GACAJCN-4M IT, and it has a capacity of 4GB.

The file of BOOT.bin is small, only less than 3MB, but the file of image.ub may become larger and larger in the future according to different needs. It is a bit dangerous to put them all on the 16MB QSPI Flash, and it is not easy to download. Too convenient.

So prepare to separate the storage locations of u-boot and kernel, burn the BOOT.bin containing u-boot into QSPI Flash, and put the image.ub file directly in eMMC for startup.

 

step1: eMMC storage space partition

Reference document URL: http://zedboard.org/sites/default/files/design/PicoZed_Petalinux_2015_2_eMMC_boot_v3.0_0.zip

The way I configured earlier is that BOOT.bin and image.ub are both in the QSPI Flash, so that I can start Linux normally and partition the eMMC in advance.

 

Since I don't have an SD card on my board, I disabled the PS's SD0 peripheral, and finally my eMMC chip was mounted on mmcblk0. (If there is both SD card <SD0> and eMMC <SD1>, SD card will be mmcblk0 under normal circumstances, and eMMC will be mmcblk1)

Start the board, enter the user name and password, and partition. According to the instructions in the manual, divide it into a 128MB partition and format it as FAT32.

Below is my partitioning and formatting process:

root@ifc_petalinux:~# fdisk /dev/mmcblk0

The number of cylinders for this disk is set to 117504.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (eg, DOS FDISK, OS / 2 FDISK)

Command (m for help): p

Disk /dev/mmcblk0: 3850 MB, 3850371072 bytes
4 heads, 16 sectors/track, 117504 cylinders
Units = cylinders of 64 * 512 = 32768 bytes

        Device Boot      Start         End      Blocks  Id System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-117504, default 1): Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-117504, default 117504): +128M


Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): L

 0 Empty                  1b Hidden Win95 FAT32     9f BSD/OS                
 1 FAT12                  1c Hidden W95 FAT32 (LBA) a0 Thinkpad hibernation  
 4 FAT16 <32M             1e Hidden W95 FAT16 (LBA) a5 FreeBSD               
 5 Extended               3c Part.Magic recovery    a6 OpenBSD               
 6 FAT16                  41 PPC PReP Boot          a8 Darwin UFS            
 7 HPFS/NTFS              42 SFS                    a9 NetBSD                
 a OS/2 Boot Manager      63 GNU HURD or SysV       ab Darwin boot           
 b Win95 FAT32            80 Old Minix              b7 BSDI fs               
 c Win95 FAT32 (LBA)      81 Minix / old Linux      b8 BSDI swap             
 e Win95 FAT16 (LBA)      82 Linux swap             be Solaris boot          
 f Win95 Ext'd (LBA)      83 Linux                  eb BeOS fs               
11 Hidden FAT12           84 OS/2 hidden C: drive   ee EFI GPT               
12 Compaq diagnostics     85 Linux extended         ef EFI (FAT-12/16/32)    
14 Hidden FAT16 <32M      86 NTFS volume set        f0 Linux/PA-RISC boot    
16 Hidden FAT16           87 NTFS volume set        f2 DOS secondary         
17 Hidden HPFS/NTFS       8e Linux LVM              fd Linux raid autodetect
Hex code (type L to list codes): b
Changed system type of partition 1 to b (Win95 FAT32)

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table
 mmcblk0: p1
root@ifc_petalinux:~# 

mkdosfs -F 32 /dev/mmcblk0p1

 

 

step2: Configure u-boot to boot PetaLinux from eMMC

Excuting an order:

petalinux-config

 

Configure the startup mode, and configure the kernel startup to eMMC startup:

#Subsystem AUTO Hardware Settings --->
#   Advanced bootable images storage Settings --->
#       boot image settings --->
#           image storage media ---> primary flash
#       kernel image settings --->
#           image storage media ---> primary sd
#       SD/SDIO Settings ----> ps_sd1

 

The SD/SDIO Settings must be configured as SD1 corresponding to eMMC.

Recompile:

petalinux-build

 

After the compilation is completed, use the Xilinx SDK for Windows again to package the three files: zynq_fsbl.elf--->IFC_TOP_wrapper.bit--->u-boot.elf into a BOOT.bin file and rename it to BOOT_EMMC.bin.

Copy the BOOT.bin and image.ub files to the U disk, and then insert the U disk into the USB port of the board.

mkdir /mnt/usb
mkdir /mnt/emmc
#Mount usb and emmc
mount /dev/sda1 /mnt/usb
mount /dev/mmcblk0p1 /mnt/emmc
#Copy image.ub to the first partition of emmc mmcblk0p1
cp /mnt/usb/image.ub /mnt/emmc
#Copy BOOT_EMMC.bin to the first partition mtd0 of QSPI FLASH
flashcp /mnt/usb/BOOT_EMMC.bin /dev/mtd0
#contact mount
umount /mnt/usb
umount /mnt/emmc

 

假如出现:FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

It means that the U disk was not removed correctly last time, which may cause a copy error of image.ub. You need to repair the U disk in Windows, and then perform the above operation again.

Reboot the board:

shutdown now -r

 

This time the board can run FSBL from QSPI, load bits, run u-boot,

Then u-boot boots the Linux operating system from the eMMC chip.

 

eMMC was finally divided into 3 areas by me,

The first partition is used to store files such as image.ub or future device trees, 128MB

The second partition is used to store user data, 2048MB

The third partition is used to store library files, such as the opencv library, and the remaining one is more than GB

 

To be improved:

eMMC has two 16MB boot partitions by default, and it also supports encryption. Is it possible to put u-boot and image.ub in it?

And the two boot partitions can be switched when the system is upgraded. It's so complicated, I'll have time to study it in the future.

yuan: https://blog.csdn.net/vacajk/article/category/6645367

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325220410&siteId=291194637