Attach-detach Feature in the remoteproc Subsystem - 2025.1 English - UG1186

Libmetal and OpenAMP User Guide (UG1186)

Document ID
UG1186
Release Date
2025-05-29
Version
2025.1 English

Introduction

  • There is a use case where RPU is already running firmware before the Linux kernel boot. In this case, Linux cannot load firmware in the RPU. Instead, Linux connects to the running firmware through a special operation in the remoteproc framework called attach. Implementation of attach and detach is platform-specific.
  • To perform the attach operation, the remoteproc driver needs to retrieve the resource table runtime from the firmware. This RPU firmware requires a special metadata that holds the resource table address and size.
  • This resource table metadata structure is pre-defined and the RPU firmware is expected to provide a specific location. This specific location is the start address of the first element of the memory-regions property list in the Linux remoteproc device-tree node.

Resource Table Metadata Structure

The firmware is expected to provide the resource table metadata through the following data structure:

struct remote_resource_table_metadata {
    const int version;  /* version of this data structure */
    const u32 magic_num;  /* 32-bit magic number constant to 78616d70 i.e. 'xamp' characters */
    const u32 comp_magic_num; /* complement of magic number */
    const u32 rsc_tbl_size;  /* size of resource table */
    const uintptr_t rsc_tbl; /* address of resource table */
}__attribute__((packed));

The version of this structure is 1 and is mapped to the order of the structure fields. The magic_num field value is constant: 78616d70, and right after that ~(magic_num) constant which is expected to be: 879e928f.

Linux Driver Parsing

  • During boot, the Linux driver looks for the magic number and the ~(magic number) at the pre-defined memory location. If found, it's assumed that the RPU firmware is loaded and already running.
  • In this case, the attach operation executes and if the resource table was parsed successfully, the Remoteproc state is moved from OFFLINE to ATTACHED.

Once the RPMsg communication is done from the Linux side, it can either stop the remote processor or detach from the remote processor. The difference is that after the stop operation, the RPU powers down and Linux loads the firmware and starts again to run the RPU. However, the detach operation notifies the RPU that Linux is done with the RPMsg communication, but it can attach again meaning that the RPU firmware is still running.