Boot to soft (STM32L151)
Hi,
II have a BIG problem: at a certain time, I was able to jump from bootloader to a soft but I can't do it anymore. Perhaps I modified something in the soft (it was with STMCubeIde but, sorry, I hate STMCubeIde because every time you change your programming machine you lost configuration) so now I'm trying to do this with MikroC so I just have to copy directory on a USB key.
The only sure thing is that processor had serial port broken so I changed it and I bought it from China (instead Farnell because the had no more when I needed). I hope this is not the problem has I ordered 100...
I want my bootloader jump to flash. Boot pin has a zero level and can't been changed.
"Bootloader" (vectors to 0x0) start at 0x200 , "soft" vectors adress start at 0xC400 and soft at 0xC800)
The "soft" vectors adress is a copy from original soft vectors (0x0) when soft has been tested, so "soft" vectors have been moved from 0x0 to 0xC400 in an ".bin" file adding "bootloader" file and "soft file".
When control "p_Led10" on, I can see flash vectors copy (0x0800C400 to 0x20000000) is OK.
But I will have a simple bootloader reset.
Any help apprecied (in french ? ;))
//------------------------------------------------------------------------------
void JumpToProg(unsigned long *VectAd)
{
unsigned int x2;
unsigned long *flashAddress = VectAd;
unsigned long *sramStartAddress = (unsigned long *)0x20000000; // SRAM destination
unsigned long *sramAddress = sramStartAddress;
char txt[18];
DisableInterrupts();
//* vect copy to SRAM
for (x2 = 0; x2 < 256; x2 += 4)
{
*sramAddress++ = *flashAddress++;
}
RCC_APB2ENR.SYSCFGEN = 1;
delay_ms(20);
//SCB_VTOR =(unsigned long)sramStartAddress; // no change
// Configuration des bits BOOT_MODE pour Embedded SRAM boot mode
SYSCFG_MEMRMP |= 0x03; // boot mode to SRAM
//EnableInterrupts(); // problem here: freeze if used
p_Led10=1;
delay_ms(3000);
SCB_AIRCR=0x05FA0004; //5FA05=key , 0x4=0b100=reset
while (1)
{
p_WDC=~p_WDC; // wait reset (this to avoid external electronic watchdog security)
}
}
//------------------------------------------------------------------------------
