Project

General

Profile

Building SD Card Image 18.1

The MitySOM-5CSx family of modules are capable of booting, running from, and accessing an SD card, assuming the carrier board has an SD card interface.

Configuration requirements

  • The BSEL pins must be set to 0x5 (101b) since the device uses 3.3V. Note: 0x4 (100b) is for a 1.8V device, so don't use it.
  • The CSEL pins must be strapped to match your clock configuration.
  • The MSEL pins must be strapped to match your desired FPGA configuration.

Prerequisites

The following files are required to be in the same directory:
  • dev_5cs.rbf
  • mitysom-image-base-mitysom-c5.tar.gz
  • preloader-mkpimage.bin
  • u-boot.img
  • ubootenv.bin
  • make_sd.sh (SD card image generation script)
    git archive --format=tar --remote=git://support.criticallink.com/home/git/meta-cl-socfpga.git rocko recipes-bsp/sd-card-scripts/files/make_sd.sh | tar -xO > make_sd.sh
    sudo chmod +x make_sd.sh
    

    The following packages must be installed before the script can be run. Note: You must reboot after adding the user to the kvm group.
    sudo apt-get install --no-install-recommends -y libguestfs-tools qemu-utils linux-image-generic
    sudo chmod o+r,g+r /boot/vmlinuz-*
    sudo chmod 0666 /dev/kvm
    sudo usermod -a -G kvm $USER
    

SD card structure

The SD cards from Critical Link are setup with the following structure. Note: There should be three partitions on the SD card after the image is written. The image contains the MBR which stores the partition information.

Offset Size Partition Filesystem
0x00400000 0x10000000 1 fat
0x10400000 0x00100000 2
0x10500000 0x2FB00000 3 ext3

Building the SD card image

Build the SD card image. The SD card image will be sd_card.img.
Note: make_sd.sh must be run on a Linux machine or virtual machine, such as Ubuntu 18.04.
Note: Make sure we have permissions to access \boot\vmlinuz-*. If it has updated, you will need read privileges for the most recent file.
Note: This command will fail if a virtual machine is running and using KVM.
Note: This files may be named differently or located in different directories.

sudo chmod o+r,g+r /boot/vmlinuz-*
./make_sd.sh -d CycloneV -p preloader-mkpimage.bin -u u-boot.img -e ubootenv.bin -f dev_5cs.rbf mitysom-image-base-mitysom-c5.tar.gz

Updating the full SD card

Warning: Be sure you are writing to your SD card and not another drive on your system! You can confirm which device you want to write to (i.e. /dev/mmcblk0 or /dev/sdd) by running the df command and finding where your SD card reader is mounted.

Replace the mmcblkX shown in the command below with your device: (i.e. mmcblk0 or sdd)

sudo umount /dev/mmcblkX*
sudo dd if=sd_card.img of=/dev/mmcblkX bs=4M status=progress
sync

Updating parts of the SD card

Updating the U-Boot environment

The U-Boot environment is stored immediately after the MBR on the SD card and not on a partition. In order to write the U-Boot environment, you will need to write it raw to the partition using the dd command.

Warning: Be sure you are writing to your SD card and not another drive on your system! You can confirm which device you want to write to (i.e. /dev/mmcblk0 or /dev/sdd) by running the df command and finding where your SD card reader is mounted.

Replace the mmcblkX shown in the command below with your device: (i.e. mmcblk0 or sdd)

sudo umount /dev/mmcblkX*
sudo dd if=ubootenv.bin of=/dev/mmcblkX bs=512 seek=1
sync

Updating the FPGA image

The Critical Link provided FPGA .rbf file is stored on the first partition of the SD card, which has the Windows FAT filesystem. This means that they can easily be updated from either a Windows machine or a Linux machine.

Replace the mmcblkXp1 shown in the command below with the first partition of your device: (i.e. mmcblk0p1 or sdd1)

sudo mount /dev/mmcblkXp1 /mnt
sudo cp dev_5cs.rbf /mnt
sync
sudo umount /mnt

Updating the preloader

The preloader is stored on the second partition of the SD card, which does not have a filesystem. In order to write the preloader, you will need to write it raw to the partition using the dd command.

Warning: Be sure you are writing to your SD card and not another drive on your system! You can confirm which device you want to write to (i.e. /dev/mmcblk0 or /dev/sdd) by running the df command and finding where your SD card reader is mounted.

Replace the mmcblkXp2 shown in the command below with the second partition of your device: (i.e. mmcblk0p2 or sdd2)

sudo umount /dev/mmcblkXp2
sudo dd if=preloader-mkpimage.bin of=/dev/mmcblkXp2 bs=64k
sync

Updating U-Boot

U-Boot is stored on the second partition of the SD card, which does not have a filesystem. In order to write the U-Boot image, you will need to write it raw to the partition using the dd command.

Warning: Be sure you are writing to your SD card and not another drive on your system! You can confirm which device you want to write to (i.e. /dev/mmcblk0 or /dev/sdd) by running the df command and finding where your SD card reader is mounted.

Replace the mmcblkXp2 shown in the command below with the second partition of your device: (i.e. mmcblk0p2 or sdd2)

sudo umount /dev/mmcblkXp2
sudo dd if=u-boot.img of=/dev/mmcblkXp2 bs=64k seek=4
sync

Updating the kernel

The Critical Link provided Linux root filesystem is stored on the third partition, which is formatted with the EXT3 filesystem. This partition can easily be updated from a Linux host.

Replace the mmcblkXp3 shown in the command below with the third partition of your device: (i.e. mmcblk0p3 or sdd3)

sudo mount /mmcblkXp3 /mnt
sudo cp zImage /mnt/boot
sync
sudo umount /mnt

Updating the device tree

The Critical Link provided Linux root filesystem is stored on the third partition, which is formatted with the EXT3 filesystem. This partition can easily be updated from a Linux host.

Replace the mmcblkXp3 shown in the command below with the third partition of your device: (i.e. mmcblk0p3 or sdd3)

sudo mount /mmcblkXp3 /mnt
sudo cp mitysom_5csx_devkit.dtb /mnt/boot
sync
sudo umount /mnt

Go to top
Add picture from clipboard (Maximum size: 1 GB)