Non-bangle bangle flashing

Posted on
  • Firstly apologies for going 'off-piste'...
    but since I was intended to do some heavy hacking I didn't want to accidentally brick/destroy an official bangle.js but had no qualms blatting a generic watch I could easilly replace. So picked up an (I think identical?) unbranded version. (and I was rather taken with the red case! :) (pic1)

    I'm connected via SWD, an STLink2 and OpenOCD (as I said I intended to do some hacking, bootloader changes, different NRF softdevice etc)

    I thought everything was going well, but now I seem to be at an impasse, I assume I've missed something obvious or done something stupid, so any suggestions welcome. However obvious!
    I've got a local build of Espruino using current git code.
    After flashing then hex through OpenOCD:

    > program /home/ivor/devel/espruino/Espruino/espru­ino_2v09.134_banglejs.hex reset
    target halted due to debug-request, current mode: Thread 
    xPSR: 0x01000000 pc: 0x000008e4 msp: 0x20000400
    ** Programming Started **
    nRF52832-QFAA(build code: E0) 512kB Flash, 64kB RAM
    Padding image section 0 at 0x00000964 with 1692 bytes
    Padding image section 1 at 0x0001ebf0 with 1040 bytes
    Flash write discontinued at 0x00072950, next section at 0x0007a000
    Adding extra erase range, 0x00072950 .. 0x00072fff
    Padding image section 3 at 0x0007dfc0 with 64 bytes
    Padding image section 4 at 0x0007e324 with 3292 bytes
    Adding extra erase range, 0x0007f324 .. 0x0007ffff
    Adding extra erase range, 0x10001000 .. 0x10001013
    Adding extra erase range, 0x1000101c .. 0x10001fff
    no flash bank found for address 0x60000000
    ** Programming Finished **
    ** Resetting Target *
    

    On reboot, says "storage is corrupt, erasing" then shows a ">" cursor. (pic2)

    I thought/wondered if this was just because no apps had been uploaded/bundled and I can connect to the watch via "bangle.js/apps" from there if I run "Install Default Apps" the "Erasing..." happens but then it proceeds to uploading bootloader, displays "Uploading boot..." and hangs. (pic3)

    Not sure if it's a related problem, but if I connect to the watch via nRFConnect it shows up as 'Nordic UART Service' with no DFU service.

    Any suggestions what I've missed or what I should/could try?


    3 Attachments

    • watch.png
    • IMG_20210710_084253_679.jpg
    • IMG_20210710_213426_424.jpg
  • Can't see nrf5 mass_erase in your statement, this might fix the storage corrupt issue.

  • Thanks, pretty sure I'd had that on an earlier flash, just retried with that and does the same.

    Is that warning in the flash output anything significant?

    Warn : no flash bank found for address 0x60000000
    
  • and great success! Thanks, the problem was the bootloader was too large... doh.
    Right, onwards to some more hacking, think I'll leave the SWD leads on for a bit, that's rather handy.
    Keeping eyes peeled for the bangle2.

  • While I wait for a Bangle2... I was tinkering with getting the ANT+ 332 softdevice working to use with secondary HRM's (only reason for going ANT rather the BLE is all my HR straps here are ANT+)

    So I picked up another F18 type board to play with, interestingly this one doesn't have GPS or use an IO expander so everything's a direct link to the NRF52.
    So far I've got everything working but the flash isn't behaving (I've definitely traced the pins correctly to their new IO lines)

    So the question I wanted to know/ask was what options there are for getting some/any debug logging out from the firmware? Is there any way to generate a debug message that can be passed back out to openocd or similar? or since the web bluetooth connection seems to be working is there any way from from the firmware to log to that? (I couldn't see either but I may have missed it)
    (up to now I've been relying on adding "vibrate buzz" statements at points in the code and counting them!) :)

  • Glad you got it working!

    what options there are for getting some/any debug logging out from the firmware?

    Yes, I'd say just use jsiConsolePrintf in your C code (or print in JS)? Then when you're connected via Bluetooth you get the text on Bluetooth, or if not you get it on-screen.

  • Is there any way to generate a debug message that can be passed back out to openocd or similar?

    I think with segger tools this is pretty straightforward - google for Segger RTT. With OpenOCD google for SWO tracing - however this need GPIO pin 18 = TRACEDATA[0] to be free. RTT does not need any extra pins since this is just preallocated buffer in SRAM read over SWD.

    Or maybe opeocd already has Segger RTT support merged https://www.reddit.com/r/embedded/commen­ts/80dg3a/how_exactly_does_the_segger_rt­t_work/ that works with any SWD dongle?

    Or as a poor man's RTT you can allocate fixed buffer, write to it and dump it periodically from openocd via memory dump commands, it s not needed to stop CPU to read memory.

    Of course you can also setup plain uart with just TX pin and log to that.

  • Perfect thanks, lots of ideas cheers! will give it a spin tonight. Having a huge amount of fun with these.

  • Thanks! lots of jsiConsolePrintf's and using Bluetooth logging was just the ticket! (couldn't get RTT working, might try that again sometime).

    All up and running now, going to be really handy having a permanently SWD connected unit to tinker with.

    It only needs minor changes to work with this model (disabling GPS and IO expander, oh and speaker! and redirecting the IO lines).
    Is there any interest/value in making a pull request for this? since I can't imagine there's going to be many people with one of these! or what it would be called either, it was just branded as F18, and was very cheap. It has a squarer edged case and metal strap.)


    1 Attachment

    • IMG_20210726_220739_919.jpg
  • I think in general, if it's something there's an easy way to get hold of, I'm up for PRs for BOARD.py files as long as there aren't loads of ifdefs for the specific watch. Like P8/DK08/etc I'd be interested in getting proper board files for I reckon.

    However, if there isn't even an obvious way to buy other devices, it's probably not a good idea for a PR in this case :(

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

Non-bangle bangle flashing

Posted by Avatar for Ivor @Ivor

Actions