Ensemble Graphics Toolkit: Preparing the Host PC and Target

Last modified by Microchip on 2024/06/20 12:44

Introduction

In this training topic, you will prepare a Host PC (native Linux® PC) and target (SAM9X60-EK) to develop applications using the Ensemble Graphics Toolkit (EGT), a C++ based graphical Linux toolkit for Microchip microprocessors.

Prerequisites

Be familiar with the features of the SAM9X60-EK Evaluation Kit.

A working cross-toolchain for Arm®-based MPU target is required.

  • You can create a cross-toolchain in the "Preparing Host PC" section below.

Preparing the Target

You will use the SAM9X60-EK evaluation kit and a High-Performance WVGA Display Module with maXTouch® Technology LCD display for this training. Features of the display include:

  • 800 x 480 TFT display
  • maXTouch MXT640
  • QTouch® QT1070 (with four navigation keys)
  • 4 K-bit 1-wire EEPROM
  • Integrated Projective Capacitive Touch (PCAP) panel

You also need:

  • USB-A to USB Micro-B cable (included with the SAM9X60-EK)
  • Ethernet crossover cable or two regular Ethernet cables and a network hub/switch
  • SD Memory Card (with at least 2 GB)

Photograph of the SAM9X60-EK and WVGA Display Module

The first step is attaching the WVGA Display to the SAM9X60-EK. Follow the instructions in "SAM9X60-EK - Attaching the TM5000 WVGA Display".

Photograph of the SAM9X60-EK and WVGA Display Module Assembled

Ensure the configuration jumpers are in their default positions:

SAM9X60-EK Jumper Location

SAM9X60-EK Jumper position defaults

Back to Top

Preparing the Host PC

We recommend using a native Linux PC to develop embedded Linux applications.

Installation of software packages are performed using the Linux distributions’ software manager. In the accompanying examples, we will use the Debian Project’s Advanced Package Tool (apt), to install software packages on Debian, Ubuntu, and related Linux distributions.

Install development software.

To develop with the Ensemble Graphics Toolkit, you will need the following software:

​$ sudo apt-get install build-essential automake autoconf libtool pkg-config libdrm-dev libinput-dev libcairo-dev libjpeg-dev libmagic-dev gettext git

Back to Top


Install recommended additional software.

The following software is optional, but recommended:​

$ sudo apt-get install librsvg2-dev liblua5.3-dev libcurl4-openssl-dev libxkbcommon-dev xkb-data libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

​$ sudo apt install libplplot-dev plplot-driver-cairo libasound2-dev libsndfile1-dev

$ sudo apt-get install subversion bison flex gettext libncurses5-dev texinfo mercurial git-core gperf gawk expat curl cvs libexpat-dev bzr unzip bc python-dev

Back to Top


Download and built the Ensemble Graphics Toolkit.

Download the Ensemble Graphics Toolkit source code and build:

$ git clone --recursive https://github.com/linux4sam/egt.git
$ cd egt
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

Back to Top


Install Doxygen and build the Ensemble Graphics Toolkit Documentation.

Documentation for the Ensemble Graphics Toolkit will be located in the egt/docs directory.

$ sudo apt-get install doxygen
$ cd egt
$ make docs

To see a list of the available classes, open /egt/docs/html/annotated.html and click on egt::v1. To learn more information about a particular class, click on the class name.

Back to Top


Install Buildroot.

Download Buildroot and the Microchip Buildroot External Tree.

$ git clone https://git.buildroot.net/buildroot
$ git clone https://github.com/linux4sam/buildroot-external-microchip

Ensure that you download the latest version of buildroot and buildroot-external-microchip. For more information see Clone with Git.

Back to Top


Build using the default configuration file sam9x60ek_graphics_defconfig.

The default configuration will configure the build to generate a SD Memory Card image with Ensemble Graphics Toolkit support and a cross toolchain including a C++ cross compiler that you can use to develop graphical applications.

​$ cd buildroot
$ BR2_EXTERNAL=../buildroot-external-microchip/ make sam9x60ek_graphics_defconfig
$ make

