BBAI-64 Cortex-R5 gpio toggle experiment

Hi Seth

There is a JTAG connection point on the PCB next the the SD card holder. You will see some small pads arrange in a 2x5 grid.

You can find probes from here https://www.tag-connect.com/ You will probably need one of the TC2050-IDC-NL variants, which one will depend on what debug adapter you are using. You can also buy small clips that are designed to hold the probes in place.

I am using a 6 pin SWD version for one of my PCB’s. I also have a 10 pin jtag version but I haven’t actually tried it yet.

1 Like

Hello @benedict.hewson ,

Seth here. Thank you for your reply. I will look into that item…

Seth

I tired using &= for the clearing of a bit in the DIR register, and |= for setting bits in the SET and CLR registers. I ran into some weird issue were Linux would get messed up.

Here is my repo with some examples:

The README.md:

Use of &= and |= on GPIO from an R5 on the BeagleBoneAI64 breaks Linux

The code in this repo is based off BBAI-64 Cortex-R5 gpio toggle experiment

Description

If I use the &= operator to clear bit 29 in the GPIO_DIR45 register, and at the same time use the |= operator to set bits 29 in the GPIO_SET_DATA45 and GPIO_CLR_DATA45 registers, random files become unreadable from linux. I also found that whenever this weird bug hits, running journal -k will not complete and when and will end with an abort message.

Making it hit

This folder has 6 example programs, 3 working and 3 not working. The bug only hits if there has not been a working example run since the last board reset/powercycle. In other words, if I run r5_toggle4_orig-working and then next run r5_toggle4_broken_1_yes-and-eql_yes-or-eql without a reset or powercycle, the broken example will seem to work and not bug out.

Alternatively, if I first reset the board and then run r5_toggle4_broken_1_yes-and-eql_yes-or-eql, the bug will hit.

  1. Run make to build

  2. Run sudo ./startup.sh to run the firmware

Spotting the crazy

  • Run journal -k and see if it aborts

  • Cat random files on the system until you see some weird input/output error

  • Random programs don’t start

  • Sometimes linux just flat out freezes

Random notes

  • bit 29 in the block 4-5 registers corresponds to pin p9-14 on the BeagleBoneAI64.

  • Although I have not tested, I highly suspect this issue hits with other gpio blocks and bits.

  • I tested this bug on two different BBAI64’s and with several different SD card of the same model and size.

  • I was using linux kernel 5.10 but iirc I also hit this bug on 6.x

  • I slowly narrowed this bug down after a week and half of fighting. That fact that the bug only hits if I had first not run a working firmware messed with me hard.

  • The r5 firmware seems to keep running fine when the bug hits. For the examples in this repo the p9-14 pin kept toggling after linux got messed up.

Random stuff:

k3conf randomly not working after bug hit:


debian@BeagleBone:~/xfox_linux/r5_toggle5$ k3conf dump processor

-bash: /usr/sbin/k3conf: Input/output error

Example by lucky chance of cat run from startup.sh not running thanks to bug:


debian@BeagleBone:~/buggy-bbai64_cortex-r5_examples/r5_toggle4_broken_1_yes-and-eql_yes-or-eql$ make

arm-none-eabi-gcc -fno-exceptions -mcpu=cortex-r5 -marm -mfloat-abi=hard -ggdb -I r5 --specs=nosys.specs --specs=nano.specs -T gcc.ld -o test.elf r5/CacheP_armv7r_asm.S r5/CpuId_armv7r_asm.S r5/HwiP_armv7r_asm.S r5/MpuP_armv7r_asm.S r5/PmuP_armv7r_asm.S r5/CacheP_armv7r.c r5/MpuP_armv7r.c r5/PmuP_armv7r.c test.c -u _printf_float

arm-none-eabi-size test.elf

text data bss dec hex filename

23400 4808 196 28404 6ef4 test.elf

arm-none-eabi-objdump -xd test.elf > test.elf.lst

sudo cp test.elf /lib/firmware/

# sudo echo stop > /sys/class/remoteproc/remoteproc18/state

# sudo echo test.elf > /sys/class/remoteproc/remoteproc18/firmware

# sudo echo start > /sys/class/remoteproc/remoteproc18/state

# sudo cat /sys/kernel/debug/remoteproc/remoteproc18/trace0

debian@BeagleBone:~/buggy-bbai64_cortex-r5_examples/r5_toggle4_broken_1_yes-and-eql_yes-or-eql$ sudo ./startup.sh

sudo: unable to execute /bin/cat: Input/output error

Bottom 15ish lines from attempting to run journalctl -k after starting up a broken example:


Aug 11 20:17:20 BeagleBone kernel: mmcblk1: recovery failed!

Aug 11 20:17:20 BeagleBone kernel: sdhci-am654 4fb0000.mmc: error -84 requesting status

Aug 11 20:17:20 BeagleBone kernel: mmcblk1: recovery failed!

Aug 11 20:17:20 BeagleBone kernel: sdhci-am654 4fb0000.mmc: error -84 requesting status

Aug 11 20:17:20 BeagleBone kernel: mmcblk1: recovery failed!

Aug 11 20:17:20 BeagleBone kernel: sdhci-am654 4fb0000.mmc: error -84 requesting status

Aug 11 20:17:20 BeagleBone kernel: mmcblk1: recovery failed!

Aug 11 20:17:20 BeagleBone kernel: sdhci-am654 4fb0000.mmc: error -84 requesting status

Aug 11 20:17:20 BeagleBone kernel: mmcblk1: recovery failed!

Aug 11 20:17:20 BeagleBone kernel: sdhci-am654 4fb0000.mmc: error -84 requesting status

Aug 11 20:17:20 BeagleBone kernel: mmcblk1: recovery failed!

Aug 11 20:17:20 BeagleBone kernel: sdhci-am654 4fb0000.mmc: error -84 requesting status

Aug 11 20:17:20 BeagleBone kernel: mmcblk1: recovery failed!

Aug 11 20:17:20 BeagleBone kernel: sdhci-am654 4fb0000.mmc: error -84 requesting status

Aug 11 20:17:20 BeagleBone kernel: mmcblk1: recovery failed!

SIGBUS handling failed: Value too large for defined data type

Aborted

Can’t read kernel logs with cat, less, or more. Sometimes by luck I can read the logs.


debian@BeagleBone:~/buggy-bbai64_cortex-r5_examples/r5_toggle4_broken_1_yes-and-eql_yes-or-eql$ cat /var/log/kern.log

-bash: /bin/cat: Input/output error

debian@BeagleBone:~/buggy-bbai64_cortex-r5_examples/r5_toggle4_broken_1_yes-and-eql_yes-or-eql$ less /var/log/kern.log

-bash: /usr/bin/less: Input/output error

debian@BeagleBone:~/buggy-bbai64_cortex-r5_examples/r5_toggle4_broken_1_yes-and-eql_yes-or-eql$ more /var/log/kern.log

-bash: /bin/more: Input/output error

This is what you see at the end of journalctl -k after starting up a working example:


Aug 11 20:40:04 BeagleBone kernel: remoteproc remoteproc18: powering up 5e00000.r5f

Aug 11 20:40:04 BeagleBone kernel: remoteproc remoteproc18: Booting fw image test.elf, size 524760

Aug 11 20:40:04 BeagleBone kernel: remoteproc18#vdev0buffer: assigned reserved memory node vision-apps-r5f-dma-mem>

Aug 11 20:40:04 BeagleBone kernel: virtio_rpmsg_bus virtio1: rpmsg host is online

Aug 11 20:40:04 BeagleBone kernel: remoteproc18#vdev0buffer: registered virtio1 (type 7)

Aug 11 20:40:04 BeagleBone kernel: remoteproc remoteproc18: remote processor 5e00000.r5f is now up

edit: should this post be it’s own thread?

My understanding is that there are some TIers and former TIers working on OpenAMP, but I cannot say for sure. When in doubt, post on e2e.ti.com to get someone from TI to chime in. They probably won’t say much about roadmap, but there’s a chance they could point to existing efforts.

cc @wmills @nmenon

1 Like

Hey. Love your example. I hadnt seen it, but scrolling down, i found it. Do you have anything for for reading the imput value of a pin?

Hi @ewaldhr, Glad you liked it. Unfortunately, I don’t have an example of reading an input.

This example was developed to further my understanding of the potential of the R5F cores. This investigation shaped my modern real-time development philosophy: 1. Do everything that is not real-time on Linux, 2. Do everything that is real-time on a baremetal core. My current rule of thumb is: 0-5MHz I/O update rate = R5F, 5MHz - 50MHz = PRU, above 50MHz = FPGA. NOTE: I have not worked with PRU or FPGA yet, so this is just theoretical. If on R5F, use the SoC peripherals. Don’t write your own drivers, use the TI provided libraries to simplify development.

1 Like

Yes. This one is the TDA4VM module. Allegedly…

HAvent used FPGA but PRU’s are awesome. R5 should be a step abive PRU

R5F is a full-blown 32-bit processor (CPU + FPU), therefore, it is a step above PRU in that respect. The issue is that you have to go through the bus fabric to get from the R5F to the outside world. From R5F you can bit-bang at <5MHz, with PRU, i believe you can go up to <12.5 MHz. Experimentation would have to be done to validate these numbers.

hey Fred

Thank you your comment. But now I’m more confused. What is the bus fabric? How does it work?

This TI document could be an intro to the concepts we are discussing:

Ensuring real-time predictability

It has been a few years since I looked at this, so I don’t have a Jacinto 7 SoC bus architecture diagram handy. The main concept is R5F has to go through one or more busses before it gets to the peripherals or the gpio. The PRU has direct IO.