eMMC

Embedded MultiMediaCard (eMMC) is an embedded (i.e., it is soldered onto the device's motherboard) non-volatile memory system. Vitro Crystal has an 8 GB eMMC flash, and the device can boot from it. As such, you can flash Yocto-based OS on the eMMC and boot Vitro Crystal with no need for an attached SD card.

📘

Non-volatile memory means that it will retain stored information, even if the hardware is not powered on.

To do that, first, you need to have an already flashed SD card. Then, you need access to Vitro Crystal. This document considers you have a Vitro Crystal that boots from an SD card flashed previously.

🚧

Don't forget to check the SW2 switches to boot from the SD card, and the pins 1-2 from J15 header must be shorted. For more information, check our Operating System document or Hardware guide.

One way to access Vitro Crystal is with a USB keyboard and a monitor with an HDMI port. You can also use an SSH connection, but you need to get an SSH public key authentication from an administrator. When you get access, please log in. The default credentials are:

OSUserPassword
Yocto-basedrootvitrotv

After you log in, follow these steps:

  1. You need to check the device denominator. To do that, please use the following command:
dmesg | grep mmc

The output should be something like this:

...
mmc1: new DDR MMC card at address 0001
...
mmc0: new high speed SDHC card at address aaaa
...

👍

There are more commands that you can use to accomplish the same thing. For example, fdisk -l or lsblk | grep mmc.

In this case, mmc0 is the SD card, and mmc1 is the eMMC. Before flashing it, we need to unmount it first (if it is mounted). To do that, let's first check if it is mounted:

mount

The output:

...
/dev/mmcblk0p2 on / type ext4 (rw,relatime)
...
/dev/mmcblk1p4 on /opt type ext4 (rw,relatime,sync)
...

👍

Feel free to use other commands! If you want, you can run lsblk -f | grep mmc. In this case, you only need to check if mmcblk1 is mounted on /opt (last column).

After analyzing the output, we can see that mmcblk1 (the same device as mmc1 from before) is mounted on /opt . If this is your case, go to step 2, otherwise, go to step 8.

  1. (Optional) We need to change the fstab file.

📘

The fstab file is a configuration file to automate the process of mounting partition. For more information, please check here.

To edit a text file, we recommend using Vim, as it is already installed on the OS. As Vim is a bit overwhelming initially, we created a concise tutorial for you with the main commands. Check the Vim documentation to learn how to start using Vim.

  1. (Optional) Open the fstab file with Vim:
vi /etc/fstab

📘

It is possible to have a single line command to fix the file for you, but it is vital to get this file just right. Otherwise, your system may not boot, and you will have a hard time! Thus, you need to change this file only when you need to, knowing what you are doing.

4, (Optional) Replace LABEL to /dev/mmcblk0p4. The file should look something like this:

# stock fstab - you probably want to override this with a machine-specific one

/dev/root            /                    auto       defaults              1  1
proc                 /proc                proc       defaults              0  0
devpts               /dev/pts             devpts     mode=0620,gid=5       0  0
tmpfs                /run                 tmpfs      mode=0755,nodev,nosuid,strictatime 0  0
tmpfs                /var/volatile        tmpfs      defaults              0  0

# uncomment this if your device has a SD/MMC/Transflash slot
/dev/mmcblk0p4       /opt auto       defaults,sync                  0  0
  1. (Optional) Before flashing the eMMC, it may contain some important files. So we need to transfer them to the SD card for now (if not, you will lose all those files!). So mount mmcblk0p4 on /media :
mount /dev/mmcblk0p4 /media/
  1. (Optional) Copy the VPN configration file from eMMC to the SD card if it doesn't already exist:
cp -p -n /opt/openvpn/vitro.conf /media/openvpn/vitro.conf

📘

cp is a copy command. For more information, please check here.

🚧

If you want the most up to date configuration file (you need to check with the VPN administrator which one should you preserve), you only need to change the -n flag to the -u one, i.e., cp -p -u /opt/openvpn/vitro.conf /media/openvpn/vitro.conf

You may also need to have a copy of all the certificates. Just run:

cp -p -n /opt/vitro_io/certs/* /media/vitro_io/certs

🚧

Again, please check with the system administrator to check for the correct certificate.

  1. (Optional) We need to sync, unmount the SD card, and reboot the system. It is safe to reboot it from the command line, but we are redundant to be safe. Just do the following:
sync; umount /media/; reboot

📘

sync synchronizes data on disk with memory, check here. reboot reboots the system, check here.

  1. Now, you need to download the eMMC image (Yocto-based). You can download it on your host computer and then send it to Vitro Crystal, or download it directly on Vitro Crystal (if it is connected to the internet). Either way, you can download the image and the bmap file by running the following command:
wget --content-disposition "https://cloud.3mdeb.com/index.php/s/WE6NMgSxCQcd6jm/download?path=%2Fv2.2.10&files=vitroio-gateway-imx6dl-crystal-emmc-2.2.10-debug.wic."{gz,bmap}

📘

If you want to choose a specific release, check here!

👍

If you are on an SSH connection, you can transfer these files by using the following command: scp -i <ssh rsa key> <file name>.wic.* <user name>@<Vitro Crystal IP>:<destination directory>. The * is a wildcard, so this way, you will transfer all files that start with <file name>.wic.

  1. With the files on you Vitro Crystal, you now can flash it to eMMC:
bmaptool copy --bmap <file name>.wic.bmap <file name>.wic.gz /dev/<device denominator, e.g. mmcblk1>
  1. (Optional) If you did step 6, now is the time to recover the configuration file! Mount the new flashed eMMC on /media:
mount /dev/mmcblk1p4 /media/

🚧

Remember to double-check the device denominator. It should be the same as in the previous steps.

and now copy the file to eMMC. First the VPN configuration file:

cp -p /opt/openvpn/vitro.conf /media/openvpn/

Now , the certificates:

cp -p /opt/vitro_io/certs/* /media/vitro_io/certs
  1. Modify name in /opt/vitro_io/node_adaptors.config to change endpoint to mitr-poc or other needed:
vi /opt/vitro_io/node_adaptors.config 

Output after modification:

[canbus]
interface=can0
plugin=socketcan

[solution]
name=mitre-poc
  1. Sync and unmount eMMC:
sync; umount /media
  1. Lastly, check if /opt/vitro_io/gateway/device_data exist. Otherwise, create it with the following content:
[provisioning]
customerId=testCustomer

You can do that in one line. Just run this command:

[[ ! -f /opt/vitro_io/gateway/device_data ]] && echo -e "[provisioning]\ncustomerId=testCustomer" > /opt/vitro_io/gateway/device_data
  1. Turn down Vitro Crystal, remove the power supply, and remove the SD card. To shut down the OS, you can use this command:
poweroff
  1. You now need to set SW2 switches (the same switches you had to set when booting from an SD card). The table with the configuration to boot from eMMC is the following:
Switch number12345678
Value01010110

📘

Value 1 is for the upper switch position, while 0 is the opposite. For more information, please check our Hardware guide.

  1. Done! Next time you power on Vitro Crystal, you will boot from eMMC.

What’s Next