Associate II
March 12, 2013
Question
Leave DFU while boot0 is high (STM32F4)
- 3 replies
- 2193 views
Posted on March 12, 2013 at 05:29
I'm having trouble leaving DFU mode (following instructions on pp 18 ~21 of
) and entering my application while boot0 is high. My application is loaded at 0x08000000 and I'm using STM32F4's system memory bootloader (reset with boot0 high). Here's my C♯ ''Leave DFU'' code for verifying the algorithm.//Open device
STDFUFunction.Call(() => STDFU.API.Open(_path, out _handle)); //Set Start Address. See pp 18 (section 5.2 of application note AN3156) byte[] address = new byte[] { 0x21, 0x00, 0x00, 0x00, 0x08 }; STDFUFunction.Call(() => STDFU.API.Dnload(ref _handle, address, (uint)address.Length, 0)); //Make start address active my issuing a GetStatus STDFU.DFUSTATUS status = new STDFU.DFUSTATUS(); STDFUFunction.Call(() => STDFU.API.GetStatus(ref _handle, ref status)); //A second Get Status to ensure address is accepted status = new STDFU.DFUSTATUS(); STDFUFunction.Call(() => STDFU.API.GetStatus(ref _handle, ref status)); //Command to leave DFU mode see pp 21 (section 5.5 of application note AN3156) byte[] dummy = new byte[] {}; STDFUFunction.Call(() => STDFU.API.Dnload(ref _handle, dummy, 0, 0)); //Get status to activate the command status = new STDFU.DFUSTATUS(); STDFUFunction.Call(() => STDFU.API.GetStatus(ref _handle, ref status)); //Close device STDFUFunction.Call(() => STDFU.API.Close(ref _handle)); Although I'm not checking the statuses in the code above, I've verified they all return the values expected as documented in AN3156. If I leave boot0 high, I hear the Windows USB disconnect ''ding'', but it appears that the my application doesn't run. However, it doesn't seem to be in the DFU mode either, as I can't re-download with resetting the processor again. If I pull boot0 low before the ''leave DFU mode'' code runs, and leave it low, it enters the application fine. I'm fairly certain my linker script and startup scripts properly place the code and vector table where they should be, at 0x08000000. You can find the full source code attached, but here's the relevant parts. Linker script (edited for brevity, see attachment for full code):CCRAM (rxw) : ORIGIN = 0x10000000, LENGTH = 64k
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512k _estack = ORIGIN(CCRAM) + LENGTH(CCRAM); .isr_vector : { . = ALIGN(4); KEEP(*(.isr_vector)) . = ALIGN(4); } >FLASH Startup (edited for brevity, see attachment for full source code):.section .isr_vector,''a'',%progbits
.type __Vectors, %object .size __Vectors, .-__Vectors __Vectors: .word _estack /* Top of the stack */ .word Reset_Handler /* System Reset Handler */ My SystemInit is stock from the STM32F4 peripheral library. Does anyone see what I'm doing wrong? #stm32f4-dfu #stm32f4-dfu-ccm #dfu-ccm-stm32f4