PRU compiling C program using clpru missing libc.a

I have a simple PRU app to control 2 stepper motors.
I’m on a Beaglebone Black

#uname -a

Linux beaglebone 3.8.13-bone67 #1 SMP Wed Sep 24 21:30:03 UTC 2014 armv7l GNU/Linux

I’ve enable the PRU module by appending the following to modules. lsmod shows it active
#sudo nano /etc/modules
uio_pruss

I’ve installed the PRU c compiler and installer
#sudo apt-get install make gcc g++ am335x-pru-package ti-pru-cgt-installer

I copied my source to a directory and created the linker commands:
#nano AM3359_PRU.cmd

-cr
-stack 0x100
-heap 0x100
MEMORY

{
PAGE 0:
PRUIMEM: o = 0x00000000 l = 0x00002000 /* 8kB PRU0 Instruction RAM /
PAGE 1:
PRUDMEM: o = 0x00000000 l = 0x00002000 /
8kB PRU Data RAM 0 */
}
SECTIONS

{
GROUP: load = PRUIMEM
{
.text:_c_int00* :
.text :
}
.stack > PRUDMEM, PAGE 1
.bss > PRUDMEM, PAGE 1
.cio > PRUDMEM, PAGE 1
.const > PRUDMEM, PAGE 1
.data > PRUDMEM, PAGE 1
.switch > PRUDMEM, PAGE 1
.sysmem > PRUDMEM, PAGE 1
.cinit > PRUDMEM, PAGE 1
}

I then compile and link the source code by issuing the following:
#clpru --silicon_version=3 -o1 pru_steppers.c -z AM3359_PRU.cmd -o pru_steppers.out -m pru_steppers.map

However, it fails to find the C libraries:

warning: automatic RTS selection: attempt to automatically link in index

library “libc.a” failed; file not found

error: no input section is linked in

warning: entry-point symbol “_c_int00” undefined

warning: no suitable entry-point found; setting to 0

error: errors encountered during linking; “pru_steppers.out” not built

Compilation failure

where is libc.a located for the PRU? Is that installed with the compiler somewhere?

I have a simple PRU app to control 2 stepper motors.
I’m on a Beaglebone Black

#uname -a

Linux beaglebone 3.8.13-bone67 #1 SMP Wed Sep 24 21:30:03 UTC 2014 armv7l GNU/Linux

I’ve enable the PRU module by appending the following to modules. lsmod shows it active
#sudo nano /etc/modules
uio_pruss

I’ve installed the PRU c compiler and installer
#sudo apt-get install make gcc g++ am335x-pru-package ti-pru-cgt-installer

I copied my source to a directory and created the linker commands:
#nano AM3359_PRU.cmd
-cr
-stack 0x100
-heap 0x100
MEMORY
{
PAGE 0:
PRUIMEM: o = 0x00000000 l = 0x00002000 /* 8kB PRU0 Instruction RAM /
PAGE 1:
PRUDMEM: o = 0x00000000 l = 0x00002000 /
8kB PRU Data RAM 0 /
}
SECTIONS
{
GROUP: load = PRUIMEM
{
.text:_c_int00
:
.text :
}
.stack > PRUDMEM, PAGE 1
.bss > PRUDMEM, PAGE 1
.cio > PRUDMEM, PAGE 1
.const > PRUDMEM, PAGE 1
.data > PRUDMEM, PAGE 1
.switch > PRUDMEM, PAGE 1
.sysmem > PRUDMEM, PAGE 1
.cinit > PRUDMEM, PAGE 1
}

I then compile and link the source code by issuing the following:
#clpru --silicon_version=3 -o1 pru_steppers.c -z AM3359_PRU.cmd -o pru_steppers.out -m pru_steppers.map

However, it fails to find the C libraries:

warning: automatic RTS selection: attempt to automatically link in index

library “libc.a” failed; file not found

error: no input section is linked in

warning: entry-point symbol “_c_int00” undefined

warning: no suitable entry-point found; setting to 0

error: errors encountered during linking; “pru_steppers.out” not built

Compilation failure

where is libc.a located for the PRU? Is that installed with the compiler somewhere?

Odd, the ti self extractor puts it under /usr/share/ti/cgt-pru/ wonder if we need an environmental variable to hint that location.

Regards,

Thanks! That got me further.
Now I’m getting a missing memory symbol

clpru -i /usr/share/ti/cgt-pru/lib --silicon_version=3 -o1 pru_steppers.c -z AM3359_PRU.cmd -o pru_steppers.out -m pru_steppers.map

undefined first referenced

symbol in file


__PRU_CREG_EXT_MEM pru_steppers.obj

error: unresolved symbols remain

error: errors encountered during linking; “pru_steppers.out” not built

Is this referencing the internal registers?

A google on it comes up empty.

Got it to compile.
I had a pragma in place to map variables to shared memory:

volatile int display[2] attribute((cregister(“EXT_MEM”)));

Is there a built-in way to declare a variable to exist in the shared memory?
Is it just using the cregister attribute and specifying the shared memory address start in the linker file?

I have it compiling to a .OUT file now.
My next step (I think) is to extract the binary part to send to the PRU.
I see I need to use hexpru to extract the program and data parts into bin files.
I can’t find hexpru on the system or in apt-cache.
Is it part of am335x-pru-package or ti-pru-cgt-installer?
Is there another program that will deploy the .out file to the pru?

The problem was not hexpru, but the text file bin.cmd was missing.

/usr/bin/hexpru bin.cmd pru_steppers.out

fails because bin.cmd is nowhere to be found.
Where should it be installed?

/usr/bin/hexpru pru_steppers.out
works, but does not output the binary files.

I either need the bin.cmd text file or the contents of it to set the arguments for hexpru
I'll also need AM3359_PRU.cmd, I made a guess at what it should contain, but it is probably wrong.
Anyone know where I can get these two files?

Hello together,

maybe someone found out where to get this bin.cmd file ?
I read somewhere else I should install the pru code generation tools.

All I found if I install this tools (including compiler and so on…) is near
/usr/share/ti/cgt-pru/library/ the file lnk.cmd.

Someone know where to get this bin.cmd ?

I searched for it in the Starterware directory, too with no success.
locate cant find it, too…

Would be really nice to get help on this.

Regards

I finally found it myself on the following site:
https://www.mail-archive.com/beagleboard@googlegroups.com/msg21682.html

bin.cmd:

-b
-image
ROMS {
PAGE 0:
text: o = 0x0, l = 0x1000, files={text.bin}
PAGE 1:
data: o = 0x0, l = 0x1000, files={data.bin}
}

Cant understand why this file cant be found in one of the compiler archives or somewhere else.

Regards

It’s in the pru_cgt package.

`

sravan:pru_2.1.1 sravan$ find . -iname “*.cmd”

./bin.cmd

./example/AM3359_PRU.cmd

./example/dummy_ARM.cmd

./example/PRU_to_ARM.cmd
./lib/lnk.cmd

`