2024-06-27 12:10 AM
Hi all,
I've recently begun playing around with Zephyr and made blinky for a custom board with a STM32H755.
To test it, I made a complete chip erase and then I flashed the application to the M7 (i.e., its flash area). I can then attach to a debugger immediately after this (without power cycling) and step around in the code, but as soon as I do a power cycle the board is completely dead - I cannot attach my debugger to the target at all.
I read in other posts that this could be caused by a bad SMPS / LDO choice.
However, this seems to be chosen correctly by the zephyr soc_m7 file (choosing SMPS).
I suspect that it has to do with the M4 blocking or somehow acting bad - even though no code is loaded into it, it is still booting (i.e., CM4 has its option byte (BCM4) set).
So my question is: what are all the possible reasons for not being able to connect the STM32H755 with a debugger (given that it is powered up), except for the bad choice of regulator?
P.S.
Let me know if I should upload the code I used.
2024-06-27 12:22 AM
If you reassign/reprogram the pins used for SWD/JTAG (or disable the clock to their port) then the debugger can't connect. Unless you explicitly "connect under reset" (not sure what the stm32cubeide calls this).
It's possible that once the debugger has connected such reassignment might be prevented.
2024-06-27 12:32 AM
But SWD / JTAG are automatically assigned to their default pins (and default is them being active) if I don't touch them, right?
2024-06-27 12:41 AM - edited 2024-06-27 12:43 AM
Did you write the code or was it auto-generated?
The BOOT0 pin gets to decide what code runs out of a power cycle. Check if you can access with BOOT0 =HIGH
Try connect uder reset if NRST was wired to the debug interface.
Add some dwell time in Reset_Handler.
Spinning in a WFI loop can power down the debug interface in some situations.
2024-06-27 01:11 AM - edited 2024-06-27 01:12 AM
All the boot-up code was autogenerated (or actually just implicitly included as part of Zephyrs startup - I think it has been hand-written by someone from ST at some point).
I only added a pin toggle and a sleep to a while loop.
Here's the code that runs at part of the boot up. Could this
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/init.h>
#include <zephyr/cache.h>
#include <soc.h>
#include <stm32_ll_bus.h>
#include <stm32_ll_pwr.h>
#include <stm32_ll_rcc.h>
#include <stm32_ll_system.h>
#include "stm32_hsem.h"
#include <cmsis_core.h>
#if defined(CONFIG_STM32H7_DUAL_CORE)
static int stm32h7_m4_wakeup(void)
{
/* HW semaphore and SysCfg Clock enable */
LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_HSEM);
LL_APB4_GRP1_EnableClock(LL_APB4_GRP1_PERIPH_SYSCFG);
if (READ_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4)) {
/* Cortex-M4 is waiting for end of system initialization made by
* Cortex-M7. This initialization is now finished,
* then Cortex-M7 takes HSEM so that CM4 can continue running.
*/
LL_HSEM_1StepLock(HSEM, CFG_HW_ENTRY_STOP_MODE_SEMID);
} else if (IS_ENABLED(CONFIG_STM32H7_BOOT_M4_AT_INIT)) {
/* CM4 is not started at boot, start it now */
LL_RCC_ForceCM4Boot();
}
return 0;
}
#endif /* CONFIG_STM32H7_DUAL_CORE */
/**
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int stm32h7_init(void)
{
sys_cache_instr_enable();
sys_cache_data_enable();
/* Update CMSIS SystemCoreClock variable (HCLK) */
/* At reset, system core clock is set to 64 MHz from HSI */
SystemCoreClock = 64000000;
/* Power Configuration */
#if !defined(SMPS) && \
(defined(CONFIG_POWER_SUPPLY_DIRECT_SMPS) || \
defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_LDO) || \
defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_LDO) || \
defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_EXT_AND_LDO) || \
defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_EXT_AND_LDO) || \
defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_EXT) || \
defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_EXT))
#error Unsupported configuration: Selected SoC do not support SMPS
#endif
#if defined(CONFIG_POWER_SUPPLY_DIRECT_SMPS)
LL_PWR_ConfigSupply(LL_PWR_DIRECT_SMPS_SUPPLY);
#elif defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_LDO)
LL_PWR_ConfigSupply(LL_PWR_SMPS_1V8_SUPPLIES_LDO);
#elif defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_LDO)
LL_PWR_ConfigSupply(LL_PWR_SMPS_2V5_SUPPLIES_LDO);
#elif defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_EXT_AND_LDO)
LL_PWR_ConfigSupply(LL_PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO);
#elif defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_EXT_AND_LDO)
LL_PWR_ConfigSupply(LL_PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO);
#elif defined(CONFIG_POWER_SUPPLY_SMPS_1V8_SUPPLIES_EXT)
LL_PWR_ConfigSupply(LL_PWR_SMPS_1V8_SUPPLIES_EXT);
#elif defined(CONFIG_POWER_SUPPLY_SMPS_2V5_SUPPLIES_EXT)
LL_PWR_ConfigSupply(LL_PWR_SMPS_2V5_SUPPLIES_EXT);
#elif defined(CONFIG_POWER_SUPPLY_EXTERNAL_SOURCE)
LL_PWR_ConfigSupply(LL_PWR_EXTERNAL_SOURCE_SUPPLY);
#else
LL_PWR_ConfigSupply(LL_PWR_LDO_SUPPLY);
#endif
LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);
while (LL_PWR_IsActiveFlag_VOS() == 0) {
}
/* Errata ES0392 Rev 8:
* 2.2.9: Reading from AXI SRAM may lead to data read corruption
* Workaround: Set the READ_ISS_OVERRIDE bit in the AXI_TARG7_FN_MOD
* register.
* Applicable only to RevY (REV_ID 0x1003)
*/
if (LL_DBGMCU_GetRevisionID() == 0x1003) {
MODIFY_REG(GPV->AXI_TARG7_FN_MOD, 0x1, 0x1);
}
return 0;
}
SYS_INIT(stm32h7_init, PRE_KERNEL_1, 0);
#if defined(CONFIG_STM32H7_DUAL_CORE)
/* Unlock M4 once system configuration has been done */
SYS_INIT(stm32h7_m4_wakeup, POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY);
#endif /* CONFIG_STM32H7_DUAL_CORE */
Could this be problematic if there is no code on the CM4? (note that
Note that