Hands-on with Automotive Linux

Victor Yeo
3 min readJul 4, 2020

The purpose of this article is to document the steps of building linux image and adding application on Automotive Grade Linux (AGL). The exercises are done on Ubuntu 18.04.

Use repo tool to get the AGL source code of version 9 (icefish) release. You can check the previous release name and initialise with different release.

mkdir aglinuxrepo init -b icefish -u https://gerrit.automotivelinux.org/gerrit/AGL/AGL-reporepo sync

After repo sync is completed, you will see yocto layers, bitbake recipes, conf files. The poky files are in the folder external/poky.

Setup the environment for qemu, build the AGL image and linux kernel.

source meta-agl/scripts/aglsetup.sh -m qemux86-64 agl-demo agl-netbootbitbake agl-image-bootbitbake virtual/kernel

The built kernel is in tmp/work/qemux86_64-agl-linux/linux-yocto/ folder.

Setup the build environment for RPi4, build the AGL image.

source meta-agl/scripts/aglsetup.sh -m raspberrypi4 agl-demo agl-appfw-smackbitbake agl-image-boot

To develop application for AGL, use the XDS tool

  • XDS Client: (xds-cli or XDS Dashboard).
  • XDS Agent: (xds-agent) running on your development host.
  • XDS Server: (xds-server) running on a remote server and/or in a container
# before running xds-cli, make sure xds-server and xds-agent are up
systemctl --user status xds-server
systemctl --user status xds-agent
xds-cli sdks ls -a # show all sdk
xds-cli sdks install <ID>
xds-cli sdks ls # show installed sdk

After installation, each time you wish to use the SDK in a new shell session, you need to source the environment setup script. e.g.
. $HOME/xds-workspace/.sdks/poky-agl/7.0.4/corei7–64/ff6d78bfff666f53a8941cf2286f0a09/environment-setup-corei7–64-agl-linux

To test with a hello world application, first clone the source code

cd $HOME/xds-workspace
git clone --recursive https://github.com/iotbzh/helloworld-native-application.git

Then, declare the project

xds-cli prj add --label="Project_helloworld-native-application" --type=pm --path=$HOME/xds-workspace/helloworld-native-application --server-path=$HOME/xds-workspace/helloworld-native-applicationxds-cli prj ls   # determine the ID of the project

Then, generate the build system using CMake:

export TARGET_ADDRESS=<target_adress>

# Go into your project directory and create a build directory
cd $HOME/xds-workspace/helloworld-native-application
mkdir build
xds-cli exec --id=<proj_id> --sdkid=<sdk_id> -- "export RSYNC_TARGET=root@${TARGET_ADDRESS} ; export RSYNC_PREFIX=/opt ; cd build && cmake .."for --id=<proj_id>, can use "-id xx" as a shorthand

After that, you can build the project:

xds-cli exec --id=<proj_id> --sdkid=<sdk_id> -- "cd build && make widget"

The binary is in build/helloworld-native-application folder.

The AGL work flow starts with building the AGL image, downloads the image on hardware, and then develops the application for the hardware.

  1. Download or build the image you are going to run on the hardware device.
  2. Download or build the Software Development Kit (SDK) you use to create your application.
  3. Create bootable media using your image.
  4. Boot your hardware device with the media.
  5. Prepare your environment so that you can develop an application. You can develop the application using XDS or using a stand-alone SDK.
  6. Create your application.
  7. Deploy the application to your hardware.
  8. Debug the application.

References:

https://docs.automotivelinux.org/docs/en/master/getting_started/

https://docs.automotivelinux.org/docs/en/master/getting_started/reference/getting-started/app-workflow-intro.html

https://wiki.automotivelinux.org/agl-distro/source-code

--

--