cancel
Showing results for 
Search instead for 
Did you mean: 

OpenAMP issue on STM32H745

MECHO
Associate

Software: CUBEIDE:1.18.0
Firmware: STM32Cube_FW_H7_V1.12.1

Board: NUCLEO-H745ZI-Q

The problem is as follows: when using this chip for dual core communication, reproducing according to the example given by ST, communication cannot be carried out no matter what.

Through debugging, it was found that the problem lies in the OPENAMP_create_endpoint() function in the M4 core. The return value is -2005, but as a beginner, I am unable to pinpoint where the problem lies. I will attach my project at the end of the article.

My original goal was for the M7 core to send data to the M4 core, which would then print the data while the M7 core's LED would flash.

I have reviewed the corresponding routines in ST's AN5617 and firmware, and watched the corresponding videos, but still cannot solve the problem. I request your help

MECHO_0-1744812753218.png

 

15 REPLIES 15
mƎALLEm
ST Employee

Hello @MECHO and welcome to the community,

OpenAMP needs a shared memory between both cores and accessible by both cores.

You need to declare a memory section where the message will be stored.

Looking at your project there is no declaration of that shared memory for OpenAMP in the linker file and the openamp conf file.

Look for example at the linker files in the example: Projects\STM32H747I-EVAL\Applications\OpenAMP\OpenAMP_PingPong\

CM4:

MEMORY
{
FLASH (rx)      : ORIGIN = 0x08100000, LENGTH = 1024K
RAM (xrw)      : ORIGIN = 0x10000000, LENGTH = 288K
OPENAMP_RSC_TAB (xrw) 	: ORIGIN = 0x38000000, LENGTH = 1K
OPEN_AMP_SHMEM (xrw) 	: ORIGIN = 0x38000400, LENGTH = 63K
}
 __OPENAMP_region_start__  = ORIGIN(OPEN_AMP_SHMEM);
 __OPENAMP_region_end__ = ORIGIN(OPEN_AMP_SHMEM) + LENGTH(OPEN_AMP_SHMEM);

CM7:

MEMORY
{
FLASH (rx)	    		: ORIGIN = 0x08000000, LENGTH = 1024K
RAM (xrw)   	   		: ORIGIN = 0x20000000, LENGTH = 128K
ITCMRAM (xrw)      		: ORIGIN = 0x00000000, LENGTH = 64K
OPENAMP_RSC_TAB (xrw) 	: ORIGIN = 0x38000000, LENGTH = 1K
OPEN_AMP_SHMEM (xrw) 	: ORIGIN = 0x38000400, LENGTH = 63K
}
 __OPENAMP_region_start__  = ORIGIN(OPEN_AMP_SHMEM);
 __OPENAMP_region_end__ = ORIGIN(OPEN_AMP_SHMEM) + LENGTH(OPEN_AMP_SHMEM);

This memory sections are used by the Common\Inc\openamp_conf.h:

#else
/*
 * for GCC add the following content to the .ld file:
 * MEMORY
 * {
 * ...
 * OPEN_AMP_SHMEM (xrw) : ORIGIN = 0x38000400, LENGTH = 63K
 * }
 * __OPENAMP_region_start__  = ORIGIN(OPEN_AMP_SHMEM);
 * __OPENAMP_region_end__ = ORIGIN(OPEN_AMP_SHMEM) + LENGTH(OPEN_AMP_SHMEM);
 *
 * using the LENGTH(OPEN_AMP_SHMEM) to set the SHM_SIZE lead to a crash thus we
 * use the start and end address.
 */

extern int __OPENAMP_region_start__[];  /* defined by linker script */
extern int __OPENAMP_region_end__[];    /* defined by linker script */

#define SHM_START_ADDRESS       ((metal_phys_addr_t)__OPENAMP_region_start__)
#define SHM_SIZE                (size_t)((void *)__OPENAMP_region_end__ - (void *) __OPENAMP_region_start__)

#endif

As you didn't declare this shared memory it seems that OpenAMP library can't find a memory where to store the shared messages.

Hope that helps.

 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Thank you for your reply. May I ask how to declare this shared memory? I compared the contents of my files and did not see any abnormal situations.

MECHO_0-1744816426309.png

If you feel that my operation is incorrect, please help me modify it in my project so that I can clearly see what I did wrong. I once again request your assistance.

Please review the linker files OpenAMP_ttest\CM7\STM32H745ZITX_RAM.ld and OpenAMP_ttest\CM4\STM32H745ZITX_RAM.ld

This is what you have in your linker files:

For CM7:

MEMORY
{
  RAM_D1 (xrw)   : ORIGIN = 0x24000000, LENGTH =  512K
  FLASH   (rx)   : ORIGIN = 0x08000000, LENGTH = 1024K    /* Memory is divided. Actual start is 0x8000000 and actual length is 2048K */
  DTCMRAM (xrw)  : ORIGIN = 0x20000000, LENGTH = 128K
  RAM_D2 (xrw)   : ORIGIN = 0x30000000, LENGTH = 288K
  RAM_D3 (xrw)   : ORIGIN = 0x38000000, LENGTH = 64K
  ITCMRAM (xrw)  : ORIGIN = 0x00000000, LENGTH = 64K
}

For CM4:

MEMORY
{
RAM_EXEC (rx)  : ORIGIN = 0x10000000, LENGTH = 128K
RAM (xrw)      : ORIGIN = 0x10020000, LENGTH = 160K
}

 And look at what I shared previously as linker files content.

You have this is missing:

