Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.18
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: "Part 3: NXP FRDM i.MX 8M Plus \u2014 Deploy BMP280 temperature sensing and an AWS IoT Core bridge"
draft: true
cascade:
draft: true
description: "Deploy MCU firmware and a Linux bridge as S3-backed custom Greengrass components."
minutes_to_complete: 120
who_is_this_for: Embedded Linux developers connecting an NXP application processor and MCU to AWS IoT Greengrass.
learning_objectives:
- "Read the external temperature via the BMP280 sensor on the Cortex-M7 using Zephyr RTOS"
- "Deploy two S3-backed AWS Greengrass components to install and run the Zephyr app and its Yocto bridge component"
- "Publish JSON messages to nxp/imx8mplus/temperature/external within AWS IoTCore containing the read temperature from the sensor"
- "Remove both apps and verify cleanup and redeployment capabilities"
prerequisites:
- "NXP FRDM i.MX 8M Plus with an appropriate power supply, microSD card and reader, wired Ethernet, and its debug USB cable"
- An Ubuntu 22.04 or 24.04 host on x86_64 (amd64) or arm64 (aarch64) with 32 GB RAM and 300–500 GB free space on a Linux filesystem
- AWS CLI v2 and an account permitted to manage IoT identities, Greengrass deployments, and component artifacts
- Complete Part 1 for this same board; retain its image, identity and thing group
- Python 3.12 or newer, west, CMake, Ninja, and Zephyr SDK 0.17.4 on the Ubuntu development host
- Complete Part 2 and verify a repeatable application MCU start and stop.
- An external BMP280 I2C module plus jumper wires
author: Doug Anson
generate_summary_faq: true
rerun_summary: false
rerun_faqs: false
skilllevels: Advanced
subjects: Embedded Linux
armips:
- Cortex-A
- Cortex-M
operatingsystems:
- Linux
- RTOS
tools_software_languages:
- Yocto Project
- AWS IoT Greengrass
- Python
- Zephyr
- C
further_reading:
- resource:
title: "NXP FRDM i.MX 8M Plus Part 1 \u2014 Yocto and Greengrass"
link: /learning-paths/embedded-and-microcontrollers/nxp-imx8uplus-yocto-gglite-part1/
type: learningpath
- resource:
title: "NXP FRDM i.MX 8M Plus Part 2 \u2014 Zephyr alongside Linux"
link: /learning-paths/embedded-and-microcontrollers/nxp-imx8uplus-yocto-zephyr-part2/
type: learningpath
### FIXED, DO NOT MODIFY
weight: 1
layout: "learningpathall"
learning_path_main_page: "yes"
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# ================================================================================
# FIXED, DO NOT MODIFY THIS FILE
# ================================================================================
weight: 21
title: "Next Steps"
layout: "learningpathall"
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "NXP FRDM i.MX 8M Plus: Package the RPMsg-to-IoT-Core bridge"
description: "Prepare offline dependencies and a foreground Linux telemetry bridge."
weight: 5
layout: "learningpathall"
---

## Introduction to the RPMsg-to-IoTCore relay/bridge

Within the bridge code, `components/bridge.py` waits for `/dev/nxp-temperature`, opens the RPMsg TTY in raw mode, and sends a host greeting to establish its endpoint address. It accepts only newline-delimited `nxp.external.temperature` schema-1 frames with valid integer fields and BMP280-range values. It publishes each accepted sample through Greengrass IPC `PublishToIoTCore`, with QoS 1, to **`nxp/imx8mplus/temperature/external`**. The boards existing Greengrass environment, by default, supplies and manages the MQTT/TLS authentication for the bridge into AWS IoTCore.

JSON messages published to AWS IoTCore will resemble this:
```json
{"schemaVersion":1,"thingName":"MyNXPIMX8MPlus","sensor":"BMP280","location":"external","temperatureC":25.08,"sequence":12,"mcuUptimeMs":60320,"linuxBootId":"example-boot-id","timestamp":"2026-10-29T18:00:00.123+00:00"}
```

