Skip to content

Latest commit

 

History

History
190 lines (149 loc) · 7.04 KB

edge-agent-dev-guide-nxp-s32g.md

File metadata and controls

190 lines (149 loc) · 7.04 KB

Getting started on an NXP S32G board

This section describes how to get started on an NXP S32G-VNP-RDB2 board.

Prerequisites

  • NXP Semiconductors S32G Reference Design 2: Part number S32G-VNP-RDB2

  • FWE Compiled for ARM64: If you are using an EC2 Graviton instance as your development machine, you will have completed this already in a previous step.

    • If you are using a local Intel x86_64 (amd64) development machine, you will need to run the following to cross-compile your Edge Agent:

      cd ~/aws-iot-fleetwise-edge \
      && sudo -H ./tools/install-deps-cross-arm64.sh \
      && rm -rf build \
      && ./tools/build-fwe-cross-arm64.sh
  • Internet Router with Ethernet: The S32G-VNP-RDB2 must be connected to an internet router via an Ethernet cable for internet connectivity. It is beyond the scope of this document to describe how this is achieved, but one possibility is to use a WiFi to Ethernet bridge and a smartphone acting as an internet hotspot.

Build an SD-Card Image

The following instructions use the development machine to build an SD-card image based on the Ubuntu variant of the NXP Linux BSP version 37.0, with the addition of the can-isotp kernel module required by FWE and a systemd service called setup-socketcan for bringing up the CAN interfaces at startup.

  1. Run the following on the development machine to install the dependencies of the bitbake tool of the Yocto / OpenEmbedded project.

    cd ~/aws-iot-fleetwise-edge \
    && sudo ./tools/install-deps-yocto.sh
  2. Run the following to create a build folder and setup the Yocto project:

    mkdir -p ~/yocto-build && cd ~/yocto-build \
    && ~/aws-iot-fleetwise-edge/tools/setup-yocto-s32g.sh
  3. Run the following to run bitbake to create the SD-card image and compress it. This can take several hours to complete depending on the performance of the development machine and the speed of the internet connection.

    source sources/poky/oe-init-build-env build_s32g274ardb2ubuntu \
    && bitbake fsl-image-ubuntu \
    && gzip -fk tmp/deploy/images/s32g274ardb2/fsl-image-ubuntu-s32g274ardb2.sdcard
  4. Run the following on your local machine to download the compressed SD-card image:

    scp -i <PATH_TO_PEM> ubuntu@<EC2_IP_ADDRESS>:yocto-build/build_s32g274ardb2ubuntu/tmp/deploy/images/s32g274ardb2/fsl-image-ubuntu-s32g274ardb2.sdcard.gz .

Flash the SD-Card Image

  1. Download and install Balena Etcher on your local machine: https://www.balena.io/etcher/
  2. Run Balena Etcher, choose 'Select image' and select the compressed SD-card image fsl-image-ubuntu-s32g274ardb2.sdcard.gz
  3. Insert the SD-card supplied with the S32G-VNP-RDB2 into your local machine's SD-card reader
  4. Choose 'Select target' and select the SD-card
  5. Choose 'Flash!'

Specify Initial Board Configuration

  1. Insert the SD-card into the S32G-VNP-RDB2's SD-card slot.

  2. Connect the S32G-VNP-RDB2's power supply.

  3. Connect an Ethernet cable from port P3A of the S32G-VNP-RDB2 to the internet router.

  4. Connect your local machine to the internet router, for example via WiFi or via Ethernet.

  5. Connect to the S32G-VNP-RDB2 via SSH, entering password bluebox: ssh bluebox@ubuntu-s32g274ardb2

    1. If you can't connect using the hostname ubuntu-s32g274ardb2, you will need to connect to the administration webpage of the internet router to obtain the IP address assigned to the S32G-VNP-RDB2. Use this IP address in place of ubuntu-s32g274ardb2 used throughout this guide.
  6. Once connected via SSH, check the board's internet connection by running: ping amazon.com. There should be 0% packet loss.

Provision AWS IoT Credentials

Run the following commands on the development machine (after compiling FWE for ARM64 as explained above), to create an IoT Thing and provision credentials for it. Your Edge Agent binary and its configuration files will be packaged into a ZIP file ready to be deployed to the board.

mkdir -p ~/aws-iot-fleetwise-deploy \
&& cd ~/aws-iot-fleetwise-deploy \
&& cp -r ~/aws-iot-fleetwise-edge/tools . \
&& mkdir -p build \
&& cp ~/aws-iot-fleetwise-edge/build/aws-iot-fleetwise-edge build \
&& mkdir -p config \
&& cd config \
&& ../tools/provision.sh \
   --region us-east-1 \
   --vehicle-name fwdemo-s32g \
   --certificate-pem-outfile certificate.pem \
   --private-key-outfile private-key.key \
   --endpoint-url-outfile endpoint.txt \
   --vehicle-name-outfile vehicle-name.txt \
&& ../tools/configure-fwe.sh \
   --input-config-file ~/aws-iot-fleetwise-edge/configuration/static-config.json \
   --output-config-file config-0.json \
   --log-color Yes \
   --vehicle-name `cat vehicle-name.txt` \
   --endpoint-url `cat endpoint.txt` \
   --can-bus0 can0 \
&& cd .. \
&& zip -r aws-iot-fleetwise-deploy.zip .

Deploy Edge Agent on NXP S32G board

  1. Run the following on your local machine to copy the deployment ZIP file from the EC2 machine to your local machine:

    scp -i <PATH_TO_PEM> ubuntu@<EC2_IP_ADDRESS>:aws-iot-fleetwise-deploy/aws-iot-fleetwise-deploy.zip .
  2. Run the following on your local machine to copy the deployment ZIP file from your local machine to the S32G (replacing ubuntu-s32g274ardb2 with the IP address of the S32G if using the hostname is not supported):

    scp aws-iot-fleetwise-deploy.zip bluebox@ubuntu-s32g274ardb2:
  3. SSH to the S32G board, as described above, then run the following on the S32G to install your Edge Agent as a service:

    mkdir -p ~/aws-iot-fleetwise-deploy \
    && cd ~/aws-iot-fleetwise-deploy \
    && unzip -o ~/aws-iot-fleetwise-deploy.zip \
    && sudo mkdir -p /etc/aws-iot-fleetwise \
    && sudo cp config/* /etc/aws-iot-fleetwise \
    && sudo ./tools/install-fwe.sh
  4. Run the following on the S32G to view and follow the log (press CTRL+C to exit):

    sudo journalctl -fu fwe@0 --output=cat

Collect OBD Data

  1. Run the following on the development machine to deploy a 'heartbeat' campaign that periodically collects OBD data:

    cd ~/aws-iot-fleetwise-edge/tools/cloud \
    && ./demo.sh \
       --region us-east-1 \
       --vehicle-name fwdemo-s32g \
       --node-file obd-nodes.json \
       --decoder-file obd-decoders.json \
       --network-interface-file network-interface-obd.json \
       --campaign-file campaign-obd-heartbeat.json

Clean up

  1. Run the following on the development machine to clean up resources created by the provision.sh and demo.sh scripts. Note: The Amazon Timestream resources are not deleted.

    cd ~/aws-iot-fleetwise-edge/tools/cloud \
    && ./clean-up.sh \
    && ../provision.sh \
       --vehicle-name fwdemo-s32g \
       --region us-east-1 \
       --only-clean-up
  2. Delete the CloudFormation stack for your development machine, which by default is called fwdev: https://us-east-1.console.aws.amazon.com/cloudformation/home