Reconfigurable Motion and Robotics Demo Build Update the SD Card - ArrowElectronics/Reconfigurable-Industrial-Robotics-Platform GitHub Wiki
In the previous sections, methods are described to build the FPGA image, the Linux kernel, the Preloader, uboot and software images. These files must be copied to the SD card in order for the system to boot. The following steps describe how to implement this. The instructions below assume that SD card is partitioned properly.
- Insert the SD card adapter
- Prerequisites
- SD card structure
- Building the SD card image
- Updating the full SD card
- Eject the SD card adapter
Determine the device associated with the SD card on the host. Run the command below before and after inserting the SD card. The new drive letter will show up as /dev/sdx/ where x represents the actual letter (a,b,c,d etc). Substitute the letter x with the actual letter in the dd commands listed below.
$ cat /proc/partitions
-
Insert the Micro SD Card into the USB to Micro SD card Adapter.
-
Plug the USB (or Micro SD card) Adapter into the host PC.
-
The VM will detect the Adapter and ask the user to choose where it should be connected
Choose "Connect to a virtual machine" and select OK
The following files are required:
- dev_5cs.rbf (in ~/ArrowCMR/hw/fpga/cmr_motor_demo/output_files)
- preloader-mkpimage.bin (Preloader in ~/ArrowCMR/hw/fpga/cmr_motor_demo/software/preloader)
- ubootenv.bin (U-Boot environment in ~/ArrowCMR/hw/fpga/cmr_motor_demo/software/preloader)
- u-boot.img (U-Boot in ~/ArrowCMR/hw/fpga/cmr_motor_demo/software/preloader/uboot-socfpga)
- cmr.bin (demo application in ~/ArrowCMR/sw/ARM/bare-metal)
- make_sd.sh (SD card image generation script. Execute commands below to acquire it)
$ cd ~/ArrowCMR
$ 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: The reboot step after adding the user to the kvm group is necessary.
$ 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 [ see note]
$ sudo usermod -a -G kvm $USER
$ sudo reboot
NOTE: /dev/kvm may not be present if you are working in a virtualized environment. The guestfish tools (which are used to create and manipulate the sd card image) use the kvm system to operate if available. If /dev/kvm does not exist, guestfish should still work, although performance may suffer and you may see warnings regarding /dev/kvm.
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 |
The SD card image will be sd_card.img. Note: make_sd.sh must be run on the virtual machine. Note: Make sure you 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.
Execute:
$ cd ~/ArrowCMR
$ ./make_sd.sh -d CycloneV -p ./hw/fpga/cmr_motor_demo/software/preloader/preloader-mkpimage.bin -s 32 -F 16 -u ./hw/fpga/cmr_motor_demo/software/preloader/uboot-socfpga/u-boot.img -e ./hw/fpga/cmr_motor_demo/software/preloader/ubootenv.bin -f ./hw/fpga/cmr_motor_demo/output_files/dev_5cs.rbf -f ./sw/ARM/bare-metal/cmr.bin
The make_sd.sh command:
Usage:
$ make_sd.sh [-s|--size <size>] [-o|--outfile <outfile>]
[-p|--preloader <preloader bin>]
[-e|--environment <env binary>] [-u|--uboot <u-Boot bin>]
[-f|--fatfile <file>] [-r|--rfsoverlay <dir>] [-t|--fatoverlay <dir>]
[-v] [-g] [-d|--device <CycloneV|Arria10>] [-F|--fatsize <size>]
[-h|--help] [<root.tar.gz>]
-d device type [CycloneV Arria10]
-s --size size of image [default 1024 MB]
-o --outfile name of the output file [default is sd_card.img]
-p --preloader preloader to be used, Only Cyclone V
-e --environment u-Boot environment to be used
-u --uboot u-Boot image to be used
-f --fatfile Files to add to the FAT partition (rbf images)
-r --rfsoverlay File structure overlay to be put on top of root fs
-t --fatoverlay FAT structure overlay to be put on top of FAT partition
-v --verbose sets verbose flag in shell
-z --zip will result in the output file + md5 being compressed with zip (good for etcher)
-g --gzip will result in the output file being compressed with gzip
-F --fatsize size of the FAT partition in MB
-h --help display this message
<root.tar.gz> is the yocto filesystem tarball to use
As the CMR demo app is a bare-metal application, the filesystem tarball is not used.
sudo umount /dev/sdx1 (sdx is determined in an earlier step)
sudo umount /dev/sdx3
sudo dd if=sd_card.img of=/dev/sdx bs=4M status=progress
sudo sync
The FAT partition named "fpga" should now have 2 files, cmr.bin and dev_5cs.rbf.
Note : Never remove the SD card media from the Linux host before it has been ejected.
To Eject the media :
- Click on the eject button of the SD Card partition in the file manager. The partition may be named fpga
Return to Build Demo
Return to Build the Example Design
Return to Reconfigurable Industrial Robotics Platform User Guide