librpmsg_lite-imx part 2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

librpmsg_lite-imx part 2

Jump to solution
2,802 Views
wonk-andy
Contributor II

Hello (possibly one for @zdenek_zadera)

I'm struggling to find a workable address for the memory hole for the ping-pong example in librpmsg_lite-imx for QNX on my i.MX8MM board.

According to my imx_init_raminfo.c file in my QNX BSP, the RAM starts at 0x40000000 and is 1GB in size. This gives an address range of 0x40000000 to (0x80000000 - 1). 

The only setting for the init.mem_addr variable that even vaguely works is 0x78000000 with a corresponding init.mem_size of 8MB.  When I use that value then the imx_rpmsg_lite_init() function fails as virtual and physical addresses don't match.  Adding some debug it shows:

init: error phy 78051000 != virt 78000000

Any other values I try seem to upset QNX and the board resets due to the watchdog timer.

Any recommendation on an appropriate value to use?

-Andy.

Labels (1)
Tags (2)
0 Kudos
Reply
1 Solution
2,316 Views
ondrejlutera
NXP Employee
NXP Employee

Hi @wonk-andy ,

I have tried NXP i.MX8MM BSP with SDP 7.1. I can try 7.0 later but currently it is a lot of effort because we use 7.1 and 8.0 SDP only. However I was able to get an issue (board freeze). Not sure if same like you.

I have modified raminfo to use only 1GB of RAM and used your setup:

+    add_ram(IMX_SDRAM0_BASE, MEG(IMX_SDRAM0_SIZE) - MEG(2));
+//    add_ram(IMX_SDRAM1_BASE, MEG(IMX_SDRAM1_SIZE));
     /* Add 4 KB /memory/dma region. This region is not used by QNX and is dedicated to DMA. */
     as_add(IMX_SDRAM0_BASE, IMX_SDRAM0_BASE + KILO(4) - 1, AS_ATTR_NONE, "dma", as_default());

In pingpong_example.c I have modified mem_addr: 

@@ -203,7 +203,7 @@ int main(int argc, char **argv)
 #else
     /* SDRAM start + 4KB offset : there is a hole for RPMsg-lite,
        defined in BSP startup/boards/../../imx_init_raminfo.c */
-    init.mem_addr = 0x80000000 + (4 * 1024);
+    init.mem_addr = 0x7ff00000;

Then I executed :

# pingpong_example -m  &

And got the board freeze. Then I used QNX debug session to check where the code hangs. On my side the hang is not caused by mmap_device_memory (it maps the memory correctly) but caused by bus error when platform_recv_thread() is trying to write a value to some MU register. MU is not enabled by default in our NXP i.MX8MM BSP startup code. Can you check this on your side ? I had to add this code in imx_init_clocks.c startup module. 

@@ -911,6 +911,7 @@ int imx_init_clocks(imx_startup_data_t * startup_data)
         /* Enable SDMA1,2 */
         out32(IMX_CCM_BASE + IMX_CCM_CCGRn_SET(IMX_CCM_CCGR_SDMA1), 0x03);
         out32(IMX_CCM_BASE + IMX_CCM_CCGRn_SET(IMX_CCM_CCGR_SDMA2), 0x03);
+        out32(IMX_CCM_BASE + IMX_CCM_CCGRn_SET(IMX_CCM_CCGR_MU), 0x03);
         return 0;
     } while (0);
     return -1;

 After this the example works fine: 

