Skip to content

Rabie45/Custom_bootloader_Stm32f303RE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Custom Bootloader for stm322f303re

💡 We made explanation earlier u can check this link (https://github.com/Rabie45/Bootloader_STM32F303RE)

First lets Explain what we are going to do :

  • The task is to create a program start with application with multiple options one for bootloader command and the other for user application to something like that we would use Flash module organization used before create multiple section in memory each section is full program it self (vector table + system init + main) once the program start choose the program u want and the bootloader will through u to the starting address holding this program
  • the figure show the addresses of each program and how to mange the space 2_drawio

And this is the workflow

3_drawio

First Create the bootloader project

  • initialize GPIO
  • initialize UART2
  • Check if the button is pressed this mean go to bootloader mode to change UserApp
  • not pressed go to default user app This program starts with default memory section which is 0x8000000

second Create the UserApp project

  • pretty simple

  • initialize GPIO

  • initialize UART2

  • toggle the LED print this word over UART "Hey from user data:Toggling" This program starts with memory address 0x8008000 66

    to start from this section using keil Uvison follow this steps :

    Screenshot (80) Screenshot (81) Screenshot (82) Screenshot (83) Screenshot (84)

Dont forget to relocate VTOR (vector table register ) to new address 0x8008000

How to make bootloader jump to user app:

  • go to system_stm23f3xx.c 21

  • Search for VTOR 22

  • Change the offset
    24

  • After loading each program in memory the bootloader program will start with default user app printing the line

  • If the button is pressed the bootloader will go to to something then go to userapp program address

  • void UserApp_Mode() in bootloader responsible to to this

	uint32_t MSP_VAL=*(volatile uint32_t * )(FLASH_PAGE2_0x08008000U)  //get the memory address to load in MSP
	__set_MSP(MSP_VAL);  // use this fuction to set the MSP value
	uint32_t resetHandler =*(volatile uint32_t *)(FLASH_PAGE2_0x08001800U +4 ); // alwayes the next instruction is the Reset handler
	appHandler=(void*) resetHandler;
	appHandler(); // Call the function 

About

This Custom bootloader Stm32f303RE neculeo board

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published