2024-07-27 04:58 PM
Hello, I am not able to program STM32G031. I have Nucleo kit F401RE and STM32G031 connected to SWD. I have connected SWDIO, SWCLK, 3V3, GND and nRST.
STM32CubeProgrammer can connect only in Hot Plug mode, but writting or errasing gives me: Error: Mass erase operation failed.Please verify flash protection
If I try to connect in Normal mode or Under reset mode, the error is: Error: ST-LINK error (DEV_TARGET_HELD_UNDER_RESET).
Can you help me how to continue? STM32G031 is completely new, never programmed before.
ST-LINK FW : V2J39M27
2024-07-27 07:10 PM - edited 2024-07-27 07:10 PM
> DEV_TARGET_HELD_UNDER_RESET
Suggests NRST is being held low. Can you verify with a multimeter?
Likely to be an issue with the board design or assembly, or the wiring between the programmer and the board. Can you share the schematic?
2024-07-28 08:40 AM
All voltages are OK.
This is the schematics:
2024-07-28 08:51 AM
Sure , that your target is powered ?
st-link seems to get no voltage:
+
try connect with mode : normal + software reset .
2024-07-28 09:20 AM
Yes, it is, I tried different kit for programming. Setup is according your recommendation
2024-07-28 09:54 AM - edited 2024-07-28 09:55 AM
But its connected here:
So look at option bytes, if something set, write protect or so.
Be careful not to do anything with rdp level - read first, what this doing. (you need a new chip then...)
Then try full chip erase and then programming...
2024-07-28 10:28 AM
I think I found the problem but I do not know why...
void CLK_Config(void)
{
RCC->CR |= RCC_CR_HSION;
while ((RCC->CR & RCC_CR_HSIRDY) == 0);
PWR->CR1 |= PWR_CR1_VOS_0;
RCC->CR &= ~RCC_CR_PLLON;
while (!(RCC->CR & RCC_CR_HSIRDY)) {
}
/*
RCC->PLLCFGR = (RCC_PLLCFGR_PLLSRC_HSI | // Zdroj PLL je HSI
(8 << RCC_PLLCFGR_PLLN_Pos) | // PLLN = 8
(0 << RCC_PLLCFGR_PLLM_Pos) | // PLLM = 1
(1 << RCC_PLLCFGR_PLLR_Pos)); // PLLR = 2
RCC->CR |= RCC_CR_PLLON;
while (!(RCC->CR & RCC_CR_PLLRDY));
RCC->PLLCFGR = (RCC_PLLCFGR_PLLSRC_HSI |
RCC_PLLCFGR_PLLM_DIV1 |
RCC_PLLCFGR_PLLN_3 | // PLLN = 8 (8 * 2 MHz = 16 MHz)
RCC_PLLCFGR_PLLR_1 | // PLLR = 2 (16 MHz / 2 = 8 MHz)
RCC_PLLCFGR_PLLREN); // Aktivujte PLLR výstup
*/
FLASH->ACR |= FLASH_ACR_LATENCY_2;
/*
RCC->CFGR = (0b10 << RCC_CFGR_SW_Pos);
while ((RCC->CFGR & RCC_CFGR_SWS_Msk) != (0b10 << RCC_CFGR_SWS_Pos));
*/
SystemCoreClockUpdate();
}
If I comment this it works fine without PLL. But I need PLL and I do not see any problem. If I send this UNCOMENTED code to CPU there is not possible to load program any more.
Do you see some trouble? I do not use HAL.
Thank you
2024-07-28 10:44 AM - edited 2024-07-28 10:45 AM
So use Cube/HAL with the setup you want, gen.code, and you can see, how its doing it.
Even if you dont use it , then you know and no reason to keep guessing.