2021-10-15 20:08:11 索煒達(dá)電子 817
項(xiàng)目編號(hào):E1531
文件大?。?64K
源碼說(shuō)明:帶中文注釋
開發(fā)環(huán)境:C編譯器
簡(jiǎn)要概述:
花了四天時(shí)間才把IAP功能做好。其中也遇到許多的坑,這次把這次IAP功能實(shí)現(xiàn)過(guò)程遇到的坑把它分享出來(lái)。
一開始做iap的時(shí)候也是先從網(wǎng)上看別人的實(shí)現(xiàn)方法,其中就下載了一套別人的程序,不過(guò)主控芯片是STM32F103zv,就是不是我想要的那個(gè)型號(hào),還有他的邏輯跟我的有點(diǎn)不一樣。所以才走了那么多天的坑。
1、先移植別人的flash燒寫代碼跟運(yùn)行APP應(yīng)用程序的代碼,基本各個(gè)版本大同小異。
2、然后實(shí)現(xiàn)自己的UART,實(shí)現(xiàn)串口接收程序(因?yàn)橐ㄟ^(guò)串口接收APP應(yīng)用固件)
3、然后接收到的固件燒寫進(jìn)flash
4、最后就是運(yùn)行到APP應(yīng)用程序了。
基本實(shí)現(xiàn)iap也是這幾個(gè)步驟,但是就是不成功一開始。
然后就開始查找問(wèn)題:
1、查看接收的固件對(duì)不對(duì)
2、通過(guò)keil編譯器里的仿真可以看到flash的具體數(shù)值,判斷memory里的數(shù)據(jù)是不是跟串口接收的數(shù)據(jù)一樣的。
查找了之后自己感覺是對(duì)的(其實(shí)沒有仔細(xì)驗(yàn)證),然后就開始跑到APP應(yīng)用程序,每一次運(yùn)行到APP程序時(shí)就進(jìn)入了硬件錯(cuò)誤中斷HardFault_Handler();就是這個(gè)問(wèn)題我查找了兩天得不到解決。
最后實(shí)在沒辦法了才有查找接收的問(wèn)題,發(fā)現(xiàn)接收處理是有問(wèn)題的,因?yàn)樾酒腟RAM是有限的,接收數(shù)組不可能開的太大,我的方法是開兩個(gè)數(shù)組輪流接收固件,一個(gè)數(shù)組接收滿了之后就先寫進(jìn)flash,另一個(gè)數(shù)組繼續(xù)接收。因?yàn)楣碳沂峭ㄟ^(guò)串口助手發(fā)送給芯片的,所以串口助手一次性發(fā)完一個(gè)固件不間斷。后面改了這個(gè)接收的問(wèn)題,然后再去檢查接收到的固件寫進(jìn)FLASH時(shí)是否是對(duì)的,這兩部做好之后基本不會(huì)有什么大問(wèn)題。
1、另一個(gè)需要注意的就是地址的偏移,Bootloader地址跟APP應(yīng)用地址分開來(lái)。
2、進(jìn)入APP應(yīng)用程序之前需要清除中斷,把一些GPIO,ADC之類的都關(guān)閉。
3、APP應(yīng)用端要配置好中斷偏移向量。
基本以上步驟檢查好了,iap應(yīng)用是沒有問(wèn)題的。
目錄│文件列表:
└ 在線應(yīng)用升級(jí)
├ APP
│ ├ CMSIS
│ │ │ core_cm3.c
│ │ │ core_cm3.h
│ │ │ stm32f10x.h
│ │ │ system_stm32f10x.c
│ │ │ system_stm32f10x.h
│ │ └ startup
│ │ │ startup_stm32f10x_hd.s
│ │ │ startup_stm32f10x_ld.s
│ │ └ startup_stm32f10x_md.s
│ ├ FWlib
│ │ ├ inc
│ │ │ │ misc.h
│ │ │ │ stm32f10x_adc.h
│ │ │ │ stm32f10x_bkp.h
│ │ │ │ stm32f10x_can.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_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
│ ├ my_c
│ │ │ usart1.c
│ │ └ usart1.h
│ ├ Output
│ │ │ STM32-DEMO.bin
│ │ └ STM32-DEMO.hex
│ ├ souceinsight
│ │ │ c8t6_host.IAB
│ │ │ c8t6_host.IAD
│ │ │ c8t6_host.IMB
│ │ │ c8t6_host.IMD
│ │ │ c8t6_host.PFI
│ │ │ c8t6_host.PO
│ │ │ c8t6_host.PR
│ │ │ c8t6_host.PRI
│ │ └ c8t6_host.PS
│ └ USER
│ │ core_cm3._2i
│ │ EventRecorderStub.scvd
│ │ JLink Regs CM3.txt
│ │ JLinkSettings.ini
│ │ main.c
│ │ misc._2i
│ │ STM32-DEMO.fed
│ │ STM32-DEMO.l2p
│ │ STM32-DEMO.uvgui.lm
│ │ STM32-DEMO.uvgui.Ping
│ │ STM32-DEMO.uvguix.123
│ │ STM32-DEMO.uvguix.lm
│ │ STM32-DEMO.uvopt
│ │ STM32-DEMO.uvoptx
│ │ STM32-DEMO.uvprojx
│ │ stm32f10x_conf.h
│ │ stm32f10x_it.c
│ │ stm32f10x_it.h
│ │ SysTick.c
│ │ SysTick.h
│ └ DebugConfig
│ └ ADC-DEMO_STM32F103C8_1.0.0.dbgconf
└ IAP
├ CMSIS
│ │ core_cm3.c
│ │ core_cm3.h
│ │ stm32f10x.h
│ │ system_stm32f10x.c
│ │ system_stm32f10x.h
│ └ startup
│ │ startup_stm32f10x_hd.s
│ │ startup_stm32f10x_ld.s
│ └ startup_stm32f10x_md.s
├ FWlib
│ ├ inc
│ │ │ misc.h
│ │ │ stm32f10x_adc.h
│ │ │ stm32f10x_bkp.h
│ │ │ stm32f10x_can.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_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
├ my_c
│ │ CAN_bus.c
│ │ CAN_bus.h
│ │ DataToPC.c
│ │ DataToPC.h
│ │ device_check.c
│ │ device_check.h
│ │ drv_AS5600.c
│ │ drv_AS5600.h
│ │ drv_spi.c
│ │ drv_spi.h
│ │ drv_TLE5012B.c
│ │ drv_TLE5012B.h
│ │ IIC.c
│ │ IIC.h
│ │ SPI_SSC.c
│ │ SPI_SSC.h
│ │ usart1.c
│ │ usart1.h
│ └ IAP
│ │ iap.c
│ │ iap.h
│ │ stmflash.c
│ └ stmflash.h
├ Output
│ └ STM32-DEMO.hex
├ souceinsight
│ │ c8t6_host.IAB
│ │ c8t6_host.IAD
│ │ c8t6_host.IMB
│ │ c8t6_host.IMD
│ │ c8t6_host.PFI
│ │ c8t6_host.PO
│ │ c8t6_host.PR
│ │ c8t6_host.PRI
│ └ c8t6_host.PS
├ USB
│ │ Queue.c
│ │ Queue.h
│ │ USB_Data.c
│ │ USB_Data.h
│ ├ Config
│ │ │ hw_config.c
│ │ │ hw_config.h
│ │ │ platform_config.h
│ │ │ usb_conf.h
│ │ │ usb_desc.c
│ │ │ usb_desc.h
│ │ │ usb_endp.c
│ │ │ usb_istr.c
│ │ │ usb_istr.h
│ │ │ usb_it.c
│ │ │ usb_prop.c
│ │ │ usb_prop.h
│ │ │ usb_pwr.c
│ │ └ usb_pwr.h
│ └ Core
│ │ 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_sil.c
│ │ usb_sil.h
│ └ usb_type.h
└ USER
│ core_cm3._2i
│ EventRecorderStub.scvd
│ JLink Regs CM3.txt
│ JLinkSettings.ini
│ main.c
│ misc._2i
│ STM32-DEMO.fed
│ STM32-DEMO.l2p
│ STM32-DEMO.uvgui.lm
│ STM32-DEMO.uvgui.Ping
│ STM32-DEMO.uvguix.123
│ STM32-DEMO.uvguix.lm
│ STM32-DEMO.uvopt
│ STM32-DEMO.uvoptx
│ STM32-DEMO.uvprojx
│ stm32f10x_conf.h
│ stm32f10x_it.c
│ stm32f10x_it.h
│ SysTick.c
│ SysTick.h
└ DebugConfig
└ ADC-DEMO_STM32F103C8_1.0.0.dbgconf