cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H573VI: Bricked in "Provisioning" product-state while tring to applicate DA on device

MattiaB
Associate III

Good morning everyone,
I need to apply the "Closed" product state to my device using the STM32H573VI.
I don't need TrustZone enabled and want to use a password for debug authentication.


I wanted to perform the operation via "code" using the HALs, but once I set the state to "Provisioning(0x17)" from "Open(0xED)," my firmware won't boot, and I can't even provision the *.obk file using the STM32CubeProgrammer.

bool ProductState::set(states newState)
{    
    FLASH_OBProgramInitTypeDef flashOptionBytes= {0};
    HAL_StatusTypeDef ret {HAL_ERROR};
    
    if(newState == states::Unknown) {
        Log::msg("Invalid product state\n");
        return false;
    }
    
    Log::msg("Setting product state to %s ...\n", toString(newState).c_str());

    HAL_FLASH_Unlock();
    HAL_FLASH_OB_Unlock();

    flashOptionBytes.OptionType = OPTIONBYTE_PROD_STATE;
    flashOptionBytes.ProductState = (static_cast<uint32_t>(newState) << FLASH_OPTSR_PRODUCT_STATE_Pos);

    Log::msg("Program state ...\n");
    ret = HAL_FLASHEx_OBProgram(&flashOptionBytes);
    if (ret == HAL_OK)
    {
        Log::msg("OB Launch ...\n");

        ret = HAL_FLASH_OB_Launch();
        if (ret != HAL_OK)
        {
          Log::msg("Error while execution OB_Launch : %d\n", ret);
        }
    }
    else {
        Log::msg("Error while setting OB Bank1 config state %s : %d\n", toString(newState).c_str(), ret);
    }
    
    HAL_FLASH_OB_Lock();
    HAL_FLASH_Lock();
    
    return (ret == HAL_OK) ? true : false; 
}

I then tried to do the entire process using the STM32CubeProgrammer on another board.
I'we followed the video: STM32H5:Product state 
- I flashed my application (a simple blinking LED) with IAR
- I changed the product state from "Open" to "Provisioning"

But no luck. Once the Provisioning state is set, I can't provide the *.obk file using the PROV dropdown.

MattiaB_0-1765277254183.png

Product state is 0x17 as correctly expected:

MattiaB_1-1765277363361.png

So both behaviours are equals using directly HALs drivers or STM32CubeProgrammer.
Can anyone please help me figure out what I'm doing wrong?
Thanks in advance for your help.

10 REPLIES 10

Thank you @Jocelyn RICARD,
connecting NRST to pin 15 of STLink V2 all works fine!

MattiaB_0-1765555378290.png