2016-01-26 01:54 AM
Hi friends ,
I found following and did not understand why __set_MSP(0x20002000) , why main stack pointer hold 0x20002000 ; why not 0x20000000 (sram start address) for stm32f429.
When I debug and look in 0x1FFF0000 , I saw 0x20002318?
Should I use __set_MSP(0x20002318) ? void jump_to_BootLoader(void) { void (*SysMemBootJump)(void) = (void (*)(void)) (*((uint32_t *) 0x1FFF0004)); __set_PRIMASK(1); RCC_DeInit(); SysTick->CTRL = 0; SysTick->LOAD = 0; SysTick->VAL = 0; RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI); __set_MSP(0x20002000); SysMemBootJump(); }
2016-01-26 11:19 PM
Sorry for trouble.
You must remap vector table in NVIC.2016-01-26 11:48 PM
Thank you very much , you tried to help me but still cant make it work :(
void jump_to_BootLoader(void){ void (*SysMemBootJump)(void) = (void (*)(void)) (*((uint32_t *) 0x1FFFF004)); __set_PRIMASK(1); SysTick->CTRL = 0; SysTick->LOAD = 0; SysTick->VAL = 0; __set_MSP(0x20000200); SysMemBootJump(); NVIC_SystemReset();}2016-02-04 10:46 PM
Still I can not make it work , I am following all steps in an2606 application note.
RCC HSI enabled The system clock frequency is 24 MHz
using the PLL.
RAM - 512 byte starting from address 0x20000000
are used by the bootloader firmware.
System memory - 2 Kbyte starting from address 0x1FFFF000
contain the bootloader firmware.
IWDG -
The independent watchdog (IWDG)
prescaler is configured to its maximum
value and is periodically refreshed to
prevent watchdog reset (in case the
hardware IWDG option was previously
enabled by the user).
USART1 Enabled Once initialized, the USART1 configuration
is: 8 bits, even parity and 1 Stop bit.
USART1_RX pin Input PA10 pin: USART1 in reception mode
USART1_TX pin Output push-pull PA9 pin: USART1 in transmission mode
SysTick timer Enabled Used to automatically detect the serial baudrate from the host.
Refer to document I try in following. void (*SysMemBootJump)(void) = (void (*)(void)) (*((uint32_t *) 0x1FFFF004)); //System memory adress __set_PRIMASK(1); //Interrupts are disable SysTick->CTRL = 1; //SysTick timer enabled SysTick->LOAD = 0; SysTick->VAL = 0; __set_MSP(0x20002000); ///Setting msp NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0000); //Mapping to rom zero SysMemBootJump();2016-02-05 12:38 AM
And also found following and tried , still does not work .
in app.c *((unsigned long *)0x20001FF0) = 0xDEADBEEF; // 64KB STM32F103 NVIC_SystemReset();in startupReset_Handler LDR R0, =0x20001FF0 LDR R1, =0xDEADBEEF LDR R2, [R0, #0] STR R0, [R0, #0] CMP R2, R1 BEQ Reboot_Loader LDR R0, =SystemInit BLX R0 LDR R0, =__iar_program_start BX R0Reboot_Loader EXPORT Reboot_Loader LDR R0, =0x1FFFF000 LDR SP,[R0, #0] LDR R0,[R0, #4] BX R02016-02-05 08:43 AM
May be we need to revisit what ''not working'' means in your context?
What exactly are you trying to do? What exactly is failing in terms of the boot loader and it's response? Be aware that the USART boot loader is going to be VERY sensitive to line noise or any junk you transmit, as the 0x7F initially sent to the loader is not received but rather used as a timing pattern to calibrate the baud rate settings.2016-02-05 08:52 AM
Suggest you put a logic analyzer on the USART1 pins and understand what's getting transmitted from your end, and what the response is back from the loader.
If you are sending 0x7F and getting some response back that isn't 0x79, it's most likely because the timing is wrong. Understand what signals are seen, and confirm the baud rate of the 0x79 that is sent back, compared to what you think it should be. Give the USART some time between you calling the boot loader, and sending the 0x7F pattern. Consider if you should tri-state the USART pins before jumping to the loader. Again a lot of this wasted time could be remedied if you actually looked at what is happening critically, with a scope or analyzer.2016-02-05 11:47 AM
Thanx clive1
I am sorry about that I behaved unpatient , but I found problem with your help thank you. Problem was fake FTDI chip . You were right , I examined USART with logic analyzer and 0x7F was never gone to stm32f 051mcu . Now I fix the problem and , I share working c code below . void jump_to_BootLoader(void){ void (*SysMemBootJump)(void) = (void (*)(void)) (*((uint32_t *) 0x1FFFEC04)); __set_PRIMASK(1); SysTick->CTRL = 0; SysTick->LOAD = 0; SysTick->VAL = 0; __set_MSP(0x20000678); SysMemBootJump();}int main(void){ jump_to_BootLoader(); while(1);}