nRF52840 (E73) reset issue

Posted on
  • Hi,
    I know it is not official: I have the E73 from Ebyte flashed with Espruino successfully, it works like a charme.
    When I load my code via IDE to RAM, I can easily get back by disconnecting power so the device gets into bootloader (I believe) waiting to get new code.
    The code makes the device non-connectable on purpose. So when I save() it to "Flash" changing the code needs a reset.
    Now I am having big trouble resetting it by applying power or GND to a specific pin (E73 datasheet says RST is pin 26 which corresponds to P0.18 of nRF52840). Whenever I do this I can see the device advertising as Espruino but just for a few (milli)seconds ... it quickly "falls back" and executes my old code instead. Or I am doing something wrong / not long enough / whatever.
    But even if this would work, resetting the device by fiddling with a specific PIN is a real pain, especially if it is already built in somewhere.
    Long talk short question: can I instead code it so when powered up to stay in "waiting for IDE connection" for maybe 10 seconds after that it goes on switching to not-connectable and continues with whatever it is used for? So every time I power it up, I get a chance to upload new code?
    Maybe this is super easy I have just not found how to do it?
    Any help is appreciated.

  • disconnecting power so the device gets into bootloader (I believe) waiting to get new code.

    not really, by disconnecting power the RAM is lost, if code is in RAM it is lost, when you apply power espruino starts again (posibly loading code saved to flash). no 'bootloader magic' happening here

    when I save() it to "Flash" changing the code needs a reset.

    it depends on what you saved, if you locked yourself out of console then you need to skip loading code at startup, this is typically done by holding BTN1 at reset or power on time

    and btw I'd suggest to not use save(), it is only for very simple cases when you randomly typed something interactively into device, don't remember what it was and don't want your code to be lost. If you can type your code in editor so it runs from top to bottom line by line use 'save to flash' button which saves it to .bootcde file in storage. this file is then executed at poweron line by line

    E73 datasheet says RST is pin 26 which corresponds to P0.18 of nRF52840

    no need to use RST if you can disconnect power, it won't change anything, resetting via RST is basically like powering off and on

    can I instead code it so when powered up to stay in "waiting for IDE connection" for maybe 10 seconds after that it goes on switching to not-connectable and continues with whatever it is used for

    Of course. It is your code that is run at boot time. If you wish to wait 10 seconds before doing something then use setTimeout() to schedule that code to be started after 10 seconds.

    function hello(){
      print("Hello World");
    }
    setTimeout(hello,5000);
    

    If you upload code above to flash then it will print a message to console 5 seconds after poweron.

  • Understand ... and I have tried to do so:
    I can see it starting up, advertising as Espruino, let's me choose to connect via IDE, tries to, says "Connected to BLE" but does not finish let alone me programming it / uploading new code. It just hangs there until the timeout comes and executes my "old code" ... which sets a new name, non-connectable etc.
    Am I missing something?
    Shall I set advertising to something specific to make it "more willing" to connect before the timeout runs my other code?
    And if the connecting works, will it stop the timeout or will I have to upload before to avoid further execution?

  • Am I missing something?

    quite likely :-)

    It just hangs there

    probably some busy loop in your code? hard to guess

  • Hehe, after some more trying it works ... the IDE is sometimes a bit "unruly" ... thank you @fanoush!

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

nRF52840 (E73) reset issue

Posted by Avatar for DanDyse @DanDyse

Actions