【E231】STM32内部Flash模拟成U盘进行固件升级

2021-08-17 00:03:40      索炜达电子      1694     

项目编号:E231

文件大小:1.2M

源码说明:带中文注释

开发环境:C编译器

简要概述

项目说明

STM32内部Flash模拟成U盘进行固件升级。系统上电之后在3S内检测到PC连接到STM32成功则进入Boot模式,此时将固件拖入U盘则完成升级,之后跳转到App区域执行用户代码。

注意事项:

  • BOOT区域划分20K

  • App区域从0x8004000开始

  • App程序进入Main后首先需要设置中断向量表地址并且在工程配置里设置flash起始地址是0x8004000

  • 支持HEX文件拖拽升级

  • 支持BIN文件拖拽升级

项目开发过程:

  1. 在Win10上bin文件烧录过程会失败,Win7待测 2019050

    • Win7同样会失败,初步原因分析是数据丢包 20190507

    • bin文件写入地址不正确,重新实现写入flash数据的算法,解决了bug 20190511

  2. 在Win10上hex文件只能烧录一次,Win7待测 20190506

    • Win7上也是只能烧录一次,已经找到BUG,再第二次烧录前flash没有擦除,问题已经解决 ----20190507

    • hex文件与LAB值解耦合,重新实现写入算法,解决了bug 20190511

  3. 文件16.xK 希望可以裁剪到10K左右 ----20190511

    • 已经将BOOT从16K压缩到10.7K,希望可以压缩到10K以内。----20190512

    文件列表:

    目录│文件列表:

     └ stm32-iap-msd

        │ clear.bat

        ├ CORE

        │  │ core_cm3.c

        │  │ core_cm3.h

        │  │ startup_stm32f10x_hd.s

        │  └ startup_stm32f10x_md.s

        ├ FATFS

        │  │ fattester.c

        │  │ fattester.h

        │  ├ doc

        │  │  │ css_e.css

        │  │  │ css_j.css

        │  │  └ img

        │  │     │ f1.png

        │  │     │ f2.png

        │  │     │ f3.png

        │  │     │ f4.png

        │  │     │ f5.png

        │  │     │ f6.png

        │  │     │ layers.png

        │  │     │ layers3.png

        │  │     │ rwtest.png

        │  │     │ rwtest2.png

        │  │     └ rwtest3.png

        │  ├ exfuns

        │  │  │ exfuns.c

        │  │  │ exfuns.h

        │  │  │ fattester.c

        │  │  │ fattester.h

        │  │  └ mycc936.c

        │  └ src

        │     │ diskio.c

        │     │ diskio.h

        │     │ ff.c

        │     │ ff.h

        │     │ ffconf.h

        │     │ integer.h

        │     └ option

        │        │ cc932.c

        │        │ cc936.c

        │        │ cc949.c

        │        │ cc950.c

        │        │ ccsbcs.c

        │        │ mycc936.c

        │        └ syscall.c

        ├ HARDWARE

        │  │ stmflash.c

        │  │ stmflash.h

        │  ├ FLASH

        │  │  │ flash.c

        │  │  └ flash.h

        │  ├ ITEMP

        │  │  │ tsensor.c

        │  │  └ tsensor.h

        │  ├ KEY

        │  │  │ key.c

        │  │  └ key.h

        │  ├ LCD

        │  │  │ font.h

        │  │  │ lcd.c

        │  │  └ lcd.h

        │  ├ LED

        │  │  │ led.c

        │  │  └ led.h

        │  ├ SD

        │  │  │ MMC_SD.C

        │  │  └ MMC_SD.H

        │  └ SPI

        │     │ spi.c

        │     └ spi.h

        ├ MALLOC

        │  │ malloc.c

        │  └ malloc.h

        ├ OBJ

        │  │ hex2bin.bat

        │  │ hex2bin.exe

        │  ├ IAP-APP_HD

        │  │  │ IAP-APP_HD1.bin

        │  │  │ IAP-APP_HD1.hex

        │  │  │ IAP-APP_HD2.bin

        │  │  └ IAP-APP_HD2.hex

        │  ├ IAP-APP_MD

        │  │  │ IAP-APP_MD1.bin

        │  │  │ IAP-APP_MD1.hex

        │  │  │ IAP-APP_MD2.bin

        │  │  └ IAP-APP_MD2.hex

        │  ├ IAP-MSD_HD

        │  │  │ BOOT_HD.bin

        │  │  └ BOOT_HD.hex

        │  └ IAP-MSD_MD

        │     │ BOOT_MD.bin

        │     └ BOOT_MD.hex

        ├ README

        │  └ USB MSD Updater User Manual.pdf

        ├ STM32F10x_FWLib

        │  ├ inc

        │  │  │ misc.h

        │  │  │ stm32f10x_adc.h

        │  │  │ stm32f10x_bkp.h

        │  │  │ stm32f10x_can.h

        │  │  │ stm32f10x_cec.h

        │  │  │ stm32f10x_crc.h

        │  │  │ stm32f10x_dac.h

        │  │  │ stm32f10x_dbgmcu.h

        │  │  │ stm32f10x_dma.h

        │  │  │ stm32f10x_exti.h

        │  │  │ stm32f10x_flash.h

        │  │  │ stm32f10x_fsmc.h

        │  │  │ stm32f10x_gpio.h

        │  │  │ stm32f10x_i2c.h

        │  │  │ stm32f10x_iwdg.h

        │  │  │ stm32f10x_pwr.h

        │  │  │ stm32f10x_rcc.h

        │  │  │ stm32f10x_rtc.h

        │  │  │ stm32f10x_sdio.h

        │  │  │ stm32f10x_spi.h

        │  │  │ stm32f10x_tim.h

        │  │  │ stm32f10x_usart.h

        │  │  └ stm32f10x_wwdg.h

        │  └ src

        │     │ misc.c

        │     │ stm32f10x_adc.c

        │     │ stm32f10x_bkp.c

        │     │ stm32f10x_can.c

        │     │ stm32f10x_cec.c

        │     │ stm32f10x_crc.c

        │     │ stm32f10x_dac.c

        │     │ stm32f10x_dbgmcu.c

        │     │ stm32f10x_dma.c

        │     │ stm32f10x_exti.c

        │     │ stm32f10x_flash.c

        │     │ stm32f10x_fsmc.c

        │     │ stm32f10x_gpio.c

        │     │ stm32f10x_i2c.c

        │     │ stm32f10x_iwdg.c

        │     │ stm32f10x_pwr.c

        │     │ stm32f10x_rcc.c

        │     │ stm32f10x_rtc.c

        │     │ stm32f10x_sdio.c

        │     │ stm32f10x_spi.c

        │     │ stm32f10x_tim.c

        │     │ stm32f10x_usart.c

        │     └ stm32f10x_wwdg.c

        ├ SYSTEM

        │  ├ delay

        │  │  │ delay.c

        │  │  └ delay.h

        │  ├ sys

        │  │  │ sys.c

        │  │  └ sys.h

        │  └ usart

        │     │ usart.c

        │     └ usart.h

        ├ USB

        │  ├ CONFIG

        │  │  │ hw_config.c

        │  │  │ hw_config.h

        │  │  │ mass_mal.c

        │  │  │ mass_mal.h

        │  │  │ memory.c

        │  │  │ memory.h

        │  │  │ msd.c

        │  │  │ msd.h

        │  │  │ platform_config.h

        │  │  │ scsi_data.c

        │  │  │ stm32f10x_it.c

        │  │  │ stm32f10x_it.h

        │  │  │ usb_bot.c

        │  │  │ usb_bot.h

        │  │  │ usb_conf.h

        │  │  │ usb_desc.c

        │  │  │ usb_desc.h

        │  │  │ usb_endp.c

        │  │  │ usb_istr.c

        │  │  │ usb_istr.h

        │  │  │ usb_prop.c

        │  │  │ usb_prop.h

        │  │  │ usb_pwr.c

        │  │  │ usb_pwr.h

        │  │  │ usb_scsi.c

        │  │  └ usb_scsi.h

        │  └ LIB

        │     │ usb_core.c

        │     │ usb_core.h

        │     │ usb_def.h

        │     │ usb_init.c

        │     │ usb_init.h

        │     │ usb_int.c

        │     │ usb_int.h

        │     │ usb_lib.h

        │     │ usb_mem.c

        │     │ usb_mem.h

        │     │ usb_regs.c

        │     │ usb_regs.h

        │     └ usb_type.h

        └ USER

           │ API.c

           │ BOOT.bin

           │ EventRecorderStub.scvd

           │ FAT16.c

           │ FAT16.h

           │ hex.c

           │ hex.h

           │ IAP-MSD.uvguix.Haven

           │ IAP-MSD.uvguix.xiebin

           │ IAP-MSD.uvopt

           │ IAP-MSD.uvoptx

           │ IAP-MSD.uvprojx

           │ main.c

           │ main.h

           │ stm32f10x.h

           │ stm32f10x_conf.h

           │ stm32f10x_it.c

           │ stm32f10x_it.h

           │ system_stm32f10x.c

           │ system_stm32f10x.h

           ├ DebugConfig

           │  │ IAP-APP_HD_STM32F103CB_1.0.0.dbgconf

           │  │ IAP-APP_HD_STM32F103ZE_1.0.0.dbgconf

           │  │ IAP-APP_MD_STM32F103CB_1.0.0.dbgconf

           │  │ IAP-MSD_APP_STM32F103CB_1.0.0.dbgconf

           │  │ IAP-MSD_F103HD_STM32F103ZE_1.0.0.dbgconf

           │  │ IAP-MSD_HD_STM32F103ZE_1.0.0.dbgconf

           │  │ IAP-MSD_MD_STM32F103C8_1.0.0.dbgconf

           │  │ IAP-MSD_MD_STM32F103CB_1.0.0.dbgconf

           │  │ IAP-MSD_MD_STM32F103RC_1.0.0.dbgconf

           │  │ IAP-MSD_MD_STM32F103ZE_1.0.0.dbgconf

           │  │ Target_1_STM32F103CB_1.0.0.dbgconf

           │  └ Target_1_STM32F103ZE_1.0.0.dbgconf

           └ RTE

              ├ _IAP-APP_HD

              │  └ RTE_Components.h

              ├ _IAP-APP_MD

              │  └ RTE_Components.h

              ├ _IAP-MSD_APP

              │  └ RTE_Components.h

              ├ _IAP-MSD_F103HD

              │  └ RTE_Components.h

              ├ _IAP-MSD_HD

              │  └ RTE_Components.h

              ├ _IAP-MSD_MD

              │  └ RTE_Components.h

              └ _Target_1

                 └ RTE_Components.h

TAGU盘
  • 13 次
  • 1 分