The timestamp is Linux's UTC receipt time. Sequence and MCU uptime restart with the firmware; QoS 1 can duplicate deliveries. Publish failures are logged and the affected sample is dropped.

## Build and stage our artifacts for the bridge

On the Ubuntu host, type:

```bash
source "$HOME/nxp-imx8uplus-zephyr-venv/bin/activate"
cd "$HOME/nxp-imx8uplus-temperature-part3"
sh tools/stage.sh build/temperature/zephyr/zephyr.elf 313
find staging -type f -print
```

Replace `313` with the board's actual python interpreter version if different (should not need to be changed though). The script downloads `awsiotsdk==1.26.0` and its pinned `awscrt==0.28.1` wheel for Linux AArch64, independent of the build host's architecture.

Before staging, the script runs the ELF inspector using the Zephyr virtual
environment's `pyelftools`. An old failing ELF is rejected before artifacts are
copied. The firmware component has three artifacts: ELF, manager and Linux
preflight helper. The bridge has four: source, lifecycle script, universal SDK wheel, and AArch64 CRT wheel.

The component version comes from `release.json` (currently `1.0.1`). Staging,
recipe generation and the deployment page use that same value. Keep earlier
staged versions for rollback; the uploader selects only the current plan.

## Understand the AWS Greengrass component install, run, and removal

Greengrass downloads S3 artifacts before the install phase. The bridge install script uses `pip --no-index --no-cache-dir --find-links` and a private digest-named target directory under component work storage. Python and pip come from the Part 1 image.

The foreground run supervisor starts Python, keeps it in the component control group, and handles termination. Python closes its RPMsg TTY and IPC client; the supervisor removes the private installed directory. It can reinstall from immutable artifacts on the next run. The firmware manager uses a different endpoint for stop control.

The recipes run with root privileges in this development image to access serial and remoteproc resources. A production image should grant the bridge a suitable device group and reserve root only for operations that require it.

## What you have learned

You can explain the bridge's RPMsg greeting and schema design as well as build/stage our bridge for inclusion into an AWS IoT Greengrass custom component.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
title: "NXP FRDM i.MX 8M Plus: Remove the apps and verify cleanup"
description: "Revise desired state and prove repeatable application-MCU cleanup."
weight: 8
layout: "learningpathall"
---

## Shutting down both applications via revised deployment

Retrieve the latest deployment ID again, since another change may have occurred. On the Ubuntu host:

```bash
aws greengrassv2 list-deployments --target-arn "$GROUP_ARN" --history-filter LATEST_ONLY
```

Set CURRENT_DEPLOYMENT_ID to the latest deployment ID found above:

```bash
export CURRENT_DEPLOYMENT_ID=YOUR_LATEST_GROUP_DEPLOYMENT_ID
```

Now, lets revise the deployment with an update effectively de-selecting both custom components:

```bash
aws greengrassv2 get-deployment --deployment-id "$CURRENT_DEPLOYMENT_ID" > current-deployment.json
python3 - <<'PYTHON'
import json,os
from pathlib import Path
current=json.loads(Path('current-deployment.json').read_text())
assert current['targetArn']==os.environ['GROUP_ARN']
components=current.get('components',{}).copy()
components.pop('com.arm.NXPIMX8MPlus.ZephyrExternalTemperature',None)
components.pop('com.arm.NXPIMX8MPlus.ExternalTemperatureBridge',None)
Path('remove-deployment.json').write_text(json.dumps({'targetArn':os.environ['GROUP_ARN'],'deploymentName':'Remove NXP FRDM i.MX 8M Plus temperature apps','components':components},indent=2)+'\n')
PYTHON
export REMOVE_ID=$(aws greengrassv2 create-deployment --cli-input-json file://remove-deployment.json --query deploymentId --output text)
aws greengrassv2 list-effective-deployments --core-device-thing-name "$THING_NAME"
aws greengrassv2 list-installed-components --core-device-thing-name "$THING_NAME"
```

Wait for this removal revision to succeed.

## Confirming that the board has been cleaned up

Using the recorded run-unit names and work paths:

