below are the changes i have made in imx_rpmsg.c file
#define RPMSG_NUM_BUFS (1024)
+#define RPMSG_BUF_SIZE (512)
+#define RPMSG_BUFS_SPACE (RPMSG_NUM_BUFS * RPMSG_BUF_SIZE)
+
+/*
+ * The alignment between the consumer and producer parts of the vring.
+ * Note: this is part of the "wire" protocol. If you change this, you need
+ * to update your BIOS image as well
+ */
+#define RPMSG_VRING_ALIGN (4096)
+.
.
.
.
.
struct imx_rpmsg_vproc *rpdev = &imx_rpmsg_vprocs[i];
+
+ if (!strcmp(rpdev->rproc_name, "m4")) {
+ ret = of_device_is_compatible(np, "fsl,imx7d-rpmsg");
+ ret |= of_device_is_compatible(np, "fsl,imx6sx-rpmsg");
+ if (ret) {
+ /* hardcodes here now. */
+ rpdev->vring[0] = 0xBF800000;//0xBFFF0000;
+ rpdev->vring[1] = 0xBF880000;//0xBFFF8000;
+ }
+ } else {
+ break;
+ }
i want to increase the number of buffers, what other changes i have to make that work.
if change the buffer number back to 512, i see rpmsg driver works fine.with above memory allocation.
i have allocated now last 8MB of shared DDR memory for RPMSG.
do i need to change "RPMSG_VRING_ALIGN", what is the value and how to calculate it.
if i change RPMSG_VRING_ALIGN, what other files are affected, what other changes i have to make.
Hi Niranjanbc,
Yes, you are.
In RPMsg Lite, the init function does not block and you need to check whether the link is up by an explicit call. 
Also, you need to announce a new "channel" creation to the other side so that the kernel modules on the linux dies get probed.
Something in this way:
    my_rpmsg = rpmsg_lite_remote_init((void *)startupData, RPMSG_LITE_LINK_ID, RL_NO_FLAGS); 
 
    while (!rpmsg_lite_is_link_up(my_rpmsg))  ; 
 
    my_queue = rpmsg_queue_create(my_rpmsg); 
    my_ept = rpmsg_lite_create_ept(my_rpmsg, LOCAL_EPT_ADDR, rpmsg_queue_rx_cb, my_queue); 
    rpmsg_ns_bind(my_rpmsg, app_nameservice_isr_cb); 
    rpmsg_ns_announce(my_rpmsg, my_ept, RPMSG_LITE_NS_ANNOUNCE_STRING, RL_NS_CREATE); 
 
    PRINTF("\r\nNameservice sent, ready for incoming messages...\r\n"); 
 
    for (;;) 
    { 
        /* Get RPMsg rx buffer with message */ 
        result = rpmsg_queue_recv_nocopy(my_rpmsg, my_queue, (unsigned long *)&remote_addr, (char **)&rx_buf, &len, 
                                         RL_BLOCK);
.
.
.
Hope it helped,
Regards,
Marek
Hi Marek
I tried has below, still no luck
struct rpmsg_lite_instance *rpmsgM4Instance;
rpmsg_queue_handle rpmsgQ;
void* rpmsg_lite_base = BOARD_SHARED_MEMORY_BASE;
struct rpmsg_lite_endpoint *ctrl_ept;
....
.
.
.
env_init();
 rpmsgM4Instance  =  rpmsg_lite_remote_init(rpmsg_lite_base, RL_PLATFORM_IMX6SX_M4_LINK_ID,                                                              RL_NO_FLAGS);
while(!rpmsg_lite_is_link_up(rpmsgM4Instance));
PRINTF("RPMSG Lite Initialized\n\r");
rpmsgQ = rpmsg_queue_create(rpmsgM4Instance);
 ctrl_ept = rpmsg_lite_create_ept(rpmsgM4Instance, RL_ADDR_ANY, rpmsg_queue_rx_cb, rpmsgQ);
rpmsg_ns_bind(rpmsgM4Instance, app_namservice_callback);
rpmsg_ns_announce(rpmsgM4Instance, ctrl_ept, "rpmsg-openamp-demo-channel", RL_NS_CREATE); 
 
for (;;)
 {
rpmsg_queue_recv_nocopy(rpmsgM4Instance, rpmsgQ, &src, &rx_buf, &len, 0xFFFFFFFF);
.
.
.
.
.
 rpmsg_queue_nocopy_free(rpmsgM4Instance, rx_buf); 
 }
Hi Niranjanbc,
Is your BOARD_SHARED_MEMORY_BASE setup correctly?
Can you please generate a patch with your changes in Linux kernel and your application for the M4 side and share it here? I think I could look into it more and help you.
Also, you can try to add more pr_error() in Linux and more PRINTF in the M4 app and you can copy here the dmesg printout from kernel and output of M4 console...
Regards,
Marek
Hi Marek,
below please find the dmesg log and attached patch kernel
dmesg 
Booting Linux on physical CPU 0x0 
Linux version 3.14.28-1.0.0_ga+g91cf351 (niranjan@niranjan) (gcc version 4.9.2 (GCC) ) #1 SMP PREEMPT Wed Jun 21 14:18:59 EDT 2017 
CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c53c7d 
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache 
Machine model: Freescale i.MX6 SoloX Honeywell PIM Board 
cma: CMA: reserved 320 MiB at aa000000 
Memory policy: Data cache writealloc 
On node 0 totalpages: 258048 
free_area_init_node: node 0, pgdat 80b31940, node_mem_map be757000 
  DMA zone: 2016 pages used for memmap 
  DMA zone: 0 pages reserved 
  DMA zone: 258048 pages, LIFO batch:31 
PERCPU: Embedded 8 pages/cpu @be739000 s8832 r8192 d15744 u32768 
pcpu-alloc: s8832 r8192 d15744 u32768 alloc=8*4096 
pcpu-alloc: [0] 0  
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 256032 
Kernel command line: console=ttymxc0,115200 root=/dev/mmcblk2p2 rootwait rw uart_from_osc 
PID hash table entries: 4096 (order: 2, 16384 bytes) 
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) 
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes) 
Memory: 682860K/1032192K available (5344K kernel code, 259K rwdata, 5568K rodata, 252K init, 387K bss, 349332K reserved, 0K highmem) 
Virtual kernel memory layout: 
    vector  : 0xffff0000 - 0xffff1000   (   4 kB) 
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB) 
    vmalloc : 0xbf800000 - 0xff000000   (1016 MB) 
    lowmem  : 0x80000000 - 0xbf000000   (1008 MB) 
    pkmap   : 0x7fe00000 - 0x80000000   (   2 MB) 
    modules : 0x7f000000 - 0x7fe00000   (  14 MB) 
      .text : 0x80008000 - 0x80ab052c   (10914 kB) 
      .init : 0x80ab1000 - 0x80af0280   ( 253 kB) 
      .data : 0x80af2000 - 0x80b32c40   ( 260 kB) 
       .bss : 0x80b32c4c - 0x80b93960   ( 388 kB) 
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 
Preemptible hierarchical RCU implementation. 
    RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1. 
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1 
NR_IRQS:16 nr_irqs:16 16 
L310 cache controller enabled 
l2x0: 16 ways, CACHE_ID 0x410000c8, AUX_CTRL 0x32030000, Cache size: 256 kB 
Switching to timer-based delay loop 
sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 1431655765682ns 
clocksource_of_init: no matching clocksources found 
Console: colour dummy device 80x30 
Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000) 
pid_max: default: 32768 minimum: 301 
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes) 
Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes) 
CPU: Testing write buffer coherency: ok 
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000 
Setting up static identity map for 0x805165c0 - 0x80516618 
Brought up 1 CPUs 
SMP: Total of 1 processors activated. 
CPU: All CPU(s) started in SVC mode. 
devtmpfs: initialized 
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4 
pinctrl core: initialized pinctrl subsystem 
regulator-dummy: no parameters 
NET: Registered protocol family 16 
DMA: preallocated 256 KiB pool for atomic coherent allocations 
cpuidle: using governor ladder 
cpuidle: using governor menu 
Use WDOG1 as reset source 
syscon 20c8000.anatop: regmap [mem 0x020c8000-0x020c8fff] registered 
vdd1p1: 800 <--> 1375 mV at 1100 mV  
vdd3p0: 2800 <--> 3150 mV at 3000 mV  
vdd2p5: 2100 <--> 2875 mV at 2500 mV  
cpu: 725 <--> 1450 mV at 1150 mV  
vddpcie-phy: 725 <--> 1450 mV  
vddsoc: 725 <--> 1450 mV at 1175 mV  
syscon 20e4000.iomuxc-gpr: regmap [mem 0x020e4000-0x020e7fff] registered 
imx_mmdc_probe: failed to enable automatic power saving 
imx-mmdc: probe of 21b0000.mmdc failed with error -16 
syscon 21bc000.ocotp-ctrl: regmap [mem 0x021bc000-0x021bffff] registered 
syscon 21ac000.romcp: regmap [mem 0x021ac000-0x021affff] registered 
hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers. 
hw-breakpoint: maximum watchpoint size is 4 bytes. 
imx6sx-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver 
20dc000.gpc supply pu not found, using dummy regulator 
MU is ready for cross core communication! 
bio: create slab <bio-0> at 0 
mxs-dma 1804000.dma-apbh: initialized 
VCC_SD3: 3000 mV  
PSU-5V0: 5000 mV  
vref-3v3: 3300 mV  
usb_otg1_vbus: 5000 mV  
usb_otg2_vbus: 5000 mV  
i2c-core: driver [max17135] using legacy suspend method 
i2c-core: driver [max17135] using legacy resume method 
SCSI subsystem initialized 
usbcore: registered new interface driver usbfs 
usbcore: registered new interface driver hub 
usbcore: registered new device driver usb 
usbphy_nop1.12 supply vcc not found, using dummy regulator 
i2c i2c-0: IMX I2C adapter registered 
i2c i2c-1: IMX I2C adapter registered 
i2c i2c-3: IMX I2C adapter registered 
pps_core: LinuxPPS API ver. 1 registered 
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it> 
PTP clock support registered 
MIPI CSI2 driver module loaded 
Advanced Linux Sound Architecture Driver Initialized. 
Switched to clocksource mxc_timer1 
NET: Registered protocol family 2 
TCP established hash table entries: 8192 (order: 3, 32768 bytes) 
TCP bind hash table entries: 8192 (order: 4, 65536 bytes) 
TCP: Hash tables configured (established 8192 bind 8192) 
TCP: reno registered 
UDP hash table entries: 512 (order: 2, 16384 bytes) 
UDP-Lite hash table entries: 512 (order: 2, 16384 bytes) 
NET: Registered protocol family 1 
hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available 
RPMSG_RING_SIZE Niranjan: 12288 
PAGE_SIZE Niranjan: 4096 
imx_rpmsg_probe rpdev0: vring0 0xbf7f0000, vring1 0xbf7f8000 
virtio_rpmsg_bus virtio0: rpmsg host is online 
imx rpmsg driver is registered. 
Bus freq driver module loaded 
futex hash table entries: 256 (order: 2, 16384 bytes) 
VFS: Disk quotas dquot_6.5.2 
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) 
jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc. 
Compressor "zlib", prio 60 
Compressor "zlib", prio 60 
Compressor "rtime", prio 50 
fuse init (API version 7.22) 
JFS: nTxBlock = 7894, nTxLock = 63158 
msgmni has been set to 1973 
io scheduler noop registered 
io scheduler deadline registered 
io scheduler cfq registered (default) 
imx-weim 21b8000.weim: Driver registered. 
backlight.17 supply power not found, using dummy regulator 
MIPI DSI driver module loaded 
2224000.lcdif supply lcd not found, using dummy regulator 
mxsfb 2224000.lcdif: registered mxc display driver ldb 
DISPLAY: Power-on latency exceeded, new value 481333 ns 
DISPLAY: Power-off latency exceeded, new value 27000 ns 
Console: switching to colour frame buffer device 128x37 
DISPLAY: Power-off latency exceeded, new value 28667 ns 
mxsfb 2224000.lcdif: initialized 
imx-sdma 20ec000.sdma: no iram assigned, using external mem 
imx-sdma 20ec000.sdma: no event needs to be remapped 
imx-sdma 20ec000.sdma: loaded firmware 3.1 
imx-sdma 20ec000.sdma: initialized 
pfuze100-regulator 0-0008: Full layer: 1, Metal layer: 1 
pfuze100-regulator 0-0008: FAB: 0, FIN: 0 
pfuze100-regulator 0-0008: pfuze3000 found. 
SW1A: 700 <--> 1475 mV at 1375 mV  
SW1B: 700 <--> 1475 mV at 1375 mV  
SW2: 2500 <--> 3300 mV at 3300 mV  
SW3: 900 <--> 1650 mV at 1350 mV  
SWBST: 5000 <--> 5150 mV at 5000 mV  
VSNVS: 1000 <--> 3000 mV at 3000 mV  
VREFDDR: 750 mV  
VLDO1: 1800 <--> 3300 mV at 3300 mV  
VLDO2: 800 <--> 1550 mV at 1500 mV  
VCCSD: 2850 <--> 3300 mV at 3300 mV  
V33: 2850 <--> 3300 mV at 3000 mV  
VLDO3: 1800 <--> 3300 mV at 3300 mV  
VLDO4: 1800 <--> 3300 mV at 1800 mV  
Serial: IMX driver 
2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 58, base_baud = 1500000) is a IMX 
console [ttymxc0] enabled 
21f0000.serial: ttymxc3 at MMIO 0x21f0000 (irq = 61, base_baud = 1500000) is a IMX 
serial: Freescale lpuart driver 
imx sema4 driver is registered. 
[drm] Initialized drm 1.1.0 20060810 
[drm] Initialized vivante 1.0.0 20120216 on minor 0 
brd: module loaded 
loop: module loaded 
usbcore: registered new interface driver asix 
usbcore: registered new interface driver ax88179_178a 
usbcore: registered new interface driver cdc_ether 
usbcore: registered new interface driver net1080 
usbcore: registered new interface driver cdc_subset 
usbcore: registered new interface driver zaurus 
usbcore: registered new interface driver cdc_ncm 
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver 
ehci-mxc: Freescale On-Chip EHCI Host driver 
usbcore: registered new interface driver usb-storage 
2184800.usbmisc supply vbus-wakeup not found, using dummy regulator 
ci_hdrc ci_hdrc.1: EHCI Host Controller 
ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 1 
ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00 
hub 1-0:1.0: USB hub found 
hub 1-0:1.0: 1 port detected 
mousedev: PS/2 mouse device common for all mice 
input: 20cc000.snvs-pwrkey as /devices/soc0/soc.0/2000000.aips-bus/20cc000.snvs-pwrkey/input/input0 
snvs_pwrkey 20cc000.snvs-pwrkey: i.MX snvs powerkey probed 
i2c-core: driver [isl29023] using legacy suspend method 
i2c-core: driver [isl29023] using legacy resume method 
snvs_rtc 20cc034.snvs-rtc-lp: rtc core: registered 20cc034.snvs-rtc-lp as rtc0 
i2c /dev entries driver 
i2c-core: driver [mag3110] using legacy suspend method 
i2c-core: driver [mag3110] using legacy resume method 
imx2-wdt 20bc000.wdog: IMX2+ Watchdog Timer enabled. timeout=60s (nowayout=0) 
sdhci: Secure Digital Host Controller Interface driver 
sdhci: Copyright(c) Pierre Ossman 
sdhci-pltfm: SDHCI platform and OF driver helper 
mmc2: no vqmmc regulator found 
mmc2: SDHCI controller on 2198000.usdhc [2198000.usdhc] using ADMA 
mmc3: no vqmmc regulator found 
mmc3: no vmmc regulator found 
mmc3: SDHCI controller on 219c000.usdhc [219c000.usdhc] using ADMA 
galcore: clk_get 2d core clock failed, disable 2d/vg! 
Galcore version 5.0.11.25762 
usb 1-1: new high-speed USB device number 2 using ci_hdrc 
mmc2: host does not support reading read-only switch. assuming write-enable. 
mmc2: new high speed SDHC card at address 59b4 
mmcblk2: mmc2:59b4 USD   7.47 GiB  
 mmcblk2: p1 p2 