# pingpong_example  &
[1] 143382
pingpong_example
# pingpong_example -m  &
[2] 147481
pingpong_example
Remote got data 0x01 len 1 bytes from source endpoint 30
Master got data 0x02 len 1 bytes from source endpoint 40
Remote got data 0x03 len 1 bytes from source endpoint 30
Master got data 0x04 len 1 bytes from source endpoint 40
Remote got data 0x05 len 1 bytes from source endpoint 30
Master got data 0x06 len 1 bytes from source endpoint 40
Remote got data 0x07 len 1 bytes from source endpoint 30
Master got data 0x08 len 1 bytes from source endpoint 40
Remote got data 0x09 len 1 bytes from source endpoint 30
Master got data 0x0a len 1 bytes from source endpoint 40
Remote got data 0x0b len 1 bytes from source endpoint 30
Master got data 0x0c len 1 bytes from source endpoint 40
Remote got data 0x0d len 1 bytes from source endpoint 30
Master got data 0x0e len 1 bytes from source endpoint 40
Remote got data 0x0f len 1 bytes from source endpoint 30
Master got data 0x10 len 1 bytes from source endpoint 40
Remote got data 0x11 len 1 bytes from source endpoint 30
Master got data 0x12 len 1 bytes from source endpoint 40
Remote got data 0x13 len 1 bytes from source endpoint 30
Master got data 0x14 len 1 bytes from source endpoint 40
Remote got data 0x15 len 1 bytes from source endpoint 30
Remote done
Master done
#

  

View solution in original post

0 Kudos
Reply
17 Replies
2,768 Views
ondrejlutera
NXP Employee
NXP Employee

Hello @wonk-andy ,

You need to create a hole in the imx_init_raminfo.c. For example if your imx_init_raminfo() contains line like this : 

add_ram(IMX_SDRAM0_BASE, MEG(IMX_SDRAM0_SIZE));

You can reserve an area for Rpmsg-lite eg. : 

add_ram(IMX_SDRAM0_BASE + MEG(8), MEG(IMX_SDRAM0_SIZE) - MEG(8));

 
This code reserves 8MB hole on the beginning of SDRAM0. In rpmsg-lite init you can use mem_addr = IMX_SDRAM0_BASE.
 
The 8MB size is not mandatory but you mentioned such size. (For the rpmsg-lite examples 512KB hole is fine)
 
In the imx_init_raminfo() there can be also code related to dma region. In such case you must avoid of overlap. i.MX8MM has SDMA so there is usually 4KB dma region from begin of SDRAM0. Then you need to align your rpmsg-lite hole and start after dma region like this : 
 
add_ram(IMX_SDRAM0_BASE + KILO(4) + MEG(8), MEG(IMX_SDRAM0_SIZE) - KILO(4) - MEG(8));
 
Then your rpmsg-lite init can use mem_addr = IMX_SDRAM0_BASE + KILO(4).
 
Ondrej

 

0 Kudos
Reply
2,762 Views
wonk-andy
Contributor II

Hi @ondrejlutera,

I'm not sure that I need an 8MB hole for RPMsg Lite, I think I just copied that value from somewhere, so I have reduced it to 128KB.

Putting the 128KB hole directly after the hole for DMA has worked and my debug output shows:

init: phy 40101000, virt 40101000

It has now errored out at the check for !context->instance after the call to rpmsg_lite_master_init().

-Andy.

0 Kudos
Reply
2,745 Views
wonk-andy
Contributor II

Hi @ondrejlutera 

The failure with the call torpmsg_lite_master_init() was down to not enough space being available for the buffers.  At the moment, this seems to be very fragile as changing values will make the system crash and reverting back to previous values doesn't always revert back to the same results.

The default version of the imx_init_raminfo.c file contains:

#define IMX_SDRAM_DMA_REGION_START		(IMX_SDRAM0_BASE + MEG(1))
#define IMX_SDRAM_DMA_REGION_END		(IMX_SDRAM_DMA_REGION_START + KILO(4))

void imx_init_raminfo(void)
{
    add_ram(IMX_SDRAM0_BASE, MEG(IMX_SDRAM0_SIZE));

    /* Add 4 KB /memory/dma region. This region is not used by QNX and is dedicated to DMA. */
    as_add(IMX_SDRAM_DMA_REGION_START, IMX_SDRAM_DMA_REGION_END - 1, AS_ATTR_NONE, "dma", as_default());
}

As I understand it this gives a memory map of:

0x40000000-0x40100000 Unused

0x40100000-0x40101000 DMA region

0x40101000-0x40800000 Unused

0x40800000-0x41b617c0 QNX .ifs image (as loaded by U-Boot)

