STM32F0 bootloader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-07 3:45 AM - last edited on ‎2024-10-07 4:49 AM by mƎALLEm
Dear Members,
I'm using the STM32F030CC controller for my RTOS-based project and currently developing a bootloader for it. The application code has been relocated to 0x08004000. The bootloader successfully jumps to the application, but after initializing all peripherals (GPIO, timers, etc.), calling `HAL_GetTick()` returns a `uwTick` value of 0.
This is the fuction iam using to jump from bootloader to application. when i try to do _enable_irq(); the jump fuction is not working .
am i missing anything?
- Labels:
-
Bootloader
-
STM32F0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-07 3:47 AM
Please see the Posting Tips for how to properly post source code - not as an image:
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-07 3:48 AM - edited ‎2024-10-07 3:48 AM
Hello @Sid_sid and welcome to the community,
First, please use </> button to paste your code instead of sharing screen shots.
Second, Did you remap your vector table (VTOR) to the new Flash address 0x08004000?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-07 4:18 AM
Thankyou for your reply.
are you asking about the linker script in application?
* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
FLASH (rx) : ORIGIN = 0x08004000, LENGTH = 240K
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-07 4:38 AM - edited ‎2024-10-07 4:39 AM
No,
I'm talking about vector table relocation on STM32F0:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-07 4:57 AM
You are disabling interrupts which prevents systick from occurring.
For working code on how to jump to the bootloader, see here: It can be easily modified to jump instead to your application. Note the section where it disables interrupts in the NVIC registers. You likely need something similar
How to jump to system bootloader from application ... - STMicroelectronics Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-07 6:09 AM
actually i mapped vector table to
memcpy((void*)0x20000000, (const void*)APP_ADDRESS, 0xC0);
0x20000000
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-07 1:54 PM
Calling from an Interrupt Handler (say EXTI or whatever) can be problematic due to how the NVIC unwinds priority. See also callback's operating from interrupt context.
RTOS can be problematic from a System / User context type point of view
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-08 4:20 AM
when i try __enable_irq(); in application, the code stuck there.
But when i tried a basic led blink project as an application code ,that was worked and the uwTick is icrementing.
This is the bootloader jump function.
void Bootloader_JumpToApplication(uint32_t address)
{
// disable global interrupt
__disable_irq();
// Disable all peripheral interrupts
HAL_NVIC_DisableIRQ(SysTick_IRQn);
// main app start address defined in linker file
extern uint32_t _main_app_start_address;
uint32_t MemoryAddr = (uint32_t)&_main_app_start_address;
uint32_t *pMem = (uint32_t *)MemoryAddr;
// First address is the stack pointer initial value
__set_MSP(*pMem); // Set stack pointer
// Now get main app entry point address
pMem++;
void (*pMainApp)(void) = (void (*)(void))(*pMem);
// Jump to main application (0x0800 0004)
pMainApp();
}
this is the starting of application code:
int main(void)
{
/* USER CODE BEGIN 1 */
// Copy interrupt vector table to the RAM.
volatile uint32_t *VectorTable = (volatile uint32_t *)0x20000000;
uint32_t ui32_VectorIndex = 0;
for(ui32_VectorIndex = 0; ui32_VectorIndex < 48; ui32_VectorIndex++)
{
VectorTable[ui32_VectorIndex] = *(__IO uint32_t*)((uint32_t)FIRMWARE_START_ADDR + (ui32_VectorIndex << 2));
}
__HAL_RCC_AHB_FORCE_RESET();
// Enable SYSCFG peripheral clock
__HAL_RCC_SYSCFG_CLK_ENABLE();
__HAL_RCC_AHB_RELEASE_RESET();
// Remap RAM into 0x0000 0000
__HAL_SYSCFG_REMAPMEMORY_SRAM();
// __enable_irq();
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_USART1_UART_Init();
MX_TIM17_Init();
MX_ADC_Init();
MX_I2C1_Init();
MX_TIM15_Init();
MX_USART5_UART_Init();
MX_CRC_Init();
MX_USART3_UART_Init();
MX_RTC_Init();
MX_USART4_UART_Init();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-08 5:17 AM
> when i try __enable_irq(); in application, the code stuck there.
Probably because you did not disable interrupts correctly.
