Aim: pthread c language code execute in PRU on BeagleBone Black Board.
I refer https://beagleboard.org/static/prucookbook/ in that in run neo LED ws28212b thats work very well.
ISSUE:
then in my next step as per my application, I am required to use thread. but in PRU I understand that that does not use GCC compiler it uses clpru.
so the clpru compiler doesn’t have pthread.h.
CODE
// C program to show thread functions
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include "LED.pru0_lib.h"
void* func1(void* arg)
{
int i1;
pthread_detach(pthread_self());
while(1)
{
printf("\nthread1 i1=%d, \t1",i1);
i1++;
}
// exit the current thread
pthread_exit(NULL);
}
void* func2(void* arg)
{
int i2;
pthread_detach(pthread_self());
while(1)
{
printf("\nthread2 i2=%d, \t\t2",i2);
//hear i want to implement my neo_led code.
i2++;
}
// exit the current thread
pthread_exit(NULL);
}
void fun()
{
pthread_t ptid1, ptid2, ptid3, ptid4;
// Creating a new thread
pthread_create(&ptid1, NULL, &func1, NULL);
pthread_create(&ptid2, NULL, &func2, NULL);
printf("This line may be printed"
" before thread terminates\n");
// Waiting for the created thread to terminate
pthread_join(ptid1, NULL);
pthread_join(ptid2, NULL);
printf("This line will be printed"
" after thread ends\n");
pthread_exit(NULL);
}
// Driver code
int main()
{
fun();
return 0;
}
ERROR:
debian@beaglebone:~$ source neo_setup.sh
TARGET=basicThread_led.pru0
Black Found
P9_29
Current mode for P9_29 is: pruout
Current mode for P9_29 is: pruout
debian@beaglebone:~$ make
/var/lib/cloud9/common/Makefile:27: MODEL=TI_AM335x_BeagleBone_Black,TARGET=basicThread_led.pru0,COMMON=/var/lib/cloud9/common
/var/lib/cloud9/common/Makefile:101: GEN_DIR=/tmp/cloud9-examples,CHIP=am335x,PROC=pru,PRUN=0,PRU_DIR=/dev/remoteproc/pruss-core0,EXE=.out
- Stopping PRU 0
/bin/sh: 1: echo: echo: I/O error
Cannot stop 0
CC basicThread_led.pru0.c
"basicThread_led.pru0.c", line 3: fatal error #1965: cannot open source file "pthread.h"
1 catastrophic error detected in the compilation of "basicThread_led.pru0.c".
Compilation terminated.
Compilation failure
How I use pthread functionality in PRU.
Thank you I appreciate your response.