0x41b617c0-0x80000000 Free (used by QNX as system memory)

To me, it seems I ought to be able to claim 1MB of memory at 0x40200000 to 0x40300000

Does that make sense?

-Andy.

0 Kudos
Reply
2,741 Views
ondrejlutera
NXP Employee
NXP Employee

Hi @wonk-andy ,

Yes the region 0x40200000 to 0x40300000 should work.

I dont think that the regions around DMA region are unused. The regions should be in sysram region . You can check memory regions using command :

pidin syspage=asinfo

I would do something like this to create a hole for the rpsmg-lite  : 

add_ram ( IMX_SDRAM_BASE, 0x40200000 - IMX_SDRAM_BASE)

add_ram ( 0x40300000, IMX_SDRAM_END - 0x40300000)

Regarding the size for rpmsg, it depends on RPMsg configuration in rpmsg_config.h and rpmsg_default_config.h and can be calculated as:

size = RL_WORD_ALIGN_UP((2*RL_BUFFER_COUNT*RL_BUFFER_SIZE)+RL_VRING_OVERHEAD)

Very quick calculation (based on my config) gives me 320 KB. 

0 Kudos
Reply
2,711 Views
wonk-andy
Contributor II

Hi @ondrejlutera 

I've still not managed to get a working solution for this.  First up, when I tried to use the two add_ram() calls as per your previous reply the QNX startup hung before it had output any console messages and then did its usual watchdog reset.

I have decided to try using the last 1MB of memory as this should be large enough for the buffers and easy to grab.  My imx_init_raminfo.c now contains the following:

#define IMX_SDRAM_DMA_REGION_START		(IMX_SDRAM0_BASE + MEG(1))
#define IMX_SDRAM_DMA_REGION_END		(IMX_SDRAM_DMA_REGION_START + KILO(4))

#define IMX_SDRAM_RPMSG_REGION_START	(IMX_SDRAM0_BASE + MEG(IMX_SDRAM0_SIZE) - MEG(1))
#define IMX_SDRAM_RPMSG_REGION_END		(IMX_SDRAM0_BASE + MEG(IMX_SDRAM0_SIZE))

void imx_init_raminfo(void)
{
    add_ram(IMX_SDRAM0_BASE, MEG(IMX_SDRAM0_SIZE));

    /* Add 4 KB /memory/dma region. This region is not used by QNX and is dedicated to DMA. */
    as_add(IMX_SDRAM_DMA_REGION_START, IMX_SDRAM_DMA_REGION_END - 1, AS_ATTR_NONE, "dma", as_default());

    /* Add the last 1MB of physical memory to be the buffer for the RPMsg Lite interface. */
    as_add(IMX_SDRAM_RPMSG_REGION_START, IMX_SDRAM_RPMSG_REGION_END - 1, AS_ATTR_NONE, "rpmsg", as_default());
}

 

This gives me the following output from pidin:

 

