cancel
Showing results for 
Search instead for 
Did you mean: 

Where would be placed instruction code for cortex-M4 core inside STM32MP1? Would M4 access external DDR to fetch instruction? Is there possibility for M4 code to be placed in internal SDRAM? Is there any limitation regarding the size of M4 code?

Srdjan Nikolic
Associate II
 
1 ACCEPTED SOLUTION

Accepted Solutions
PatrickF
ST Employee

1) Cortex-M4 is seen as a Linux Coprocessor, and it's code is loaded from Linux Filesystem, see https://wiki.st.com/stm32mpu/index.php/How_to_start_the_coprocessor_from_the_bootloader for details.

2) Cortex-M4 is not intended to access DDR content. Cortex-M4 has no cache and asynchronous path to AXI bus has not been optimized for that, so Cortex-M4 performance will be very largely impacted.

Furthermore, accessing small chunk of data to a DDR is never a good choice, as this will affect the DDRCTRL scheduling and so the performance of other AXI masters accessing the DDR SDRAM.

Although it is possible from HW point of view, in our Linux deliveries, Cortex-M4 access is forbidden inside TrustZone address space controller for DDR (TZC).

3) by internal SDRAM, I assume you talk about SYSRAM.

Cortex-M4 is not intended to access SYSRAM content. Cortex-M4 has no cache and asynchronous path to AXI bus has not been optimized for that, so Cortex-M4 performance will be very largely impacted.

Although it is possible from HW point of view, in our Linux deliveries, Cortex-M4 access is usually forbidden by system security settings.

4) Cortex-M4 Code/Data should fit within SRAM+RETRAM, i.e. 448KBytes.

Please note that although this could sound small Vs high-perf MCUs, the Cortex-M4 inside STM32MP1 is intended to act as a coprocessor, it will not have any User Interface nor FrameBuffer which are usually eating large porting of Flash/RAM on standalone MCU solutions. Futhermore, large protocol stack (Ethernet, WLAN, BT, USB, etc..) and Filesystem are also handled on Linux side.

Regards

In order 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.

View solution in original post

3 REPLIES 3
PatrickF
ST Employee

1) Cortex-M4 is seen as a Linux Coprocessor, and it's code is loaded from Linux Filesystem, see https://wiki.st.com/stm32mpu/index.php/How_to_start_the_coprocessor_from_the_bootloader for details.

2) Cortex-M4 is not intended to access DDR content. Cortex-M4 has no cache and asynchronous path to AXI bus has not been optimized for that, so Cortex-M4 performance will be very largely impacted.

Furthermore, accessing small chunk of data to a DDR is never a good choice, as this will affect the DDRCTRL scheduling and so the performance of other AXI masters accessing the DDR SDRAM.

Although it is possible from HW point of view, in our Linux deliveries, Cortex-M4 access is forbidden inside TrustZone address space controller for DDR (TZC).

3) by internal SDRAM, I assume you talk about SYSRAM.

Cortex-M4 is not intended to access SYSRAM content. Cortex-M4 has no cache and asynchronous path to AXI bus has not been optimized for that, so Cortex-M4 performance will be very largely impacted.

Although it is possible from HW point of view, in our Linux deliveries, Cortex-M4 access is usually forbidden by system security settings.

4) Cortex-M4 Code/Data should fit within SRAM+RETRAM, i.e. 448KBytes.

Please note that although this could sound small Vs high-perf MCUs, the Cortex-M4 inside STM32MP1 is intended to act as a coprocessor, it will not have any User Interface nor FrameBuffer which are usually eating large porting of Flash/RAM on standalone MCU solutions. Futhermore, large protocol stack (Ethernet, WLAN, BT, USB, etc..) and Filesystem are also handled on Linux side.

Regards

In order 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.

Hi, PatrickF!

I am currently porting an application from a microcontroller to the MP157C, and right now I am trying to run the original application directly from the M4 core.

The original application unfortunately doesn't fit in the M4 internal RAM, so I am trying to place and execute some code of the M4 in DDR.

I am able to load the code into the DDR area from 0xDC00 0000 to 0xDFFF FFFF using rproc (I just managed to set a DDR reserved area and to extend the DMA-RANGES to include the reserved area).

The Cortex M4 boots OK, starts its execution and synchronizes OK with the A7, but when the program of the core M4 tries to execute the first instruction from the DDR, the M4 core goes to hard fault.

I checked the ...fw-config.dtsi file for the tf-a and the region around 0xDC00 0000 seems accessible from the Cortex M4:

#ifdef AARCH32_SP_OPTEE
memory-ranges = <
DDR_NS_BASE DDR_NS_SIZE TZC_REGION_S_NONE TZC_REGION_NSEC_ALL_ACCESS_RDWR
DDR_SHARE_BASE DDR_SHARE_SIZE TZC_REGION_S_NONE
TZC_REGION_ACCESS_RDWR(STM32MP1_TZC_A7_ID)
DDR_SEC_BASE DDR_SEC_SIZE TZC_REGION_S_RDWR 0>;
#else
memory-ranges = <
DDR_NS_BASE DDR_NS_SIZE TZC_REGION_S_NONE TZC_REGION_NSEC_ALL_ACCESS_RDWR>;
#endif

 

Do you have any hints about what to check to understand why the M4 gives a fault?

Do you have a checklist to follow to enable the core M4 to access the DDR for code execution?

 

Many thanks for your help!

Michele

mikesponk2
Associate III

Hi, I followed what has been done in:
https://community.st.com/t5/stm32-mpu-products/how-to-give-execution-permission-to-the-m4-core-for-ddr-ram/m-p/95222#M1876

and in the examples that come with the EV1 board, under the Examples/Cortex directory, file stm32_mpu.c, and now the DDR is accessible and i can proceed with my project!

 

Many thx for your help!

BR

Michele