Updating Espruino Bootloader

Posted on
  • Hello,
    I have some questions about updating the espruino bootloader.

    But let me first explain what I done (sorry for the lengthy explanation)

    I compiled successfully firmware 1v79 with the espruino bootloader combined then used the advance flashing in the IDE to update the original espruino board. All went ok, update successful.

    Then I changed the pin definition for BTN1 to be on port A0 (i need this for my experiments) , re-compiled and all went ok again, new .bin was created.
    I re-flashed again using advanced flash option and all went ok. I connected again with the IDE and typed BTN1 and it displays "A0" so things seem to be ok as far as my change.
    Then I proceeded to test that the bootloader was using A0 port but it did not. it was still using the original port B12 attached to the pushbutton. I tried several times to re-flash but the results where the same. it seems that the my new espruino bootloader is not being replaced.

    I finally used stm32 flasher and UART to flash the very same .bin file i used previously and this time the espruino bootloader was updated and I was able to activated using port A0.

    Why my espruino bootloader is not updated using the IDE-advanced flasher but it worked using STM32 flasher? what am I missing?

    -Thx

  • The bootloader is designed to not overwrite itself so that a failed firmware update won't brick the board.

  • Thx. I get it now.

    #1) So what's the point of combining the espruino bootloader in the firmware? to only offset the space for espruino runtime ?

    #2) Shouldn't the "advanced flashing" overwrite it and normal updates should not overwrite? I imagine that the number of people doing "advanced flashing" are small and have the tools to re-flash with stm32 uart tools. I'm getting spoiled using espruino IDE :)

  • So what's the point of combining the espruino bootloader in the firmware? to only offset the space for espruino runtime ?

    Yes, but also to make sure that if someone does update the firmware using Serial (or DFU on the Espruino Pico), they get everything they need.

    Shouldn't the "advanced flashing" overwrite it and normal updates should not overwrite?

    The USB bootloader (which exists so that the Web IDE can update firmware without any extra tools/drivers) is actually incapable of overwriting itself, as @DrAzzy said. Making it do so would actually require some pretty major hacks (like writing a new bootloader into RAM and jumping to it). It's work that's not really worth doing, because as you say most people who need to do it would have the capability to just use the UART.

    Also, if you could overwrite the bootloader, you might be unlucky and choose a build where the bootloader itself was broken - 'bricking' your Espruino. At least requiring people to use a USB-TTL dongle to update the bootloader ensures that they also have the tools to fix their board if something goes wrong!

  • That clarifies all my questions and makes sense. Thank you for taking the time to explain it in detail.

  • Well said, Gordon :-P

    It boggles my mind how many people don't have USB serial adapters sitting around - on Arduino forums, it's a little defensible, since you need the ones with DTR broken out. But... any old serial adapter will work for this, like the $1-shipped CH340G ones from ebay (note - the cheapo black ones did a lousy job of wave soldering; they work fine, but the USB connector's "ears" often aren't soldered down, so it could break off easily if you don't solder them in place)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Updating Espruino Bootloader

Posted by Avatar for user47006 @user47006

Actions