Use case: GUI with an AI agent
Goal
Add an AD5593R (8-channel ADC, DAC and GPIO) to the devicetree of an Alif Ensemble DK-E8 with the GUI, let the GUI’s Assistant set up its channels, build the devicetree, flash it, and read the channels back in Scopy.
The DK-E8 boots a single devicetree from its MRAM and has no overlay support,
so this project builds a full devicetree (output is devicetree) instead
of an overlay. The steps are the same for a Raspberry Pi, where the result is an
overlay copied to the board.
What you need
Item |
Details |
|---|---|
Board / carrier |
Alif Ensemble DK-E8, running Linux built with Buildroot ( |
Evaluation board / part |
MikroElektronika ADAC Click (AD5593R), in the DK-E8’s mikroBUS socket
(GND towards the centre of the board). Click jumpers: ADDR SEL |
Cables and power |
USB-C to the DK-E8’s PRG USB port (power, flashing and the serial console); Ethernet to the host, for Scopy |
Host |
Linux machine with Analog Attach installed, Alif SETOOLS (to flash the
MRAM), |
Software versions |
Analog Attach 0.2.0, Linux |
Walkthrough video
Steps
Step 1: Prepare the project folder
Build and deploy are the project’s aa_build.sh and aa_deploy.sh. The
starters that analog-attach init writes are for a Raspberry Pi, so for the
DK-E8 put two scripts of your own in the project folder before the setup (the
setup keeps scripts that are there):
aa_build.shcompiles$AA_DTS(the full devicetree, preprocessed) into$AA_DTBwith the kernel’s owndtc, as Buildroot does (without-@, so the DTB fits the DTB area in MRAM).aa_deploy.shpacks$AA_DTBwith the Buildroot images and writes the MRAM with SETOOLS over the PRG USB port.
The board devicetree devkit-e8-adi.dts includes devkit-e8.dts from
its own folder, so the preprocessor needs that folder too. Set the project
variable AA_PREPROCESS_COMMAND (in the GUI: the Project tab):
cpp -nostdinc -undef -x assembler-with-cpp -P -I "$AA_LINUX/include" \
-I "$AA_LINUX/arch/arm/boot/dts/alif/ensemble/devkit" \
-o "$AA_PREPROCESS_OUTPUT" "$AA_PREPROCESS_INPUT"
Step 2: Start the GUI and set up the project
cd ~/aa-demo/adac
analog-attach gui
The setup asks for:
Step |
Value |
|---|---|
Ecosystem |
Linux |
Linux tree |
The kernel Buildroot unpacked, suggested by the GUI:
|
Base devicetree |
|
Overlay: workfile |
|
Overlay: output |
devicetree (the DK-E8 boots one full DTB) |
Then click Create Overlay.
Figure 1 The project setup: the workfile, the overlay syntax and the output
Step 3: Add the AD5593R
Click + Add Device, search for ad5593 and pick adi,ad5593r, on
the bus i2c0 (/apb@49010000/i2c@49010000, the mikroBUS I2C). Pick
adi,ad5593r, not adi,ad5592r: the AD5592R is the SPI version of the
part, and its driver never binds to a node on an I2C bus.
On the new node, set the properties the binding requires:
Property |
Value |
|---|---|
|
|
|
|
|
|
vref-supply stays unset: the part then uses its internal 2.5 V reference.
Step 4: Set up the channels with the Assistant
Open ✦ Assistant and ask, for example:
On the AD5593R add 3 channels: channel 0 as a DAC, channel 1 as an ADC and channel 2 as both. Use numeric adi,mode values. Then validate.
The Assistant runs analog-attach commands only; each one shows in the chat
and in the console, and the tree updates as it goes:
Channel |
|
|
Meaning |
|---|---|---|---|
|
|
|
DAC (drives IO0) |
|
|
|
ADC (reads IO1, wired to IO0) |
|
|
|
DAC and ADC |
adi,mode takes 1 (ADC), 2 (DAC), 3 (DAC and ADC) or 8 (GPIO).
Figure 3 The Assistant adding the channels, the commands it ran in the chat
Step 5: Validate, build and flash
Click Validate: no errors.
Click Build Overlay:
build/adac-click.dtb, the board’s devicetree with the AD5593R in it.Set the DK-E8’s SW4 to SE, then click Deploy. Flashing takes a couple of minutes and ends with
Deploy completed successfully.
Step 6: Boot the board
Set SW4 to U2 (the Linux console on the PRG USB port).
Open the console and press the reset button:
picocom -b 115200 /dev/ttyACM0
Log in as
rootand check the part:# i2cdetect -y -r 0 ... 10: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- # cat /sys/bus/iio/devices/iio:device0/name ad5593r
UU means the driver has the device.
Step 7: Read the channels in Scopy
Connect the Ethernet cable; the DK-E8 runs
iiod.In Scopy, add the device with the URI
ip:<board address>and connect.In IIO Explorer (Debugger), write
ad5593rvoltage0(output)raw: 0 to 4095 is 0 to 2.5 V.In Data Logger, plot
voltage1: it follows the DAC through the IO0–IO1 wire.
Result
The AD5593R probes at boot, its DAC drives IO0 and its ADC reads it back on
IO1: writing 2048 to out_voltage0_raw reads about 2044 on
in_voltage1_raw.
The workfile written by the GUI and the Assistant:
/dts-v1/;
/plugin/;
/ {
fragment@0 {
target = <&i2c0>;
__overlay__ {
ad5593r: dac@10 {
compatible = "adi,ad5593r";
reg = <0x10>;
#address-cells = <1>;
#size-cells = <0>;
channel@0 {
reg = <0>;
adi,mode = <2>;
};
channel@1 {
reg = <1>;
adi,mode = <1>;
};
channel@2 {
reg = <2>;
adi,mode = <3>;
};
};
};
};
};
Troubleshooting
Deploy says “Target did not respond”. SW4 is not fully on SE, or the board needs a power cycle: set SW4 to SE, unplug and plug the PRG USB cable, and deploy again.
The console shows nothing. SW4 must be on U2 for the Linux console, and only one program can have
/dev/ttyACM0open: closepicocombefore deploying.No device at 0x10, no error in dmesg. Check that the node’s compatible is
adi,ad5593r(notadi,ad5592r), that the Click is seated with GND towards the centre of the board, and that ADDR SEL is on 0.The Assistant writes ``CH_MODE_*`` macros. Ask it for the numeric
adi,modevalues instead.
Next steps
Use case template, to write up another board or part.