Generating Booting TF Card

If you don't use a local TFTP server, then you may want to make the TF card target.
Important: The operation will overwrite all existing data on the target TF card.

The default size is 16 GB. The GPT Partition Table for the TF card is recommended.

Perform the following steps to generate the booting SD card:

  1. Execute the following commands to generate sdcard.img file.

    $ make -j$(nproc)
    $ make buildroot_rootfs -j$(nproc)
    $ make img
    
    Result:

    The output file work/sdcard.img will be generated.

    Tip: The image file can be burned into a TF card by:
    • executing the following dd command:

      $ sudo dd if=work/sdcard.img of=/dev/sdX bs=4096
      $ sync
    • or using rpi-imager or balenaEtcher tool.
  2. (Optional) Extend the partition if needed. The following methods are both applicable:
    • Option 1: On the Ubuntu host:
      1. Install the package by running the following command on the Ubuntu host:
        $ sudo apt install cloud-guest-utils e2fsprogs 
      2. Insert the TF card to the Ubuntu host.
      3. Execute the following command to extend partition.
        Note: /dev/sdX is the TF card device name. Change this variable according the actual situation.
        $ sudo growpart /dev/sdX 4  # extend partition 4
        $ sudo e2fsck -f /dev/sdX4
        $ sudo resize2fs /dev/sdX4  # extend filesystem
        $ sudo fsck.ext4 /dev/sdX4
        
    • Option 2: Run the fdisk and resize2fs commands on the VisionFive 2 board:
      # fdisk /dev/mmcblk1
      Welcome to fdisk (util-linux 2.37.2).
      Changes will remain in memory only, until you decide to write them.
      Be careful before using the write command.
      This disk is currently in use - repartitioning is probably a bad idea.
      It's recommended to umount all file systems, and swapoff all swap
      partitions on this disk.
      Command (m for help): d
      Partition number (1-4, default 4): 4
      Partition 4 has been deleted.
      Command (m for help): n
      Partition number (4-128, default 4): 4
      First sector (614400-62333918, default 614400):
      ): t sector, +/-sectors or +/-size{K,M,G,T,P} (614400-62333918, default 62333918)
      Created a new partition 4 of type 'Linux filesystem' and of size 29.4 GiB.
      Partition #4 contains a ext4 signature.
      Do you want to remove the signature? [Y]es/[N]o: N
      Command (m for help): w
      The partition table has been altered.
      Syncing disks.
      
      # resize2fs /dev/mmcblk1p4
      resize2fs 1.46.4 (18-Aug-2021)
      Filesystem at /d[
      111.756178] EXT4-fs (mmcblk1p4): resizing filesystem from 512000
      to 30859756 blocks
      ev/mmcblk1p4 is [
      111.765203] EXT4-fs (mmcblk1p4): resizing filesystem from 512000
      to 30859265 blocks
      mounted on /; on-line resizing required
      old_desc_blocks = 2, new_desc_blocks = 118
      [ 112.141953] random: crng init done
      [ 112.145369] random: 7 urandom warning(s) missed due to ratelimiting
      [ 115.474184] EXT4-fs (mmcblk1p4): resized filesystem to 30859265
      The filesystem on /dev/mmcblk1p4 is now 30859756 (1k) blocks long.