by

Running a Yocto generated distribution on Google Coral Dev Board

Updated instructions can be found here https://github.com/mirzak/meta-coral/wiki/Quick-start-guide

Last week I got my hands on a Google Coral Dev Board and finally got some time to play with it.
If you are not familiar with this board please read this article and also pay the official product site a visit for more technical details. But in short it is a Linux based System-on-Module called Edge TPU Module that is mounted on a development board which contains some additional peripherals. Some key hardware features of the EDGE TP Module:
  • i.MX8MQ SoC with integrated GPU
  • 1 GB LPDDR4
  • 8 GB eMMC
  • Google Edge TPU coprocessor (used to accelerate ML models)
  • WiFI / Bluetooth
The Coral Dev Board serves as an evaluation board for the Edge TPU Module but it can also be used as a single-board computer similar to Rasbperry Pi 3 boards. The Coral Dev Board comes with Linux distribution called Mendel OS which is Debian derivative. The board did not actually contain the Mendel OS pre-programmed, and I had to flash the board to get started. But this was relativity easy as they do provide pre-built OS images and well documented procedure how to flash the board. You can find the getting started guide here, As I spend a lot of time building Linux distributions using Yocto/OE-core and Linux distributions on embedded Linux devices in general are of interest to me, I had to dig deeper in what Mendel OS was. I asked nicely on Coral website if the tooling to generate Mendel OS was available publicly, and I received a prompt response that it was and I got this link: By following the outlined documentation above, I was able to fetch the source code of all the components for further inspection. There where no real surprises when I started looking closer and soon realized that that Mendel OS was built upon fairly standard components coming from the NXP i.MX BSP for the i.MX8 SoC. With this information I realized that I would be fairly easy to port this and I set out to create a Yocto BSP layer to be able to build something that boots on the Coral Dev Board. I only needed to implement three things in this layer to get it to boot:
  • Recipe for U-boot fork
  • Recipe for Linux kernel fork
  • Created a recipe to deploy a boot.scr, and the source for the script I copied from Mendel OS
To build an image with Yocto you can use the following steps, Create directory where you want to store the environment and change the shell to that location: Initialize repo manifest: Fetch layers in manifest: Clone meta-clang: Clone meta-coral: Setup the environment: Add the meta-clang layer to bblayers.conf: Add the meta-coral layer to bblayers.conf: Start baking: After the build has finished you should now have a WIC image:
  • tmp/deploy/images/coral-dev/core-image-base-coral-dev.wic.gz
This is an image that you can write either to the eMMC or an SD card to get a booting system. To simplify things I changed boot mode of the Coral Dev Board to boot from SD card instead of eMMC which is the default, and to do this I adjusted the boot switches to the following,
Boot modeSwitch 1Switch 2Switch 3Switch 4
SD CardONOFFONON
Here is a picture of the boot switches in “SD card mode”
Since we already built our image, we can now write it to a SD card: Insert the SD card and boot the system, we should now end up at login prompt of a Yocto build distribution: I have not yet done much testing of the different peripherals, but the basic components (HDMI, Ethernet, USB) should work as I am using the same Linux kernel as Mendel OS. I know of a couple of things that need some more work as it depends on user-space components, and here is a very short list:
  • WiFi and Bluetooth (need to install correct firmware files)
  • Google Edge TPU coprocessor (would be fun to get the ML demo from Mendel OS running in Yocto)
The source code of the Yocto/OE-core BSP layer for Google Coral Dev can be found here Happy testing and feel free to reach out if you are interested in getting involved.

Update 2019-06-28: There have been multiple reports of an build error caused by the imx-boot recipe. This is a bug in meta-freescale and a quick workaround is to make the following edit: Update 2019-07-12: I have update the instructions in this post to use the “warrior” release in which case no local edits are necessary.

Write a Comment

Comment

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

This site uses Akismet to reduce spam. Learn how your comment data is processed.

