Espruino on your watch!

Posted on
Page
of 9
First Prev
/ 9
  • That's fantastic - thanks!

    Just a quick update - I now have some ID205 watches here and I'm working on an Espruino build that can be flashed by the factory. Reverse engineering is a slow painful process as the watch is glued together and they're using a 4 layer board with BGA packages. However I am getting there - we now have the two buttons, LCD and vibration motor going. With a bit of work that'll be good enough to port the bootloader.

  • Good news, thanks for update. Previously I did not find FCC ID page but it looks like it is this one https://fccid.io/2AHFT226 , the User Manual says ID205 - but as you already got it opened this is no help.

    And if you are reverse engineering by examining the board traces and would also want firmware, then this link points to ID205 veryfit pro OTA download zip (public http link to their servers). depends what is easier but one can get e.g. display initialization code etc. Recently I have used ghidra decompiler and got a bit familar with it and it is sometimes quite helpful. It even tries to show you C code and sometimes it is more readable than assembly (and sometimes not).

  • Aaargh, it's currently 35$ at banggood hate u all :)
    Looks like there are 4 pins on the back of the watch. Can you flash new firmware without opening it? But honestly should just wait for you to do the work, already have too many half-done projects...

  • Can you flash new firmware without opening it?

    No, the firmware is signed. You can do it with all other nrf52832 devices from that company because they use SDK11 however this is 52840 chip so with that one they moved to later SDK => signed firware. More info 2 pages back in this topic.

  • Thanks - that firmware image might be handy. I'm doing ok for the moment but there might be a few things that are needed at a later date (like HRM/touch/etc).

    edit: definitely going to need it for touch I think :) The touch controller has its own CPU so I'll need to dump the firmware for it so it can be re-uploaded on fresh watches.

    But please don't buy the ID205 in the hope that you can flash it. It's got a metal and gorilla glass front that is glued shut and is almost impossible to get into. I've basically destroyed two watches trying to get into them now.

  • wanted to use E.enableWatchdog, because it's pretty hard to reset the watch if something goes wrong.

    Just a big warning related to watchdog. I just managed to brick HX03W while doing upload from Espruino WebIDE. The default is calling reset() before upload, which is normally sane thing to do but it interacts with watchdog in unfortunate way. reset() clears your watchdog pinging routine but not the watchdog itself as it is not real CPU reset and then starts upload. If upload does not finish in time you get watchdog reboot in the middle of upload. For me this causes my HX03W to not start properly now.

    I see nothing in serial console and bluetooth device can be seen but cannot be connected to UART service. So now I need to open it or wait until battery dies and then try to hold the button while powering on. Hopefully it will skip loading the partially saved code.

    So just beware it is not that easy with the watchdog. One safe way to upload is first clear code via require("Storage").erase(".bootcde") and then call reset() manually, then wait for watchdog reboot and only then upload new code. Or run everything in RAM until code is finished and stable.

  • Ouch.
    One thing you may try: try to put it into bootloader mode with the DSD6 app. Absolutely no idea whether that clears the watchdog, or what might happen, but may work. Probably wait for you watchdog timeout, before trying to reflash, so it doesn't restart the watch while flashing, and bricks it even more :)

  • There is no way to switch to (stock Desay) bootloader now as the switch needs espruino console working. Holding button at startup time after battery dies might help but it may take weeks :-) Anyway, I have couple of other devices to bri^H^H^Hhack and also more HX03W ones will arive from that banggood sale so I will wait until battery dies in this one just to see what happens.

    EDIT: maybe I can hammer it with some bluetooth packets constantly so it will die much sooner?

  • Oh after some time it recovered. I left it alone and after few hours I tried to connect and it still failed and serial console was dead but suddenly - in nrfconnect I tried directly write RX characteristics and it suddenly echoed the data into TX. I sent string E.reboot() and after some time I checked serial console and saw

    Uncaught SyntaxError: Got EOF expected '}'
     at line 2 col 6493
    ...?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255] ?[255]]
    

    So either it rebooted or not and printed this. Then I tried

    s=require("Storage");s.read(".bootcde")
    ="Modules.addCached" ... "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xF­F\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
    > console.log(btoa(s.read(".bootcde")))
    

    and copied the base64 string to computer and decoded back into binary and there is beginning of the program and the rest of file is 0xff. first 0x400 bytes in sensible code and rest until 0x1b66 is all 0xff.

    I will try to copy this to opened DS-D6 I can recover and see what the file does after reboot. Maybe it takes time for the interpreter to handle such long line of 0xff bytes , i.e no end of line and strange 0xff 'tokens'?

    Anyway, I erased storage in HX03W and it is fine now.

    EDIT: when looking at the partial code it even looks like it is not the latest version, I think I had the watchdog setup code on the beginning that later caused this mishap so this looks like flash page of some older code. And BTW when webide uploaded the code, I think the progress bar went to end normally so there was not any feedback that anything went wrong. It happily progressed while the watch was already rebooted. I'm not sure but think it was over serial so that may explain since there is no echo(?) so data is just pushed without any check(?).

  • Thanks - I guess it'd make sense to stop the watchdog inside jshReset (or ensure that 'auto' watchdog stayed working) to avoid this sort of problem?

    Come to think of it, should auto watchdog cause Espruino to automatically wake up in time to kick the watchdog? It'd seem sensible.

    I wouldn't have thought Espruino would get 'stuck' executing code since it should break out with an exception when it hits the first 0xff - but you may have been unlucky in that the part of the code that was saved may have enabled watchdog, but then the bit that actually kicked it didn't get loaded?

  • I guess it'd make sense to stop the watchdog inside jshReset (or ensure that 'auto' watchdog stayed working) to avoid this sort of problem?

    I guess you can't disable watchdog without doing reboot which is the point of having reset() call (so it works e.g. over BLE connection without disconnecting). So if upload could find that manual watchdog mode is enabled, then switch to automatic mode (if possible) or just refuse upload. Or at leasrt disable 'reset before upload', or .... it is complicated due to different upload modes (to ram vs to storage). I guess upload to storage does not need reset before upload checkbox enabled. It just writes .bootcde and then could reset after upload an load it. Reset before upload makes more sense with upload to RAM since it is full and stuff is otherwise modified in place (?).
    BTW, I find all those settings for code upload scattered over all other IDE setings hard to manage as I want to change them often. Would prefer the 'send to espruino' button pop up small dialog (maybe only when holding the button longer?) with just few options : reset before upload,save on send mode, set time and maybe minify yes/no. Sometime I would even only check 'set time' without any code upload.

    Come to think of it, should auto watchdog cause Espruino to automatically wake up in time to kick the watchdog? It'd seem sensible.

    Well, yes but the empty setInterval workaround solves it too, depend how much work and code it is.

    I wouldn't have thought Espruino would get 'stuck' executing code since it should break out with an exception when it hits the first 0xff

    Yes sounds strange. I don't know what is was, just that both serial and NUS console was not available after that watchdog reboot. The device was still advertising but web ide could no connect. So after trying it for few minutes I left it alone and tried later.

    but you may have been unlucky in that the part of the code that was saved may have enabled watchdog, but then the bit that actually kicked it didn't get loaded?

    It was like this:
    I uploaded code with first two lines added like this

    E.enableWatchdog(6, false);
    var wdint=setInterval(function(){if(!BTN1.re­ad())E.kickWatchdog();},1000);
    

    and then my other code. This worked fine and after testing it and doing some changes in IDE I wanted upload another version with changes. And unfortunately I had 'Reset before Send' setting enabled. So it called reset() and then started upload which was longer that 6 seconds.

    And so my guess is that it rebooted with inconsistent storage with half of code and rest of 0xff and additionally after reboot and running through this, the serial console was further flooded with the rest of uploaded code.

  • I've just pushed some watchdog changes - in auto mode it now resets it automatically, and if you reset() the auto kicking carries on. But that won't help you here because it's going to get rid of your setInterval anyway.

    Best bet is to save the code to .boot0 - that should be executed regardless of whether the watch was reset or not: http://www.espruino.com/Saving

  • Oh, so I can have both? Two lines of watchdog pinging in .boot0 and rest in .bootcde? And the IDE will not clear the other one at upload? That would be best. Will try. Thanks.
    EDIT:
    It works, I saved just watchdog setup and kicking code into .boot1 and it gets run together with main code, IDE does not touch it and uploading works also with reset before upload! Also as a bonus when I hold button for 6 seconds it reboots and does not start .bootcde because I still hold the button at boot time. So the code is not automatically started which is what is best when there is some bug that needs watchdog reset. All this still without your recent changes.
    Your changes however fix the auto mode that could cause similar unexpected isssues after reset()

  • Oh, so I can have both?

    That's right, yeah :) Glad it's working!

  • Hi! Quick question - while I've been working hard on the ID205 reverse engineering (and the nRF52840 is obviously nicer to have), I've had a lot of interest in watches with GPS and I'm coming back to the No.1 F5 and F7 watches as they're packed full of features.

    I just found a link to a firmware updater for it (which is actually just an APK file) and looked inside and found firmware that references SDK 7/8/9. That feels super old to me, but do you think it's a possibility that's what they're using?

    If so I guess OTA firmware updates could be a realistic option and I could just reflash the watches here?

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

Espruino on your watch!

Posted by Avatar for Gordon @Gordon

Actions