Skip to main content
spa
Associate II
March 26, 2009
Question

Boot loader and I2C

  • March 26, 2009
  • 15 replies
  • 2998 views
Posted on March 26, 2009 at 09:47

Boot loader and I2C

    This topic has been closed for replies.

    15 replies

    16-32micros
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    Hi spa1,

    You have just to write your own IAP program using the first page(s) of the flash and you will get your I2C bootloader.

    Cheers,

    STone-32.

    spa
    spaAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    Hi.

    My task is to make a boot loader that take data from the I2C and save it to the flash and then reboot the chip. Simple…

    My question is, can I use the internal boot loader or do I have to write my own. As fare as I can see, the internal boot loader can only receive data from the USART. :|

    If somebody knows about a boot loader to the STM32 that can take data form the I2C, please leave a link.

    Thanks

    Søren P.

    trevor1
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    Hi,

    My two cents worth:

    If you run from RAM and do a mass erase and then lose power for some reason before you've had a chance to program the flash you will have lost your bootloader.

    Unless speed is a huge issue it will be much easier to just run from a few pages of flash and rather than doing a mass erase just erase the pages you need to fit your app into (and never erase the bootloader pages of course). The ST IAP example illustrates this although it uses UART and YMODEM instead of I2C but approach is the same.

    Cheers

    Trevor

    spa
    spaAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    Ok Thanks...

    I have 2 questions regarding Flash programming according to PM0042 it seems that’s only possible to write one half-word before testing the FLASH_SR_BSY flag, is this correct?

    My plan is to copy my boot loader from flash to Ram, and then execute it from Ram(to speed it up), then perform a mass erase, and start to program the flash again.

    But can I protect some pages in the flash (for the boot loader) so that the boot loader remain in the flash after a mass erase?

    Thanks

    Søren

    spa
    spaAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    HI.

    If you run from RAM and do a mass erase and then lose power for some reason before you've had a chance to program the flash you will have lost your bootloader.

    That’s why I would protect some pages in the flash (for the boot loader) so that the boot loader remain in the flash after a mass erase.

    Cheers

    Søren

    spa
    spaAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    Hi.

    I can see that in all the examples provided by ST they use the FLASH_ErasePage(). But how can they be sure that the function “FLASH_ErasePage()� not is located in the page that they are erasing?

    Best regards

    Søren

    trevor1
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    I'm pretty sure a mass erase will always erase all pages.

    st3
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    Quote:

    But how can ST make they examples works

    Which particular example(s) are you talking about?

    The IAP application note (AN2557) alluded to earlier specifically states where the bootloader part has to be loaded...

    http://www.st.com/stonline/products/literature/an/13588.pdf

    spa
    spaAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    But how can ST make they examples works, is it luck?? They just use they own library, and they don’t define were to place the erase function in flash.

    Best regards

    st3
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    Quote:

    But how can they be sure that the function “FLASH_ErasePage()� not is located in the page that they are erasing?

    Quite possibly they can't - it is up to the developer (ie, you) to ensure that...