Skip to content

Gpio toggle dual core enable - #194

Draft
y-motwani wants to merge 2 commits into
TexasInstruments:mainfrom
y-motwani:gpio_toggle_dual_core_enable
Draft

y-motwani wants to merge 2 commits into
TexasInstruments:mainfrom
y-motwani:gpio_toggle_dual_core_enable

Conversation

@y-motwani

Copy link
Copy Markdown
Contributor

Adding support for PRU0 and PRU1 cores enabled together for AM64x and AM243x. This toggles both the pins for the core. Updated the readme and main source files with detailed comments and debug steps to help new users.

@y-motwani
y-motwani marked this pull request as draft November 23, 2026 09:27
@qodo-code-review

qodo-code-review Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Enable dual-core GPIO toggling on AM64x and AM243x

✨ Enhancement 📝 Documentation ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Pinmux PRU1 GPO4 alongside PRU0 GPO4 in the C and assembly examples on AM64x and AM243x.
• Document both output pins, expected signal frequencies, build steps, and troubleshooting for new
 PRU users.
• Add firmware comments explaining register access, delay timing, and experiments for exploring GPO
 outputs.
Merge Risk 🟢 Low

Blast radius 🔴 High 💥 2 capabilities

  • 2 affected capabilities span independent functional scopes: C GPIO-toggle EVM integration, assembly GPIO-toggle EVM integration.
  • This is one bounded example integration: the shared assembly firmware is loaded by the R5F application into both PRU cores, while the board-specific SysConfig maps the two core outputs.
  • The PRU1 configuration change reaches the same end-to-end user outcome of observing the assembly example's GPIO signals; the firmware, host loader, and board pinmux are propagation hops rather than separate capabilities.
  • This is one bounded example integration: the shared C firmware is loaded by the R5F application into both PRU cores, while board-specific SysConfig maps the two core outputs.
  • The PRU1 configuration change reaches the same end-to-end user outcome of observing the C example's GPIO signals; the firmware, host loader, and board pinmux are propagation hops rather than separate capabilities.
Behavioral complexity 🟢 Low 🧩 Straightforward

  • Before: the SysConfig created one PRU GPIO instance for PRU0 GPO4.
  • After: it creates a second instance and assigns it to PRU1 GPO4.
  • New correctness condition: the second declarative resource must be valid for the selected board and must map to the intended PRU1 header pin.
  • This is a direct configuration/resource mapping with no new algorithm, state machine, concurrency protocol, persistence, or mixed-version interaction.
Potential damage 🟡 Medium 🩹 Temporary loss

  • The concrete failure is loss of the newly intended PRU1 observable output, or loss of the example build if the declarative resource assignment is invalid.
  • Reverting the SysConfig change and rebuilding restores the prior PRU0-only behavior.
  • No persistent state repair or external compensation is required; the PRU output is transient hardware behavior.
  • The equal-importance baseline is used because no business criticality declaration is supplied.
  • Recoverable by correcting or reverting the SysConfig resource assignment and regenerating/rebuilding the R5F application.
  • A running image must be stopped and redeployed; source rollback alone does not repair an already generated binary until rebuild and redeployment.
Assessed commit bae9bb9
Diagram

graph TD
  Config["AM64x/AM243x SysConfig"] --> Host["R5F host"] --> Pru0["PRU0"] --> Out0["PRU0 GPO4"]
  Host --> Pru1["PRU1"] --> Out1["PRU1 GPO4"]
  Firmware["Shared ASM/C firmware"] --> Pru0
  Firmware --> Pru1
Loading
High-Level Assessment

Reusing each example's existing firmware and dual-core R5F loader while enabling the missing PRU1 pinmux is the smallest coherent approach. Separate core-specific firmware or a new loading path would duplicate behavior without improving this example.

Files changed (8) +642 / -53

Documentation (4) +620 / -47
main.asmExplain assembly GPIO toggling and debugging +160/-17

Explain assembly GPIO toggling and debugging

• Adds instruction-level explanations, a calculated 200 MHz timing breakdown, build guidance, and commented debugging experiments. The active toggle loop remains unchanged.

academy/gpio/gpio_toggle/firmware/main.asm

readme.mdDocument dual-core assembly outputs and bring-up +161/-6

Document dual-core assembly outputs and bring-up

• Identifies both AM64x/AM243x header pins and explains PRU operation, firmware flow, expected 500 Hz output, build steps, and troubleshooting.

academy/gpio/gpio_toggle/readme.md

main.cExplain C firmware register access and debugging +126/-17

Explain C firmware register access and debugging

• Documents R30/R31, the cycle-delay intrinsic, build steps, and experiments for checking or changing GPO outputs. The active toggle behavior remains unchanged.

