cancel
Showing results for 
Search instead for 
Did you mean: 

I2C firmware upload issue on RDP L1

Hello dear friends,
this is my first post and I need your help with an issue I have. I designed some devices based on STM32C031C6. I use an I2C command to jump to bootloader and I upload the new firmware via I2C also from a microcomputer using the stm32flash software.

The problem comes when I switch to RDP L1. Then, stm32flash can't upload the new firmware. As far I understood, before the upload a mass erase should be done, which is not possible. I can change the RDP level from stm32flash using -k and -j parameters, but this is possible only when I enter bootloader using the jumper configuration. If I enter bootloader from the software via the I2C command, -k and -j parameters result on a NACK from the device.

- How can I complete the upload process via I2C, while my devices are secured with RDP L1?
- Is the issue software related?
- Do I need to switch RDP levels, before the upload? If yes, is a power circle also required? 

Here is the code I use for the bootloader jump:

void JumpToBootloader(void) {
    void (*SysMemBootJump)(void);

    // System memory base address for STM32C031xx series
    volatile uint32_t addr = 0x1FFF0000;

    // Disable all interrupts and reset peripherals to avoid conflicts
    __disable_irq();  
    HAL_RCC_DeInit();
    HAL_DeInit();

    RCC->APBENR1 &= ~RCC_APBENR1_I2C1EN;  // Disable I2C1 clock
    RCC->IOPENR &= ~(RCC_IOPENR_GPIOAEN | RCC_IOPENR_GPIOBEN | RCC_IOPENR_GPIOCEN);

    SysTick->CTRL = 0;
    SysTick->LOAD = 0;
    SysTick->VAL = 0;

    NVIC_ClearPendingIRQ(I2C1_IRQn);  // Clear any pending I2C interrupts

    SYSCFG->CFGR1 |= 0x01;  // Remap system memory

    SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4)));
    __set_MSP(*(uint32_t *)addr);  // Set main stack pointer

    SysMemBootJump();  // Jump to bootloader
}


Thank you for any help in advance!
Konstantinos

0 REPLIES 0