OpenAMP support on STM32H747
Requirements
- Communication channel over RPmsg protocol
- IPM driver support for notification
- The
remoteproc
feature needs to be considered on slave for resource management requirement from Linux side. - Endpoints need to be managed by session
- Established OpenAMP sessions must be acknowledged by an initial read/write pair
Implementation
- There are problems with integrating OpenAMP APIs into CPP files, therefore helper functions are implemented in
device/openamp.c
. - The communication channel use
comm_buffer
under the hood, which means high level protocol is stream-based. The first implementation would be OACS command set, and correspondingOpenAMPStream
needs to be implemented. - QEMU implementation on
mps2_an521
helps prototyping as the remote cpu can print messages. The only difference between H747 and MPS2 is that IPM drivers are different. - Cache needs to be configured as write-through on shared memory of H747. This is configured in device tree file.
- Simple implementation of
rpmsg
handshaking and default endpoint establish- m.clear_virtio_status
- m.setup_virtio_region
- m.setup_ipm
- m.setup_vrings
- m.rpmsg_virtio_init_shm_pool
- m.rpmsg_init_vdev
- m.wait_for_slave_response_from_ns_setup
- s.setup_virtio_region
- s.setup_ipm
- s.setup_vrings
- s.rpmsg_virtio_init_shm_pool
- s.rpmsg_init_vdev
- s.ready
- s.register<ept=default>
- s.ipm_notify
- m.ipm_notified
- m.bind<ept=default>
- m.ready
- Typical echo flow
- m.send(msg)
- m.ipm_notify
- s.ipm_notified
- s.recv(msg)
- s.send(msg)
- s.ipm_notify
- m.ipm_notified
- m.recv(msg)
- A default session must exist as long as OpenAMP channel is established. The default session is responsible for conveying heartbeat message and managing other sessions.
- When slave boots up, the
s.rpmsg_init_vdev
call would block and wait for completion ofm.rpmsg_init_vdev
which setsvirtio_status
to OK (as implemented in OpenAMP Framework). Thevirtio_status
locates at a fixed offset of the shared memory. If master is continously running, thevirtio_status
should remain OK, and then slave program should pass as master is already initialized. However, slave program should notify master over IPM that zombie endpoints should be freed. If master boots up in the mean time, care must be taken regarding startup timing asvirtio_status
would be cleared before setting to OK. - When master boots up, the
m.wait_for_slave_response_from_ns_setup
needs to wait for establishing the default session. Unfortunately the slave already established default session which is a zombie one after master reboots. Therefore the master should notify slave over IPM that zombie endpoints should be freed and a new default session should be registered. - There is no
remoteproc
on STM32H7. A common practice is to allow M7 and M4 to boot up individually without clock gating. This is achieved by clearing BCM4 and BCM7 in option bytes. A startup synchronization is required to avoid accessing intermittentvirtio_status
.
由 Victor Chen 编辑于