OPENAMP_RSC_TAB (xrw) 	: ORIGIN = 0x38000000, LENGTH = 1K
OPEN_AMP_SHMEM (xrw) 	: ORIGIN = 0x38000400, LENGTH = 63K
}
 __OPENAMP_region_start__  = ORIGIN(OPEN_AMP_SHMEM);
 __OPENAMP_region_end__ = ORIGIN(OPEN_AMP_SHMEM) + LENGTH(OPEN_AMP_SHMEM)

And forget about the files location as they are not the source of the issue.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Thank you for your answer, but there is still a problem on my end, even though I have made changes to the corresponding code according to your suggestion.

MECHO_0-1744818430894.png

However, the debugging situation is still the same as before, with a return value of -2005, which makes me very confused. If you feel there are still issues, please make the necessary modifications directly in my project. Because I may make mistakes and receive many invalid responses, I believe direct modification is the most effective way. I earnestly request your assistance.

Hello,

First, please use </> button to share you code. Please read this post.

Second, please remove this memory region declaration at 0x38000000:

RAM_D3 (xrw)   : ORIGIN = 0x38000000, LENGTH = 64K

as it's already used by:

OPENAMP_RSC_TAB (xrw) 	: ORIGIN = 0x38000000, LENGTH = 1K
OPEN_AMP_SHMEM (xrw) 	: ORIGIN = 0x38000400, LENGTH = 63K

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

这是我的 M4 和 M7 内核的主要功能、闪存和 RAM

M4(FLASH.ld)
/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x1000;      /* required amount of heap  */
_Min_Stack_Size = 0x800; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
FLASH (rx)     : ORIGIN = 0x08100000, LENGTH = 1024K
RAM (xrw)      : ORIGIN = 0x10000000, LENGTH = 288K
OPENAMP_RSC_TAB (xrw)     : ORIGIN = 0x38000000, LENGTH = 1K
OPEN_AMP_SHMEM (xrw) : ORIGIN = 0x38000400, LENGTH = 63K
}
__OPENAMP_region_start__  = ORIGIN(OPEN_AMP_SHMEM);
__OPENAMP_region_end__ = ORIGIN(OPEN_AMP_SHMEM) + LENGTH(OPEN_AMP_SHMEM);


M4(RAM.ld)
/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM);    /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200;      /* required amount of heap  */
_Min_Stack_Size = 0x400; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
RAM_EXEC (rx)  : ORIGIN = 0x10000000, LENGTH = 128K
RAM (xrw)      : ORIGIN = 0x10020000, LENGTH = 160K
OPENAMP_RSC_TAB (xrw) 	: ORIGIN = 0x38000000, LENGTH = 1K
OPEN_AMP_SHMEM (xrw) 	: ORIGIN = 0x38000400, LENGTH = 63K
}
 __OPENAMP_region_start__  = ORIGIN(OPEN_AMP_SHMEM);
 __OPENAMP_region_end__ = ORIGIN(OPEN_AMP_SHMEM) + LENGTH(OPEN_AMP_SHMEM);

M7(FLASH.ld)
MEMORY
{
  RAM_D1 (xrw)   : ORIGIN = 0x24000000, LENGTH =  512K
  FLASH  (rx)    : ORIGIN = 0x08000000, LENGTH = 1024K    /* Memory is divided. Actual start is 0x08000000 and actual length is 2048K */
  DTCMRAM (xrw)  : ORIGIN = 0x20000000, LENGTH = 128K
  RAM_D2 (xrw)   : ORIGIN = 0x30000000, LENGTH = 288K
  ITCMRAM (xrw)  : ORIGIN = 0x00000000, LENGTH = 64K
  OPENAMP_RSC_TAB (xrw)   : ORIGIN = 0x38000000, LENGTH = 1K
  OPEN_AMP_SHMEM (xrw) : ORIGIN = 0x38000400, LENGTH = 63K
}
__OPENAMP_region_start__  = ORIGIN(OPEN_AMP_SHMEM);
__OPENAMP_region_end__ = ORIGIN(OPEN_AMP_SHMEM) + LENGTH(OPEN_AMP_SHMEM);

M7(RAM.ld)
/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of "RAM_D1" Ram type memory */

_Min_Heap_Size = 0x200; /* required amount of heap  */
_Min_Stack_Size = 0x400; /* required amount of stack */

/* Memories definition */
MEMORY
{
  RAM_D1 (xrw)   : ORIGIN = 0x24000000, LENGTH =  512K
  FLASH   (rx)   : ORIGIN = 0x08000000, LENGTH = 1024K    /* Memory is divided. Actual start is 0x8000000 and actual length is 2048K */
  DTCMRAM (xrw)  : ORIGIN = 0x20000000, LENGTH = 128K
  RAM_D2 (xrw)   : ORIGIN = 0x30000000, LENGTH = 288K
  ITCMRAM (xrw)  : ORIGIN = 0x00000000, LENGTH = 64K
  OPENAMP_RSC_TAB (xrw) 	: ORIGIN = 0x38000000, LENGTH = 1K
  OPEN_AMP_SHMEM (xrw) 	: ORIGIN = 0x38000400, LENGTH = 63K
}
 __OPENAMP_region_start__  = ORIGIN(OPEN_AMP_SHMEM);
 __OPENAMP_region_end__ = ORIGIN(OPEN_AMP_SHMEM) + LENGTH(OPEN_AMP_SHMEM);
mƎALLEm
ST Employee

Also please read this article: How to implement inter-processor communication in an STM32H7 using OpenAMP

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

感谢您提供另一个答案,但我只是复制了他的代码并遇到了异常。

Translation:

"Thanks for providing another answer but I just copied his code and got the exception"

Please kindly write in English.

And please follow step by step the article I provided. Don't just copy the code. You need also to follow the CubeMx configuration including the MPU configuration.

If you have an issue while following the steps described in that article you need to post your question in it.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.