Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Bootloader

© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4


Bootloader overview
Definition:
Bootloader is a small application used to erase
flash and load user applications to a device.

Advantages:
- The user can update device firmware easily
without using debugger

© FPT SOFTWARE – TRAINING MATERIAL – Internal use TRAINING MATERIALS 04e-BM/NS/HDCV/FSOFT


2 v2/4
FPT-Soft Confidential
Bootloader memory map

Note: Bootloader region must be protected to


avoid accidentally erasing the bootloader code.

© FPT SOFTWARE – TRAINING MATERIAL – Internal use TRAINING MATERIALS 04e-BM/NS/HDCV/FSOFT


3 v2/4
FPT-Soft Confidential
Bootloader flow chart

© FPT SOFTWARE – TRAINING MATERIAL – Internal use TRAINING MATERIALS 04e-BM/NS/HDCV/FSOFT


4 v2/4
FPT-Soft Confidential
Bootloader mode operation
The user can use different protocol to
receive image file
• USB
• Serial
• Ethernet
•…

There are some image file types:


• S-record file
• CW binary file
• Binary file

© FPT SOFTWARE – TRAINING MATERIAL – Internal use TRAINING MATERIALS 04e-BM/NS/HDCV/FSOFT


5 v2/4
FPT-Soft Confidential
USB Mass Storage Device Bootloader

© FPT SOFTWARE – TRAINING MATERIAL – Internal use TRAINING MATERIALS 04e-BM/NS/HDCV/FSOFT


6 v2/4
FPT-Soft Confidential
Developing new applications

• Modify linker command files

• Redirecting interrupt vectors

© FPT SOFTWARE – TRAINING MATERIAL – Internal use TRAINING MATERIALS 04e-BM/NS/HDCV/FSOFT


7 v2/4
FPT-Soft Confidential
Modify linker command files
• Because the bootloader is used it is located at the beginning of
flash, the application must be placed after the bootloader.
• Only memory section of linker file must be modified

© FPT SOFTWARE – TRAINING MATERIAL – Internal use TRAINING MATERIALS 04e-BM/NS/HDCV/FSOFT


8 v2/4
FPT-Soft Confidential
Modify linker command files
- Original memory section in linker file
MEMORY {
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x00073BF0
m_data (RW) : ORIGIN = 0x1FFF0400, LENGTH = 0x0001FC00
}

- Modified memory section in linker file


MEMORY {
m_interrupts (RX) : ORIGIN = 0x0000B000, LENGTH = 0x00000400
m_cfmprotrom (RX) : ORIGIN = 0x0000B400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x0000B410, LENGTH = 0x00073BF0
m_data (RW) : ORIGIN = 0x1FFF0400, LENGTH = 0x0001FC00
}

© FPT SOFTWARE – TRAINING MATERIAL – Internal use TRAINING MATERIALS 04e-BM/NS/HDCV/FSOFT


9 v2/4
FPT-Soft Confidential
Redirecting interrupt vectors

-The application cannot change the default interrupt vector


table. Therefore, the application needs to store its interrupt
vector table in application flash memory and then move
the vectors to RAM.

- The methods to redirect a vector table to RAM are


different between MCU families.

- Some MCU families have vector base address register


which can be used to redirect the vector table to RAM

© FPT SOFTWARE – TRAINING MATERIAL – Internal use TRAINING MATERIALS 04e-BM/NS/HDCV/FSOFT


10 v2/4
FPT-Soft Confidential
Redirecting interrupt vectors for Kinetis

Step 1: Specify the RAM address to store vector table (0x1FFF0000)

Step 2 : Copy Application Stored Interrupt Vector table to RAM


pdst=(uint_32*)0x1FFF0000;
psrc=(uint_32*)0xC000;
for (i=0;i<0x100;i++,pdst++,psrc++)
{
*pdst=*psrc;
}

Step 3: Then redirect the vector table to RAM by changing the SCB_VTOR
SCB_VTOR = (uint_32)0x1FFF0000;

© FPT SOFTWARE – TRAINING MATERIAL – Internal use TRAINING MATERIALS 04e-BM/NS/HDCV/FSOFT


11 v2/4
FPT-Soft Confidential
Thanks for your attention!

© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4

You might also like