Skip to content

Add GCC example for rpmsg echo#113

Merged
pratheesh-ti merged 6 commits intoTexasInstruments:mainfrom
dinuxbg:gcc-for-rpmsg-example
May 2, 2026
Merged

Add GCC example for rpmsg echo#113
pratheesh-ti merged 6 commits intoTexasInstruments:mainfrom
dinuxbg:gcc-for-rpmsg-example

Conversation

@dinuxbg
Copy link
Copy Markdown

@dinuxbg dinuxbg commented Feb 19, 2026

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 #ifdef statements 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

    • New Makefile and INTC map header for gnu-pru-gcc toolchain
    • Conditional compilation directives for GCC-specific syntax
  • Fix compiler warnings and compatibility issues

    • Fix signedness comparison warning in pru_virtqueue.c
    • Fix pointer-to-integer cast warning using uintptr_t consistently
    • Add missing string.h header for memcpy usage
  • Update resource table initialization for GCC compatibility

    • Restructure initialization with proper nested braces
    • Add GCC section attribute support

Diagram Walkthrough

flowchart LR
  A["GCC Toolchain Support"] --> B["New Build System"]
  A --> C["Code Compatibility"]
  B --> D["Makefile for gnu-pru-gcc"]
  B --> E["INTC Map Header"]
  C --> F["Conditional Compilation"]
  C --> G["Compiler Warnings Fixed"]
  F --> H["Register Access via pru/io.h"]
  F --> I["Section Attributes"]
  G --> J["Signedness Cast Fix"]
  G --> K["Pointer Cast Fix"]
  G --> L["Missing Header Added"]
Loading

File Walkthrough

Relevant files
Configuration changes
Makefile
GCC build system for PRU rpmsg echo                                           

examples/rpmsg_echo_linux/firmware/am62x-sk/pruss0_pru0_fw/gnu-pru-gcc/Makefile

  • New build system for GCC-based PRU compilation
  • Configures compiler flags, header directories, and source files
  • Defines RPMsg and INTC configuration macros
  • Provides targets for ELF, assembly, and binary image generation
+116/-0 
Enhancement
intc_map.h
INTC mapping header for GCC toolchain                                       

examples/rpmsg_echo_linux/firmware/am62x-sk/pruss0_pru0_fw/gnu-pru-gcc/intc_map.h

  • New header file defining PRU INTC mapping for rpmsg
  • Configures system event 17 mapping to host interrupt
  • Uses conditional compilation for GCC vs CGT syntax
  • Includes documentation on INTC configuration and device tree usage
+53/-0   
main.c
GCC-compatible register access in main                                     

examples/rpmsg_echo_linux/firmware/main.c

  • Add conditional compilation for __R31 register access
  • GCC uses pru/io.h header instead of direct register declaration
  • Maintains compatibility with CGT compiler
+5/-1     
pru_intc.h
GCC-compatible INTC register declaration                                 

source/include/c_code/am62x/pru_intc.h

  • Add conditional compilation for CT_INTC declaration
  • GCC uses macro-based pointer cast instead of cregister attribute
  • Maintains CGT compatibility with pragma directives
+4/-0     
resource_table.h
GCC-compatible resource table definition                                 

source/include/c_code/linux/resource_table.h

  • Add conditional compilation for resource table section placement
  • GCC uses __attribute__((section())) instead of pragmas
  • Restructure initialization with proper nested braces for GCC
  • Maintains compatibility with CGT compiler
+14/-6   
Bug fix
pru_virtio_ring.h
Fix pointer cast warning in vring init                                     

source/include/c_code/linux/pru_virtio_ring.h

  • Fix pointer-to-integer cast warning in vring_init function
  • Change intermediate cast from uint64_t to uintptr_t
  • Ensures consistent pointer size handling across architectures
+1/-1     
pru_rpmsg.c
Add missing string.h header                                                           

source/rpmsg/pru_rpmsg.c

  • Add missing #include <string.h> header
  • Required for memcpy function usage
+1/-0     
pru_virtqueue.c
GCC compatibility and signedness warning fix                         

source/rpmsg/pru_virtqueue.c

  • Add conditional compilation for __R31 register access
  • GCC uses pru/io.h header instead of direct register declaration
  • Fix signedness comparison warning by casting head to uint32_t
  • Ensures negative values are properly handled as invalid heads
+5/-1     

@qodo-code-review
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Build Break

The GCC path uses an __attribute__ with unavailable(...), which is not a standard GCC attribute (commonly Clang-specific). This may break builds on gnu-pru-gcc; consider replacing with a GCC-supported attribute (or omitting it) while still ensuring the symbol is retained/placed in the expected section.

#if !defined(__GNUC__)
  #pragma DATA_SECTION(my_irq_rsc, ".pru_irq_map")
  #pragma RETAIN(my_irq_rsc)
  #define __pru_irq_map		/* */
#else
  #define __pru_irq_map __attribute__((section(".pru_irq_map"),unavailable("pru_irq_map is for usage by the host only")))
#endif

struct pru_irq_rsc my_irq_rsc __pru_irq_map = {
	0,			/* type = 0 */
	1,			/* number of system events being mapped */
	{
		{17, 0, 0},	/* {sysevt, channel, host interrupt} */
	},
};
Boundary Check

The head index validation was changed to cast head to uint32_t before comparison. Verify the intended bounds: typically valid heads are in the range [0, num-1], so the check may need to be >= num (and/or an explicit head < 0 check) to avoid accepting head == num if that is invalid for the ring implementation.

