This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/am5728: RPMsg error

Part Number: AM5728


Tool/software: Code Composer Studio

I am developing a UART application both on PRU and  A15(as master) base on the hands on example:PRU_RPMsg_Echo_Interrupt1_0.

And some error occurs when I run the application on A15 to communicate with PRU

error like:omap_l3_noc 44000000.ocp: L3 debug error: target 5 mod:1 (unclearable)     ,Data Access in User mode during Functional access

I want to know what cause these errors ,as far as I know ,may be 1.the dts 2 the driver bug 3 illegal memory access .

and what's more ,how to debug the pru C  program more efficiently in CCS?

some of TI tutorials suggest to access the PRU memory and debug from memory window in CCS, then is there a C demo about how to access memory of PRU ?

later on I will post the whole dmesg up,and my code .Need Help !

 

  • The software team have been notified. They will respond here.
  • Hi,

    That error message usually means a MMU violation. You probably need to have resource table for the RTOS application if you didn't define it, Please refer to the wiki page for more info, processors.wiki.ti.com/.../IPC_Resource_customTable

    For debugging PRU using CCS, please submit a new thread, the RTOS engineer should be able to help you.

    Rex
  • Thanks for reply,Rex.

    Here is my resource_table ,it's the original file from pru-software-support-package-pru-software-support-package/examples.

    The system I am using is ti-processor-sdk-linux-rt-am57xx-evm-04.01.00.06. The link you showed is IPC_Resource_customTable,I think IPC  is for DSP, now I am using PRU_RPMsg.Could you please help me to modify my own resource_table on PRU?

    resource_table_0.h

  • here is the  log when I start the app on A15:

    [45975.288388] remoteproc remoteproc4: Booting fw image am57xx-pru1_0-fw, size 90276
    [45975.296244] ti-pruss 4b200000.pruss: configured system_events = 0x0000000000030000 intr_channels = 0x00000005 host_intr = 0x00000005
    [45975.312080] virtio_rpmsg_bus virtio0: rpmsg host is online
    [45975.312108] virtio_rpmsg_bus virtio0: creating channel rpmsg-pru addr 0x1e
    [45975.327995] rpmsg_pru virtio0.rpmsg-pru.-1.30: new rpmsg_pru device: /dev/rpmsg_pru30
    [45975.336056] remoteproc remoteproc4: registered virtio0 (type 7)
    [45975.342011] remoteproc remoteproc4: remote processor 4b234000.pru0 is now up
    [45977.301972] ------------[ cut here ]------------
    [45977.306631] WARNING: CPU: 1 PID: 27 at drivers/bus/omap_l3_noc.c:147 l3_interrupt_handler+0x228/0x374
    [45977.315892] 44000000.ocp:L3 Custom Error: MASTER PRUSS1 PRU1 TARGET L4_PER1_P3 (Idle): Data Access in Supervisor mode during Functional access
    [45977.328725] Modules linked in: bc_example(O) xhci_plat_hcd xhci_hcd usbcore dwc3 udc_core usb_common sha512_generic sha512_arm sha256_generic sha1_generic sha1_arm_neon sha1_arm md5 cbc xfrm_user xfrm4_tunnel ipcomp xfrm_ipcomp esp4 ah4 snd_soc_omap_hdmi_audio prueth af_key xfrm_algo pvrsrvkm(O) c_can_platform c_can omap_aes_driver can_dev omap_sham ahci_platform omap_wdt libahci_platform libahci libata scsi_mod bluetooth ti_vip ti_vpe ti_sc ti_csc ti_vpdma dwc3_omap rtc_omap extcon_palmas extcon_core gpio_pisosr rtc_palmas ov2659 gpio_tpic2810 omap_des des_generic crypto_engine sch_fq_codel uio_module_drv(O) uio gdbserverproxy(O) cryptodev(O) cmemk(O)
    [45977.386828] CPU: 1 PID: 27 Comm: irq/23-l3-app-i Tainted: G        W  O    4.9.41-rt23-gc038d21a22 #23
    [45977.386830] Hardware name: Generic DRA74X (Flattened Device Tree)
    [45977.386834] Backtrace: 
    [45977.386852] [<c020af74>] (dump_backtrace) from [<c020b210>] (show_stack+0x18/0x1c)
    [45977.386859]  r6:00000000 r5:c1024b80 r4:60070013 r3:00000000
    [45977.386871] [<c020b1f8>] (show_stack) from [<c04c2aec>] (dump_stack+0x8c/0xa8)
    [45977.386880] [<c04c2a60>] (dump_stack) from [<c022cf94>] (__warn+0xdc/0x108)
    [45977.386885]  r6:c0bc1684 r5:00000000 r4:ee625e28 r3:00000000
    [45977.386890] [<c022ceb8>] (__warn) from [<c022d000>] (warn_slowpath_fmt+0x40/0x48)
    [45977.386895]  r9:f0882164 r8:00000000 r7:c0bc1a14 r6:ee5f2f50 r5:c0bc15e0 r4:00000000
    [45977.386904] [<c022cfc4>] (warn_slowpath_fmt) from [<c04f203c>] (l3_interrupt_handler+0x228/0x374)
    [45977.386907]  r3:ee5f2dc0 r2:c0bc16a0
    [45977.386909]  r4:80080003
    [45977.386918] [<c04f1e14>] (l3_interrupt_handler) from [<c027ded8>] (irq_forced_thread_fn+0x28/0x5c)
    [45977.386923]  r10:c027deb0 r9:ee5fa2c0 r8:ee5f8000 r7:00000001 r6:ee5fa2e4 r5:ee5f8000
    [45977.386925]  r4:ee5fa2c0
    [45977.386931] [<c027deb0>] (irq_forced_thread_fn) from [<c027e18c>] (irq_thread+0x110/0x1e0)
    [45977.386935]  r6:ee5fa2e4 r5:00000000 r4:ee624000 r3:00000004
    [45977.386942] [<c027e07c>] (irq_thread) from [<c0249798>] (kthread+0x100/0x11c)
    [45977.386948]  r10:00000000 r9:00000000 r8:00000000 r7:c027e07c r6:ee5fa2c0 r5:00000000
    [45977.386949]  r4:ee5fa300
    [45977.386957] [<c0249698>] (kthread) from [<c0207a50>] (ret_from_fork+0x14/0x24)
    [45977.386961]  r7:00000000 r6:00000000 r5:c0249698 r4:ee5fa300
    [45977.386963] ---[ end trace 0000000000000007 ]---
    



    The C code on PRU side:

    /*
     * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
     *
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     *	* Redistributions of source code must retain the above copyright
     *	  notice, this list of conditions and the following disclaimer.
     *
     *	* Redistributions in binary form must reproduce the above copyright
     *	  notice, this list of conditions and the following disclaimer in the
     *	  documentation and/or other materials provided with the
     *	  distribution.
     *
     *	* Neither the name of Texas Instruments Incorporated nor the names of
     *	  its contributors may be used to endorse or promote products derived
     *	  from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    #include <stdint.h>
    #include <stdio.h>
    #include <pru_cfg.h>
    #include <pru_intc.h>
    #include <rsc_types.h>
    #include <pru_rpmsg.h>
    #include "resource_table_0.h"
    #include "pru_uart_init.h"
    #include <sys_mailbox.h>
    
    
    
    /* Host-0 Interrupt sets bit 30 in register R31 */
    #define HOST_INT			((uint32_t) 1 << 30)
    
    /* The PRU-ICSS system events used for RPMsg are defined in the Linux device tree
     * PRU0 uses system event 16 (To ARM) and 17 (From ARM)
     * PRU1 uses system event 18 (To ARM) and 19 (From ARM)
     */
    #define TO_ARM_HOST			16
    #define FROM_ARM_HOST			17
    
    #define TxSize 160
    #define RxSize (uint8_t)64
    #define Tx_data_size 140
    #define IOSize 12
    #define SizeOfOffset  24
    #define route_data_size  240
    #define new_array_size 360
    #define PRU1
    volatile register uint32_t __R30;
    volatile register uint32_t __R31;
    #define PRU1_PRU0_INTERRUPT (18)
    
    /*
     * Using the name 'rpmsg-pru' will probe the rpmsg_pru driver found
     * at linux-x.y.z/drivers/rpmsg/rpmsg_pru.c
     */
    #define CHAN_NAME			"rpmsg-pru"
    #define CHAN_DESC			"Channel 30"
    #define CHAN_PORT			30
    
    /*
     * Used to make sure the Linux drivers are ready for RPMsg communication
     * Found at linux-x.y.z/include/uapi/linux/virtio_config.h
     */
    #define VIRTIO_CONFIG_S_DRIVER_OK	4
    uint8_t new_array[RPMSG_BUF_SIZE];
    uint8_t payload[RPMSG_BUF_SIZE];
    uint8_t tmp[RPMSG_BUF_SIZE];
    uint8_t IOData[IOSize];
    //uint8_t req_to_send[RxSize];
    
    
    union char2short{
    	uint16_t sint;  
    	unsigned char c[2];
    };
    
    union ui2uc{
    	unsigned int ui;
    	unsigned char c[4];
    };
    
    void create_Tx_data(unsigned char *Txbuf, unsigned char ts, unsigned char ctlbyte, unsigned char *data, int no_of_char){
    	int i;
    	union char2short checksum;	//!< check sum variable
    
    	Txbuf[0] = 0;	//!< head must be 0;
    	Txbuf[1] = ts;	//!< current time stamp
    	Txbuf[2] = ctlbyte;	//!< ctlbyte, 0
    
    	if (no_of_char > 136)//20150630 xiaoxia add "+4" for get g_clock
    	{
    		//fprintf(stderr,"%cyour size of data is exceed the limit\n",getlocaltime());
    	}
    	memcpy(Txbuf+3, data, no_of_char); //!< convert float into unsigned char
    
    	//! calculate checksum of the data
    	checksum.sint = 0;
    	for (i = 3; i < TxSize-3; ++i)
    	{
    		checksum.sint += Txbuf[i];
    	}
    
    	Txbuf[TxSize-3]=checksum.c[1];	//!MSB
    	Txbuf[TxSize-2]=checksum.c[0];	//!LSB
    	Txbuf[TxSize-1]=255; 	//!< end of Txbuf, must be 255
    
    }
    
    void uchar2uint(unsigned int *ibuf, const unsigned char *cbuf, int bufno){
    	union ui2uc x;
    	int i;
    	for (i=0; i<bufno/4; i++){
    		x.c[0] = cbuf[4*i];
        	x.c[1] = cbuf[4*i+1];
        	x.c[2] = cbuf[4*i+2];
        	x.c[3] = cbuf[4*i+3];
        	ibuf[i] = x.ui;
      	}
    }
    
    /*
     * main.c
     */
    void main(void)
    {
    	  int count=0;//static
    	unsigned int ts_cur,ts_lcur=0;
    	const unsigned int Tx_raw_size=120;
    	int  i=0,OutputDataSize = 4, PLCConveyorDataSize = 4,CurrentPos,CurrentPos1;
    	unsigned char Txbuf[TxSize],Txbuf1[TxSize];
    	uint8_t   Rxbuf[RxSize+1];  
    	for(i=0;i < TxSize;i++)
    		Txbuf[i] = i+1;
    	for(i=RxSize;i >0;i--)
    		Rxbuf[i] = i;
    
    	int time_counter;
    
    
    	struct pru_rpmsg_transport transport;
    	uint16_t src, dst, len=0,iodata_len;
    	volatile uint8_t *status;
    
    
    
    
    	/* Allow OCP master port access by the PRU so the PRU can read external memories */
    	CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
    
    	/* Clear the status of the PRU-ICSS system event that the ARM will use to 'kick' us */
    	CT_INTC.SICR_bit.STATUS_CLR_INDEX = FROM_ARM_HOST;
    
    	/* Make sure the Linux drivers are ready for RPMsg communication */
    	status = &resourceTable.rpmsg_vdev.status;
    
    	while (!(*status & VIRTIO_CONFIG_S_DRIVER_OK));
    
    	/* Initialize the RPMsg transport structure */
    	pru_rpmsg_init(&transport, &resourceTable.rpmsg_vring0, &resourceTable.rpmsg_vring1, TO_ARM_HOST, FROM_ARM_HOST);
    
    	/* Create the RPMsg channel between the PRU and ARM user space using the transport structure. */
    	while (pru_rpmsg_channel(RPMSG_NS_CREATE, &transport, CHAN_NAME, CHAN_DESC, CHAN_PORT) != PRU_RPMSG_SUCCESS);
    	pru_uart_initialize();
    
    	while(1)
    				{
    
    
    						if (__R31 & HOST_INT) {
    							//pru_uart_write(Txbuf,TxSize);
    							CT_INTC.SICR_bit.STATUS_CLR_INDEX = FROM_ARM_HOST;
    
    
    								while (pru_rpmsg_receive(&transport, &src, &dst, tmp, &len) != PRU_RPMSG_SUCCESS);
    
    
    
    
    
    							}
    			
    						if(count==0)
    							memcpy(payload,tmp,len);
    						else
    							
    							memcpy(new_array,tmp,len);
    					}
    
    					if(count==0){
    
    
    										for(CurrentPos=0;CurrentPos<=route_data_size-Tx_raw_size;CurrentPos+=SizeOfOffset)
    													{
    														pru_uart_read(Rxbuf,RxSize);
    
    												
    */
    
    
    //														uchar2uint(&ts_cur,Rxbuf+57,4);
    //														ts_lcur = (ts_cur/20)%256 ;
    														pru_rpmsg_send(&transport, dst, src, Rxbuf,RxSize+1);
    														//problem here
    														memcpy(Txbuf1,payload+CurrentPos,Tx_raw_size);//1 .&payload[CurrentPos],2.payload+CurrentPos,dont use 1
    
    														//memcpy(&Txbuf1[120], IOData, OutputDataSize) ;
    														//memcpy(&Txbuf1[136], &payload[244], PLCConveyorDataSize);
    //														create_Tx_data(Txbuf, ts_lcur, 0, Txbuf1, Tx_data_size);
    														pru_uart_write(Txbuf1,Tx_raw_size);
    														
    
    
    													}
    							}
    					else {
    
    
    						for(time_counter=4;time_counter>0;time_counter--)
    						{
    							//i=4;
    								CurrentPos=route_data_size-time_counter*SizeOfOffset;
    									{
    											memcpy(Txbuf1,payload+CurrentPos,time_counter*SizeOfOffset);
    
    											memcpy(Txbuf1+time_counter*SizeOfOffset,new_array,Tx_raw_size-(time_counter*SizeOfOffset));
    											pru_uart_read(Rxbuf,RxSize);
    		//									uchar2uint(&ts_cur,Rxbuf+57,4);
    		//									ts_lcur = (ts_cur/20)%256 ;
    											pru_rpmsg_send(&transport,dst,src,Rxbuf,RxSize+1);
    											//memcpy(&Txbuf1[120], IOData, OutputDataSize) ;
    											//memcpy(&Txbuf1[136], &payload[244], PLCConveyorDataSize);
    		//									create_Tx_data(Txbuf, ts_lcur, 0, Txbuf1, Tx_data_size);
    											pru_uart_write(Txbuf1,Tx_raw_size);
    											}
    						}
    						
    						
    					len=0;
    					i=0;
    					count=!count;
    
    
    /*							//加一个pru_rpmsg_send 反馈?
    							//pru_uart_read(Rxbuf,RxSize);
    							//pru_rpmsg_send(&transport, dst, src, Rxbuf,RxSize);
    							//pru_uart_write(Txbuf,TxSize);
    
    								//while((CurrentPos+=SizeOfOffset*i)<Tx_raw_size)
    	//						IOData=&payload[240];
    	//						pru_rpmsg_send(&transport, dst, src, payload,len);
    	//						pru_rpmsg_send(&transport, dst, src, IOData,iodata_len);
    
    							//get the timestampe to fsignal->ts_cur
    						pru_uart_write(Txbuf,TxSize*10);
    							uchar2uint(&ts_cur,Rxbuf+57,4);
    							ts_lcur = (ts_cur/20)%256 ;
    							//while(len-(CurrentPos+=SizeOfOffset*i)>Tx_raw_size-2)
    							for(CurrentPos=0;CurrentPos<=len-Tx_raw_size;CurrentPos+=SizeOfOffset*i)
    								{
    
    									if (__R31 & HOST_INT) {
    										//pru_uart_write(Txbuf,TxSize);
    										 Clear the event status
    										CT_INTC.SICR_bit.STATUS_CLR_INDEX = FROM_ARM_HOST;
    										while(pru_rpmsg_receive(&transport, &src, &dst, IOData, &iodata_len) == PRU_RPMSG_SUCCESS);//
    										}
    									if(CurrentPos==len-Tx_raw_size)
    										//only 5*24 Bytes data left, call A15 to send route
    										{
    
    										memcpy(&Rxbuf[RxSize],"1",1);
    										pru_rpmsg_send(&transport, dst, src, Rxbuf,RxSize+1);
    										}
    									if(payload[CurrentPos]!=i)
    										pritnf("A15 to dsp data error !");
    //									memcpy(Txbuf1,&payload[CurrentPos],Tx_raw_size);
    //									memcpy(&Txbuf1[120], &payload[240], OutputDataSize) ;
    //									memcpy(&Txbuf1[136], &payload[244], PLCConveyorDataSize);
    //									create_Tx_data(Txbuf, ts_lcur, 0, Txbuf1, Tx_data_size);//i=0;i=1;i=2
    //									pru_uart_write(Txbuf,TxSize);
    									pru_uart_read(Rxbuf,RxSize);
    
    
    
    									//pru_rpmsg_send(&transport, dst, src, Rxbuf,RxSize);
    									i++;
    
    								}
    								i=0;*/
    
    
    
    				}
    
    
    
    }
    
    

    and code on A15:

    /*
     * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
     *
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     *	* Redistributions of source code must retain the above copyright
     *	  notice, this list of conditions and the following disclaimer.
     *
     *	* Redistributions in binary form must reproduce the above copyright
     *	  notice, this list of conditions and the following disclaimer in the
     *	  documentation and/or other materials provided with the
     *	  distribution.
     *
     *	* Neither the name of Texas Instruments Incorporated nor the names of
     *	  its contributors may be used to endorse or promote products derived
     *	  from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    #include <stdio.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <string.h>
    #include <sys/poll.h>
    #include "realtime.h"
    #include "timer.h"
    
    // char readBuf[MAX_BUFFER_SIZE];
    
    
    #define DEVICE_NAME		"/dev/rpmsg_pru30"
    
    #define MY_PRIORITY 99 /*! we use 49 as the PRREMPT_RT use 50
                                as the priority of kernel tasklets
                                and interrupt handler by default */
    #define TxSize 120*2	//!< transmission data frame size is 160 bytes
    
    #define RxSize 64+1	//!< recieved data frame size is 64 bytes      
    int main(void)
    {
    	static struct timespec t1,t2,ton,toff;
    	float tdiff;
    	struct pollfd pollfds[1];
    	int i=0,j;
    	int result = 0,result1 = 0,result2 = 0;
    
    	unsigned char Txbuf[TxSize];	// 160!< define Tx data buffer, CHECK! what Ready_buf does
    	unsigned char Rxbuf[RxSize];	// 64!< define Rx data buffer, CHECK! what Rxbuf does
    	ton=tic();
    	for(i=0;i<TxSize;i++)
    		Txbuf[i]=i;
    	make_realtime(getpid(), MY_PRIORITY);
    	/* Open the rpmsg_pru character device file */
    	pollfds[0].fd = open(DEVICE_NAME, O_RDWR);//| O_NDELAY | O_NOCTTY|O_NONBLOCK );
    
    	/*
    	 * If the RPMsg channel doesn't exist yet the character device
    	 * won't either.
    	 * Make sure the PRU firmware is loaded and that the rpmsg_pru
    	 * module is inserted.
    	 */
    	if (pollfds[0].fd < 0) {
    		printf("Failed to open %s\n", DEVICE_NAME);
    		return -1;
    	}
    
    	/* The RPMsg channel exists and the character device is opened */
    	printf("Opened %s\n", DEVICE_NAME);
    
    	 while(1){
    				result = write(pollfds[0].fd, Txbuf, TxSize);
    				if(result>0)
    					//printf("write Txbuf\n");
    				
    			//	for(i=0;i<8;i++)
    					{					
    					result2 = read(pollfds[0].fd, Rxbuf,RxSize);//block
    					
    					if (result2 > 0)
    						{
    						//printf("cost_time is %f\n",tdiff);
    						for (i=0;i<RxSize;i++)
    							printf("--%d",Rxbuf[i]);
    						printf("\n");
    						}
    					}
    			
    	}
    
    	toc(ton,&tdiff);
    	printf("whole_process_cost %f\n",tdiff);
    	/* Received all the messages the example is complete */
    	printf("closing %s\n",DEVICE_NAME);
    
    	/* Close the rpmsg_pru character device file */
    	close(pollfds[0].fd);
    	
    	return 0;
    }
    
    

  • Could you check if your .DATA area is defined in the resource table? I'll have my RTOS coworker to take a look at your resource table.

    Rex
  • I am using pru-software-support-package newest version.
    You metioned .DATA area ,I look through and find this : #pragma DATA_SECTION(resourceTable, ".resource_table")
    In struct "resourceTable" it only define pru_ints & rpmsg_vdev(vring0 &vring 1).
    L3,L4_PER1_P3 are not metioned .Change PRU_RPMSG_VQ0_SIZE will help?

  • philos,

    Can you post your UART code as well? From the log it looks like the PRU is booted correctly and the RPMsg channel is configured correctly. The next line in your code (line 179 in the rpmsg_pru.c file) is the 'pru_uart_initialize' function that you haven't shared yet.

    My current hunch is that you are trying to access one of the SOC UART peripherals and that it may not be powered on when you try to access its registers. You need to make sure that the clock for the UART peripheral have been enabled before trying to access its registers.

    Jason Reeder
  • Jason, Merry Christmas.

    Sorry for the late reply,in  AM57xx_PRU.cmd:

    /* Specify the sections allocation into memory */
    SECTIONS {
    	/* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading
    	   an ELF file, but useful when loading a binary */
    	.text:_c_int00*	>  0x0, PAGE 0
    
    	.text		>  PRU_IMEM, PAGE 0
    	.stack		>  PRU_DMEM_0_1, PAGE 1
    	.bss		>  PRU_DMEM_0_1, PAGE 1
    	.cio		>  PRU_DMEM_0_1, PAGE 1
    	.data		>  PRU_DMEM_0_1, PAGE 1
    	.switch		>  PRU_DMEM_0_1, PAGE 1
    	.sysmem		>  PRU_DMEM_0_1, PAGE 1
    	.cinit		>  PRU_DMEM_0_1, PAGE 1
    	.rodata		>  PRU_DMEM_0_1, PAGE 1
    	.rofardata	>  PRU_DMEM_0_1, PAGE 1
    	.farbss		>  PRU_DMEM_0_1, PAGE 1
    	.fardata	>  PRU_DMEM_0_1, PAGE 1
    
    	.resource_table > PRU_DMEM_0_1, PAGE 1
    }



    
    
    
    


    The .stack,.bss,.data and so on are all defined in 8kB Data_mem,so will that be a overflow ? I then deleted the functions and values that are not used yet.
    And I notice that I have to define the following "buffer" size to 512B(uint8_t buffer[512]),or it will opps with same error"omap_l3_noc 44000000.ocp:L3 debug error:target 5 mod :1(unclearable)"

    pru_rpmsg_receive(&transport, &src, &dst, buffer, &len)

    Now it  works !

    PS :this file contains the 'pru_uart_initialize' function

    #include "pru_uart_init.h"
    
    #define UART_PRU_INTERRUPT 6
    
    void pru_uart_initialize()
    {
    
    	/*Over-Sampling mode select,0:16x 1:13x*/
    	CT_UART.MDR = 0;
    
    	/*Most-significant bits and least-significant bits of
    	 *16-bit divisor for generation of the baud clock
    	 */
    	CT_UART.DLH = 0;
    	CT_UART.DLL = 0x00000002;
    
    	/*Interrupt enable register.[0-3]
    	 *1:enable interrupt 0:disable interrupt
    	 *7:enable data available,transmitter empty,line status interrupt
    	 */
    	CT_UART.IER = 0x00000007;
    
    	/*1:FIFO mode 0:Non-FIFO mode*/
    //	CT_UART.IIR_FCR_bit.FCR_FIFOEN = 0x1;
    
    	//tx_trig= 16   rx_trig=16
    	CT_UART.IIR_FCR = 0x00000047;
    	/*1:Clear receiver FIFO and reset FIFO counter*/
    //	CT_UART.IIR_FCR_bit.FCR_RXCLR = 0x1;
    	/*1:Clear transmitter FIFO and reset FIFO counter*/
    //	CT_UART.IIR_FCR_bit.FCR_TXCLR = 0x1;
    	/*DMA MODE1 is disabled*/
    //	CT_UART.IIR_FCR_bit.FCR_DMAMODE1 = 0x0;
    	/*Receiver FIFO trigger level.	When trigger level is reached,data-ready
    	 *interrupt is generated.0:1 byte 1:4 bytes 2:8 bytes
    	 *3:14 bytes*/
    //	CT_UART.IIR_FCR_bit.FCR_RXFIFTL = 0x2;
    
    	/*Line control register*/
    	CT_UART.LCR = 0x00000003;
    
    	/*Modem control register
    	 *autoflow control is disabled,loop back mode is enabled
    	 *RTS is disabled */
    	CT_UART.MCR = 0x00000000;
    	
    	/*Free-running mode is enabled*/
    	CT_UART.PWREMU_MGMT_bit.FREE = 0x1;
    	/*Receiver is enabled*/
    	CT_UART.PWREMU_MGMT_bit.URRST = 0x1;
    	/*Transmitter is enabled*/
    	CT_UART.PWREMU_MGMT_bit.UTRST = 0x1;
    
    
    
    
    }
    
    /*
    void pru_uart_interrupt_init()
    {
    	CT_INTC.SIPR0 = 0xFFFFFFFF;
    	CT_INTC.SITR0 = 0x00000000;
    	CT_INTC.CMR1 = 0x01000101;
    	CT_INTC.HMR0 = 0x03020100;
    
    	CT_INTC.SECR0 = 0xFFFFFFFF;
    	CT_INTC.SECR1 = 0xFFFFFFFF;
    
    	CT_INTC.EISR = UART_PRU_INTERRUPT;
    	CT_INTC.HIEISR = 0;
    	CT_INTC.GER = 0x00000001;
    
    	CT_UART.IER = 0x00000007;
    }
    */
    
    uint16_t pru_uart_write( unsigned char *Txbuf , uint16_t TxSize)
    {
    	uint16_t i,j;
    
    	for(i = 0;i < TxSize; i=i+16)
    	{
    		for(j = 0;j < 16;j++)
    			CT_UART.RBR_THR_bit.DATA = Txbuf[i+j];
    		while(CT_UART.LSR_bit.THRE == 0);
    	}
    	return 0;
    }
    
    uint16_t pru_uart_read(unsigned char *Rxbuf, uint16_t RxSize)
    {
    	uint16_t i;
    
    //	while((CT_UART.IIR_FCR_bit.IIR_IPEND == 1) || (CT_UART.IIR_FCR_bit.IIR_INTID != 0x2) )
    //	{}
    //	for(j=0; j < RxSize/8 ; j++){
    //		while((CT_UART.IIR_FCR_bit.IIR_IPEND == 1) || (CT_UART.IIR_FCR_bit.IIR_INTID != 0x2) )
    //		{}
    //	while((CT_UART.IIR_FCR_bit.IIR_INTID != 0x2) )
    //	{}
    //	while(CT_UART.LSR_bit.DR == 0)
    //	{}
    
    
    
    			for(i = 0; i < RxSize ; i++)
    			{
    				while(CT_UART.LSR_bit.DR == 0);
    
    				Rxbuf[i] = CT_UART.RBR_THR_bit.DATA;
    			}//?
    
    //		k=k+8;
    
    //	}
    	return 0;
    }
    
    
    
    

  • philos,

    Good catch on the possible overflow! You have to be careful with the small memories in the PRU-ICSS subsystem. One way to check the memory used by your program is to use the '-m' flag during the linking phase of your build process. This will create a map file that will show how much memory is being used in each memory as well as in each section. The PRU Compiler User's Guide describe the Linker flags in section 2.3.1 (www.ti.com/.../spruhv7).

    Another thing to note is that when you create your transmit and receive buffers as local variables (in the main method) that they will get placed on the stack. The RPMsg examples provided use a 256 byte stack. It is likely that your two transmit buffers (160 bytes each) and one receive buffer (64 bytes) are still overflowing the stack unless you've changed their size (or changed the stack size).

    The stack size can be changed at the top of the provided Makefile if desired.

    Jason Reeder

    PS. When I was developing the RPMsg examples I ended up moving the payload array (512 bytes) to a global variable because when I created it as a local variable I ran into a stack overflow that took me a while to track down.