```bash
export FW_UNIT=`systemctl list-unit-files --type=service | grep NXPIMX8MPlus | awk '{print $1}' | grep Zephyr`
export BRIDGE_UNIT=`systemctl list-unit-files --type=service | grep NXPIMX8MPlus | awk '{print $1}' | grep Bridge`
journalctl -u "$FW_UNIT" -u "$BRIDGE_UNIT" -b --no-pager -n 100
nxp-mcore status
systemctl is-active "$FW_UNIT" "$BRIDGE_UNIT"
```

You should see that the application Cortex-M7 is now **offline**, prior firmware filename restored, normal quiescence/stop messages, inactive or removed component units, and no new IoTCore JSON messages being published in the MQTT test console.

## Additional detail: To re-enable, invoke a redeployment adding the components back into the deployment itself

Reapply the saved `deployment.json` to re-enable both components to be listed as part of the revised deployment. Once successfully deployed, you should again see JSON temperature messages published into AWS IoTCore via the MQTT test client.

## Additional detail: Optionally retire cloud resources

After removal from every target, delete the two recorded private component version ARNs with `aws greengrassv2 delete-component --arn VERSION_ARN`. Remove only their versioned S3 prefixes and delete the bucket only if dedicated and empty.

If no device still needs this path's supplemental policy and role permission:

```bash
aws iot detach-policy --policy-name NXPIMX8MPlusExternalTemperaturePublish --target "$CERT_ARN"
aws iot delete-policy --policy-name NXPIMX8MPlusExternalTemperaturePublish
aws iam delete-role-policy --role-name "$ROLE_NAME" --policy-name NXPIMX8MPlusExternalTemperatureArtifacts
```

## What you have learned

You can successfully enable and disable these two components via updated deployments. This feature provides an `on/off` management capability for the components and their associated apps (artifacts). In generalized lifecycle management of edge devices, this technique, along with updating S3 artifacts, revising component versions, and revising deployment references to component versions, are all used to manage the overall application and its lifecycle within the edge device.
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: "NXP FRDM i.MX 8M Plus: Deploy both components and verify temperature"
description: "Preserve the group selection and observe actual BMP280 JSON in IoT Core."
weight: 7
layout: "learningpathall"
---

## Preserve the latest group deployment

On the Ubuntu host in `$HOME/nxp-imx8uplus-temperature-part3`, retain the variables from the previous section:

```bash
export GROUP_ARN=$(aws iot describe-thing-group --thing-group-name "$THING_GROUP" --query thingGroupArn --output text)
aws iot list-things-in-thing-group --thing-group-name "$THING_GROUP"
aws greengrassv2 list-deployments --target-arn "$GROUP_ARN" --history-filter LATEST_ONLY
```

Set `BASE_DEPLOYMENT_ID` to the latest deployment ID just listed:

```bash
export BASE_DEPLOYMENT_ID=YOUR_LATEST_GROUP_DEPLOYMENT_ID
aws greengrassv2 get-deployment --deployment-id "$BASE_DEPLOYMENT_ID" \
> previous-deployment.json
```

Create the deployment now:

```bash
python3 - <<'PYTHON'
import json,os
from pathlib import Path
base=json.loads(Path('previous-deployment.json').read_text())
assert base['targetArn']==os.environ['GROUP_ARN']
components=base.get('components',{}).copy()
version=json.loads(Path('release.json').read_text())['version']
components['com.arm.NXPIMX8MPlus.ZephyrExternalTemperature']={'componentVersion':version}
components['com.arm.NXPIMX8MPlus.ExternalTemperatureBridge']={'componentVersion':version,'configurationUpdate':{'merge':json.dumps({'serialDevice':'/dev/nxp-temperature'})}}
Path('deployment.json').write_text(json.dumps({'targetArn':os.environ['GROUP_ARN'],'deploymentName':'NXP FRDM i.MX 8M Plus BMP280 telemetry','components':components},indent=2)+'\n')
PYTHON
export DEPLOYMENT_ID=$(aws greengrassv2 create-deployment --cli-input-json file://deployment.json --query deploymentId --output text)
aws greengrassv2 list-effective-deployments --core-device-thing-name "$THING_NAME"
aws greengrassv2 list-installed-components --core-device-thing-name "$THING_NAME"
```

