My Setup
I'm using a Portenta H7 Lite with the Breakoutboard. I supply external 5V via the Screw Terminals on the breakoutbord. I have "bricked" the PMIC multiple times and now am very practiced in reprogramming it externally :). I want to use CM4 & CM7 and keep the official bootloader.
Why keep the official bootloader?
Even tough I have no need for it, I was not able to get the PMIC initialization over i2c1 to work. Since my Program is not that big I can accept using the official bootloader.
What have I done
Looking at previous posts in this Forum i was able to get a minimum working example to run. My example only consists of toggling GPIO3 (PD5) in the main loop. With that im able to Powercycle the board and use the Button(PB1) on the Portenta to get into the Bootloader. I'm writing my code to 0x08040000.
I changed the
"STM32H747XIHX_FLASH.ld"
MEMORY
{
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
FLASH (rx) : ORIGIN = 0x08040000, LENGTH = 1024K-0x40000 /* 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
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
}
and the "system_stm32h7xx_dualcore_boot_cm4_cm7_c"
#else
#define VECT_TAB_BASE_ADDRESS FLASH_BANK1_BASE /*!< Vector Table base address field.
This value must be a multiple of 0x400. */
#define VECT_TAB_OFFSET 0x00040000U /*!< Vector Table base offset field.
This value must be a multiple of 0x400. */
files to change the flash address and size and to update the vector table. With this setup also able to debug the program.
The Problem
When i port the changed files over to my real project I'm still able to debug the program. But double pressing PB1(NRST) on the Portenta itself "crashes" it in a way so that i can no longer connect via STLINKV3MINIE and i have to erase the flash manually to get it in a working state. The same happens when pressing PB1(PWRON) on the breakoutboard with the only difference that the orange battery charge LED (DL2) now stays on since it cuts the power. I also tried this with the option bytes NRST_STOP_D1 & NRST_STOP_D2 checked and unchecked as well as with NRST_STBY_D1 & NRST_STBY_D2 (Default is checked) with no positive difference.
Theory
Somehow my code manages to reconfigure some stuff the bootloader configured different, so the reset function no longer works like its supposed to. Has someone had this problem and is able to suggest some fixes?
Edit:
Github Repos of my Code
Minimal Example
Main Code