​If building Buildroot for a different evaluation kit, you may use the following defconfigs:

  • sama5d27_som1_ek_graphics_defconfig
  • sama5d27_wlsom1_ek_graphics_defconfig

After a successful build…

  • The SD card image (sdcard.img) for the SAM9X60-EK is available in the ~/buildroot-at91/output/images directory.
  • The cross toolchain (arm-buildroot-linux-gnueabi-XX) is installed in the ~/buildroot-at91/output/host/bin directory.
  • The sysroot directory containing the target headers, libraries, binaries, etc. are installed in the ~/buildroot-at91/output/host/arm-buildroot-linux-gnueabi/sysroot directory.

The cross toolchain that is built using the default configuration file sam9x60ek_graphics_defconfig will include a C++ cross-compiler. The accompanying screen capture shows the cross toolchain settings that were enabled:

Cross Toolchain Settings

Buildroot can export the cross toolchain and the development files of selected packages, as a Software Development Kit (SDK), by running the command: make sdk

$ cd buildroot
$ make sdk

This generates a tarball of the content of the host directory ~/buildroot-at91/output/host/, named <TARGET-TUPLE>_sdk-buildroot.tar.gz. This tarball can then be distributed to application developers to develop applications that are not packaged as a Buildroot package.

$ tar -xvf <TARGET-TUPLE>_sdk-buildroot.tar.gz .

Upon extracting the SDK tarball, the application developer must run the script relocate-sdk.sh (located at the top directory of the SDK), to make sure all paths are updated with the new location.

$ cd <TARGET-TUPLE>_sdk-buildroot/
$./relocate.sh

Back to Top


Flash sdcard.img to SD Memory Card:

The easiest method to flash an image to a SD Memory Card is to use the utility program balenaEtcher. It is available for Windows®, macOS®, or Linux. Always make sure you have the latest version of balenaEtcher.

Browse and select the image file you downloaded from the previous step.

 BalenaEtcher Select Image

Insert SD Memory Card to your PC:

Insert SD Memory Card to the SD Memory Card slot on your PC, if one is available. If not, use an external USB SD Memory Card reader.

Screen Capture of Etcher: select drive

Locate and select the SD Memory Card:

Once the SD Memory Card is inserted to your PC, Etcher will automatically detect it.

Screen Capture of Etcher: flash

Flash:

This will take a few minutes.

Back to Top

That’s it. You’ve made all the preparations for your host PC to develop Ensemble Graphics Toolkit applications.

Host PC and Target Setup

Once you have Prepared your Host PC and flashed the SD Memory Card image, it is time to connect the host PC with the SAM9X60-EK with the WVGA Display (otherwise known as the Target).

On the Host PC, start a terminal emulation program.

How-to information is available at: SAM9X60-EK – Console Serial Communications

A diagram showing how to connect host pc to SAM9X60-EK

Back to Top


Insert SD Memory Card into J4.

Back to Top


Connect the USB cable between the Host PC and J22 on the target.

This will power the J-Link portion of the target, LED D9 will light steady green, and the USB port will enumerate.

Back to Top


Power the target by plugging in +5VDC power to J1 -or- connecting a micro USB cable to J7.

​J1 – External Power jack is a 2.1 mm coaxial connector, center positive.

Back to Top


Press the Reset Button (SW3).

Back to Top


On the Host PC, observe the target booting on the console (terminal emulator).

Back to Top


On the target console, you can login as “root” (no password).

Observe the Ensemble Graphics demonstration on the WVGA Display:

EGT Splash Screen

Back to Top

 You have completed booting the image on the SD Memory Card.

Before you can run another graphics application, you must stop the Ensemble Graphics demonstration program.

To stop the Ensemble Graphics demonstration program, you must stop the init script that runs the egt-launcher. On the Target Console, type the following command:

# /etc/init.d/S99demo stop

Host PC and Target LAN Connection

In this section, you will connect the Host PC with the Target via an Ethernet connection. As you develop Ensemble Graphics Toolkit applications the LAN connection provides a quick method to deploy your application to the target. It also provides a connection for remote debugging using GNU Debugger: gdb.

There are two methods by which you can establish a LAN connection:

Method 1: Dynamic IP addressing