Wait for this deployment to succeed on this device and for both components to run. You can view the deployment progress on the AWS Console if desired.

## Examine events on the board

After deployment fully completes on our board, we should see that our MCU is active and that we have new device files for temperature and MCU control:

```bash
nxp-mcore status
systemctl list-units --all --type=service --no-pager | grep -F NXPIMX8MPlus
journalctl -u ggl.core.ggdeploymentd.service -b --no-pager -n 100
ls -l /dev/nxp-temperature /dev/nxp-mcore-control
```

Lets check the status on each of the services for our two apps:

```bash
export FW_UNIT=`systemctl list-unit-files --type=service | grep NXPIMX8MPlus | awk '{print $1}' | grep Zephyr`
export BRIDGE_UNIT=`systemctl list-unit-files --type=service | grep NXPIMX8MPlus | awk '{print $1}' | grep Bridge`
export FW_WORK=$(systemctl show "$FW_UNIT" --property=WorkingDirectory --value)
export BRIDGE_WORK=$(systemctl show "$BRIDGE_UNIT" --property=WorkingDirectory --value)
journalctl -u "$FW_UNIT" -u "$BRIDGE_UNIT" -b -f
```

Expect FRDM Linux preflight `PASS` lines before remoteproc start, then `MCore started firmware=...` and bridge `Published sequence=... topic=nxp/imx8mplus/temperature/external` messages. Do not run `cat` on the telemetry endpoint concurrently with the bridge. Press Ctrl+C to stop journal following; the applications keep running.

## Observe the external sensor in AWS

In **AWS IoT Core → MQTT test client**, subscribe to `nxp/imx8mplus/temperature/external` using the same account/Region. Verify `thingName=MyNXPIMX8MPlus`, `sensor=BMP280`, advancing sequence/uptime, and plausible temperature. Gently warm the external module and observe the value change and recover.

A deployment status and journal entry do not replace a real observed message. Complete the removal/redeployment test on the next page.


## Additional detail: diagnosing issues

| Failure | Inspect |
| --- | --- |
| S3 denied | Actual UTC/time source and diagnostic error code, then device role, prefix policy, bucket/Region, boundaries and encryption |
| Offline wheel install fails | Actual board Python version and AArch64 wheels declared in the recipe |
| MCU owner refuses startup | Correct image profile, offline core, and no stale owner record |
| RPMsg endpoints missing | Resource-table patch, vring/memory agreement, mailbox, cache settings and RPMSG_TTY |
| No sensor frames | BMP280 chip/address, board-specific bus/pins, pull-ups, and peripheral ownership |
| IPC denied | Recipe operation and exact topic policy |
| Nothing in IoT Core | Certificate publish permission, endpoint/Region and subscriber permissions |

## What you have learned

You can deploy the two Greengrass components, verify operations, and confirm a real external temperature JSON response in AWS IoT Core.
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
title: "NXP FRDM i.MX 8M Plus: Build and test the BMP280 temperature firmware"
description: "Compile the MCU sensor app and validate its operation manually."
weight: 4
layout: "learningpathall"
---

## Build the temperature sensor MCU application ELF

On the Ubuntu host, lets initiate a build of the temperature sensor MCU source:

```bash
source "$HOME/nxp-imx8uplus-zephyr-venv/bin/activate"
export ZEPHYR_WORKSPACE="$HOME/nxp-imx8uplus-zephyr-workspace"
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR="$HOME/zephyr-sdk-0.17.4"
cd "$HOME/nxp-imx8uplus-temperature-part3"
bash setup-zephyr-sdk.sh
bash build-zephyr.sh temperature
python3 inspect-elf.py build/temperature/zephyr/zephyr.elf
"$ZEPHYR_SDK_INSTALL_DIR/arm-zephyr-eabi/bin/arm-zephyr-eabi-readelf" -h -S -l build/temperature/zephyr/zephyr.elf
```