academy/gpio/gpio_toggle_c/firmware/main.c

readme.mdDocument dual-core C outputs and bring-up +173/-7

Document dual-core C outputs and bring-up

• Adds both output-pin locations, PRU C concepts, firmware and host flow, expected 1 Hz output, build instructions, and debugging exercises.

academy/gpio/gpio_toggle_c/readme.md

Other (4) +22 / -6
example.syscfgEnable AM243x PRU1 GPO4 for assembly example +5/-1

Enable AM243x PRU1 GPO4 for assembly example

• Adds a second PRU GPIO configuration assigned to PRU1 and enables its GPO4 pin alongside PRU0 GPO4.

academy/gpio/gpio_toggle/mcuplus/am243x-evm/r5fss0-0_freertos/example.syscfg

example.syscfgEnable AM64x PRU1 GPO4 for assembly example +6/-2

Enable AM64x PRU1 GPO4 for assembly example

• Explicitly assigns the existing GPIO configuration to PRU0 and adds a PRU1 configuration with GPO4 enabled.

academy/gpio/gpio_toggle/mcuplus/am64x-evm/r5fss0-0_freertos/example.syscfg

example.syscfgEnable AM243x PRU1 GPO4 for C example +5/-1

Enable AM243x PRU1 GPO4 for C example

• Creates a PRU1 GPIO configuration and enables its GPO4 output in addition to the existing PRU0 output.

academy/gpio/gpio_toggle_c/mcuplus/am243x-evm/r5fss0-0_freertos/example.syscfg

example.syscfgEnable AM64x PRU1 GPO4 for C example +6/-2

Enable AM64x PRU1 GPO4 for C example

• Makes the PRU0 assignment explicit and adds a PRU1 GPIO configuration with GPO4 enabled.

academy/gpio/gpio_toggle_c/mcuplus/am64x-evm/r5fss0-0_freertos/example.syscfg

@qodo-code-review

qodo-code-review Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Code Review by Qodo


Action required

Nice, no open findings for this group


Remediation recommended

Nice, no open findings for this group


Informational

Nice, no open findings for this group


@y-motwani
y-motwani force-pushed the gpio_toggle_dual_core_enable branch from bae9bb9 to df083d5 Compare November 23, 2026 10:07
@y-motwani

Copy link
Copy Markdown
Contributor Author

/agentic_review

@y-motwani
y-motwani force-pushed the gpio_toggle_dual_core_enable branch from df083d5 to 8cbb08e Compare November 23, 2026 11:08
; firmware/<board>/icss_g0_pru0_fw/ti-pru-cgt and run: make
;
; Timing (assuming a 200 MHz PRU core clock, 5 ns per cycle. This is the
; AM64x/AM243x MCU+ SDK SysConfig default. Other devices may differ):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should have a note that different processors support different core frequencies on the PRU subsystem. Not sure if it's sufficient to point to the PRU Subsystem Features Comparison app note (AI-friendly link here: https://github.com/TexasInstruments/open-pru/blob/main/docs_ai/reference/pru_subsystem_features_comparison_g/pru_subsystem_features_comparison_g.md), or if something else makes sense here (for example, I don't think AM62x supports all the same frequencies as AM64x - it might be missing 225MHz and 300MHz? - so some information is not fully represented in the features comparison app note)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can add the link for now and once the Academy page with the clock frequencies is updated, I'll update the link to that

Comment thread academy/gpio/gpio_toggle/readme.md Resolved
Comment thread academy/gpio/gpio_toggle/readme.md Resolved
Comment thread academy/gpio/gpio_toggle/readme.md Resolved
Comment thread academy/gpio/gpio_toggle/readme.md Resolved
Comment thread academy/gpio/gpio_toggle/readme.md Resolved
Add a PRU1 GPO instance of the GPIO toggle, assembly
and C examples. This allows toggle of both PRU0 and
PRU 1 core pins simulataneously.

Signed-off-by: Yashraj Motwani <[email protected]>
Add comments and documentation to the GPIO toggle
assembly and C examples to make them easier to
follow for users new to the PRU.

- main.asm, main.c: describe what the example teaches
  and who loads the PRU, document the cycle count and
  expected frequency, and describe the three ways to
  change an output pin (overwrite, set/clear, XOR).
- readme.md: document the PRU0 and PRU1 GPO4 pins,
  expected output, PRU clock and timing references,
  and debug steps.

Signed-off-by: Yashraj Motwani <[email protected]>
@y-motwani
y-motwani force-pushed the gpio_toggle_dual_core_enable branch from 8cbb08e to 157b0e4 Compare November 24, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants