AI-64 Running code from R5F cores

So I have been trying to figure this out and have finally manged to find an example that compiles and will boot on the core without an error.

This is for the R5 cores in the MAIN domain, not the MCU domain as I think that probably needs to be setup at boot.

This is all on a Linux host. If using Windows, it will be slightly different.

I have downloaded the PROCESSOR-SDK-RTOS-J721E (1.7G) from the TI website
Extract the file.

By investigating the firmware files on the Beaglebone I narrowed down a couple of possible examples.

switch to

ti-processor-sdk-rtos-j721e-evm-08_02_00_05/pdk_jacinto_08_02_00_21/packages/ti/build

make ipc_echo_test_freertos CORE=mcu2_0

built binary is in

ti-processor-sdk-rtos-j721e-evm-08_02_00_05/pdk_jacinto_08_02_00_21/packages/ti/binary/ipc_echo_test_freertos/bin/j721e_evm/

copy ipc_echo_test_freertos_mcu2_0_release_strip.xer5f to the beaglebone /lib/firmware

then

echo ipc_echo_test_freertos_mcu2_0_release_strip.xer5f > /dev/remoteproc/j7-main-r5f0_0/firmware
echo start > /dev/remoteproc/j7-main-r5f0_0/state

I have not yet delved into any detail of what this actually does, but it will load and run.

There are also a lot of other examples, however most so far come back with a boot failed: -22 error when loading the firmware. I think some/many are designed to be run from boot, with no OS.

Perhaps they do actually work, but because they don’t setup rpmsg the kernel thinks they have failed ? No idea what error 22 is.

There is quite a bit of documentation, however not so much to get a bare-bones project up and running.

The -22 I think is a bit of a catchall, I think it may well be to do with how it was linked, memory access, DMA who knows. I thought it was maybe something to do with how the kernel was set up with memory for each core, I have not investigated this yet.

I have taken a similar approach but used the vision apps examples from the same RTOS package, trying to run something built for one core on another can give you that -22, or totally hang everything!

To be honest the vision apps make stuff is a behemoth I’m guessing they have some tool to generate it, so have not got much further than enabling the extra cores and running them on the AI-64, so it is great you have found a better example to use, I will take a look at that one.

I’ve just started looking at the R5F cores and how to build binaries, preferably without the bulky PDK.

We are using the Yocto/Poky approach with meta-ti added. Since it’s a multi-build, it starts with building the code for R5F (and perhaps the Cortex M4) then proceeds with the A72’s, like this:

bomellberg@bosse-buildcom:~/se3linux/yocto-base/build$ MACHINE=beaglebone-ai64 bitbake linux-bb.org
Loading cache: 100% |#######################################################################################################################################| Time: 0:00:00
Loaded 8754 entries from dependency cache.
Parsing recipes: 100% |#####################################################################################################################################| Time: 0:00:00
Parsing of 5684 .bb files complete (5682 cached, 2 parsed). 8756 targets, 501 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
NOTE: Resolving any missing task queue dependencies
NOTE: Resolving any missing task queue dependencies
NOTE: Resolving any missing task queue dependencies

Build Configuration (mc:default):
BB_VERSION           = "2.0.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "aarch64-poky-linux"
MACHINE              = "beaglebone-ai64"
DISTRO               = "se3linux"
DISTRO_VERSION       = "3.0"
TUNE_FEATURES        = "aarch64"
TARGET_FPU           = ""
DISTRO_CODENAME      = "muriwaimanu"
GCCVERSION           = "11.3%"
meta
meta-poky
meta-yocto-bsp       = "HEAD:03e4da602f0dbd46b4f03f2a5c6fccae6d547045"
meta-se-as
meta-se3linux
meta-nsp             = "add-meta-ti:a282c8874fe517375a5f35bdd0b250adf8126c85"
meta-oe
meta-networking
meta-perl
meta-python
meta-multimedia      = "HEAD:8f96c05f6d82fde052f2cb1652c13922814accb0"
workspace            = "add-meta-ti:a282c8874fe517375a5f35bdd0b250adf8126c85"
meta-arm-toolchain
meta-arm             = "HEAD:a0216a41bde3f191037332a9238648bedfbc61bd"
meta-ti-bsp
meta-ti-extras       = "HEAD:1d7123f85a84113a39a5e22397a0d63dfa5edf21"
meta-tpm             = "kirkstone:cc20e2af2ae1c74e306f6c039c4963457c4cbd0f"


Build Configuration:
BB_VERSION           = "2.0.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "arm-poky-linux-gnueabi"
MACHINE              = "beaglebone-ai64-k3r5"
DISTRO               = "se3linux"
DISTRO_VERSION       = "3.0"
TUNE_FEATURES        = "arm armv7a vfp thumb callconvention-hard"
TARGET_FPU           = "hard"
DISTRO_CODENAME      = "muriwaimanu"
GCCVERSION           = "11.3%"
meta
meta-poky
meta-yocto-bsp       = "HEAD:03e4da602f0dbd46b4f03f2a5c6fccae6d547045"
meta-se-as
meta-se3linux
meta-nsp             = "add-meta-ti:a282c8874fe517375a5f35bdd0b250adf8126c85"
meta-oe
meta-networking
meta-perl
meta-python
meta-multimedia      = "HEAD:8f96c05f6d82fde052f2cb1652c13922814accb0"
workspace            = "add-meta-ti:a282c8874fe517375a5f35bdd0b250adf8126c85"
meta-arm-toolchain
meta-arm             = "HEAD:a0216a41bde3f191037332a9238648bedfbc61bd"
meta-ti-bsp
meta-ti-extras       = "HEAD:1d7123f85a84113a39a5e22397a0d63dfa5edf21"
meta-tpm             = "kirkstone:cc20e2af2ae1c74e306f6c039c4963457c4cbd0f"

WARNING: /home/bomellberg/se3linux/yocto-base/sources/meta-ti/meta-ti-bsp/recipes-kernel/linux/linux-bb.org_git.bb:do_compile is tainted from a forced run  | ETA:  0:00:00
WARNING: /home/bomellberg/se3linux/yocto-base/sources/meta-ti/meta-ti-bsp/recipes-kernel/linux/linux-bb.org_git.bb:do_deploy is tainted from a forced run
Initialising tasks: 100% |##################################################################################################################################| Time: 0:00:01
Sstate summary: Wanted 8 Local 8 Mirrors 0 Missed 0 Current 152 (100% match, 100% complete)
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 743 tasks of which 743 didn't need to be rerun and all succeeded.

Summary: There were 2 WARNING messages.

As a result there are two binaries in my deploy-folder:

-rw-r--r-- 2 bomellberg bomellberg   292348 May  5 10:48 ipc_echo_testb_mcu1_0_release_strip.xer5f
-rw-r--r-- 2 bomellberg bomellberg   290668 May  5 10:48 ipc_echo_testb_mcu1_0_release_strip.xer5f.unsigned

I haven’t been able to use these in any of the R5F-cores. I guess it is not meant to run there. mcu1_0 must be one of the other cores.

However, I find a lot of other xer5f files in my build tree. Two of these I have been able to load and run:

root@beaglebone-ai64:~# echo ipc_echo_test_mcu2_0_release_strip.xer5f > /sys/class/remoteproc/remoteproc4/firmware
root@beaglebone-ai64:~# echo ipc_echo_test_mcu3_0_release_strip.xer5f > /sys/class/remoteproc/remoteproc5/firmware

root@beaglebone-ai64:~# echo start > /sys/class/remoteproc/remoteproc4/state
root@beaglebone-ai64:~# echo start > /sys/class/remoteproc/remoteproc5/state

root@beaglebone-ai64:~# modprobe rpmsg_client_sample count=5

root@beaglebone-ai64:~# dmesg | tail
[  549.244919] rpmsg_client_sample virtio0.ti.ipc4.ping-pong.-1.13: new channel: 0x400 -> 0xd!
[  549.245024] rpmsg_client_sample virtio1.ti.ipc4.ping-pong.-1.13: new channel: 0x400 -> 0xd!
[  549.245406] rpmsg_client_sample virtio0.ti.ipc4.ping-pong.-1.13: incoming msg 1 (src: 0xd)
[  549.245431] rpmsg_client_sample virtio1.ti.ipc4.ping-pong.-1.13: incoming msg 1 (src: 0xd)
[  549.245520] rpmsg_client_sample virtio0.ti.ipc4.ping-pong.-1.13: incoming msg 2 (src: 0xd)
[  549.245531] rpmsg_client_sample virtio1.ti.ipc4.ping-pong.-1.13: incoming msg 2 (src: 0xd)
[  549.245624] rpmsg_client_sample virtio1.ti.ipc4.ping-pong.-1.13: incoming msg 3 (src: 0xd)
[  549.245641] rpmsg_client_sample virtio0.ti.ipc4.ping-pong.-1.13: incoming msg 3 (src: 0xd)
[  549.245718] rpmsg_client_sample virtio1.ti.ipc4.ping-pong.-1.13: incoming msg 4 (src: 0xd)
[  549.245732] rpmsg_client_sample virtio0.ti.ipc4.ping-pong.-1.13: incoming msg 4 (src: 0xd)
[  549.245805] rpmsg_client_sample virtio1.ti.ipc4.ping-pong.-1.13: incoming msg 5 (src: 0xd)
[  549.245808] rpmsg_client_sample virtio1.ti.ipc4.ping-pong.-1.13: goodbye!
[  549.245817] rpmsg_client_sample virtio0.ti.ipc4.ping-pong.-1.13: incoming msg 5 (src: 0xd)
[  549.245820] rpmsg_client_sample virtio0.ti.ipc4.ping-pong.-1.13: goodbye!

