【E128】STM32F103大容量存储设备引导加载程序

2021-08-15 17:18:46      索炜达电子      820     

项目编号:E128

文件大小:775K

源码说明:带中文注释

开发环境:C编译

简要概述:

Device: STM32F103C8T6 (Flash size: 64KB) / STM32F103CBT6 (Flash size: 128KB)

My example:

【E128】STM32F103大容量存储设备引导加载程序

imulate a USB removable disk (FAT32). The content of firmware.bin is mapped to Appcode area. Hence, the size of firmware.bin is also 48KB / 112KB.

Just drag and drop the intel hex file to update the appcode. The bootloader will automatically restart if EOF RecordType is found in the hex file. Drag and drop the BIN file is removed. Since intel hex file has the following advantages over the bin file:

  1. Most of the compiler tools support direct export to intel hex file. No need to covert to bin file anymore

  2. provides better integrity check

  3. macOS works properly because of unique format in ihex file

During power up, the bootloader will check the content of 0x0800_4000 exists or not. Hold PA0 (Connect to GND) during power up can force to enter bootloader mode.

Only tested on Windows 8, MacOS Sierra and Ubuntu 18.04

Several examples are provided in "example-hex" folder to validate the bootloader feature.

Test Procedure:

  1. Hold PA0 during power up to enter bootloader mode.

  2. A removable disk drive named "BOOTLOADER" is recognized.

  3. Ensure PA0 is released.

  4. Drag and drop STM32F103_FlashPC13LED_FAST.hex to the removable disk.

  5. Since the intel hex file contains EOF record type, the bootloader will be self-reset.

  6. The bootloader jumps to Appcode. LED (PC13) blinks.

Added AES256-CTR Encryption:

For more detail, please see the hex-crypt folder.

文件列表:

