bin/dat to hex?

Posted on
  • Is there a way to convert the available files to hex to flash them using STLink? I bought a chinese nrf52840 (E73 from ebyte) and would like to try Bangle's firmware. I have already successfully flashed this one, but it is obviously a little old and missing some functions ...


    1 Attachment

    • Bildschirmfoto 2023-12-17 um 17.42.49.png
  • STLink should really be able to use bin files - or you could convert them with objdump. However I'm not sure there are pre-made builds for nRF52840.

    Probably the easiest thing is to build your own firmware. It's really not hard and there are docs at https://github.com/espruino/Espruino/blo­b/master/README_Building.md

    You could even just fork the repo and change the GitHub actions file at https://github.com/espruino/Espruino/blo­b/master/.github/workflows/build.yml#L28­ to add NRF52840 and get GitHub to build it for you

  • Is there a way to convert the available files to hex to flash them using STLink?

    If you mean the bin files inside zip files then those are DFU files for OTA update so they are not meant for blank board. DFU zip only contains the application and it is expected the device already has correct bootloader or at least the softdevice. So if you first flash those missing bits you could then convert this bin to hex and flash it (flashing bin directly is also an option).

    Since this is at least second time you want firmware build that is not available I'd suggest to really learn building the stuff yourself, it is not hard at all. In this case there is even no existing build suitable for your board so making your own board file is better. If this is 52840 you can start with NRF52840DK.py and remove this line and maybe USB on the line below and then buttons and LEDs more down below.

    And BTW this topic should better go to "Other Boards", not "Official Espruino Devices / Bangle.js"

  • Thank you guys for the quick replies, and sorry for posting it here. Thought it would be easier to just use an existing 52840 built than create it new. Building my own is tough for me as I really don't have a single clue what I am doing. I already see myself in installing loads of depencies that I will surely never need again and "fixing" problems by googeling and hacking things apart instead of doing it right. Your hint to remove "this line" is best example: what is this and why should I remove it?! There is simply a difference between a user and a developer.
    I will try to get STLink working with the bin files available.

  • So I have flashed two of my devices using STLink and the binary of Bangle using openocd. It looked good, program verify ... but after reconnecting power they both don't advertise. Unfortunately openocd is now unable to connect to them to re-flash them with a working firmware. Guess I have killed both.

  • So I have flashed two of my devices using STLink and the binary of Bangle using openocd. It looked good, program verify ... but after reconnecting power they both don't advertise.

    Oh, I better won't ask what "binary of Bangle" means and how exactly you did it :-) It does not make any sense to flash Bangle.js (1 or 2) firmware into completely different board even if you did it correctly. There is so many pieces of missing Bangle hardware in your module that lot of firmware code will fail.

    There is simply a difference between a user and a developer.

    Yes, user (javascript developer) simply buys supported device like Puck or MDBT42Q. Trying to get random unsupported device working means you are Espruino firmware developer.

    Unfortunately openocd is now unable to connect to them to re-flash

    I think that's quite unlikely. I'd even say it is impossible but "users" are indeed very clever in breaking stuff. Anyway, keep trying, openocd should work no matter what.

  • Ok, I have now edited build.yml at Github, added NRF52840DK and removed all other boards.
    I have also made changes to NRF52840DK.py like @fanoush advised.
    And run the build action, I don't know if anyone else can see this, but it has built a espruino_2v19.119_nrf52840.hex now. :-)
    First thing I have noticed: it loads MUCH faster via IDE than the older hex I have tried.
    Thanks again!


    1 Attachment

  • Wow, excellent progress!

    You may also tune the board file a bit further. If you don't plan to connect serial console to pins 6 and 8 you may set console to EV_BLUETOOTH instead of EV_SERIAL1 and comment out three lines below it with rx/tx pins and baudrate. Then if you removed/commented out button/led definitions you may also comment out matching negated pin lines further down near the end otherwise reading/writing those pins will invert values read/written - which may not bother you if don't plan to use them. Those changes are not strictly needed but will make the board definition more generic.

    Then if you need more storage for files you can replace number 10 on three places starting here https://github.com/espruino/Espruino/blo­b/072a066dcb94ab7eab775267c5d91420f86e79­f6/boards/NRF52840DK.py#L68 and two more places on lines below. Not sure how high it can go before build breaks with some 'code overlaps storage' error but at least 80 (=320KB) could work? on some trimmed down configuration I could go as high as 140. Again this is not very important if you don't plan to upload or create lot of files in storage.

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

bin/dat to hex?

Posted by Avatar for DanDyse @DanDyse

Actions