# pidin syspage=asinfo
Header size=0x00000108, Total Size=0x00001748, #Cpu=4, Type=257
Section:asinfo offset:0x00000aa8 size:0x00000440 elsize:0x00000020
  0000) 0000000000000000-0000ffffffffffff o:ffff a:0010 p:100 c:0 n:/memory
  0020) 0000000000000000-00000000ffffffff o:0000 a:0010 p:100 c:0 n:/memory/below4G
  0040) 0000000053100000-000000005313ffff o:0000 a:0013 p:100 c:0 n:/memory/gpu-reg-base-3D
  0060) 0000000053100000-000000005313ffff o:0040 a:0013 p:100 c:0 n:/memory/gpu-reg-base-3D/io
  0080) 0000000054100000-000000005413ffff o:0000 a:0013 p:100 c:0 n:/memory/gpu-reg-base-3D1
  00a0) 0000000054100000-000000005413ffff o:0080 a:0013 p:100 c:0 n:/memory/gpu-reg-base-3D1/io
  00c0) 0000000040000000-00000000530fffff o:0020 a:0037 p:100 c:0 n:/memory/below4G/ram
  00e0) 0000000053100000-000000005313ffff o:0060 a:0037 p:100 c:0 n:/memory/gpu-reg-base-3D/io/ram
  0100) 0000000053140000-00000000540fffff o:0020 a:0037 p:100 c:0 n:/memory/below4G/ram
  0120) 0000000054100000-000000005413ffff o:00a0 a:0037 p:100 c:0 n:/memory/gpu-reg-base-3D1/io/ram
  0140) 0000000054140000-000000007fffffff o:0020 a:0017 p:100 c:0 n:/memory/below4G/ram
  0160) 0000000000000000-0000ffffffffffff o:ffff a:0010 p:100 c:0 n:/memory
  0180) 0000000040100000-0000000040100fff o:0160 a:0000 p:100 c:0 n:/memory/dma
  01a0) 0000000000000000-0000ffffffffffff o:ffff a:0010 p:100 c:0 n:/memory
  01c0) 000000007ff00000-000000007fffffff o:01a0 a:0000 p:100 c:0 n:/memory/rpmsg
  01e0) 0000000038800000-000000003880ffff o:0000 a:0003 p:100 c:0 n:/memory/gicd
  0200) 0000000038880000-00000000388fffff o:0000 a:0003 p:100 c:0 n:/memory/gicr
  0220) 0000000052000000-0000000052001fff o:0000 a:0003 p:100 c:0 n:/memory/gicc
  0240) 0000000052020000-0000000052020fff o:0000 a:0003 p:100 c:0 n:/memory/gicv
  0260) 0000000052010000-0000000052010fff o:0000 a:0003 p:100 c:0 n:/memory/gich
  0280) 000000004000f800-000000004000ffff o:0000 a:0007 p:100 c:0 n:/memory/hypervisor_vector
  02a0) 0000000040841108-000000004398009f o:0000 a:0005 p:100 c:0 n:/memory/imagefs
  02c0) 0000000040800000-0000000040841107 o:0000 a:0007 p:100 c:0 n:/memory/startup
  02e0) 0000000040841108-000000004398009f o:0000 a:0007 p:100 c:0 n:/memory/bootram
  0300) 0000000000000000-00000000ffffffff o:ffff a:0010 p:100 c:0 n:/virtual
  0320) ffffff8060049000-ffffff80601113b0 o:0300 a:0000 p:100 c:0 n:/virtual/vboot
  0340) 0000000040000000-0000000040007fff o:00c0 a:0007 p:100 c:0 n:/memory/below4G/ram/sysram
  0360) 000000004000f000-000000004000efff o:00c0 a:0007 p:100 c:0 n:/memory/below4G/ram/sysram
  0380) 0000000040014000-00000000407fffff o:00c0 a:0007 p:100 c:0 n:/memory/below4G/ram/sysram
  03a0) 0000000043981000-00000000530fffff o:00c0 a:0027 p:100 c:0 n:/memory/below4G/ram/sysram
  03c0) 0000000053100000-000000005313ffff o:00e0 a:0027 p:100 c:0 n:/memory/gpu-reg-base-3D/io/ram/sysram
  03e0) 0000000053140000-00000000540fffff o:0100 a:0027 p:100 c:0 n:/memory/below4G/ram/sysram
  0400) 0000000054100000-000000005413ffff o:0120 a:0027 p:100 c:0 n:/memory/gpu-reg-base-3D1/io/ram/sysram
  0420) 0000000054140000-000000007f3f4fff o:0140 a:0007 p:100 c:0 n:/memory/below4G/ram/sysram

 

It looks to have allocated the requested block of memory (offset 1c0 in the output).  It is in the same region (/memory) as the dma.  Should it be in /memory/below4G/ram/sysram?

Any other ideas on what may be wrong?

-Andy

0 Kudos
Reply
2,708 Views
ondrejlutera
NXP Employee
NXP Employee

Hi @wonk-andy ,

pidin output looks good. Point is to do not have the reserved memory area within /memory/below4G/ram/sysram. 