目录│文件列表:

 └ STM32F103_MSD_BOOTLOADER

    │ .mxproject

    │ STM32_MSD_BTLDR.ioc

    ├ Drivers

    │  ├ CMSIS

    │  │  ├ Device

    │  │  │  └ ST

    │  │  │     └ STM32F1xx

    │  │  │        └ Include

    │  │  │           │ stm32f103xb.h

    │  │  │           │ stm32f1xx.h

    │  │  │           └ system_stm32f1xx.h

    │  │  └ Include

    │  │     │ arm_common_tables.h

    │  │     │ arm_const_structs.h

    │  │     │ arm_math.h

    │  │     │ cmsis_armcc.h

    │  │     │ cmsis_armcc_V6.h

    │  │     │ cmsis_gcc.h

    │  │     │ core_cm0.h

    │  │     │ core_cm0plus.h

    │  │     │ core_cm3.h

    │  │     │ core_cm4.h

    │  │     │ core_cm7.h

    │  │     │ core_cmFunc.h

    │  │     │ core_cmInstr.h

    │  │     │ core_cmSimd.h

    │  │     │ core_sc000.h

    │  │     └ core_sc300.h

    │  └ STM32F1xx_HAL_Driver

    │     ├ Inc

    │     │  │ stm32f1xx_hal.h

    │     │  │ stm32f1xx_hal_cortex.h

    │     │  │ stm32f1xx_hal_def.h

    │     │  │ stm32f1xx_hal_dma.h

    │     │  │ stm32f1xx_hal_dma_ex.h

    │     │  │ stm32f1xx_hal_flash.h

    │     │  │ stm32f1xx_hal_flash_ex.h

    │     │  │ stm32f1xx_hal_gpio.h

    │     │  │ stm32f1xx_hal_gpio_ex.h

    │     │  │ stm32f1xx_hal_pcd.h

    │     │  │ stm32f1xx_hal_pcd_ex.h

    │     │  │ stm32f1xx_hal_pwr.h

    │     │  │ stm32f1xx_hal_rcc.h

    │     │  │ stm32f1xx_hal_rcc_ex.h

    │     │  │ stm32f1xx_hal_tim.h

    │     │  │ stm32f1xx_hal_tim_ex.h

    │     │  │ stm32f1xx_ll_bus.h

    │     │  │ stm32f1xx_ll_cortex.h

    │     │  │ stm32f1xx_ll_dma.h

    │     │  │ stm32f1xx_ll_exti.h

    │     │  │ stm32f1xx_ll_gpio.h

    │     │  │ stm32f1xx_ll_pwr.h

    │     │  │ stm32f1xx_ll_rcc.h

    │     │  │ stm32f1xx_ll_system.h

    │     │  │ stm32f1xx_ll_usb.h

    │     │  │ stm32f1xx_ll_utils.h

    │     │  └ Legacy

    │     │     └ stm32_hal_legacy.h

    │     └ Src

    │        │ stm32f1xx_hal.c

    │        │ stm32f1xx_hal_cortex.c

    │        │ stm32f1xx_hal_dma.c

    │        │ stm32f1xx_hal_flash.c

    │        │ stm32f1xx_hal_flash_ex.c

    │        │ stm32f1xx_hal_gpio.c

    │        │ stm32f1xx_hal_gpio_ex.c

    │        │ stm32f1xx_hal_pcd.c

    │        │ stm32f1xx_hal_pcd_ex.c

    │        │ stm32f1xx_hal_pwr.c

    │        │ stm32f1xx_hal_rcc.c

    │        │ stm32f1xx_hal_rcc_ex.c

    │        │ stm32f1xx_hal_tim.c

    │        │ stm32f1xx_hal_tim_ex.c

    │        │ stm32f1xx_ll_exti.c

    │        │ stm32f1xx_ll_gpio.c

    │        │ stm32f1xx_ll_rcc.c

    │        │ stm32f1xx_ll_usb.c

    │        └ stm32f1xx_ll_utils.c

    ├ example-hex

    │  │ STM32F103C8T6_EraseAll.hex

    │  │ STM32F103_FlashPC13LED_FAST.hex

    │  │ STM32F103_FlashPC13LED_FAST_CRYPT.hex

    │  │ STM32F103_FlashPC13LED_FAST_UNALIGN.hex

    │  └ STM32F103_FlashPC13LED_SLOW.hex

    ├ hex-crypt

    │  │ aes.c

    │  │ aes.h

    │  │ build.bat

    │  │ crypt.c

    │  │ crypt.h

    │  │ hex_crypt.cpp

    │  │ hex_crypt.exe

    │  │ ihex_parser.c

    │  │ ihex_parser.h

    │  └ README.md

    ├ Inc

    │  │ aes.h

    │  │ btldr_config.h

    │  │ crypt.h

    │  │ fat32.h

    │  │ ihex_parser.h

    │  │ main.h

    │  │ stm32f1xx_hal_conf.h

    │  │ stm32f1xx_it.h

    │  │ stm32_assert.h

    │  │ usbd_conf.h

    │  │ usbd_desc.h

    │  │ usbd_storage_if.h

    │  └ usb_device.h

    ├ MDK-ARM

    │  │ startup_stm32f103xb.s

    │  │ STM32_MSD_BTLDR.uvoptx

    │  │ STM32_MSD_BTLDR.uvprojx

    │  ├ RTE

    │  │  └ RTE_Components.h

    │  └ STM32_MSD_BTLDR

    │     │ ExtDll.iex

    │     │ STM32_MSD_BTLDR.axf

    │     │ STM32_MSD_BTLDR.hex

    │     └ STM32_MSD_BTLDR.map

    ├ Middlewares

    │  └ ST

    │     └ STM32_USB_Device_Library

    │        ├ Class

    │        │  └ MSC

    │        │     ├ Inc

    │        │     │  │ usbd_msc.h

    │        │     │  │ usbd_msc_bot.h

    │        │     │  │ usbd_msc_data.h

    │        │     │  └ usbd_msc_scsi.h

    │        │     └ Src

    │        │        │ usbd_msc.c

    │        │        │ usbd_msc_bot.c

    │        │        │ usbd_msc_data.c

    │        │        └ usbd_msc_scsi.c

    │        └ Core

    │           ├ Inc

    │           │  │ usbd_core.h

    │           │  │ usbd_ctlreq.h

    │           │  │ usbd_def.h

    │           │  └ usbd_ioreq.h

    │           └ Src

    │              │ usbd_core.c

    │              │ usbd_ctlreq.c

    │              └ usbd_ioreq.c

    └ Src

       │ aes.c

       │ crypt.c

       │ fat32.c

       │ ihex_parser.c

       │ main.c

       │ stm32f1xx_hal_msp.c

       │ stm32f1xx_it.c

       │ system_stm32f1xx.c

       │ usbd_conf.c

       │ usbd_desc.c

       │ usbd_storage_if.c

       └ usb_device.c

TAGBootloader
  • 6 次
  • 1 分