cancel
Showing results for 
Search instead for 
Did you mean: 

What does STM32 System Bootloader do with unused pins?

CBigg.1
Associate II

Hello,

In the past we have utilised the system bootloader on the STM32F429ZIT6, to implement a command to allow firmware upgrades to be completed by the end user. As part of this, the command would configure an LED Driver IC to update an RGB status LED, giving the user an indication that they are in bootloader mode.

This works great, and led to the assumption that the system bootloader does not reconfigure pins that are not used as by any of the interfaces listed in the application note AN2606, since if this was the case, the LED would not stay on since an enable pin needs to be held high by the STM32.

We are now looking to implement the same firmware upgrade command on a different product that uses the STM32G473VET6TR instead, and have not had as much success.

It appears as though once you enter the system bootloader, the LED enable pin (PD2) is reconfigured since the line is no longer being driver high by the STM32.

For some context, I have included the function that we are using to switch to the system bootloader from our application code below, and please note that before this function is called the LED is configured and confirmed to be on. However once I step into SysMemBootJump(), the LED enable line is no longer driven high and hence the LED is turned off.

Also just to confirm once this function is executed, the product does enter bootloader mode and can be connected to and programmed by the STM32Programmer tool.

Seeing as I have been unable to find any documentation stating what the System Bootloader does with unused pins, I wanted to reach out for some guidance.

Can we rely on the system bootloader to not reconfigure pins not listed in AN2606?

Many thanks

Calum

static void EnterFactoryBootloader(void)
{
    //Set the stack and privilege levels - thread mode, default stack pointer MSP used.
    __set_CONTROL(0);
    
    // STM Doc AN2606 specifies the system memory location for the STM32F429 as 0x1FFF0000 (Same applies to STM32G47xx)       
    // When Cortex-M boots it expects to find the vector table at this address.
    // The first thing in the vector table is the address of its stack
    // and the second the address of the program entry point (offset 4 bytes). 
    volatile const uint32_t sysMemAddress = 0x1FFF0000;
    volatile const uint32_t progEntryPoint = sysMemAddress + 4;
    volatile const uint32_t mspAddress = (*((uint32_t *)sysMemAddress));  //=0x20002d40
    
    //delclare a void function pointer 
    void (*SysMemBootJump)(void);  
    
    //set the pointer to the jump location
    SysMemBootJump = (void (*)(void)) (*((uint32_t *) progEntryPoint));
 
    //Disable the SysTick timer and reset it to default values
    SysTick->CTRL = 0; //reset systic timer
    SysTick->LOAD = 0;
    SysTick->VAL = 0;
    
    //set vector table offset to zero    
    SCB->VTOR = 0; 
    
    //Remap system memory to address 0x0000-0000
    __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
 
    //Set the main stack pointer to its default values
    //Note this must be done last as the local variables of this function use the stack
    //__set_MSP(0x20002d40); 
    __set_MSP(mspAddress);
 
    //do the jump
    SysMemBootJump();        // <-- ** LED stays on up to here! **
 
    //code should never get here
    while(1);
}

1 ACCEPTED SOLUTION

Accepted Solutions

> Could it be that the system bootloader only configures a range of ports?

Yes.

Again, you can single-step the bootloader and see yourself. Or place a data breakpoint ("watchpoint") on GPIOF.

I know it's not a good method, as the bootloader may change in the future; and it would be better if ST would comment. They traditionally don't.

JW

View solution in original post

3 REPLIES 3

The bootloader most probably does change *all* GPIO/pins. You can single-step the beginning of the bootloader to see yourself.

> STM32F429ZIT6, [...]

> LED Driver IC to update an RGB status LED, giving the user an indication that they are in bootloader mode.

> This works great, and led to the assumption that the system bootloader does not reconfigure pins that

> are not used as by any of the interfaces listed in the application note AN2606, since if this was the case, the LED would not stay on

I'd say, this was a coincidence. What pin exactly is that enable?

JW

On the STM32F429ZIT6, its pin PF6.

We also have another pin (PF7) that can also not be reconfigured, which is unaffected by the bootloader.

Taking another look at AN2606, I can see that none of the interfaces for the system bootloader on the STM32F429ZIT6 use pins connected to port F. But then again the same can be said for STM32G473VET6TR for port D (LED enable is PD2)

Could it be that the system bootloader only configures a range of ports?

> Could it be that the system bootloader only configures a range of ports?

Yes.

Again, you can single-step the bootloader and see yourself. Or place a data breakpoint ("watchpoint") on GPIOF.

I know it's not a good method, as the bootloader may change in the future; and it would be better if ST would comment. They traditionally don't.

JW