int16_t pru_virtqueue_add_used_buf(
    struct pru_virtqueue	*vq,
    int16_t			head,
    uint32_t			len
)
{
	struct vring_used_elem	*used_elem;
	uint32_t		num;
	struct vring_used	*used;

	num = vq->vring.num;
	used = vq->vring.used;

	if ((uint32_t)head > num)
		return PRU_VIRTQUEUE_INVALID_HEAD;
Build Robustness

The build uses mkdir $(OUT) without -p, which can fail when the directory already exists or in parallel builds. Consider using mkdir -p $(OUT) and (optionally) using order-only prerequisites consistently if parallelism is expected.

$(OUT):
	mkdir $(OUT)

$(ELF): $(SRC) $(HEADERS) | $(OUT)
	$(CROSS_COMPILE)gcc $(CFLAGS) $(SRC) -o $@

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Feb 19, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Consider a more scalable build structure

Instead of adding a toolchain-specific directory like gnu-pru-gcc for build
files, centralize the build logic. A configurable, higher-level system that
selects the toolchain via parameters would improve maintainability.

Examples:

examples/rpmsg_echo_linux/firmware/am62x-sk/pruss0_pru0_fw/gnu-pru-gcc/Makefile [1-116]
# Copyright (c) 2026, Dimitar Dimitrov
#   All rights reserved.
#
#   Redistribution and use in source and binary forms, with or without
#   modification, are permitted provided that the following conditions are met:
#
#   * Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
#   * Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in

 ... (clipped 106 lines)
examples/rpmsg_echo_linux/firmware/am62x-sk/pruss0_pru0_fw/gnu-pru-gcc/intc_map.h [1-53]
#ifndef _INTC_MAP_H_
#define _INTC_MAP_H_

/*
 * ======== PRU INTC Map ========
 *
 * Define the INTC mapping for interrupts going to the ICSS / ICSSG:
 * 	ICSS Host interrupts 0, 1
 * 	ICSSG Host interrupts 0, 1, 10-19
 *

 ... (clipped 43 lines)

Solution Walkthrough:

Before:

/examples/rpmsg_echo_linux/firmware/am62x-sk/pruss0_pru0_fw/
  |- cgt-pru/      # Existing toolchain-specific directory
  |   |- Makefile
  |   |- ...
  |- gnu-pru-gcc/  # New toolchain-specific directory
  |   |- Makefile
  |   |- intc_map.h
  |- main.c

After:

/build/
  |- common.mk # Centralized build logic

/examples/rpmsg_echo_linux/firmware/am62x-sk/pruss0_pru0_fw/
  |- Makefile      # Generic makefile, includes common.mk
  |- main.c
  |- intc_map.h    # Uses ifdefs for toolchain differences
  |- ...

# Build command
# make TOOLCHAIN=gnu-pru-gcc
# make TOOLCHAIN=cgt-pru
Suggestion importance[1-10]: 8

__

Why: This is a strong architectural suggestion that addresses a significant maintainability and scalability issue with the proposed build system structure, which would become problematic as the project grows.

Medium
Possible issue
Fix incorrect signed-to-unsigned comparison

Fix the validation of the head parameter in pru_virtqueue_add_used_buf. Add a
check for head < 0 before the unsigned comparison to correctly handle negative
values, which would otherwise be misinterpreted as large positive indices.

source/rpmsg/pru_virtqueue.c [103-117]

 int16_t pru_virtqueue_add_used_buf(
     struct pru_virtqueue	*vq,
     int16_t			head,
     uint32_t			len
 )
 {
 	struct vring_used_elem	*used_elem;
 	uint32_t		num;
 	struct vring_used	*used;
 
 	num = vq->vring.num;
 	used = vq->vring.used;
 
-	if ((uint32_t)head > num)
+	if (head < 0 || (uint32_t)head >= num)
 		return PRU_VIRTQUEUE_INVALID_HEAD;
 
 	/*
 ...

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a latent bug in the validation logic for the head parameter. The PR's change from head > num to (uint32_t)head > num silences a compiler warning but introduces incorrect behavior for negative head values, which this suggestion fixes.

Medium
Preserve resource table in binary

Add the used attribute to the __resource_table macro. This prevents the compiler
from optimizing away the resourceTable variable, ensuring it is included in the
final binary.

source/include/c_code/linux/resource_table.h [42]

-#define __resource_table __attribute__((section(".resource_table")))
+#define __resource_table __attribute__((section(".resource_table"), used))
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly points out that without the used attribute, the resourceTable might be optimized away by the compiler as an unused variable. Adding __attribute__((used)) ensures this critical table is retained in the final binary.

Medium
Fix incorrect handling of .bss section

In the Makefile, modify the dmem.bin rule to stop including the .bss section in
the output binary. This will reduce the binary size and correctly handle
uninitialized data.

examples/rpmsg_echo_linux/firmware/am62x-sk/pruss0_pru0_fw/gnu-pru-gcc/Makefile [97-102]

 %.dmem.bin : %.elf
 	$(CROSS_COMPILE)objcopy -O binary              \
 	  --only-section=.data*                        \
-	  --only-section=.bss*                         \
-	  --set-section-flags .bss=alloc,load,contents \
 	  $< $@
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that including the .bss section with the contents flag in the binary image is incorrect and inefficient, leading to a larger file size. The proposed change aligns with standard practices for handling .bss sections.

Low
  • Update

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Feb 19, 2026

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@nsaulnier-ti
Copy link
Copy Markdown
Collaborator

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".

  1. At this point in time, your GCC additions are ignored by my PRU-CGT makefiles - so we don't have any build automation in place to make sure that the GCC build does not break in the future. Is that the vision, or were you eventually hoping to add GCC support to the automated build tests?

  2. Can you help me think through the usecases for when someone would want to use the GCC compiler instead of the PRU-CGT compiler?

  3. I have been focused on the TI-supported stuff so far: no programming in the older PASM, only using the TI compiler, etc. So perspectives like yours are useful to expose my blind spots. Are there other PRU compiler options people are using other than PRU-CGT and your gnupru project? I am not clear if GCC pages like this refer specifically to your repository, or if there are multiple versions of the GCC PRU compiler out there that people are using.

  4. This repo is big, and it's going to get much bigger. I want to make it as easy as possible for customers to find the specific information they are looking for. I am concerned that your GCC code is so well hidden that customers might not be able to find it. My initial thought was that it might be better to have a separate GCC project, like this: examples/gcc_project_name, and then include a short description of the GCC project in examples/readme.md. That would also give you a space to provide more information for customers in examples/gcc_project_name/readme.md, link to other trainings, etc. Thoughts?

@dinuxbg
Copy link
Copy Markdown
Author

dinuxbg commented Feb 20, 2026

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".

  1. At this point in time, your GCC additions are ignored by my PRU-CGT makefiles - so we don't have any build automation in place to make sure that the GCC build does not break in the future. Is that the vision, or were you eventually hoping to add GCC support to the automated build tests?

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.

  1. Can you help me think through the usecases for when someone would want to use the GCC compiler instead of the PRU-CGT compiler?

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 open-pru, I would totally understand if you reject this pull request, in order to avoid confusion that TI supports PRU GCC.

As author and maintainer of the PRU port for GCC, I'm biased. Anyway, here are my reasons for using it:

  • GCC is free software, which seems to be appealing to fellow hobbyists.
  • GCC supports the latest language standards (e.g. C23 and C2Y), and numerous extensions.
  • GCC has a really nice static analyzer.
  • GCC has powerful extension for writing snippets of inline assembly inside C functions.
  1. I have been focused on the TI-supported stuff so far: no programming in the older PASM, only using the TI compiler, etc. So perspectives like yours are useful to expose my blind spots. Are there other PRU compiler options people are using other than PRU-CGT and your gnupru project? I am not clear if GCC pages like this refer specifically to your repository, or if there are multiple versions of the GCC PRU compiler out there that people are using.

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.

  1. This repo is big, and it's going to get much bigger. I want to make it as easy as possible for customers to find the specific information they are looking for. I am concerned that your GCC code is so well hidden that customers might not be able to find it. My initial thought was that it might be better to have a separate GCC project, like this: examples/gcc_project_name, and then include a short description of the GCC project in examples/readme.md. That would also give you a space to provide more information for customers in examples/gcc_project_name/readme.md, link to other trainings, etc. Thoughts?

This sounds reasonable.

Regards,
Dimitar

@nsaulnier-ti
Copy link
Copy Markdown
Collaborator

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.

  • Make it look however you want
  • Similar to your current implementation, it is probably cleaner if the example is not included in the top-level makefile build infrastructure
  • Add the project to the examples folder readme
  • Use the project readme as your billboard to point customers to useful resources and pitch people on GCC. For example, I liked a lot of the links you listed above. As long as you state up top that PRU GCC and the GCC example is not supported by TI, anything goes

@nsaulnier-ti
Copy link
Copy Markdown
Collaborator

Additional notes:

  • The ASM functionality for GCC is a fun alternative to our implementation. With the PRU-CGT, the cleanest way I've found to pass data between C and assembly is to use a function call to force variables into known registers, demonstrated in the PRU Getting Started Labs. Not sure if GCC allows more flexibility in returning more than one updated value back to the C code?
  • I am curious if PRU GCC includes support for additional PRU assembly instructions added in silicon v4. It's fairly minor if I understand correctly, related to enabling Task Manager on PRU_ICSSG subsystems

@dinuxbg
Copy link
Copy Markdown
Author

dinuxbg commented Feb 20, 2026

Additional notes:

  • The ASM functionality for GCC is a fun alternative to our implementation. With the PRU-CGT, the cleanest way I've found to pass data between C and assembly is to use a function call to force variables into known registers, demonstrated in the PRU Getting Started Labs. Not sure if GCC allows more flexibility in returning more than one updated value back to the C code?

Yes, GCC supports arbitrary number of inputs, outputs and clobbers for inline assembly.

  • I am curious if PRU GCC includes support for additional PRU assembly instructions added in silicon v4. It's fairly minor if I understand correctly, related to enabling Task Manager on PRU_ICSSG subsystems

The v4 instructions are not yet supported. I plan to add them.

@nsaulnier-ti
Copy link
Copy Markdown
Collaborator

nsaulnier-ti commented Feb 24, 2026

Yes, GCC supports arbitrary number of inputs, outputs and clobbers for inline assembly.

Good to know, I'll make a mental note about this if any customers ask

The v4 instructions are not yet supported. I plan to add them.

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

@dinuxbg dinuxbg force-pushed the gcc-for-rpmsg-example branch from b040fe7 to 58da413 Compare March 29, 2026 17:50
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Add GCC toolchain support for PRU RPMSG echo example with compiler fixes

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Add GCC toolchain support for PRU RPMSG echo example
• Fix compiler warnings and compatibility issues for GCC
• Include missing headers and correct pointer-to-integer casts
• Add CI workflow for GNU toolchain validation
Diagram
flowchart LR
  A["GCC Example<br/>gcc_rpmsg_echo_linux"] --> B["Config & Headers"]
  A --> C["Main Firmware<br/>with Inline ASM"]
  D["Shared RPMSG<br/>Library"] --> E["Compiler Fixes"]
  E --> F["String.h Include"]
  E --> G["Pointer Cast Fix"]
  E --> H["Sign Compare Fix"]
  B --> I["Resource Table<br/>GCC Support"]
  C --> J["Reversed Echo<br/>using ASM"]
  K["CI Workflow"] --> L["GNU Toolchain<br/>Build & Test"]
Loading

Grey Divider

File Changes

1. examples/gcc_rpmsg_echo_linux/config.h ✨ Enhancement +34/-0

PRU instance-specific configuration constants

examples/gcc_rpmsg_echo_linux/config.h


2. examples/gcc_rpmsg_echo_linux/intc_map.h ✨ Enhancement +46/-0

INTC mapping for PRU interrupt configuration

examples/gcc_rpmsg_echo_linux/intc_map.h


3. examples/gcc_rpmsg_echo_linux/main.c ✨ Enhancement +122/-0

RPMSG echo firmware with inline assembly

examples/gcc_rpmsg_echo_linux/main.c


View more (9)
4. examples/gcc_rpmsg_echo_linux/pru_intc.h ✨ Enhancement +9/-0

Wrapper header for GNU toolchain INTC support

examples/gcc_rpmsg_echo_linux/pru_intc.h


5. examples/gcc_rpmsg_echo_linux/Makefile ✨ Enhancement +105/-0

Build configuration for GNU PRU toolchain

examples/gcc_rpmsg_echo_linux/Makefile


6. examples/gcc_rpmsg_echo_linux/README.md 📝 Documentation +38/-0

Documentation for GNU toolchain RPMSG example

examples/gcc_rpmsg_echo_linux/README.md


7. source/include/linux/pru_virtio_ring.h 🐞 Bug fix +1/-1

Fix pointer-to-integer cast for GCC compatibility

source/include/linux/pru_virtio_ring.h


8. source/include/linux/resource_table.h ✨ Enhancement +16/-6

Add GCC attribute support for resource table section

source/include/linux/resource_table.h


9. source/rpmsg/pru_rpmsg.c 🐞 Bug fix +1/-0

Add missing string.h header for memcpy

source/rpmsg/pru_rpmsg.c


10. source/rpmsg/pru_virtqueue.c 🐞 Bug fix +5/-1

Fix GCC compiler warnings and add R31 register support

source/rpmsg/pru_virtqueue.c


11. .github/workflows/gnu-toolchain.yml 🧪 Tests +60/-0

CI workflow for GNU toolchain build validation

.github/workflows/gnu-toolchain.yml


12. examples/readme.md 📝 Documentation +3/-0

Add reference to new GCC RPMSG example

examples/readme.md


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Mar 29, 2026

Code Review by Qodo

🐞 Bugs (4)   📘 Rule violations (11)   📎 Requirement gaps (0)
🐞\ ≡ Correctness (2) ⛨ Security (1) ⚙ Maintainability (1)
📘\ ≡ Correctness (1) ⛨ Security (1) ⚙ Maintainability (9) ⭐ New (1)

Grey Divider


Action required

1. e.g. used in docs 📘
Description
Documentation/comments introduce e.g. which is disallowed by the documentation wording standard.
This reduces documentation consistency across the repo.
Code

examples/gcc_rpmsg_echo_linux/config.h[R4-6]

+ * Show-off here the GCC's "-mmcu=" option, which among other things
+ * automatically defines PRU-instance-specific macros (e.g. __AM62X_PRU0__).
+ * Thus instead of manually changing these constants in the Makefile
Evidence
PR Compliance ID 18 requires using standardized phrases ("for example") instead of e.g.. The new
comment in config.h and the new README text both use e.g..

examples/gcc_rpmsg_echo_linux/config.h[4-6]
examples/gcc_rpmsg_echo_linux/README.md[46-48]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Documentation/comment text uses `e.g.` which is disallowed.

## Issue Context
Project documentation wording must use "for example" instead of `e.g.`.

## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/config.h[4-6]
- examples/gcc_rpmsg_echo_linux/README.md[46-48]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. pru_rpmsg_channel() infinite retry 📘
Description
The code adds busy-wait loops while (!(*status & ...)); and `while (pru_rpmsg_channel(...) !=
...);` with no timeout or escape path, so firmware can hang indefinitely if the host never becomes
ready. This violates the requirement for bounded loops and safe recovery on errors.
Code

examples/gcc_rpmsg_echo_linux/main.c[R75-83]

+	/* Make sure the Linux drivers are ready for RPMsg communication */
+	status = &resourceTable.rpmsg_vdev.status;
+	while (!(*status & VIRTIO_CONFIG_S_DRIVER_OK));
+
+	/* Initialize the RPMsg transport structure */
+	pru_rpmsg_init(&transport, &resourceTable.rpmsg_vring0, &resourceTable.rpmsg_vring1, TO_ARM_HOST, FROM_ARM_HOST);
+
+	/* Create the RPMsg channel between the PRU and ARM user space using the transport structure. */
+	while (pru_rpmsg_channel(RPMSG_NS_CREATE, &transport, CHAN_NAME, CHAN_PORT) != PRU_RPMSG_SUCCESS);
Evidence
The checklist requires termination conditions/bounds for loops and expects recoverable error
handling rather than indefinite spinning; both loops can run forever with no max-iteration/timeout
handling.

examples/gcc_rpmsg_echo_linux/main.c[75-85]
Best Practice: Repository guidelines
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Two new busy-wait loops have no timeout or fallback and can hang the PRU indefinitely if Linux drivers are not ready.
## Issue Context
This is firmware running on PRU; infinite waits prevent any further processing and provide no error signaling/recovery.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/main.c[75-85]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Headers missing TI copyright 📘
Description
New headers config.h, intc_map.h, and pru_intc.h do not include the required Texas Instruments
copyright statement and standard header metadata. This violates the repository requirement for
consistent provenance in source/header files.
Code

examples/gcc_rpmsg_echo_linux/config.h[R1-17]

+
+/* These constants are excellently explained in examples/rpmsg_echo_linux/readme.md.
+ *
+ * Show-off here the GCC's "-mmcu=" option, which among other things
+ * automatically defines PRU-instance-specific macros (e.g. __AM62X_PRU0__).
+ * Thus instead of manually changing these constants in the Makefile
+ * as in the TI CGT example, we can simply define them in this header.
+ * An ifdef block is used for each supported PRU core instance.
+ *
+ *
+ * For a list of supported PRU core instances (a.k.a. MCUs), see
+ *   https://github.com/dinuxbg/gnuprumcu/blob/master/MCU-LIST.md
+ *
+ * For list of defined macros, simply open the correspondingly named
+ * spec file from the above project. Example:
+ *   https://github.com/dinuxbg/gnuprumcu/blob/master/device-specs/am62x.pru0
+ */
Evidence
The compliance checklist requires a standard header (including TI copyright statement) on all
source/header files; the newly added headers begin directly with comments/guards and contain no TI
copyright text.

examples/gcc_rpmsg_echo_linux/config.h[1-17]
examples/gcc_rpmsg_echo_linux/intc_map.h[1-27]
examples/gcc_rpmsg_echo_linux/pru_intc.h[1-9]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New header files are missing the required TI copyright statement and standard header metadata.
## Issue Context
This repo’s compliance checklist requires TI copyright attribution/standard headers in source and header files.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/config.h[1-17]
- examples/gcc_rpmsg_echo_linux/intc_map.h[1-27]
- examples/gcc_rpmsg_echo_linux/pru_intc.h[1-9]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (2)
4. len unchecked before lbbo 📘
Description
The inline-assembly buffer reversal computes p_end = &payload[len-1] and then performs
lbbo/sbbo without validating len is non-zero and within RPMSG_MESSAGE_SIZE. This can
underflow/overflow the buffer and cause out-of-bounds PRU memory accesses and undefined behavior.
Code

examples/gcc_rpmsg_echo_linux/main.c[R93-116]

+				while (pru_rpmsg_receive(&transport, &src, &dst, payload, &len) == PRU_RPMSG_SUCCESS) {
+					/* Show off GCC: Reverse the payload buffer using inline assembly. */
+					uint8_t *p_begin = &payload[0];
+					uint8_t *p_end = &payload[len-1];
+					asm volatile (
+					    "jmp	2f\n\t"			/* Jump forward to local label 2. */
+					    "1:\n\t"
+					    "lbbo	r0.b0, %[R_begin], 0, 1\n\t" /* Load characters at beginning
+											and end of buffer. */
+					    "lbbo	r0.b1, %[R_end], 0, 1\n\t"
+					    "sbbo	r0.b1, %[R_begin], 0, 1\n\t" /* Store, but swapped. */
+					    "sbbo	r0.b0, %[R_end], 0, 1\n\t"
+					    "add	%[R_begin], %[R_begin], 1\n\t" /* Adjust pointers. */
+					    "sub	%[R_end], %[R_end], 1\n\t"
+					    "2:\n\t"
+					    "qblt	1b, %[R_end], %[R_begin]\n\t" /* Jump to local label 1 backward,
+										     if R_begin < R_end. */
+					    : [R_begin] "+r" (p_begin),		/* Register, both read and written to.
+										   See https://gcc.gnu.org/onlinedocs/gcc/Modifiers.html */
+					      [R_end] "+r" (p_end)
+					    : 					/* No input-only operands. */
+					    : "memory",				/* Memory will be clobbered. */
+					      "r0.b0", "r0.b1");		/* clobbered registers (always 8-bit!) */
+					/* Echo the message back to the same address from which we just received */
Evidence
PR Compliance requires bounds/sanity checks before PRU memory accesses (lbbo/sbbo). The new code
derives pointers from len without checking len > 0 and len <= RPMSG_MESSAGE_SIZE, then
reads/writes via lbbo/sbbo using those pointers.

examples/gcc_rpmsg_echo_linux/main.c[93-116]
Best Practice: Repository guidelines
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The code performs PRU inline-assembly `lbbo`/`sbbo` operations using pointers derived from `len` without verifying `len` is valid (non-zero and within the `payload` buffer).
## Issue Context
`p_end = &payload[len-1]` underflows when `len == 0` and can go out-of-bounds if `len > RPMSG_MESSAGE_SIZE`, leading to unsafe PRU memory accesses.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/main.c[93-116]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. IRQ map not retained/portable 🐞
Description
my_irq_rsc is placed in the .pru_irq_map section but is not marked as retained/used and also
uses a non-portable unavailable(...) attribute; because firmware never references this symbol, it
may be stripped or fail to compile depending on toolchain support, preventing remoteproc from
reading the interrupt map.
Code

examples/gcc_rpmsg_echo_linux/intc_map.h[R32-44]

+/*
+ * .pru_irq_map is used by the RemoteProc driver during initialization. However,
+ * the map is NOT used by the PRU firmware. That means DATA_SECTION and RETAIN
+ * are required to prevent the PRU compiler from optimizing out .pru_irq_map.
+ */
+
+struct pru_irq_rsc my_irq_rsc __attribute__((section(".pru_irq_map"),unavailable("pru_irq_map is for usage by the host only"))) = {
+	0,			/* type = 0 */
+	1,			/* number of system events being mapped */
+	{
+		{FROM_ARM_HOST, INTMAP_CHANNEL, INTMAP_HOST},	/* {sysevt, channel, host interrupt} */
+	},
+};
Evidence
The GCC example’s intc_map.h states retention is required because .pru_irq_map is host-consumed
only, yet it only applies section(".pru_irq_map") (no used/retain equivalent) and adds
unavailable(...). The TI CGT reference implementation explicitly uses #pragma RETAIN(my_irq_rsc)
to prevent optimization/removal of this host-only section.

examples/gcc_rpmsg_echo_linux/intc_map.h[32-44]
examples/rpmsg_echo_linux/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/intc_map.h[31-45]
source/include/linux/pru_types.h[65-82]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`my_irq_rsc` is host-only data in `.pru_irq_map`, but it is not clearly prevented from dead-stripping and uses an `unavailable(...)` attribute that is not validated/guarded for the target compiler.
### Issue Context
RemoteProc may rely on this optional section to obtain PRUSS interrupt routing information. The TI-CGT example retains this symbol explicitly.
### Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/intc_map.h[32-44]
### Suggested change
- Replace the current attribute list with a GCC-friendly retention approach, e.g.:
- `__attribute__((section(".pru_irq_map"), used))`
- Remove `unavailable(...)` or guard it behind a feature-test macro (e.g. `#if defined(__has_attribute)` / `__has_attribute(unavailable)`), so GCC builds don’t depend on unsupported attributes.
- If the GNU linker script uses section GC, ensure the linker script keeps `.pru_irq_map` (e.g. `KEEP(*(.pru_irq_map))`) for the GCC flow.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

6. Workflow line exceeds 129 columns 📘
Description
The workflow adds an extremely long echo line containing the full SHA-512 string, exceeding the
maximum column limit. This violates repository-wide formatting constraints and reduces
readability/portability.
Code

.github/workflows/gnu-toolchain.yml[R48-49]

+            echo "23d4a8e8a64400ab73565be5575bc6ea5a3c1f5c06858a03b441e1549427380256ce7b22c3131f7b09d45e941ef133c5d51da38331cfaa338f6b601f21065a3e pru-elf-2025.05.amd64.tar.xz" > pru-elf-2025.05.amd64.sum
+            sha512sum -c pru-elf-2025.05.amd64.sum
Evidence
PR Compliance ID 10 requires no text exceeding column 129 in source files. The added SHA-512 echo
line is far longer than 129 characters.

.github/workflows/gnu-toolchain.yml[48-49]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A workflow script line embeds the entire SHA-512 in one `echo`, exceeding the 129-column limit.
## Issue Context
This is a formatting compliance requirement; keeping lines within limits improves readability and consistency.
## Fix Focus Areas
- .github/workflows/gnu-toolchain.yml[48-49]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Tabs in intc_map.h 📘
Description
examples/gcc_rpmsg_echo_linux/intc_map.h contains tab characters in comments/indentation,
violating the whitespace standard that restricts whitespace to spaces and newlines. This can cause
inconsistent formatting across tools and diffs.
Code

examples/gcc_rpmsg_echo_linux/intc_map.h[R7-10]

+ * Define the INTC mapping for interrupts going to the ICSS / ICSSG:
+ * 	ICSS Host interrupts 0, 1
+ * 	ICSSG Host interrupts 0, 1, 10-19
+ *
Evidence
The formatting checklist disallows tabs and requires consistent whitespace. The added comment lines
in intc_map.h use tab indentation (e.g., before ICSS Host interrupts 0, 1).

examples/gcc_rpmsg_echo_linux/intc_map.h[7-10]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`intc_map.h` includes tab characters, which violates the repo whitespace/formatting standard.
## Issue Context
The PRU formatting checklist requires spaces-only indentation/whitespace for consistent rendering across tooling.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/intc_map.h[7-10]
- examples/gcc_rpmsg_echo_linux/intc_map.h[38-45]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. Workflow has trailing whitespace 📘
Description
The new .github/workflows/gnu-toolchain.yml contains whitespace-only lines and trailing spaces
(e.g., after test -x ... and after the first make command). This violates the repository
formatting requirements.
Code

.github/workflows/gnu-toolchain.yml[R49-60]

+          test -x "$HOME/gnupru/pru-elf-2025.05/bin/pru-gcc"
+          
+      - name: Export toolchain environment
+        run: |
+          {
+            echo "PATH=$PATH:$HOME/gnupru/pru-elf-2025.05/bin"
+          } >> $GITHUB_ENV
+          
+      - name: Build examples folder
+        run: |
+          make -C examples/gcc_rpmsg_echo_linux -j$(nproc) 
+          make -C examples/gcc_rpmsg_echo_linux -j$(nproc) MCU_DEVICE=am62x.pru1
Evidence
The formatting rule disallows trailing whitespace and inconsistent whitespace patterns; the added
workflow includes whitespace-only lines and commands with trailing spaces.

.github/workflows/gnu-toolchain.yml[49-60]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Workflow YAML includes whitespace-only lines and trailing spaces.
## Issue Context
Repo formatting rules disallow trailing whitespace and inconsistent whitespace patterns.
## Fix Focus Areas
- .github/workflows/gnu-toolchain.yml[49-60]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (7)
9. Tabs in main.c 📘
Description
The new GCC example source uses tab characters for alignment (e.g., in macro definitions like
#define VIRTIO_CONFIG_S_DRIVER_OK        4) rather than 4-space indentation. This violates the
repository formatting rules and can cause inconsistent rendering across tools.
Code

examples/gcc_rpmsg_echo_linux/main.c[R37-60]

+#define HOST_INT			((uint32_t) 1 << HOST_INT_BIT)
+
+/*
+ * FROM_ARM_HOST < 32 for all cores, so (ENA_STATUS_REG0 & FROM_ARM_HOST_BIT)
+ * can be used to check the status of the system event.
+ */
+#define FROM_ARM_HOST_BIT		((uint32_t) 1 << FROM_ARM_HOST)
+
+/* 
+ * RPMSG CONFIGURATION
+ *
+ * Using the name 'rpmsg-raw' will probe the Linux rpmsg_char driver
+ * at linux-x.y.z/drivers/rpmsg/rpmsg_char.c
+ *
+ * Each PRU subsystem core should have a unique channel port (endpoint)
+ */
+#define CHAN_NAME                       "rpmsg-raw"
+
+/*
+ * Used to make sure the Linux drivers are ready for RPMsg communication
+ * Found at linux-x.y.z/include/uapi/linux/virtio_config.h
+ */
+#define VIRTIO_CONFIG_S_DRIVER_OK	4
+
Evidence
The formatting checklist prohibits tabs and requires consistent 4-space indentation; the new file
contains tabs in macro alignment and other lines.

examples/gcc_rpmsg_echo_linux/main.c[37-60]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`main.c` uses tab characters for alignment instead of 4-space indentation.
## Issue Context
Formatting compliance requires no tabs and consistent indentation.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/main.c[37-60]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


10. Virtqueue head bounds wrong 🐞
Description
pru_virtqueue_add_used_buf allows head == num because it checks head > num instead of `head >=
num, but descriptor indices are only valid in [0, num-1]`. This can lead to out-of-bounds access
because the code uses head as an index into vq->vring.desc[head].
Code

source/rpmsg/pru_virtqueue.c[R116-117]

+	if ((uint32_t)head > num)
return PRU_VIRTQUEUE_INVALID_HEAD;
Evidence
num is set from vq->vring.num, while head is used directly as an index into the descriptor
array (vq->vring.desc[head]). With head == num, the current guard in
pru_virtqueue_add_used_buf would not reject the value (since head > num is false).

source/rpmsg/pru_virtqueue.c[74-99]
source/rpmsg/pru_virtqueue.c[103-127]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The bounds check in `pru_virtqueue_add_used_buf` is off-by-one (`head > num`) and does not reject `head == num`. Descriptor indices must be `< num`.
### Issue Context
`head` is later used as an index into `vq->vring.desc[head]` (in `pru_virtqueue_get_avail_buf`), so accepting an out-of-range head can cause memory corruption or crashes.
### Fix Focus Areas
- source/rpmsg/pru_virtqueue.c[94-99]
- source/rpmsg/pru_virtqueue.c[113-118]
### Suggested fix
- Change the check to reject `head < 0` and `head >= num`, e.g.:
- `if (head < 0 || (uint32_t)head >= num) return PRU_VIRTQUEUE_INVALID_HEAD;`
- Also consider adding the same validation in `pru_virtqueue_get_avail_buf` before indexing `vq->vring.desc[head]`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


11. README shell commands unfenced 📘
Description
The documentation presents shell commands as indented text rather than fenced code blocks. This
violates the requirement to use fenced blocks for copy/paste-safe shell commands.
Code

examples/gcc_rpmsg_echo_linux/README.md[R16-24]

+## Compiling the example
+
+	cd examples/gcc_rpmsg_echo_linux
+	make MCU_DEVICE=am62x.pru0
+
+Or, if compiling for the other PRU core:
+
+	make MCU_DEVICE=am62x.pru1
+
Evidence
PR Compliance requires shell commands in documentation to be shown in fenced code blocks (```), but
the added README uses indented command lines instead.

examples/gcc_rpmsg_echo_linux/README.md[16-24]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Shell commands in the README are not in fenced code blocks.
## Issue Context
Indented commands may wrap or copy incorrectly; the compliance standard requires fenced blocks.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/README.md[16-24]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


12. README lines exceed 129 📘
Description
The new README contains multiple lines longer than the 129-column hard limit and is not reflowed to
the preferred line length. This reduces readability and violates documentation style requirements.
Code

examples/gcc_rpmsg_echo_linux/README.md[R3-14]

+This is an RPMSG firmware built using the GNU toolchain for PRU. This firmware is the classical RPMSG echo example from Texas Instruments, but with a twist to show-off some GCC features. The returned echo string is reversed using inline assembly routine.
+
+WARNING: Neither the GNU PRU toolchain nor this example are supported by Texas Instruments!
+
+## Getting the GNU toolchain for PRU
+
+Convenient prebuilt toolchain binaries are offered [here](https://github.com/dinuxbg/gnupru/releases). They are prepared by the same hobbyist, who also maintains the PRU port for GCC and Binutils. This toolchain includes:
+  * [GCC](https://gcc.gnu.org/) compiler.
+  * [Binutils](https://www.gnu.org/software/binutils/) assembler, linker and tools.
+  * [newlib](https://sourceware.org/newlib/) C library.
+
+Being free software, the GNU toolchain can also be built from sources. PRU support has been mainlined, and is part of recent official source releases for GCC, Binutils and newlib. Apart from official GNU sources, you need only a [small additional package](https://github.com/dinuxbg/gnuprumcu) for SoC-specific support in order to [build the toolchain](https://github.com/dinuxbg/gnupru/?tab=readme-ov-file#building-from-sources) by yourself.
Evidence
The documentation style compliance requires reflowed text and adherence to preferred line lengths;
multiple added README lines exceed 129 characters (e.g., line 3 and other paragraphs).

examples/gcc_rpmsg_echo_linux/README.md[3-14]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Several README lines exceed the hard line-length limit and should be reflowed.
## Issue Context
Long unwrapped lines reduce readability and violate the documentation style rules.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/README.md[3-14]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


13. my_irq_rsc line too long 📘
Description
The my_irq_rsc declaration line exceeds the 129-column hard limit. This violates the repository
formatting standard for line length.
Code

examples/gcc_rpmsg_echo_linux/intc_map.h[38]

+struct pru_irq_rsc my_irq_rsc __attribute__((section(".pru_irq_map"),unavailable("pru_irq_map is for usage by the host only"))) = {
Evidence
The formatting standard requires lines to never exceed 129 columns; the added declaration with the
__attribute__(...) string exceeds that limit.

examples/gcc_rpmsg_echo_linux/intc_map.h[38-38]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A source line exceeds the 129-character hard limit.
## Issue Context
`my_irq_rsc` includes a long `__attribute__((...))` annotation that should be wrapped for compliance.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/intc_map.h[38-38]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


14. Toolchain download unverified 🐞
Description
The new GitHub Actions workflow downloads and extracts a prebuilt toolchain tarball without
checksum/signature verification, creating a CI supply-chain risk.
Code

.github/workflows/gnu-toolchain.yml[R39-46]

+          # Install gnupru-2025.05
+          if [ ! -d "$HOME/gnupru/pru-elf-2025.05" ]; then
+            cd "$HOME/gnupru/downloads"
+            wget -q --retry-connrefused --waitretry=1 --tries=5 --timeout=30 \
+              https://github.com/dinuxbg/gnupru/releases/download/2025.05/pru-elf-2025.05.amd64.tar.xz
+            cd "$HOME/gnupru"
+            tar xaf "$HOME/gnupru/downloads/pru-elf-2025.05.amd64.tar.xz"
+            mv pru-elf pru-elf-2025.05
Evidence
The workflow uses wget to fetch a tarball and immediately extracts it via tar xaf with no
integrity check (no sha256sum/GPG verification).

.github/workflows/gnu-toolchain.yml[39-46]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
CI installs an externally downloaded toolchain without verifying integrity.
### Issue Context
A compromised release artifact or network-path attack could execute arbitrary code during CI.
### Fix Focus Areas
- .github/workflows/gnu-toolchain.yml[39-46]
### Suggested change
- Add a pinned SHA256 (or GPG signature) verification step before extracting, e.g. download a `.sha256` file from the same release (or hardcode the expected hash) and run `sha256sum -c`.
- Consider pinning to an immutable artifact digest if available.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


15. Header deps ineffective 🐞
Description
The GCC example Makefile attempts to manually list headers for dependency tracking, but places them
as order-only prerequisites, so header changes will not trigger a rebuild of the ELF during
incremental builds.
Code

examples/gcc_rpmsg_echo_linux/Makefile[R96-97]

+$(ELF): $(SRC) | $(HEADERS) $(OUT)
+	$(CROSS_COMPILE)gcc $(CFLAGS) $(SRC) -o $@
Evidence
The Makefile explicitly avoids -MMD dependency generation and instead builds a HEADERS list, but
HEADERS appear after the | separator, making them order-only (not rebuild-triggering). There is
also no .d generation/inclusion, so header modifications won’t be tracked otherwise.

examples/gcc_rpmsg_echo_linux/Makefile[64-67]
examples/gcc_rpmsg_echo_linux/Makefile[96-97]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Header edits won’t cause an incremental rebuild because `HEADERS` are order-only prerequisites and there is no generated dependency mechanism.
### Issue Context
The Makefile comment says headers are manually listed due to `-MMD` limitations, so the manual list must be a real prerequisite.
### Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/Makefile[64-67]
- examples/gcc_rpmsg_echo_linux/Makefile[96-97]
### Suggested change
Change the rule to make headers normal prerequisites and keep only the output directory order-only, e.g.:
- `$(ELF): $(SRC) $(HEADERS) | $(OUT)`
This way, touching any header in `HEADERS` forces a rebuild of the ELF.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Grey Divider

Previous review results

Review updated until commit ca22512

Results up to commit 5602037


🐞 Bugs (4)  
📘 Rule violations (10)  
📎 Requirement gaps (0)  
🎨 UX Issues (0)

Grey Divider
Action required
1. pru_rpmsg_channel() infinite retry 📘
Description
The code adds busy-wait loops while (!(*status & ...)); and `while (pru_rpmsg_channel(...) !=
...);` with no timeout or escape path, so firmware can hang indefinitely if the host never becomes
ready. This violates the requirement for bounded loops and safe recovery on errors.
Code

examples/gcc_rpmsg_echo_linux/main.c[R75-83]

+	/* Make sure the Linux drivers are ready for RPMsg communication */
+	status = &resourceTable.rpmsg_vdev.status;
+	while (!(*status & VIRTIO_CONFIG_S_DRIVER_OK));
+
+	/* Initialize the RPMsg transport structure */
+	pru_rpmsg_init(&transport, &resourceTable.rpmsg_vring0, &resourceTable.rpmsg_vring1, TO_ARM_HOST, FROM_ARM_HOST);
+
+	/* Create the RPMsg channel between the PRU and ARM user space using the transport structure. */
+	while (pru_rpmsg_channel(RPMSG_NS_CREATE, &transport, CHAN_NAME, CHAN_PORT) != PRU_RPMSG_SUCCESS);
Evidence
The checklist requires termination conditions/bounds for loops and expects recoverable error
handling rather than indefinite spinning; both loops can run forever with no max-iteration/timeout
handling.

examples/gcc_rpmsg_echo_linux/main.c[75-85]
Best Practice: Repository guidelines
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Two new busy-wait loops have no timeout or fallback and can hang the PRU indefinitely if Linux drivers are not ready.
## Issue Context
This is firmware running on PRU; infinite waits prevent any further processing and provide no error signaling/recovery.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/main.c[75-85]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Headers missing TI copyright 📘
Description
New headers config.h, intc_map.h, and pru_intc.h do not include the required Texas Instruments
copyright statement and standard header metadata. This violates the repository requirement for
consistent provenance in source/header files.
Code

examples/gcc_rpmsg_echo_linux/config.h[R1-17]

+
+/* These constants are excellently explained in examples/rpmsg_echo_linux/readme.md.
+ *
+ * Show-off here the GCC's "-mmcu=" option, which among other things
+ * automatically defines PRU-instance-specific macros (e.g. __AM62X_PRU0__).
+ * Thus instead of manually changing these constants in the Makefile
+ * as in the TI CGT example, we can simply define them in this header.
+ * An ifdef block is used for each supported PRU core instance.
+ *
+ *
+ * For a list of supported PRU core instances (a.k.a. MCUs), see
+ *   https://github.com/dinuxbg/gnuprumcu/blob/master/MCU-LIST.md
+ *
+ * For list of defined macros, simply open the correspondingly named
+ * spec file from the above project. Example:
+ *   https://github.com/dinuxbg/gnuprumcu/blob/master/device-specs/am62x.pru0
+ */
Evidence
The compliance checklist requires a standard header (including TI copyright statement) on all
source/header files; the newly added headers begin directly with comments/guards and contain no TI
copyright text.

examples/gcc_rpmsg_echo_linux/config.h[1-17]
examples/gcc_rpmsg_echo_linux/intc_map.h[1-27]
examples/gcc_rpmsg_echo_linux/pru_intc.h[1-9]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New header files are missing the required TI copyright statement and standard header metadata.
## Issue Context
This repo’s compliance checklist requires TI copyright attribution/standard headers in source and header files.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/config.h[1-17]
- examples/gcc_rpmsg_echo_linux/intc_map.h[1-27]
- examples/gcc_rpmsg_echo_linux/pru_intc.h[1-9]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. len unchecked before lbbo 📘
Description
The inline-assembly buffer reversal computes p_end = &payload[len-1] and then performs
lbbo/sbbo without validating len is non-zero and within RPMSG_MESSAGE_SIZE. This can
underflow/overflow the buffer and cause out-of-bounds PRU memory accesses and undefined behavior.
Code

examples/gcc_rpmsg_echo_linux/main.c[R93-116]

+				while (pru_rpmsg_receive(&transport, &src, &dst, payload, &len) == PRU_RPMSG_SUCCESS) {
+					/* Show off GCC: Reverse the payload buffer using inline assembly. */
+					uint8_t *p_begin = &payload[0];
+					uint8_t *p_end = &payload[len-1];
+					asm volatile (
+					    "jmp	2f\n\t"			/* Jump forward to local label 2. */
+					    "1:\n\t"
+					    "lbbo	r0.b0, %[R_begin], 0, 1\n\t" /* Load characters at beginning
+											and end of buffer. */
+					    "lbbo	r0.b1, %[R_end], 0, 1\n\t"
+					    "sbbo	r0.b1, %[R_begin], 0, 1\n\t" /* Store, but swapped. */
+					    "sbbo	r0.b0, %[R_end], 0, 1\n\t"
+					    "add	%[R_begin], %[R_begin], 1\n\t" /* Adjust pointers. */
+					    "sub	%[R_end], %[R_end], 1\n\t"
+					    "2:\n\t"
+					    "qblt	1b, %[R_end], %[R_begin]\n\t" /* Jump to local label 1 backward,
+										     if R_begin < R_end. */
+					    : [R_begin] "+r" (p_begin),		/* Register, both read and written to.
+										   See https://gcc.gnu.org/onlinedocs/gcc/Modifiers.html */
+					      [R_end] "+r" (p_end)
+					    : 					/* No input-only operands. */
+					    : "memory",				/* Memory will be clobbered. */
+					      "r0.b0", "r0.b1");		/* clobbered registers (always 8-bit!) */
+					/* Echo the message back to the same address from which we just received */
Evidence
PR Compliance requires bounds/sanity checks before PRU memory accesses (lbbo/sbbo). The new code
derives pointers from len without checking len > 0 and len <= RPMSG_MESSAGE_SIZE, then
reads/writes via lbbo/sbbo using those pointers.

examples/gcc_rpmsg_echo_linux/main.c[93-116]
Best Practice: Repository guidelines
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The code performs PRU inline-assembly `lbbo`/`sbbo` operations using pointers derived from `len` without verifying `len` is valid (non-zero and within the `payload` buffer).
## Issue Context
`p_end = &payload[len-1]` underflows when `len == 0` and can go out-of-bounds if `len > RPMSG_MESSAGE_SIZE`, leading to unsafe PRU memory accesses.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/main.c[93-116]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
4. IRQ map not retained/portable 🐞
Description
my_irq_rsc is placed in the .pru_irq_map section but is not marked as retained/used and also
uses a non-portable unavailable(...) attribute; because firmware never references this symbol, it
may be stripped or fail to compile depending on toolchain support, preventing remoteproc from
reading the interrupt map.
Code

examples/gcc_rpmsg_echo_linux/intc_map.h[R32-44]

+/*
+ * .pru_irq_map is used by the RemoteProc driver during initialization. However,
+ * the map is NOT used by the PRU firmware. That means DATA_SECTION and RETAIN
+ * are required to prevent the PRU compiler from optimizing out .pru_irq_map.
+ */
+
+struct pru_irq_rsc my_irq_rsc __attribute__((section(".pru_irq_map"),unavailable("pru_irq_map is for usage by the host only"))) = {
+	0,			/* type = 0 */
+	1,			/* number of system events being mapped */
+	{
+		{FROM_ARM_HOST, INTMAP_CHANNEL, INTMAP_HOST},	/* {sysevt, channel, host interrupt} */
+	},
+};
Evidence
The GCC example’s intc_map.h states retention is required because .pru_irq_map is host-consumed
only, yet it only applies section(".pru_irq_map") (no used/retain equivalent) and adds
unavailable(...). The TI CGT reference implementation explicitly uses #pragma RETAIN(my_irq_rsc)
to prevent optimization/removal of this host-only section.

examples/gcc_rpmsg_echo_linux/intc_map.h[32-44]
examples/rpmsg_echo_linux/firmware/am62x-sk/pruss0_pru0_fw/ti-pru-cgt/intc_map.h[31-45]
source/include/linux/pru_types.h[65-82]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`my_irq_rsc` is host-only data in `.pru_irq_map`, but it is not clearly prevented from dead-stripping and uses an `unavailable(...)` attribute that is not validated/guarded for the target compiler.
### Issue Context
RemoteProc may rely on this optional section to obtain PRUSS interrupt routing information. The TI-CGT example retains this symbol explicitly.
### Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/intc_map.h[32-44]
### Suggested change
- Replace the current attribute list with a GCC-friendly retention approach, e.g.:
- `__attribute__((section(".pru_irq_map"), used))`
- Remove `unavailable(...)` or guard it behind a feature-test macro (e.g. `#if defined(__has_attribute)` / `__has_attribute(unavailable)`), so GCC builds don’t depend on unsupported attributes.
- If the GNU linker script uses section GC, ensure the linker script keeps `.pru_irq_map` (e.g. `KEEP(*(.pru_irq_map))`) for the GCC flow.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
5. Workflow line exceeds 129 columns 📘
Description
The workflow adds an extremely long echo line containing the full SHA-512 string, exceeding the
maximum column limit. This violates repository-wide formatting constraints and reduces
readability/portability.
Code

.github/workflows/gnu-toolchain.yml[R48-49]

+            echo "23d4a8e8a64400ab73565be5575bc6ea5a3c1f5c06858a03b441e1549427380256ce7b22c3131f7b09d45e941ef133c5d51da38331cfaa338f6b601f21065a3e pru-elf-2025.05.amd64.tar.xz" > pru-elf-2025.05.amd64.sum
+            sha512sum -c pru-elf-2025.05.amd64.sum
Evidence
PR Compliance ID 10 requires no text exceeding column 129 in source files. The added SHA-512 echo
line is far longer than 129 characters.

.github/workflows/gnu-toolchain.yml[48-49]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A workflow script line embeds the entire SHA-512 in one `echo`, exceeding the 129-column limit.

## Issue Context
This is a formatting compliance requirement; keeping lines within limits improves readability and consistency.

## Fix Focus Areas
- .github/workflows/gnu-toolchain.yml[48-49]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Tabs in intc_map.h 📘
Description
examples/gcc_rpmsg_echo_linux/intc_map.h contains tab characters in comments/indentation,
violating the whitespace standard that restricts whitespace to spaces and newlines. This can cause
inconsistent formatting across tools and diffs.
Code

examples/gcc_rpmsg_echo_linux/intc_map.h[R7-10]

+ * Define the INTC mapping for interrupts going to the ICSS / ICSSG:
+ * 	ICSS Host interrupts 0, 1
+ * 	ICSSG Host interrupts 0, 1, 10-19
+ *
Evidence
The formatting checklist disallows tabs and requires consistent whitespace. The added comment lines
in intc_map.h use tab indentation (e.g., before ICSS Host interrupts 0, 1).

examples/gcc_rpmsg_echo_linux/intc_map.h[7-10]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`intc_map.h` includes tab characters, which violates the repo whitespace/formatting standard.
## Issue Context
The PRU formatting checklist requires spaces-only indentation/whitespace for consistent rendering across tooling.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/intc_map.h[7-10]
- examples/gcc_rpmsg_echo_linux/intc_map.h[38-45]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Workflow has trailing whitespace 📘
Description
The new .github/workflows/gnu-toolchain.yml contains whitespace-only lines and trailing spaces
(e.g., after test -x ... and after the first make command). This violates the repository
formatting requirements.
Code

.github/workflows/gnu-toolchain.yml[R49-60]

+          test -x "$HOME/gnupru/pru-elf-2025.05/bin/pru-gcc"
+          
+      - name: Export toolchain environment
+        run: |
+          {
+            echo "PATH=$PATH:$HOME/gnupru/pru-elf-2025.05/bin"
+          } >> $GITHUB_ENV
+          
+      - name: Build examples folder
+        run: |
+          make -C examples/gcc_rpmsg_echo_linux -j$(nproc) 
+          make -C examples/gcc_rpmsg_echo_linux -j$(nproc) MCU_DEVICE=am62x.pru1
Evidence
The formatting rule disallows trailing whitespace and inconsistent whitespace patterns; the added
workflow includes whitespace-only lines and commands with trailing spaces.

.github/workflows/gnu-toolchain.yml[49-60]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Workflow YAML includes whitespace-only lines and trailing spaces.
## Issue Context
Repo formatting rules disallow trailing whitespace and inconsistent whitespace patterns.
## Fix Focus Areas
- .github/workflows/gnu-toolchain.yml[49-60]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (7)
8. Tabs in main.c 📘
Description
The new GCC example source uses tab characters for alignment (e.g., in macro definitions like
#define VIRTIO_CONFIG_S_DRIVER_OK        4) rather than 4-space indentation. This violates the
repository formatting rules and can cause inconsistent rendering across tools.
Code

examples/gcc_rpmsg_echo_linux/main.c[R37-60]

+#define HOST_INT			((uint32_t) 1 << HOST_INT_BIT)
+
+/*
+ * FROM_ARM_HOST < 32 for all cores, so (ENA_STATUS_REG0 & FROM_ARM_HOST_BIT)
+ * can be used to check the status of the system event.
+ */
+#define FROM_ARM_HOST_BIT		((uint32_t) 1 << FROM_ARM_HOST)
+
+/* 
+ * RPMSG CONFIGURATION
+ *
+ * Using the name 'rpmsg-raw' will probe the Linux rpmsg_char driver
+ * at linux-x.y.z/drivers/rpmsg/rpmsg_char.c
+ *
+ * Each PRU subsystem core should have a unique channel port (endpoint)
+ */
+#define CHAN_NAME                       "rpmsg-raw"
+
+/*
+ * Used to make sure the Linux drivers are ready for RPMsg communication
+ * Found at linux-x.y.z/include/uapi/linux/virtio_config.h
+ */
+#define VIRTIO_CONFIG_S_DRIVER_OK	4
+
Evidence
The formatting checklist prohibits tabs and requires consistent 4-space indentation; the new file
contains tabs in macro alignment and other lines.

examples/gcc_rpmsg_echo_linux/main.c[37-60]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`main.c` uses tab characters for alignment instead of 4-space indentation.
## Issue Context
Formatting compliance requires no tabs and consistent indentation.
## Fix Focus Areas
- examples/gcc_rpmsg_echo_linux/main.c[37-60]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


9. Virtqueue head bounds wrong 🐞
Description
pru_virtqueue_add_used_buf allows head == num because it checks head > num instead of `head >=
num, but descriptor indices are only valid in [0, num-1]`. This can lead to out-of-bounds access
because the code uses head as an index into vq->vring.desc[head].
Code

[source/rpmsg/pru_virtqueue.c[R116-117]](https://github.com/TexasInstruments/open-pru/pul...

Comment thread examples/gcc_rpmsg_echo_linux/main.c
Comment thread examples/gcc_rpmsg_echo_linux/intc_map.h
@dinuxbg dinuxbg force-pushed the gcc-for-rpmsg-example branch from 58da413 to 63757ef Compare March 29, 2026 18:07
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Add GCC toolchain support for PRU RPMSG echo example

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Add GCC toolchain support for PRU RPMSG echo example
• Fix compiler warnings and compatibility issues for GCC
• Include missing header and fix pointer-to-integer casts
• Add CI workflow for GNU toolchain validation
Diagram
flowchart LR
  A["Shared RPMSG Library"] -->|"Fix warnings"| B["pru_virtqueue.c"]
  A -->|"Add missing header"| C["pru_rpmsg.c"]
  A -->|"Fix pointer cast"| D["pru_virtio_ring.h"]
  E["Resource Table"] -->|"Add GCC pragmas"| F["resource_table.h"]
  G["GCC Example"] -->|"New files"| H["gcc_rpmsg_echo_linux/"]
  H -->|"Contains"| I["main.c, config.h, intc_map.h"]
  J["CI Pipeline"] -->|"Validate build"| K["gnu-toolchain.yml"]
Loading

Grey Divider

File Changes

1. source/rpmsg/pru_rpmsg.c 🐞 Bug fix +1/-0

Add missing string.h header for memcpy

source/rpmsg/pru_rpmsg.c


2. source/rpmsg/pru_virtqueue.c 🐞 Bug fix +5/-1

Fix signedness comparison warning and add GCC R31 support

source/rpmsg/pru_virtqueue.c


3. source/include/linux/pru_virtio_ring.h 🐞 Bug fix +1/-1

Fix pointer-to-integer cast using uintptr_t

source/include/linux/pru_virtio_ring.h


View more (9)
4. source/include/linux/resource_table.h ✨ Enhancement +16/-6

Add GCC attribute support for linker sections

source/include/linux/resource_table.h


5. examples/gcc_rpmsg_echo_linux/main.c ✨ Enhancement +127/-0

New GCC RPMSG echo example with inline assembly

examples/gcc_rpmsg_echo_linux/main.c


6. examples/gcc_rpmsg_echo_linux/config.h ✨ Enhancement +34/-0

Configuration for PRU instance-specific RPMSG parameters

examples/gcc_rpmsg_echo_linux/config.h


7. examples/gcc_rpmsg_echo_linux/intc_map.h ✨ Enhancement +47/-0

INTC interrupt mapping for GCC RPMSG example

examples/gcc_rpmsg_echo_linux/intc_map.h


8. examples/gcc_rpmsg_echo_linux/pru_intc.h ✨ Enhancement +9/-0

Wrapper header for GNU toolchain PRU IO definitions

examples/gcc_rpmsg_echo_linux/pru_intc.h


9. examples/gcc_rpmsg_echo_linux/Makefile ✨ Enhancement +105/-0

Build configuration for GNU PRU toolchain compilation

examples/gcc_rpmsg_echo_linux/Makefile


10. examples/gcc_rpmsg_echo_linux/README.md 📝 Documentation +54/-0

Documentation for GNU toolchain RPMSG example usage

examples/gcc_rpmsg_echo_linux/README.md


11. examples/readme.md 📝 Documentation +3/-0

Add reference to new GCC RPMSG example

examples/readme.md


12. .github/workflows/gnu-toolchain.yml 🧪 Tests +60/-0

CI workflow for GNU toolchain build validation

.github/workflows/gnu-toolchain.yml


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Mar 29, 2026

Persistent review updated to latest commit 63757ef

Comment thread examples/gcc_rpmsg_echo_linux/main.c
Comment thread examples/gcc_rpmsg_echo_linux/config.h
@dinuxbg dinuxbg force-pushed the gcc-for-rpmsg-example branch from 63757ef to cba7115 Compare March 29, 2026 18:14
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Add GCC toolchain support for RPMSG echo example with CI

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Add GCC toolchain support for PRU RPMSG echo example
• Fix compiler warnings and portability issues in shared code
• Include GNU toolchain CI workflow for automated builds
• Create new example with inline assembly demonstration
Diagram
flowchart LR
  A["Shared RPMSG Library"] -->|Fix warnings| B["pru_virtqueue.c<br/>pru_rpmsg.c"]
  A -->|Fix pointer cast| C["pru_virtio_ring.h"]
  A -->|Add GCC pragmas| D["resource_table.h"]
  E["GCC Example"] -->|New files| F["gcc_rpmsg_echo_linux/"]
  F -->|Config & Build| G["Makefile<br/>config.h"]
  F -->|RPMSG Setup| H["main.c<br/>intc_map.h"]
  I["CI Pipeline"] -->|Build GCC| J["gnu-toolchain.yml"]
Loading

Grey Divider

File Changes

1. source/rpmsg/pru_rpmsg.c 🐞 Bug fix +1/-0

Add missing string.h header for memcpy

source/rpmsg/pru_rpmsg.c


2. source/rpmsg/pru_virtqueue.c 🐞 Bug fix +5/-1

Fix signedness comparison warning and add GCC R31 support

source/rpmsg/pru_virtqueue.c


3. source/include/linux/pru_virtio_ring.h 🐞 Bug fix +1/-1

Fix pointer-to-integer cast size warning

source/include/linux/pru_virtio_ring.h


View more (9)
4. source/include/linux/resource_table.h ✨ Enhancement +16/-6

Add GCC section attribute support for resource table

source/include/linux/resource_table.h


5. examples/gcc_rpmsg_echo_linux/main.c ✨ Enhancement +127/-0

New GCC RPMSG echo example with inline assembly

examples/gcc_rpmsg_echo_linux/main.c


6. examples/gcc_rpmsg_echo_linux/config.h ⚙️ Configuration changes +34/-0

PRU instance-specific configuration for GCC example

examples/gcc_rpmsg_echo_linux/config.h


7. examples/gcc_rpmsg_echo_linux/intc_map.h ⚙️ Configuration changes +47/-0

INTC mapping configuration for GCC example

examples/gcc_rpmsg_echo_linux/intc_map.h


8. examples/gcc_rpmsg_echo_linux/pru_intc.h ✨ Enhancement +9/-0

Wrapper header for GNU toolchain PRU IO definitions

examples/gcc_rpmsg_echo_linux/pru_intc.h


9. examples/gcc_rpmsg_echo_linux/Makefile ⚙️ Configuration changes +105/-0

Build configuration for GCC PRU cross-compilation

examples/gcc_rpmsg_echo_linux/Makefile


10. examples/gcc_rpmsg_echo_linux/README.md 📝 Documentation +54/-0

Documentation for GNU toolchain RPMSG example

examples/gcc_rpmsg_echo_linux/README.md


11. .github/workflows/gnu-toolchain.yml 🧪 Tests +62/-0

CI workflow for GNU toolchain build validation

.github/workflows/gnu-toolchain.yml


12. examples/readme.md 📝 Documentation +3/-0

Add reference to new GCC RPMSG example

examples/readme.md


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Mar 29, 2026

Persistent review updated to latest commit cba7115

Comment thread .github/workflows/gnu-toolchain.yml
Comment thread examples/gcc_rpmsg_echo_linux/config.h
Comment thread examples/gcc_rpmsg_echo_linux/main.c
Comment thread examples/gcc_rpmsg_echo_linux/pru_intc.h
Comment thread examples/gcc_rpmsg_echo_linux/README.md Outdated
Comment thread source/include/linux/resource_table.h Outdated
Comment thread source/include/linux/resource_table.h
@nsaulnier-ti
Copy link
Copy Markdown
Collaborator

I am going to be out of office until mid May. Please rebase on top of main so we can see if this passes the new CI make infrastructure. As soon as the automated build stuff is working, please treat this as my approval of this PR. All the actual content of the PRU looks good. cc @pratheesh-ti @dhavaljk

Dimitar Dimitrov added 4 commits April 10, 2026 17:43
Using memcpy requires string.h header, so include it.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
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 <dimitar@dinux.eu>
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 64-it intermediate result would be discarded
anyway by the second cast to uintptr_t.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
GCC and TI CGT have different methods to implement some non-standard
C language features, which are used in the rpmsg library. Add
such implementation for GCC, and use the `__GNUC__` macro to pick either
the TI CGT or the GCC snippet.

 * The R30 and R31 global register declarations are different, and
   conveniently provided by GNU toolchain in the `pru/io.h` file.
 * Aggregate member initializers inside an aggregate type must be
   enclosed in curly braces (i.e. the initializer must follow the type
   hierarchy).
 * Placing a variable into a specific section is accomplished by an
   attribute in GCC.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
@dinuxbg dinuxbg force-pushed the gcc-for-rpmsg-example branch from cba7115 to 5602037 Compare April 10, 2026 18:12
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Add GCC toolchain support for PRU RPMSG echo example with compiler fixes

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Add GCC toolchain support for PRU RPMSG echo example
• Fix compiler warnings and pointer casting issues
• Include missing string.h header for memcpy usage
• Add GitHub Actions CI workflow for GNU toolchain builds
Diagram
flowchart LR
  A["GCC Example<br/>gcc_rpmsg_echo_linux"] --> B["Config & Headers"]
  A --> C["Main Firmware"]
  D["Shared RPMSG Library"] --> E["Compiler Fixes"]
  E --> F["String.h Include"]
  E --> G["Pointer Casting"]
  E --> H["Sign Comparison"]
  B --> I["MCU-specific Setup"]
  C --> J["Inline Assembly"]
  K["CI/CD"] --> L["GNU Toolchain Workflow"]
Loading

Grey Divider

File Changes

1. examples/gcc_rpmsg_echo_linux/config.h ⚙️ Configuration changes +34/-0

MCU-specific RPMSG channel configuration

examples/gcc_rpmsg_echo_linux/config.h


2. examples/gcc_rpmsg_echo_linux/intc_map.h ✨ Enhancement +47/-0

INTC interrupt mapping for PRU subsystem

examples/gcc_rpmsg_echo_linux/intc_map.h


3. examples/gcc_rpmsg_echo_linux/main.c ✨ Enhancement +127/-0

GCC RPMSG echo firmware with inline assembly

examples/gcc_rpmsg_echo_linux/main.c


View more (9)
4. examples/gcc_rpmsg_echo_linux/pru_intc.h ✨ Enhancement +9/-0

GCC-specific INTC header wrapper

examples/gcc_rpmsg_echo_linux/pru_intc.h


5. examples/gcc_rpmsg_echo_linux/Makefile ⚙️ Configuration changes +105/-0

Build configuration for GNU PRU toolchain

examples/gcc_rpmsg_echo_linux/Makefile


6. examples/gcc_rpmsg_echo_linux/README.md 📝 Documentation +56/-0

Documentation for GCC RPMSG example

examples/gcc_rpmsg_echo_linux/README.md


7. source/include/linux/pru_virtio_ring.h 🐞 Bug fix +1/-1

Fix pointer-to-integer cast warning in vring_init

source/include/linux/pru_virtio_ring.h


8. source/include/linux/resource_table.h 🐞 Bug fix +16/-6

Add GCC attribute support for resource table section

source/include/linux/resource_table.h


9. source/rpmsg/pru_rpmsg.c 🐞 Bug fix +1/-0

Add missing string.h header for memcpy

source/rpmsg/pru_rpmsg.c


10. source/rpmsg/pru_virtqueue.c 🐞 Bug fix +5/-1

Fix sign comparison warning and add GCC R31 register support

source/rpmsg/pru_virtqueue.c


11. .github/workflows/gnu-toolchain.yml 🧪 Tests +66/-0

CI workflow for GNU PRU toolchain builds

.github/workflows/gnu-toolchain.yml


12. examples/readme.md 📝 Documentation +3/-0

Add GCC RPMSG example to examples index

examples/readme.md


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Apr 10, 2026

Persistent review updated to latest commit 5602037

Copy link
Copy Markdown
Member

@manojKoppolu manojKoppolu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi dinuxbg,

Please rebase your PR to trigger new CI make build.

Validated on BeaglePlay with kernel 6.12.43-ti-arm64-r54.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
@dinuxbg dinuxbg force-pushed the gcc-for-rpmsg-example branch from 5602037 to ca22512 Compare April 15, 2026 17:32
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Add GCC toolchain support for RPMSG echo example with compiler fixes

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Add GCC toolchain support for PRU RPMSG echo example
• Fix compiler warnings and pointer casting issues
• Include missing string.h header for memcpy usage
• Add CI workflow for GNU toolchain validation
Diagram
flowchart LR
  A["GCC Example<br/>gcc_rpmsg_echo_linux"] --> B["Config & Build<br/>config.h, Makefile"]
  A --> C["Firmware Code<br/>main.c, intc_map.h"]
  D["Shared RPMSG Library<br/>pru_rpmsg.c, pru_virtqueue.c"] --> E["Compiler Fixes<br/>string.h, type casts"]
  F["Resource Table<br/>resource_table.h"] --> G["GCC Pragmas<br/>__attribute__ section"]
  H["Shared Headers<br/>pru_virtio_ring.h"] --> I["Pointer Cast Fix<br/>uintptr_t consistency"]
  J["CI Workflow<br/>gnu-toolchain.yml"] --> K["Automated Build<br/>Testing"]
Loading

Grey Divider

File Changes

1. examples/gcc_rpmsg_echo_linux/config.h ✨ Enhancement +34/-0

PRU instance-specific configuration constants

examples/gcc_rpmsg_echo_linux/config.h


2. examples/gcc_rpmsg_echo_linux/intc_map.h ✨ Enhancement +47/-0

INTC interrupt mapping for GCC example

examples/gcc_rpmsg_echo_linux/intc_map.h


3. examples/gcc_rpmsg_echo_linux/main.c ✨ Enhancement +127/-0

RPMSG echo firmware with inline assembly

examples/gcc_rpmsg_echo_linux/main.c


View more (9)
4. examples/gcc_rpmsg_echo_linux/pru_intc.h ✨ Enhancement +9/-0

Wrapper header for GNU toolchain INTC

examples/gcc_rpmsg_echo_linux/pru_intc.h


5. examples/gcc_rpmsg_echo_linux/Makefile ✨ Enhancement +105/-0

Build configuration for GNU PRU toolchain

examples/gcc_rpmsg_echo_linux/Makefile


6. examples/gcc_rpmsg_echo_linux/README.md 📝 Documentation +56/-0

Documentation for GCC RPMSG example usage

examples/gcc_rpmsg_echo_linux/README.md


7. source/rpmsg/pru_rpmsg.c 🐞 Bug fix +1/-0

Add missing string.h header for memcpy

source/rpmsg/pru_rpmsg.c


8. source/rpmsg/pru_virtqueue.c 🐞 Bug fix +5/-1

Fix signedness warning and add GCC R31 support

source/rpmsg/pru_virtqueue.c


9. source/include/linux/pru_virtio_ring.h 🐞 Bug fix +1/-1

Fix pointer-to-int cast with uintptr_t

source/include/linux/pru_virtio_ring.h


10. source/include/linux/resource_table.h ✨ Enhancement +16/-6

Add GCC attribute support for linker sections

source/include/linux/resource_table.h


11. .github/workflows/gnu-toolchain.yml 🧪 Tests +66/-0

CI workflow for GNU toolchain builds

.github/workflows/gnu-toolchain.yml


12. examples/readme.md 📝 Documentation +3/-0

Add GCC RPMSG example to documentation

examples/readme.md


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Apr 15, 2026

Persistent review updated to latest commit ca22512

Comment thread examples/gcc_rpmsg_echo_linux/config.h
@pratheesh-ti pratheesh-ti merged commit 5f02c36 into TexasInstruments:main May 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants