BBAI64 C6x DSP

As many of you, I would like to use the C6x DSP of my BB AI-64 board so I tried to build a minimal example for it, just like I have tested before for PRU. My current code is available at https://github.com/loic-fejoz/beaglebone-ai64-tutorial/tree/main/example-02-c6x-dsp

I am somehow stuck as I always get a boot failure:

[ 1916.412416] remoteproc remoteproc12: powering up 4d80800000.dsp
[ 1916.418583] remoteproc remoteproc12: Booting fw image dsp12-hello, size 29072
[ 1916.425971] remoteproc remoteproc12: Boot failed: -22

I guess it is related to memory mapping but not event sure!
I am using /usr/share/ti/cgt-c6x/lib/rts64plus_elf.lib library from ti-c6000-cgt-v8.3 package

Basically, commands are:

cl6x --include_path=/usr/share/ti/cgt-c6x/include main-dsp.c --output_file main-dsp.o
lnk6x J721E_DSP12.cmd main-dsp.o /usr/share/ti/cgt-c6x/lib/rts64plus_elf.lib -o dsp12-hello -m debug-mem.txt
sudo cp dsp12-hello /lib/firmware/dsp12-hello
sudo sh -c "echo 'stop' > /sys/class/remoteproc/remoteproc12/state" 
sudo sh -c "echo 'dsp12-hello' > /sys/class/remoteproc/remoteproc12/firmware"
sudo sh -c "echo 'start' > /sys/class/remoteproc/remoteproc12/state"

I obviously tried few combination of memory mapping and such but cannot managed progress…
Can someone guide me or provide pointers maybe?

2 Likes

I am somehow progressing… :thinking:

I found following file to get inspiration from:

Thanks to the readelf command and other troules I have managed, I know my resource_table exists:

$readelf -x .resource_table /lib/firmware/dsp12-hello
Hex dump of section '.resource_table':
  0xa8100000 01000000 01000000 00000000 00000000 ................
  0xa8100010 14000000 02000000 000000ac 00040000 ................
  0xa8100020 00000000 74726163 653a6336 36785f31 ....trace:c66x_1
  0xa8100030 00000000 00000000 00000000 00000000 ................
  0xa8100040 00000000      

Yet I now get following message:

[15576.757734] remoteproc remoteproc12: powering up 4d80800000.dsp
[15576.764001] remoteproc remoteproc12: Booting fw image dsp12-hello, size 62428
[15576.771434] remoteproc remoteproc12: bad phdr da 0xa8100000 mem 0x44
[15576.777874] remoteproc remoteproc12: Failed to load program segments: -22
[15576.784910] remoteproc remoteproc12: Boot failed: -22

Has someone already manage this error bad phdr da?

1 Like

When you built, did you create a .map file? As I understand, the DSP code is statically linked with hard memory addresses. I think the tools should be able to give you a .map file to show where things are linked. Also, if you can share the whole project with build files, that might make it easier for people to know what is going wrong.

Thanks @jkridner to have a look. The whole project is available at https://github.com/loic-fejoz/beaglebone-ai64-tutorial/tree/main/example-02-c6x-dsp

Indeed I have a map file. I just managed to make this example work but it is by complete guess/chance. :frowning:

As stated in the file’s comment, I took inspiration from other TI files. I have read also lots of documentation on TDA4V’s memory and such, yet could not find how to get the actual memory configuration (as for example MSMC memory could be configured).

NB: I am working and compiling directly from the BBAI64 as per out of the box.

Maybe I need to read again the memory map section of the J721E DRA829/TDA4VM Processors Technical Reference Manual but previous value I have tried should have work…

So I have read in details and done some drawing of the memory map. Basically, in my working example, everything goes into the C66 COREPAC RAT REGION.

Which tool could give me the .map file? I run everything on the board itself and I am discovering the TI way of doing it… The whole project consist only of the shared Makefile, no CCS involved or whatever.

I guess now I need to find out how is the Region-based Address translation (RAT) configured to better understand why some address are invalid.

My misunderstanding: the memory configuration I was looking for is simply in the device tree!

$ ls -1 -d /proc/device-tree/reserved-memory/c66*
/proc/device-tree/reserved-memory/c66-dma-memory@a6000000
/proc/device-tree/reserved-memory/c66-dma-memory@a7000000
/proc/device-tree/reserved-memory/c66-memory@a6100000
/proc/device-tree/reserved-memory/c66-memory@a7100000

$ ls -1 -d /proc/device-tree/__symbols__/*c66*
/proc/device-tree/__symbols__/c66_0
/proc/device-tree/__symbols__/c66_0_dma_memory_region
/proc/device-tree/__symbols__/c66_0_memory_region
/proc/device-tree/__symbols__/c66_1
/proc/device-tree/__symbols__/c66_1_dma_memory_region
/proc/device-tree/__symbols__/c66_1_memory_region
/proc/device-tree/__symbols__/mbox_c66_0
/proc/device-tree/__symbols__/mbox_c66_1

$ cat /proc/device-tree/__symbols__/c66_0_memory_region
/reserved-memory/c66-memory@a6100000