usbcore: registered new interface driver usbhid 
usbhid: USB HID core driver 
mmc3: BKOPS_EN bit is not set 
mmc3: switch to highspeed failed 
mmc3: new MMC card at address 0001 
mmcblk3: mmc3:0001 P1XXXX 3.60 GiB  
mmcblk3boot0: mmc3:0001 P1XXXX partition 1 2.00 MiB 
mmcblk3boot1: mmc3:0001 P1XXXX partition 2 2.00 MiB 
mmcblk3rpmb: mmc3:0001 P1XXXX partition 3 128 KiB 
 mmcblk3: unknown partition table 
 mmcblk3boot1: unknown partition table 
 mmcblk3boot0: unknown partition table 
ax88179_178a 1-1:1.0 eth0: register 'ax88179_178a' at usb-ci_hdrc.1-1, ASIX AX88179 USB 3.0 Gigabit Ethernet, d8:eb:97:b7:37:08 
wm8962 3-001a: Failed to read ID register 
wm8962: probe of 3-001a failed with error -110 
fsl-asrc 2034000.asrc: driver registered 
imx6sx-pinctrl 20e0000.iomuxc: pin MX6SX_PAD_SD4_DATA4 already requested by 219c000.usdhc; cannot claim for 2004000.spdif 
imx6sx-pinctrl 20e0000.iomuxc: pin-164 (2004000.spdif) status -22 
imx6sx-pinctrl 20e0000.iomuxc: could not request pin 164 (MX6SX_PAD_SD4_DATA4) from group spdifgrp  on device 20e0000.iomuxc 
fsl-spdif-dai 2004000.spdif: Error applying setting, reverse things back 
imx-wm8962 sound.24: audmux internal port setup failed 
imx-wm8962: probe of sound.24 failed with error -22 
imx-spdif sound-spdif.25: snd-soc-dummy-dai <-> 2004000.spdif mapping ok 
TCP: cubic registered 
cpu cpu0: dev_pm_opp_get_opp_count: device OPP not found (-19) 
A9-M4 sema4 num 6, A9-M4 magic number 0x12345678 - 0x4f4d4213. 
SWBST: disabling 
usb_otg1_vbus: disabling 
vref-3v3: disabling 
PSU-5V0: disabling 
regulator-dummy: disabling 
gpio-keys gpio-keys.19: Button without keycode: 0x6a 
gpio-keys: probe of gpio-keys.19 failed with error -22 
snvs_rtc 20cc034.snvs-rtc-lp: setting system clock to 1970-01-01 00:00:01 UTC (1) 
ALSA device list: 
  #0: imx-spdif 