The way you did the reserved area should be also correct. You can try to provide the address 0x7ff00000 to imx_rpmsg_lite_init() to see whether mmap_device_memory() will map from the reserved /memory/rpmsg section. If the mmap_device_memory() fails to map from /memory/rpmsg section you can try to remove your as_add()  and simply shrink add_ram() like this : 

add_ram(IMX_SDRAM0_BASE, MEG(IMX_SDRAM0_SIZE) - MEG(1));

 

FIY: To little bit clarify usage of the sections like /memory/dma or /memory/rpmsg (why defined for dma) you can look to sdma library source code (should be within /lib folder of your BSP). Good thing on named sections is that you do not need to know phy address of section in your application.  You can use posix_typed_mem_open(../memory/rpmsg, .. ) and then mmap() contiguous memory from the section . You can refer to sdma source code if you are curious. Also rpmsg-lite wrapper could use posix_typed_mem_open() but you would need to implement it as for now it is using simply mmap_device_memory() and expects phy and size provided by user.

 
0 Kudos
Reply
2,387 Views
wonk-andy
Contributor II

Hi @ondrejlutera,

I am back looking at this issue.  I mentioned it to a contact at Lauterbach, who I think is an ex-QNX guy, and he said

Somewhere along the way, calling this function (mmap_device_memory) results in a page fault which traps into the QNX kernel’s handler for this and then it works out what it needs to do to map the correct physical address into a virtual pointer that your task can use to access that physical memory.

I'm guessing that this is where it is falling over but I have no idea how to start debugging it.  Before I get too much further into this, has there been any update, I have QNX RPMsg-Lite 1.1.0.  I might have a look at posix_typed_mem_open() and see whether that makes life any easier.

-Andy.

0 Kudos
Reply
2,357 Views
ondrejlutera
NXP Employee
NXP Employee

Hi @wonk-andy ,

Could you share:

1. Actual imx_init_raminfo() code + symbol values used 

2. Output of pidin syspage=asinfo command

3. Initialization values of imx_rpmsg_init_t struct

 

Thanks

0 Kudos
Reply
2,346 Views
wonk-andy
Contributor II

Hi @ondrejlutera 

The current version of the imx_init_raminfo() function contains:

 

void imx_init_raminfo(void)
{
    add_ram(IMX_SDRAM0_BASE, MEG(IMX_SDRAM0_SIZE));

    /* Add 4 KB /memory/dma region. This region is not used by QNX and is dedicated to DMA. */
    as_add(IMX_SDRAM_DMA_REGION_START, IMX_SDRAM_DMA_REGION_END - 1, AS_ATTR_NONE, "dma", as_default());

    /* Add the last 1MB of physical memory to be the buffer for the RPMsg Lite interface. */
    as_add(IMX_SDRAM_RPMSG_REGION_START, IMX_SDRAM_RPMSG_REGION_END - 1, AS_ATTR_NONE, "rpmsg", as_default());
}

 

 

The constants defined are as follows:

 

#define IMX_SDRAM0_BASE                    0x40000000
#define IMX_SDRAM0_SIZE                    1024

#define IMX_SDRAM_DMA_REGION_START		(IMX_SDRAM0_BASE + MEG(1))
#define IMX_SDRAM_DMA_REGION_END		(IMX_SDRAM_DMA_REGION_START + KILO(4))

#define IMX_SDRAM_RPMSG_REGION_START	(IMX_SDRAM0_BASE + MEG(IMX_SDRAM0_SIZE) - MEG(1))
#define IMX_SDRAM_RPMSG_REGION_END		(IMX_SDRAM0_BASE + MEG(IMX_SDRAM0_SIZE))

 

 

The output of pidin syspage=asinfo:

