HID bootloader for STM32F0 series
Posted: Mon Jul 12, 2021 7:01 am
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:
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:
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
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
}
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;
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