Add GCC example for rpmsg echo#113
Conversation
Validated on BeaglePlay with kernel 6.12.43-ti-arm64-r54. Signed-off-by: Dimitar Dimitrov <[email protected]>
Using memcpy requires string.h header, so include it. Signed-off-by: Dimitar Dimitrov <[email protected]>
GCC issues the following warning:
../../../../../../source/rpmsg/pru_virtqueue.c:116:18: warning: comparison of integer expressions of different signedness: ‘int16_t’ {aka ‘short int’} and ‘uint32_t’ {aka ‘long unsigned int’} [-Wsign-compare]
116 | if (head > num)
Fix by explicitly using unsigned integers for the comparison.
Negative value should never be passed to pru_virtqueue_add_used_buf
because it is an invalid head. If it is passed, though, making it
unsigned would make it too large, and trigger the early exit with an
error.
Signed-off-by: Dimitar Dimitrov <[email protected]>
GCC issues this warning:
../../../../../../source/include/c_code/linux/pru_virtio_ring.h:138:41: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
138 | vr->used = (void *)(uintptr_t)(((uint64_t)&vr->avail->ring[num]
Fix by using uintptr_t consistently. On the 32-bit PRU the
upper bits of the intermediate result would be discarded anyway by the
second cast to uintptr_t, anyway.
Signed-off-by: Dimitar Dimitrov <[email protected]>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||
|
Hey @dinuxbg, thank you for submitting a pull request! I have not spent any time yet playing with a GCC version of the PRU compiler at this point in time, so please forgive me if my questions are a bit "beginner level".
|
I can add a CI pipeline to verify that the GCC example builds. Looking at this CI pipeline from a GCC user, it should be easy.
I admit that commercial users would probably pick the toolchain provided and supported by the SoC vendor (i.e. PRU-CGT). So if that it is the target for As author and maintainer of the PRU port for GCC, I'm biased. Anyway, here are my reasons for using it:
I know someone tried to port LLVM, but I think it never got finished or mainlined. Since the PRU port of GCC is in mainline, there is only one PRU GCC source code, and it is in the main GCC GIT repository. I provide prebuilt toolchains as a convenience in my gnupru Github page. I'm not aware of anyone else providing prebuilt toolchains, but I've shared my build scripts so anyone is free to do so.
This sounds reasonable. Regards, |
|
Hello @dinuxbg , Ok. Let's keep this PR for updates to the RPMsg libraries, but drop the GCC updates to the rpmsg_echo example. Our team has not done a great job of pointing customers to all the great work you and others are doing in the broader community. I can't promise that we will turn a full 180 degrees (e.g., I joined the beagleboard discord last year, but never have time to read it unless someone points me to a specific post), but I DO want to be more intentional about helping customers to find useful resources, regardless of whether those resources come from TI or from the community. In this PR or a separate PR, it would be great if I could get you to create a separate example, just for showing off GCC.
|
|
Additional notes:
|
Yes, GCC supports arbitrary number of inputs, outputs and clobbers for inline assembly.
The v4 instructions are not yet supported. I plan to add them. |
Good to know, I'll make a mental note about this if any customers ask
I have not yet added the v4 instructions to https://www.ti.com/lit/spruij2. We'll see if I get around to updating that doc in 1H2026, if you need guidance on the v4 instructions in the future feel free to create an e2e thread |
User description
I figured it would be nice to have one example with GCC.
The GCC support is relatively non-intrusive. A few places in shared code required
#ifdefstatements due to different syntax in GCC and CGT.I tested the firmware on BeaglePlay with kernel 6.12.43-ti-arm64-r54.
PR Type
Enhancement, Bug fix
Description
Add GCC compiler support for rpmsg echo example
Fix compiler warnings and compatibility issues
Update resource table initialization for GCC compatibility
Diagram Walkthrough
File Walkthrough
Makefile
GCC build system for PRU rpmsg echoexamples/rpmsg_echo_linux/firmware/am62x-sk/pruss0_pru0_fw/gnu-pru-gcc/Makefile
intc_map.h
INTC mapping header for GCC toolchainexamples/rpmsg_echo_linux/firmware/am62x-sk/pruss0_pru0_fw/gnu-pru-gcc/intc_map.h
main.c
GCC-compatible register access in mainexamples/rpmsg_echo_linux/firmware/main.c
__R31register accesspru/io.hheader instead of direct register declarationpru_intc.h
GCC-compatible INTC register declarationsource/include/c_code/am62x/pru_intc.h
CT_INTCdeclarationresource_table.h
GCC-compatible resource table definitionsource/include/c_code/linux/resource_table.h
__attribute__((section()))instead of pragmaspru_virtio_ring.h
Fix pointer cast warning in vring initsource/include/c_code/linux/pru_virtio_ring.h
vring_initfunctionuint64_ttouintptr_tpru_rpmsg.c
Add missing string.h headersource/rpmsg/pru_rpmsg.c
#include <string.h>headerpru_virtqueue.c
GCC compatibility and signedness warning fixsource/rpmsg/pru_virtqueue.c
__R31register accesspru/io.hheader instead of direct register declarationheadtouint32_t