EXT3-fs (mmcblk2p2): warning: mounting fs with errors, running e2fsck is recommended 
kjournald starting.  Commit interval 5 seconds 
EXT3-fs (mmcblk2p2): using internal journal 
EXT3-fs (mmcblk2p2): recovery complete 
EXT3-fs (mmcblk2p2): mounted filesystem with ordered data mode 
VFS: Mounted root (ext3 filesystem) on device 179:2. 
devtmpfs: mounted 
Freeing unused kernel memory: 252K (80ab1000 - 80af0000) 
udevd[82]: starting version 182 
evbug: Connected device: input0 (20cc000.snvs-pwrkey at snvs-pwrkey/input0) 
random: nonblocking pool is initialized 
Blank Screen: Setting LCD backlight to 0 
CPUFreq Utilities: Setting interactive CPUFreq governor 
CPU0 
CPUFreq Utilities: Setting 792000 CPUFreq Max Scaling Freq 
CPUFreq Utilities: Setting 198000 CPUFreq Min Scaling Freq 
DISPLAY: Power-off latency exceeded, new value 69333 ns 
DISPLAY: Power-off latency exceeded, new value 1081666 ns 
file system registered
Hi Niranjan,
I cannot see the print-outs with "niranjan" string anywhere in the patch, are you sure you include everything?
Also, could you add more PRINTs in the M4 application and post here the printouts from M4? 
I would also suggest, if possible, to first test RPMsg Lite with default VRING addresses and then to change the addresses in Linux and on M4 side, so that we make one change per step... 
Thanks,
Marek
i didnt add any print errors yet, i just attached patch and dmesg thinking that code might already have print error messages.
i am attaching m4 side FreeRtos code as well
the value for BOARD_SHARED_MEMORY_BASE
#define BOARD_SHARED_MEMORY_BASE ((void*)0xBF7F0000)
i am attaching IAR linker file as well.
Printf message from M4
rpmsg_lite_remote_init: sucess
rpmsg_queue_create: success
rpmsg_lite_create_ept: success
rpmsg_ns_bind: success
rpmsg_ns_announce: success
thanks for the clarification Marek, i will work on porting to RPMsg-lite.
You can refer these RPMsg examples:
https://community.nxp.com/docs/DOC-333803
Have a great day,
Victor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Victor,
thanks for sharing the link, but i dont find any information/example related to increasing buffer and dependencies.
can you point me to right document, if i am missing anything.
my main problem is, if increase buffer number. RPMSG is not working.
thanks
Niranjan