0

I am currently trying to program my PortentaH7 using the registers in the STM32H747 datasheet. So far I was only trying to access one core (M7) and now I want to try using the two cores at the same time. There are a lot of exemples on how to use both at the same time but none explains where the CORE_CM7 and CORE_CM4 are defined. Here is what I have done up till now :

volatile uint32_t* const SYSCFG_UR1 = (uint32_t *) 0x58002704;
volatile uint32_t* const RCC_GCR = (uint32_t *) 0x58024400A0;//to boot M4
void boot_CM4(void){
   *SYSCFG_UR1 = (1<<0);//BCM4 = 1;
   *RCC_GCR|=(1<<3);//BOOT_C2
}

This function should boot the M4 core. Most of the codes I have read online use :

#ifdef CORE_CMx

#endif

And it allows them to work with the CORE_CMx. My question is how is CORE_CMx defined. The datasheet here : https://www.st.com/resource/en/reference_manual/dm00176879-stm32h745755-and-stm32h747757-advanced-armbased-32bit-mcus-stmicroelectronics.pdf has me thinking that I should use the SYSCFG_UR3 register to write the starting address of the core in order to define CORE_CMx. However there is close to no information on this register in the datasheet. Any hints is appreciated.

  • If the symbol `CORE_CMx` is used in an `#ifdef`-statement, then it must be defined at compile-time for the compiler preprocessor. It does not have anything to do with STM32H7 registers. The symbol may be defined by the IDE (STM32CubeIDE?) in the build command or somewhere in the code. – nielsen Apr 15 '22 at 09:28
  • Sorry if that may sound stupid I am not familiar with identifiers but according to what I have read the #ifdef mainly check wether the identifier has been defined so how does the IDE knows that he should talk to one core or another. Should (and can) I define a core memory address for my identifier like #define CORE_CMx (type*) address? – Sympathic_Cone Apr 15 '22 at 10:05
  • Yes, `#ifdef` checks if the symbol is defined (at compile-time). I do not have experience with dual-core on STM32, so I am not sure how it works, but I suppose that two applications have to be built, one for each core. If there is a single source for both cores, this must be built twice, once for each core and defining `CORE_CMx` can be used to include/exclude core-specific sections of the code. I do not know if the IDE manages the builds and automatically defines the right symbol for each build or if you have to do it yourself. In the latter case, best use a compiler option `-D CORE_CMx`. – nielsen Apr 15 '22 at 10:57
  • `0x58024400A0` with cast to 4-bytes variable? – unalignedmemoryaccess Apr 15 '22 at 11:04
  • My bad when I wrote it the register address is 0x580244A0. Thanks for the hints I will take a look at the compiler option. – Sympathic_Cone Apr 15 '22 at 11:44

1 Answers1

0

After some research I found out that the identifier CORE_CMx is defined by the IDE and to get something equivalent to :

#ifdef 1

All you need to do (on Arduino IDE) is to go to Tools>boards>Arduino Mbed OS Portenta Boards and choose the core you want to program. And that's where the identifier is considered to be defined. It is still needed to boot CM4 on CM7 before using it.
(Fast check : during compilation the Flash memory address to where the code is wtritten is 0x08100000 for CM4 and 0x08000000 for CM7 as defined in the datasheet).
Thanks for your help.