-
Notifications
You must be signed in to change notification settings - Fork 1k
[MP1] Add RPMsg virtual serial protocol support (VirtIOSerial) #766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Great! |
A workaround for OpenAMP/open-amp#182 has been added. Now
|
25d4aae
to
601e343
Compare
If you talk about files copied in the core then yes they could be removed else ones in OpenAmp no to avoid any issue with OpenAMP update |
After a first quick review, here's my first feedback:
|
Do you mean splitting like other libraries such as STM32duinoBLE? I know this library is very specific to the STM32MP1 series, but one of the main idea of the PR is to take over I hope that VirtIO would be considered as the same level as USB CDC.
Do you mean the default should be |
Yes I'm talking especially about |
No, like a builtin library this is not the exactly the same.
Yes
So yes this could be cleaned |
@kbumsik |
@fpistm Please take your time, the holiday is coming :) |
@arnopo FYI |
Hi @kbumsik, As I proposed some improvement, instead of making a review like usually, I propose a PR in your fork: In addition, I have few questions/remarks:
Why raising an error? why not allowing user to redefine this value ? Is it linked to definition in linux driver ?
If so, maybe you can add a comment before
|
I was just focused on other stuff until this week and now I can look into this PR again. For 1 and 4, this PR currently needs a little bit of cleanup after receiving feedbacks of the initial design, so I will do them after the design is confirmed. Also note that this PR is a redesign of ST's OpenAMP_TTY example. So there are some uncleaned traces from the example code yet. For 2,
yes. The Linux kernel specified the buffer size as 512. You can see this here: https://elixir.bootlin.com/linux/v5.5.2/source/drivers/rpmsg/virtio_rpmsg_bus.c#L137 It was also a guard to make sure the definition is not overritten by rpmsg_virtio.h. I was originally tried to use rpmsg_virtio.h for RPMSG_BUFFER_SIZE but including this header causes problems that comes from the included headers of rpmsg_virtio.h. So I created virtio_config.h and included a checker like this to make sure virtio_config.h is effective. I think it is fine to remove this guard to let developers to adjust the size, as long as the dev don't forget to increase the buffer in the Linux kernel as well. Maybe we can give For 3,
No, also replacing it by The design of the ring buffer is influenced by cdc-queue.h. The ring buffer is introduced to make the original ST's example code mentioned above more general-purpose, and it increases responsiveness of the Linux's synchronous rpmsg channel but not Arduino.
Let's look at the diagram here, the virtio / rpmsg / OpenAMP is implemented using IPCC interrupts and shared memory (MCU SRAM3 region). Imagine A7 send a message to /dev/ttyRPMSG0. A7 sends a packet (max 512 bytes - 16 bytes header) to rvq virtqueue and trigger "new msg" interrupt. The message is stored in vring1 buffer which is associated with rvq. When copying vring1 to our Arduino virtio_buffer is done (thie is what The important thing is that A7's sending the message to /dev/ttyRPMSG0 is fully synchronous operation. The A7 process is blocked until it receives "buf free" interrupt. If M4 don't trigger it in timely manner the A7 process will be blocked indefinitely until it gets kernel timeout error in the worst case. So my idea is to increase virtio_buffer to I will look into your PR and will leave more feedbacks :) |
Hi @kbumsik |
This line originates from the CubeMP1 examples but it is considered legacy and can be removed. stm32duino#766 (comment)
Minors comments then LGTM |
Fixed 😛. Thanks for the review @arnopo 😉 |
@fpistm I made a mistake in the last commit "mbox_ipcc.c: rx_status_t -> mbox_status_t", which is fixed by the following fixup commit. However, the CI somehow passed the build of the failing commit. I guess the CI ignored board options. It should be fixed but I don't know how to locally test Github CI. What is the best way to locally debug the new CI? |
I will check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kbumsik thanks again.
Just on last thing, please, could you do some cleanup in commits (squash,...)?
Thanks in advance.
@fpistm Thanks for approval. Sure, I kept them unclean to preserve the history but it's time to squash. |
For sure 😉 |
2576a9d
to
d585e0b
Compare
Well, it turns out to be it was a great idea to enable CI for VirtIOSerial. Edit: I excluded VirtIO from the failing lines in BareMinimum.ino. See a6dcefe. Tell me if you want to do a different approach. |
2e2d3c3
to
a6dcefe
Compare
Right, that's why I've updated also the CI sketch else this would not be raised. Thanks for the update and the clean PR 👍 🥇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Great job. Thanks
Depends:
This PR currently includes commits from #717. Please look at commits with [VirtIO] title.As #717 is almost being merged I propose VirtIOSerial as promised.
VirtIOSerial.cpp is a virtual serial based on RPMsg messaging protocol, which is built on top of VirtIO.
To clarify the terminologies the OpenAMP project standardizes RPMsg, VirtIO, and etc.
I named it VirtIOSerial because this is the most intuitive name for the most users. The code is based on OpenAMP_TTY_echo example from ST but it is heavily modified for Arduino Stream/Serial implementation.
The work is almost done and VirtIOSerial currently works well, but they are some minor issues needed to be addressed:
OPENAMP_log_dbg()
,log_dbg()
....)__ICCARM__
,__CC_ARM
) to reduce code noise?This is the updated version of README.md
I'm currently testing with the simple example code below:
You can compile & upload the script, and run
sh run_arduino.sh start
. After that you can test it by running minicom:$ TERM=xterm minicom -D /dev/ttyRPMSG0
Edit: there is a better Arduino Sketch to test:
This change is