My question is, where are the source files for these binaries? I can’t find them anywhere.

1 Like

The IPC echo test source files are under:

…/packages/ti/drv/ipc/examples/

The main function can be found under common/src.

Note that this directory structure (for me) is under the pdk directory (pdk_jacinto_08_05_00_36 in my case).

1 Like

Thanks for the answer,

I have found the recipes for these binarys, and they are actually pre-built firmware.

In recipe ti-rtos-firmware.bb:

SUMMARY = "TI RTOS prebuilt binary firmware images"
...
INSTALL_DM_FW_DIR  = "${nonarch_base_libdir}/firmware/${DM_FW_DIR}"
INSTALL_IPC_FW_DIR = "${nonarch_base_libdir}/firmware/${IPC_FW_DIR}"
...
DM_FIRMWARE = "ipc_echo_testb_mcu1_0_release_strip.xer5f"

MCU_1_0_FW = "ipc_echo_test_mcu1_0_release_strip.xer5f"
MCU_1_1_FW = "ipc_echo_test_mcu1_1_release_strip.xer5f"
MCU_2_0_FW = "ipc_echo_test_mcu2_0_release_strip.xer5f"
MCU_2_1_FW = "ipc_echo_test_mcu2_1_release_strip.xer5f"
MCU_3_0_FW = "ipc_echo_test_mcu3_0_release_strip.xer5f"
MCU_3_1_FW = "ipc_echo_test_mcu3_1_release_strip.xer5f"
MCU_4_0_FW = "ipc_echo_test_mcu4_0_release_strip.xer5f"
MCU_4_1_FW = "ipc_echo_test_mcu4_1_release_strip.xer5f"
C66_1_FW   = "ipc_echo_test_c66xdsp_1_release_strip.xe66"
C66_2_FW   = "ipc_echo_test_c66xdsp_2_release_strip.xe66"
C7X_1_FW   = "ipc_echo_test_c7x_1_release_strip.xe71"
C7X_2_FW   = "ipc_echo_test_c7x_2_release_strip.xe71"
C7X_3_FW   = "ipc_echo_test_c7x_3_release_strip.xe71"
C7X_4_FW   = "ipc_echo_test_c7x_4_release_strip.xe71"
...
IPC_FW_LIST:j721e =   "              ${MCU_1_1_FW} ${MCU_2_0_FW} ${MCU_2_1_FW} ${MCU_3_0_FW} ${MCU_3_1_FW}                             ${C66_1_FW} ${C66_2_FW} ${C7X_1_FW}"

So, prebuilt, and pretty clear of which SoC:s that support which of these echo-tests (and in what core).

I guess we need the PDK then. :frowning:

/Bo

I can build the echo test for the main R5F cores (MCU_2_0, MCU_2_1, MCU_3_0, MCU_3_1) from the PDK sources. I’m setting BOARD=j721e_evm which is the TI evaluation board.

So maybe it’s not surprising that the resulting firmware doesn’t exactly work as expected. Only MCU_2_0 (which is also known as main-r5f0-0) will run and generate echo responses. BUT – my serial interface goes away. I can only log on to the BBAI-64 over ethernet. The other three R5F cores don’t seem to work at all and typically lock up the Linux side as well.

Now I guess I need to find out how TI pre-built the firmware for the BeagleBone. Perhaps in a newer PDK they have a BOARD=bbai64 or something like that? It’s not in the version I am currently using.

Okay, I found my problem with the serial interface going away. In the latest PDK source, the call to board_init only happens if the R5F is booting before Linux comes up. I removed that call from my code and now things are working better.

Hi again, I am trying to use MCU(r5f) on BBAI-64, but how to upload firmware? → i lost

So, What I would like to ask you is the following.

  1. as I said, how to upload firmware to use MCU?
  2. is there any example code for it? I cannot find any sources from the directory below : ti-processor-sdk-rtos-j721e-evm-08_02_00_05/pdk_jacinto_08_02_00_21/packages/ti/
  3. how to use mikro bus? like editing device tree here : BBAI-64 Pinmux Spreedsheet - #5 by jks

Thank you!

-22,because ddr config is error, please reference this BBAI64 now can use TI SDK10.0 and debug R5 - #6 by jiance.zahng

may be this link is help you: BBAI64 now can use TI SDK10.0 and debug R5 - #6 by jiance.zahng