# pidin syspage=asinfo
Header size=0x00000108, Total Size=0x00001748, #Cpu=4, Type=257
Section:asinfo offset:0x00000aa8 size:0x00000440 elsize:0x00000020
  0000) 0000000000000000-0000ffffffffffff o:ffff a:0010 p:100 c:0 n:/memory
  0020) 0000000000000000-00000000ffffffff o:0000 a:0010 p:100 c:0 n:/memory/below4G
  0040) 0000000053100000-000000005313ffff o:0000 a:0013 p:100 c:0 n:/memory/gpu-reg-base-3D
  0060) 0000000053100000-000000005313ffff o:0040 a:0013 p:100 c:0 n:/memory/gpu-reg-base-3D/io
  0080) 0000000054100000-000000005413ffff o:0000 a:0013 p:100 c:0 n:/memory/gpu-reg-base-3D1
  00a0) 0000000054100000-000000005413ffff o:0080 a:0013 p:100 c:0 n:/memory/gpu-reg-base-3D1/io
  00c0) 0000000040000000-00000000530fffff o:0020 a:0037 p:100 c:0 n:/memory/below4G/ram
  00e0) 0000000053100000-000000005313ffff o:0060 a:0037 p:100 c:0 n:/memory/gpu-reg-base-3D/io/ram
  0100) 0000000053140000-00000000540fffff o:0020 a:0037 p:100 c:0 n:/memory/below4G/ram
  0120) 0000000054100000-000000005413ffff o:00a0 a:0037 p:100 c:0 n:/memory/gpu-reg-base-3D1/io/ram
  0140) 0000000054140000-000000007fffffff o:0020 a:0017 p:100 c:0 n:/memory/below4G/ram
  0160) 0000000000000000-0000ffffffffffff o:ffff a:0010 p:100 c:0 n:/memory
  0180) 0000000040100000-0000000040100fff o:0160 a:0000 p:100 c:0 n:/memory/dma
  01a0) 0000000000000000-0000ffffffffffff o:ffff a:0010 p:100 c:0 n:/memory
  01c0) 000000007ff00000-000000007fffffff o:01a0 a:0000 p:100 c:0 n:/memory/rpmsg
  01e0) 0000000038800000-000000003880ffff o:0000 a:0003 p:100 c:0 n:/memory/gicd
  0200) 0000000038880000-00000000388fffff o:0000 a:0003 p:100 c:0 n:/memory/gicr
  0220) 0000000052000000-0000000052001fff o:0000 a:0003 p:100 c:0 n:/memory/gicc
  0240) 0000000052020000-0000000052020fff o:0000 a:0003 p:100 c:0 n:/memory/gicv
  0260) 0000000052010000-0000000052010fff o:0000 a:0003 p:100 c:0 n:/memory/gich
  0280) 000000004000f800-000000004000ffff o:0000 a:0007 p:100 c:0 n:/memory/hypervisor_vector
  02a0) 0000000040841108-0000000040baa27f o:0000 a:0005 p:100 c:0 n:/memory/imagefs
  02c0) 0000000040800000-0000000040841107 o:0000 a:0007 p:100 c:0 n:/memory/startup
  02e0) 0000000040841108-0000000040baa27f o:0000 a:0007 p:100 c:0 n:/memory/bootram
  0300) 0000000000000000-00000000ffffffff o:ffff a:0010 p:100 c:0 n:/virtual
  0320) ffffff8060043000-ffffff806010b3b0 o:0300 a:0000 p:100 c:0 n:/virtual/vboot
  0340) 0000000040000000-0000000040007fff o:00c0 a:0007 p:100 c:0 n:/memory/below4G/ram/sysram
  0360) 000000004000f000-000000004000efff o:00c0 a:0007 p:100 c:0 n:/memory/below4G/ram/sysram
  0380) 0000000040014000-00000000407fffff o:00c0 a:0007 p:100 c:0 n:/memory/below4G/ram/sysram
  03a0) 0000000040bab000-00000000530fffff o:00c0 a:0027 p:100 c:0 n:/memory/below4G/ram/sysram
  03c0) 0000000053100000-000000005313ffff o:00e0 a:0027 p:100 c:0 n:/memory/gpu-reg-base-3D/io/ram/sysram
  03e0) 0000000053140000-00000000540fffff o:0100 a:0027 p:100 c:0 n:/memory/below4G/ram/sysram
  0400) 0000000054100000-000000005413ffff o:0120 a:0027 p:100 c:0 n:/memory/gpu-reg-base-3D1/io/ram/sysram
  0420) 0000000054140000-000000007f3f4fff o:0140 a:0007 p:100 c:0 n:/memory/below4G/ram/sysram

 

The imx_rpmsg_init_t structure is initialised as follows:

#define	RPMSG_LITE_MEM_ADDR		0x7ff00000
#define	RPMSG_LITE_MEM_SIZE		KILO(512)
#define	RPMSG_LINK_ID			0

xInit.mem_addr = RPMSG_LITE_MEM_ADDR;
xInit.mem_length = RPMSG_LITE_MEM_SIZE;
xInit.link_id = RPMSG_LINK_ID;
xInit.init_flags = 0;

 

I've looked at all of these many times now and can't see anything obviously wrong with them.  If you do manage to spot anything that would be great.

-Andy.

0 Kudos
Reply
2,339 Views
ondrejlutera
NXP Employee
NXP Employee

Hi @wonk-andy ,

Let me reproduce it on my side.

Based on your setup and based on previous conversation I think that mmap_device_memory() may fail because of region defined by as_add() - there is /memory/rpmsg entry in asinfo. Kernel can deny any mmap_device_memory() to known region. posix_typed_mem_open() and mmap() should work fine with such region. 

However to avoid any modification in rpmsg wrapper I would expect working solution like this (MEG(2) is there just to be sure. MEG(1) should be final correct value) : 

void imx_init_raminfo(void)
{
    add_ram(IMX_SDRAM0_BASE, MEG(IMX_SDRAM0_SIZE) - MEG(2));

    /* Add 4 KB /memory/dma region. This region is not used by QNX and is dedicated to DMA. */
    as_add(IMX_SDRAM_DMA_REGION_START, IMX_SDRAM_DMA_REGION_END - 1, AS_ATTR_NONE, "dma", as_default());

}

 This simply keeps last 2 MB unused. I used this way in various situations including rpmsg, DSP, Cortex-M memory reservation. It should work. This is first step I would try. 

Ondrej

0 Kudos
Reply
2,334 Views
wonk-andy
Contributor II

Hi @ondrejlutera 

With those proposed changes, the "rpmsg" section is no longer present in the output from pidin syspage=asinfo.  The relevant line about the RAM has changed, as expected, to:

0140) 0000000054140000-000000007fdfffff o:0020 a:0017 p:100 c:0 n:/memory/below4G/ram

When I call mmap_device_memory() with my application, I still see the same issue.

-Andy.

0 Kudos
Reply
2,327 Views
ondrejlutera
NXP Employee
NXP Employee

Hi @wonk-andy ,

Do you use 7.0 , 7.1 or 8.0 QNX SDP ?

Is your application based on rpmsg-lite QNX examples or something custom ? 

Thank you

0 Kudos
Reply
2,323 Views
wonk-andy
Contributor II

Hi @ondrejlutera 

The hardware is an i.MX8MM with 1GB RAM running QNX SDP 7.0.

My application code is based on the ping-pong example which also shows the same problem.  We can use the ping-pong example as the test application.

My application and the ping-pong example are configured to use the no SCFW option the same as the i.MX8MP.

-Andy.

0 Kudos
Reply
2,317 Views
ondrejlutera
NXP Employee
NXP Employee

Hi @wonk-andy ,

I have tried NXP i.MX8MM BSP with SDP 7.1. I can try 7.0 later but currently it is a lot of effort because we use 7.1 and 8.0 SDP only. However I was able to get an issue (board freeze). Not sure if same like you.

I have modified raminfo to use only 1GB of RAM and used your setup:

+    add_ram(IMX_SDRAM0_BASE, MEG(IMX_SDRAM0_SIZE) - MEG(2));
+//    add_ram(IMX_SDRAM1_BASE, MEG(IMX_SDRAM1_SIZE));
     /* Add 4 KB /memory/dma region. This region is not used by QNX and is dedicated to DMA. */
     as_add(IMX_SDRAM0_BASE, IMX_SDRAM0_BASE + KILO(4) - 1, AS_ATTR_NONE, "dma", as_default());

