2022-10-31 07:51 AM
I have code that's meant to put an STM32L552xx microcontroller into bootloader mode after reset, so I can connect it to CubeProgrammer afterwards. I tested the code and while it does appear to be doing something, it isn't showing up in the device manager in any sort of update mode, nor can CubeProgrammer find it under the USB tab.
I'm still looking into causes, but I wanted to check to make sure that this wasn't a simple case of me misunderstanding the instructions from AN2606, table 2 (I'm using Bootloader Pattern 12, trustzone disabled and boot0 pin pulled low).
Code for starting the bootloader from user code is below:
void prepareForUpdate()
{
uint32_t boot_addr = 0x017F200;
FLASH_OBProgramInitTypeDef ob_cfg;
HAL_FLASHEx_OBGetConfig(&ob_cfg);
ob_cfg.OptionType = OPTIONBYTE_USER;
ob_cfg.USERType = OB_USER_nSWBOOT0;
ob_cfg.USERConfig = OB_nBOOT0_SET;
ob_cfg.BootAddrConfig = OB_BOOTADDR_NS0;
ob_cfg.BootAddr = boot_addr;
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBProgram(&ob_cfg);
HAL_FLASH_OB_Launch();
}
When I execute the code, the microcontroller resets but does not appear to enter bootloader mode. I can execute all other code in the project before and after reset, so it isn't outright breaking anything that I can see. I can confirm it can detect the usb, since that's how I tell it to execute other parts of the code. I should also note that I haven't the USB_DEVICE in CUBEMX configured as a Communication Device Class and haven't configured it for DFU or as a composite device. I don't believe that this is the problem, but I'm not writing it off entirely.
I'm going to keep testing and researching for more information to narrow the problem down, but I figured I'd check in to make sure this isn't a simple case of bad code from misunderstanding.
Thanks in advance!
2022-11-02 09:07 AM
Where did you find that? I've been trying to find that kind of stuff for the L552 series and I can't find it anywhere online. I tried looking in CubeIDE's examples and things just crash
2023-11-23 09:35 AM
use this ,its work ))
void JumpToBootloader(void) {
void (*SysMemBootJump)(void);
volatile uint32_t addr = 0x0BF90000; // ADDRES FOR SYSTEM BOOTLOADER
HAL_RCC_DeInit();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
__disable_irq();
SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4)));
__set_MSP(*(uint32_t *)addr);
SysMemBootJump();
/**
* Step: Connect USB<->UART converter to dedicated USART pins and test
* and test with bootloader works with STM32 Flash Loader Demonstrator software
*/
}