Page 1 of 1

HID bootloader for STM32F0 series

Posted: Mon Jul 12, 2021 7:01 am
by geraldjustice
Hi there guys! im new but i wanted to ask this question as you guys are more familiar with the arduinos side of the STM32 stuff. I recently wrote a Bootloader for the stm32F0 in HID following losely the example HAL for the F4 platform. managed to use to to flash chips. But hit the brick wall until i found out about the SRAM vector table for the F0 since it doest not have a VTOR like the F4 does. fixed it and "main" apps now run when i copy over the vector table in code when im using CubeIDE. But i wanted to try to see if i can get the STM32duino to work with it. It basically uses the same upload protocol as the F1 and F4 bootloaders. Later i discovered someone already made one lol. https://github.com/aroerina/STM32_HID_Bootloader_F0

So im trying to support it in stm32duino. I got it working just fine on cubeIDE but i miss the quickness you can throw together code from there. I tried to add this by doing the following: 1 under boards.txt i added the F0 to the HID upload method to have this automated. Made the vector offset to 0x0000. Then modified the ld script to offset like the github link:

Code: Select all

MEMORY
{
  RAM    (xrw)    : ORIGIN = 0x200000c0,   LENGTH = 16192
  FLASH    (rx)    : ORIGIN = 0x8000800,   LENGTH = 126K
}
Therefore even when selecting the HID as upload method the vector offset and im also offsetting the RAM too at once.

Last bit of code i need to add would be this:

Code: Select all

	memcpy((void*)SRAM_VTABLE_ADDR,(void*)FLASH_VTABLE_ADDR,VTABLE_SIZE);
	SYSCFG->CFGR1 |= 3;
But not exactly sure were to add this. This has to be before HAL_Init();

Also i did test the bootloader in the link with HID-flash and works like a charm with the example using cube IDE.

Edit: also the bootloader i linked is set for a 128kB flash. so page size are 2kB. if your using something with less then change it to 1k

Re: HID bootloader for STM32F0 series

Posted: Mon Jul 12, 2021 7:18 am
by fpiSTM

Re: HID bootloader for STM32F0 series

Posted: Mon Jul 12, 2021 8:47 am
by geraldjustice
Thanks! i will come back to see how it when!

Re: HID bootloader for STM32F0 series

Posted: Tue Jul 13, 2021 11:01 pm
by geraldjustice
Dam it did not work. i need to see why. But i discovered that under STM32duino variant for "MALYANMx00_F070CB" also uses a sram offset. but im a little stumped. I will see what else i can do. Does anyone have any suggestions on how this can be done?

Re: HID bootloader for STM32F0 series

Posted: Wed Jul 05, 2023 8:55 am
by florencio48
Use the PB2 port tied to +3.3V after a RESET. This will kick in the HID Bootloader (even with anything written previously). One also can unplug the USB, tie PB2 to +3.3V, and plug it to the USB port, this also can kick in the HID Bootloader.