## Manually run the ELF on the MCU and verify sensor connectivity

In a SSH shell on the Ubuntu host, manually copy over the compiled elf to the i.MX8MPLUS dev board:

```bash
scp $HOME/nxp-imx8uplus-temperature-part3/build/temperature/zephyr/zephyr.elf root@OUR_BOARD_IP_ADDRESS:./temperature-zephyr.elf
```

In a SSH onto our dev board, lets manually invoke the elf to confirm it is working:

```bash
ssh root@OUR_BOARD_IP_ADDRESS
nxp-mcore load ./temperature-zephyr.elf
nxp-mcore status
```

You should see output similar to:

```output
device=/sys/class/remoteproc/remoteproc0 name=imx-rproc state=running firmware=nxp-imx8uplus-gg-34be8b5189faa9e9.elf
```

With your access to the MCU UART DEBUG console previously setup, you should see output similar to:

```output
*** Booting Zephyr OS build v4.3.0 ***
NXP FRDM i.MX 8M Plus: Zephyr on application MCU
External BMP280 found at I2C address 0x77
```

Lastly, we can confirm that temperature JSONs are being published locally on the dev board. On the dev board, type:

```bash
stty -F /dev/nxp-temperature raw -echo
printf 'HELLO\n' > /dev/nxp-temperature
timeout 60 cat /dev/nxp-temperature
```

You get approximately 60 seconds of periodic output that resembles:

```output
{"type":"nxp.external.temperature","schema":1,"seq":14,"uptime_ms":70298,"temperature_uC":25730000}
{"type":"nxp.external.temperature","schema":1,"seq":15,"uptime_ms":75308,"temperature_uC":25570000}
{"type":"nxp.external.temperature","schema":1,"seq":16,"uptime_ms":80318,"temperature_uC":25550000}
```

This output indicates that the MCU has proper wiring to the BMP280 temperature sensor and that the elf is correctly reading and publishing temperature values.

We can now stop the ELF:

```bash
nxp-mcore stop
nxp-mcore status
```

Output should resemble:

```output
device=/sys/class/remoteproc/remoteproc0 name=imx-rproc state=offline firmware=rproc-imx-rproc-fw
```

## Additional detail: Acquire and compensate actual temperature

The application detects the BMP280 at `0x76` or `0x77`, verifies chip ID, resets it, reads factory `dig_T1/2/3` calibration, and triggers one forced temperature measurement approximately every five seconds. It skips pressure and uses the signed integer compensation helper tested on the host.

The hundredths-of-a-degree result is scaled into the existing microdegree transport field. It does not imply microdegree sensor precision. A frame looks like:

```json
{"type":"nxp.external.temperature","schema":1,"seq":12,"uptime_ms":60320,"temperature_uC":25080000}
```

A failed sensor read emits a diagnostic and no temperature frame. The bridge does not substitute a SoC thermal reading, a fixed value, or a Linux sensor value. The NXP FRDM i.MX 8M Plus overlay selects the physical bus described on the preparation page.

## Additional Detail: Manage the full MCU lifecycle

The first recipe downloads `zephyr.elf`, `firmware_manager.py` and
`check-linux.py` before installation. `install` validates and stages the ELF.
Before modifying firmware or sysfs, `run` checks FRDM Linux identity, the running
`clk-imx8mp.mcore_booted` argument, exact named reserved-memory ranges, released
UART4 and an offline M7. A failed preflight aborts the start. It then records
ownership, installs a digest-derived firmware filename, starts remoteproc and
completes the control endpoint's HELLO/READY exchange.

On normal SIGTERM, the manager exchanges `STOP` / `QUIESCED`, waits briefly for the MCU to enter WFI, requests remoteproc stop, requires offline state, restores the previous firmware filename, and removes its installed ELF and ownership record. It leaves a safe lock inode and the runtime's own cache infrastructure.


## What you have learned

You can compile the actual NXP FRDM i.MX 8M Plus BMP280 firmware and manually confirm that the firmware runs successfully on the MCU and that the BMP280 temperature sensor is reachable and connected to the firmware when it runs.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading