devmem load shell

Browse source code on GitHub

Overview

This module adds a devmem load command that allows data to be loaded into device memory. The devmem load command is supported by every transport the Zephyr shell can run on.

After invoking the command in the Zephyr shell, the device receives the transferred data and writes it to the specified memory address. The transfer ends when the user presses Ctrl+X followed by Ctrl+Q.

Requirements

  • A target configured with the shell interface, exposed through any of its backends.

Building and Running

The sample can be built for several platforms.

Emulation Targets

The sample may run on emulation targets. The following commands build the application for the qemu_x86.

west build -b qemu_x86 samples/subsys/shell/devmem_load
west build -t run

After running the application, the console displays the shell interface, and shows the shell prompt, at which point the user may type in the devmem load command.

Note

When using the devmem load command over UART, it is recommended to use interrupts whenever possible. If this is not possible, reduce the baud rate to 9600.

If you use polling mode, you should also use prj_poll.conf instead of prj.conf.

Building for boards without UART interrupt support:

west build -b native_sim samples/subsys/shell/devmem_load -- -DCONF_FILE=prj_poll.conf
west build -t run

On-Hardware

west build -b nrf52840dk/nrf52840 samples/subsys/shell/shell_module
west flash

Sample Output

After connecting to the UART console, you should see the following output:

uart:~$

The devmem load command can now be used:

uart:~$ devmem load 0x20020000
Loading...
press ctrl-x ctrl-q to escape

At this point, the devmem load command waits for data input. You can either type the data directly from the console or send it from the host PC (replace ttyX with your UART console device):

xxd -p data > /dev/ttyX

Note

It is important to use a plain-style hex dump.

Once the data transfer is complete, use Ctrl+X followed by Ctrl+Q to quit the loader. The shell then displays the number of bytes read and returns to the prompt:

Number of bytes read: 3442
uart:~$

Options

The devmem load command currently supports the following option:

  • -e Interpret data as little endian, e.g. 0xDEADBEFF0xFFBEADDE.

See also

Shell API