cancel
Showing results for 
Search instead for 
Did you mean: 

How to make the bootloader(IAP) Firmware with STM32L151RE ?

colleague
Associate II
Posted on October 28, 2014 at 11:29

hi. I'm Min-sung Jo.

My MCU is STM32L151RE.

I used IAP example source code.

Unfortunately,

it doesn't support STM32L151xE version.

so I can't download program on it.

first 128 byte succecful download, but anymore not work.

I just modified 

Flash_If.c :

&sharpdefine

STM32L1XX_HD

->

STM32L1XX_XL

0x0802FF00

->

0x0803FF00

0x08030000

->

0x08040000

Flash_if.h

&sharpdefine

STM32L1XX_HD

->

STM32L1XX_XL

&sharpdefine APPLICATION_ADDRESS   (uint32_t)

0x08003000

-> &sharpdefine APPLICATION_ADDRESS   (uint32_t)

0x08004000

&sharpdefine USER_FLASH_LAST_PAGE_ADDRESS 

0x0805FF00

-> &sharpdefine USER_FLASH_LAST_PAGE_ADDRESS 

0x0807FF00

&sharpdefine USER_FLASH_END_ADDRESS       

0x0805FFFF

-> &sharpdefine USER_FLASH_END_ADDRESS       

0x0807FFFF

What should I do additionally ?

#stm32l151xe #iap
4 REPLIES 4
Posted on October 28, 2014 at 14:19

Probably need to fix FLASH_If_GetWriteProtectionStatus(void)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
colleague
Associate II
Posted on October 29, 2014 at 02:29

Thank you for reply. 0690X0000060MoiQAE.gif

I modified it..

uint32_t FLASH_If_GetWriteProtectionStatus(void)

{

#ifdef STM32L1XX_MD

return(FLASH_OB_GetWRP() & FLASH_PROTECTED_SECTORS);

#elif defined STM32L1XX_XL

uint32_t WRP_Status = 0, WRP1_Status = 0, WRP2_Status = 0,WRP3_Status = 0, sectornumber = 0;

sectornumber=FLASH_SECTOR_NUMBER;

/* Test on the start address in Bank1 */

if (FLASH_START_ADDRESS <= 0x0803FF00)

{

/* Test on the user application to be programmed in Bank1 */

if (APPLICATION_ADDRESS <= 0x0803FF00)

{

WRP2_Status = FLASH_OB_GetWRP2();

WRP3_Status = FLASH_OB_GetWRP3();

if(sectornumber < 32)

{

WRP_Status = FLASH_OB_GetWRP() & ((uint32_t)~((1<<sectornumber) - 1));

WRP1_Status = FLASH_OB_GetWRP1();

}

else

{

WRP1_Status = (FLASH_OB_GetWRP1() & ((uint32_t)~((1<<(sectornumber-32)) - 1)));

}

}

else if (APPLICATION_ADDRESS >= 0x08040000) /* Test on the user application to be programmed in Bank2 */

{

sectornumber = (uint32_t)((APPLICATION_ADDRESS - 0x08040000)>>12);

if (sectornumber < 32)

{

WRP2_Status = FLASH_OB_GetWRP2() & (uint32_t)~((1 << (sectornumber + 32) - 1));

WRP3_Status = FLASH_OB_GetWRP3();

}

else

{

WRP3_Status = FLASH_OB_GetWRP3() & (uint32_t)~((1 << (sectornumber-32) - 1));

}

}

}

/////////////////////////down.. never operate.. no think about...

else if (FLASH_START_ADDRESS >= 0x08040000) /* Test on the start address in Bank2 */

{

if (APPLICATION_ADDRESS <= 0x0803FF00) /* Test on the user application to be programmed in Bank1 */

{

sectornumber = (uint32_t)(APPLICATION_ADDRESS - 0x08000000)>>12;

if(sectornumber < 32)

{

WRP_Status = FLASH_OB_GetWRP() & (uint32_t)~((1<<sectornumber - 1));

WRP1_Status = FLASH_OB_GetWRP1()&0x0000FFFF;

}

else

{

WRP1_Status = (FLASH_OB_GetWRP1() & (uint32_t)~((1 << (sectornumber-32) - 1)))&0x0000FFFF;

}

}

else /* Test on the user application to be programmed in Bank2 */

{

if(sectornumber < 16)

{

WRP1_Status = FLASH_OB_GetWRP1() & ((uint32_t)~(1 << (sectornumber + 16) - 1));

WRP2_Status = FLASH_OB_GetWRP2();

}

else

{

WRP2_Status = (FLASH_OB_GetWRP2() & (uint32_t)~(1 <<( sectornumber - 16) - 1));

}

}

}

if ((WRP_Status!=0)||(WRP1_Status!=0)||(WRP2_Status!=0) || (WRP3_Status != 0))

return 1;

else

return 0;

#endif

} is it right?

colleague
Associate II
Posted on October 29, 2014 at 02:36

I find strange thing. that is I add the register WRPR3.

WRPR, WRPR1 and WRPR2 immediatly are exist.

128k + 128k + 128k +128k(add) = 512k...

register window of My compiler didn't display WRPR.

I can see WRPR1, WRPR2 and WRPR3.

I use IAR.

what should I do?

Posted on October 29, 2014 at 16:13

I'm not a user of the L151RE, or IAR, and haven't looked at the exact mapping of the flash protection registers.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..