In pingpong_example.c I have modified mem_addr: 

@@ -203,7 +203,7 @@ int main(int argc, char **argv)
 #else
     /* SDRAM start + 4KB offset : there is a hole for RPMsg-lite,
        defined in BSP startup/boards/../../imx_init_raminfo.c */
-    init.mem_addr = 0x80000000 + (4 * 1024);
+    init.mem_addr = 0x7ff00000;

Then I executed :

# pingpong_example -m  &

And got the board freeze. Then I used QNX debug session to check where the code hangs. On my side the hang is not caused by mmap_device_memory (it maps the memory correctly) but caused by bus error when platform_recv_thread() is trying to write a value to some MU register. MU is not enabled by default in our NXP i.MX8MM BSP startup code. Can you check this on your side ? I had to add this code in imx_init_clocks.c startup module. 

@@ -911,6 +911,7 @@ int imx_init_clocks(imx_startup_data_t * startup_data)
         /* Enable SDMA1,2 */
         out32(IMX_CCM_BASE + IMX_CCM_CCGRn_SET(IMX_CCM_CCGR_SDMA1), 0x03);
         out32(IMX_CCM_BASE + IMX_CCM_CCGRn_SET(IMX_CCM_CCGR_SDMA2), 0x03);
+        out32(IMX_CCM_BASE + IMX_CCM_CCGRn_SET(IMX_CCM_CCGR_MU), 0x03);
         return 0;
     } while (0);
     return -1;

 After this the example works fine: 

# pingpong_example  &
[1] 143382
pingpong_example
# pingpong_example -m  &
[2] 147481
pingpong_example
Remote got data 0x01 len 1 bytes from source endpoint 30
Master got data 0x02 len 1 bytes from source endpoint 40
Remote got data 0x03 len 1 bytes from source endpoint 30
Master got data 0x04 len 1 bytes from source endpoint 40
Remote got data 0x05 len 1 bytes from source endpoint 30
Master got data 0x06 len 1 bytes from source endpoint 40
Remote got data 0x07 len 1 bytes from source endpoint 30
Master got data 0x08 len 1 bytes from source endpoint 40
Remote got data 0x09 len 1 bytes from source endpoint 30
Master got data 0x0a len 1 bytes from source endpoint 40
Remote got data 0x0b len 1 bytes from source endpoint 30
Master got data 0x0c len 1 bytes from source endpoint 40
Remote got data 0x0d len 1 bytes from source endpoint 30
Master got data 0x0e len 1 bytes from source endpoint 40
Remote got data 0x0f len 1 bytes from source endpoint 30
Master got data 0x10 len 1 bytes from source endpoint 40
Remote got data 0x11 len 1 bytes from source endpoint 30
Master got data 0x12 len 1 bytes from source endpoint 40
Remote got data 0x13 len 1 bytes from source endpoint 30
Master got data 0x14 len 1 bytes from source endpoint 40
Remote got data 0x15 len 1 bytes from source endpoint 30
Remote done
Master done
#

  

0 Kudos
Reply
2,312 Views
wonk-andy
Contributor II

Hi @ondrejlutera 

I've added the addition line into imx_init_clocks.c and I have now been able to replicate the correct operation of the pingpong example. I'm a little confused, as when I did the initial debugging it definitely seemed to be the call to mmap_device_memory() that seemed to be causing the issue.

Now that the pingpong example is working, I am going to try my application now which runs as the master with the Cortex-M firmware as the slave.

-Andy.

0 Kudos
Reply
2,299 Views
ondrejlutera
NXP Employee
NXP Employee

Hi @wonk-andy ,

Great news.

Please mark my previous answer as "Accept as solution" if fixed. 

Thanks

0 Kudos
Reply
2,784 Views
jimmychan
NXP TechSupport
NXP TechSupport

Hello @zdenek_zadera ,

 

Would you please help this? Thanks.

 

Best regards,

Jimmy

0 Kudos
Reply