32 Comments

  1. Awesome work I was planning on trying to get yocto running on this a few months ago and never had the time. I have some ML stuff running tensorflow lite and yocto, so this might be a natural extension of that.

    • Cool, I am not really in the ML space and my expertise is in getting hardware running :). If you end up with some examples that can shared it would be cool to include that in the meta-coral layer.

      I do plan to move over the demos from Mendel OS, eventually.

  2. I build on ubuntu 16 desktop and meeet a error as below, it seems not found u-boot-nodtb.bin, any suggestion to fix this issue? thanks.

    ======================================================
    ERROR: imx-boot-0.2-r0 do_compile: Function failed: do_compile (log file is located at /home/vmuser/projects/coral/build/tmp/work/coral_dev-fslc-linux/imx-boot/0.2-r0/temp/log.do_compile.28103)
    ERROR: Logfile of failure stored in: /home/vmuser/projects/coral/build/tmp/work/coral_dev-fslc-linux/imx-boot/0.2-r0/temp/log.do_compile.28103
    Log data follows:
    | DEBUG: Executing shell function do_compile
    | NOTE: 8MQ/8MM boot binary build
    | NOTE: Copy ddr_firmware: lpddr4_pmu_train_1d_imem.bin from /home/vmuser/projects/coral/build/tmp/deploy/images/coral-dev -> /home/vmuser/projects/coral/build/tmp/work/coral_dev-fslc-linux/imx-boot/0.2-r0/git/iMX8M
    | NOTE: Copy ddr_firmware: lpddr4_pmu_train_1d_dmem.bin from /home/vmuser/projects/coral/build/tmp/deploy/images/coral-dev -> /home/vmuser/projects/coral/build/tmp/work/coral_dev-fslc-linux/imx-boot/0.2-r0/git/iMX8M
    | NOTE: Copy ddr_firmware: lpddr4_pmu_train_2d_imem.bin from /home/vmuser/projects/coral/build/tmp/deploy/images/coral-dev -> /home/vmuser/projects/coral/build/tmp/work/coral_dev-fslc-linux/imx-boot/0.2-r0/git/iMX8M
    | NOTE: Copy ddr_firmware: lpddr4_pmu_train_2d_dmem.bin from /home/vmuser/projects/coral/build/tmp/deploy/images/coral-dev -> /home/vmuser/projects/coral/build/tmp/work/coral_dev-fslc-linux/imx-boot/0.2-r0/git/iMX8M
    | cp: cannot stat ‘/home/vmuser/projects/coral/build/tmp/deploy/images/coral-dev/imx-boot-tools/u-boot-nodtb.bin’: No such file or directory
    | WARNING: exit code 1 from a shell command.
    | ERROR: Function failed: do_compile (log file is located at /home/vmuser/projects/coral/build/tmp/work/coral_dev-fslc-linux/imx-boot/0.2-r0/temp/log.do_compile.28103)
    ERROR: Task (/home/vmuser/projects/coral/sources/meta-freescale/recipes-bsp/imx-mkimage/imx-boot_0.2.bb:do_compile) failed with exit code ‘1’
    NOTE: Tasks Summary: Attempted 1639 tasks of which 1031 didn’t need to be rerun and 1 failed.
    NOTE: Writing buildhistory

    Summary: 1 task failed:
    /home/vmuser/projects/coral/sources/meta-freescale/recipes-bsp/imx-mkimage/imx-boot_0.2.bb:do_compile
    Summary: There was 1 ERROR message shown, returning a non-zero exit code.

    • I believe that I have also seen this and seems to be a race condition in imx-boot recipe. The quick workaround is just to run:

      • This workaround is not worked for me, It seems we generate wrong file name for build/tmp/deploy/images/coral-dev/imx-boot-tools/u-boot-nodtb.bin-coral-dev-sd, I rename it to build/tmp/deploy/images/coral-dev/imx-boot-tools/u-boot-nodtb.bin, the build process is continued.
        I’m not familiar with yocto, may be there is some error in one recipe to generate this u-boot-nodtb.bin.

          • Do you remember how to fix this bug? 🙂 thanks.

          • I believe I just worked around it with a manual edit (same as you).

            To fix it properly, I would need to do some more research as the recipe is used by many boards.

  3. Great Job! I have a very basic question about formatting sd-card. What kind of format did you use? I was successful to make images. But Can’t not boot from sd-card. Can I see that prompt from HDMI? Thanks.

    • It is a “standard” 16 GB card from SanDisk.

      Make sure that you have adjusted the boot switches accordingly and yes you should see the prompt on HDMI.

  4. Hi Mirzak,

    Thanks for this interesting work.

    I followed the instructions but have issues.

    First problem was the same as faced by Jordon Wu; resolved it as he suggested in his comment regarding /u-boot-nodtb.bin
    Second problem is not able to boot.

    Here is what I have tried to so far –

    If I use BalenaEtcher to burn core-image-base-coral-dev.wic.gz in my SD Card (have tried 64GB card only). I am able to use the serial port. The prompt displays – “in fastboot mode. Press ct-c to exit. I do that and then I enter into uboot shell.Issue version command in u-boot shell shows build date to be June27 (which is when it got built). This means that at least u-boot is being picked and dip switches on board are set to boot from SD card. When I type boot command in the shell it shows following errors:

    bash
    Failed to mount ext2 filesystem ..
    ** unrecognized filesystem type **
    wrong image format for "source" command

    I am fairly new to yocto and bringing up the boards using u-boot so probably doing something silly here.

    If I use zcat tmp/deploy/images/coral-dev/core-image-base-coral-dev.wic.gz | sudo dd of=<device> bs=4M then I do not see anything at all on the serial port.

    Would appreciate if you can guide

    Regards
    Kapil

    • The prompt displays – “in fastboot mode. Press ct-c to exit. I do that and then I enter into uboot shell

      This is not default behavior for it to enter fastboot mode, so I suspect that something is wrong here as well.

      First problem was the same as faced by Jordon Wu; resolved it as he suggested in his comment regarding /u-boot-nodtb.bin

      Can you just provide how you resolved this?

      This is what I locally,

      • Thanks Mirzak for a quick reply.

        I rename it to build/tmp/deploy/images/coral-dev/imx-boot-tools/u-boot-nodtb.bin, the build process is continued.

        Above is what I saw in one of the comments on this post from Jordon Wu. I tried it and indeed it helped in continuing with the build

      • I’m facing the same problem as Kapil , that is – I’m unable to go forward from uboot prompt in sd card mode.

      • Definitely delayed but worth noting for anyone else who comes along in the future:

        If you have followed Google’s Getting Started guide and run fastboot 0, you will always see the in fastboot mode. Press ct-c to exit. Once you hit Control-C, you’ll drop into the regular u-boot shell and then can run boot to start the SD card image.

        I believe this is necessary when switching between Mendel and Yocto as Google uses fastboot for the flashing portion of Mendel.

  5. HI Mirzak,
    I have IMX8QM SOM with me, NXP has released 4.19 BSP with yocto thud.
    If i follow the above procedure, kernel version 4.9 is used in example provided. I have got M.2 PCI module of Coral TPU and trying to interface with IMX8QM on PCI-B bus.
    Can you guide me what should i take care during building application for coral.

  6. Hi Mirza, Nice article with all details.
    I need one suggestion, if I want to build this image with eMMC with customized board what are all changes requires ? Does this same image can work in eMMC ? Or do I need to set some setting in boot config.

  7. Hi Mirzak,
    Thanks for the nice article.
    If i want to build a customised kernel for the latest version 4.14.98 what would be the steps i need to follow ? Also i’m need of the display galcore.ko file . Kindly help me out with the same .

  8. Got through the Yocto build and just fixed up SD card and it booted up good. Nice compact looking system. Plan on developing it further and using QT on it to do system tests for product development I do.
    Thanks for the help with this.
    Gary

  9. Hi Mirzak,
    Thanks for sharing this guide.
    I followed every step in the guide and I was able to build the Yocto for Coral using Ubuntu 20.04.1 LTS.
    I write the all binary to the SD card.
    But, the Coral was unable to go forward from uboot.
    Sometimes, it stuck as the log below:

    and Sometimes, it stuck as the log below:

    Did I miss something to get this behavior?
    best regards

  10. I follow the instructions to create a SD card, but fail to boot

    below are message from debug port

    any idea for it?