This method requires connecting the Host PC and Target to an Ethernet Router using regular patch cables. Both the Host PC and Target will be issued an IP address from the embedded DHCP server in the router.

You can create an isolated workbench LAN with only the Host PC, Target, and Ethernet Router. Take care if the router is connected to the Internet, as both are exposed if they are not behind a firewall.

Method 2: Static IP addressing

This method requires configuring the Host PC and Target for static IP addresses. The accompanying steps are similar for both.

Connect the Ethernet cross-over cable between the Host PC and J5 on the target.

Back to Top


On the target console, configure a static IP address:

Open the text file /etc/network/interfaces with the text editor vi:

Edit the interfaces file below the auto eth0 as shown. Set the target’s static IP address as shown in the accompanying example:

​When you start the vi editor you will be in command mode. Use the arrow keys to place the cursor next to the text you wish to edit.To start editing, type the letter “i” (insert mode). You can delete text while in insert mode using the delete or back-space keys. To exit insert mode, type ESC.

To exit without saving changes, ensure you are in command mode and type :q!

To save and quit, insure you are in command mode and type :wq or ZZ

.
.
auto eth0
iface eth0 inet static
  address 10.0.0.20
  netmask 255.255.255.0
.
.

Back to Top


Execute the following commands to configure the Ethernet interface eth0:

# ifdown eth0
# ifup eth0
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.20 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::5610:ecff:febe:a785 prefixlen 64 scopeid 0x20<link>
ether 54:10:ec:be:a7:85 txqueuelen 1000 (Ethernet)
RX packets 578 bytes 79907 (78.0 KiB)
RX errors 0 dropped 2 overruns 0 frame 0
TX packets 7 bytes 826 (826.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 30 base 0xc000

Back to Top


On the Host PC console, configure a static IP address:

Open the text file /etc/network/interfaces with the text editor vi (or your favorite text editor):

​# vi /etc/network/interfaces

Edit the interfaces file below the auto eth0 as shown. Set the target’s static IP address as shown in the accompanying example:

.
.
auto eth0
iface eth0 inet static
  address 10.0.0.10
netmask 255.255.255.0
.
.

 Ensure that the Host PC and Target do not have the same IP address. All IP addresses on the LAN must be unique.

Back to Top


Execute the following commands to configure the Ethernet interface eth0:

​# ifdown eth0
# ifup eth0
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet addr:10.0.0.10 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::68a4:7c4e:cce0:a6ad prefixlen 64 scopeid 0x20<link>
ether f8:16:54:51:36:3c txqueuelen 1000 (Ethernet)
RX packets 423889 bytes 582081068 (582.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 61446 bytes 9709881 (9.7 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Back to Top


Test the Ethernet connection:

Ping the Host PC from the target console. Exit the ping command by typing CTRL-C:

# ping 10.0.0.10
PING 10.0.0.10 (10.0.0.10) 56(84) bytes of data.
64 bytes from 10.0.0.10: icmp_seq=1 ttl=128 time=1.48 ms
64 bytes from 10.0.0.10: icmp_seq=2 ttl=128 time=1.15 ms

--- 10.0.0.10 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1009ms
rtt min/avg/max/mdev = 1.156/1.318/1.480/0.162 ms

 You may also ping the target from the Host PC:

​$ sudo ping 10.0.0.20

Back to Top

You have completed creating an Ethernet connection between the Host PC and the target.

Target Root Password Setup

In this section you will create a password for the target’s root account. This is necessary when developing over a remote connection. You will be using the secure SSH connection to deploy applications from the Host PC to the target.

​The SSH server will not allow a secure connection with an account that does not have a password.

On the target console, enter a password for the root account:

​# passwd
Changing password for root
New password:
Retype password:
Password for root changed by root

 You may get a warning message if the password is too weak or too short.

Back to Top

You have completed creating a password for the target’s root account.

Summary

At the end of this topic, you have created a development platform (preferably a native Linux computer) for the development of graphics applications on Microchip microprocessor devices.

The steps you followed were:

  • Preparing the Target
  • Preparing the Host PC
  • Host PC and Target Setup
  • Host PC and Target LAN Connection
  • Target Root Password Setup

Learn More

Back to Top