sparkfun / Artemis-Firmware-Upload-GUI

A cross-platform GUI for uploading new firmware to an Artemis based device.
Other
27 stars 12 forks source link

Feature request: add support for .bin files compiled with mbed-cli #5

Closed idea--list closed 4 years ago

idea--list commented 4 years ago

I know at the time of being this tool is supposed to be used in conjunction with the AmbiqSDK only, however it would be great to add support for .bin files compiled with mbed (even if the mbed stack is still under work for the Artemis boards).

nseidle commented 4 years ago

The tool should support any bin file. I made it specifically to load bin's generated by the Arduino IDE. The tool doesn't care. Have you tried it with mbed generated bins? Problems?

idea--list commented 4 years ago

What i try is to code my Artemis Thing Plus board with Mbed (using mbed-cli V1.10.4 on a Win10 x64 system).

  1. I type mbed import https://github.com/ARMmbed/mbed-os-example-blinky (this imports the official mbed blinky example bundled with mbed-os V6.0.0)
  2. As Mbed-os V6.0.0 does not know about the Artemis boards, i replace the contents of the mbed-os folder inside the project folder to your dev branch (ambiq-apollo3-dev) found here.
  3. Compile the example succesfully by typing mbed compile --target SFE_ARTEMIS_THING_PLUS --toolchain GCC_ARM

4a. Then using the Artemis Firmware Upload GUI tool i upload the .bin file to the Artemis board. I can see the orange LED lighting up on the board, the status window the GUI tool tells me the upload is complete, but the board does not run any of my firmware i write in Mbed. Even pushing the reset button or powercycling the board does not help.

4b. Even if i upload without the GUI tool by typing python3 C:/AmbiqSuiteSDK/boards_sfe/common/tools_sfe/ambiq/ambiq_bin2board.py --bin "BUILD/SFE_ARTEMIS_THING_PLUS/GCC_ARM/mbed-os-example-blinky.bin" --load-address-blob 0x20000 --magic-num 0xCB -o "." --version 0x0 --load-address-wired 0x10000 -i 6 --options 0x1 -b 115200 -port "COM4" -r 2 -v. The script tells me the upload was successful, but the board does not run any of my firmware i write in Mbed.

While any code i write in AmbiqSDK or Arduino runs on the board as expected. So i think i might be missing something in step 4a and 4b.

I would highly appreciate any help allowing me to run my Mbed programs on this board!

nseidle commented 4 years ago

Ah, I bet your linker script is pointing to the wrong location.

Checkout the linker scripts for the Think Plus here. There are two:

One for artemis_sbl_svl_app.ld - this is the linker script called by Arduino to create a bin for the SparkFun Variable Loader which is called, be default, by the GUI. It compiles code starting at location 0x10000.

The one for ambiq_sbl_app.ld is the original linker script that you can use with the Ambiq Secure Bootloader (ASB). It compiles code starting at location 0xC000. You can get the gui to send code using the ASB (update bootloader button) but it will load a local bin (located in the tools directory).

It's confusing to say the least. It all works seamlessly in the context of Arduino.

Try changing your linker to start flash at 0x10000.

idea--list commented 4 years ago

Tried to changed it, but there is no difference. Will have to wait until the mbed way works out of the box via USB.

idea--list commented 4 years ago

@nseidle Gave it another try and this time the board starts my code as expected.

I flashed my board using this command python3 C:/AmbiqSuiteSDK/boards_sfe/common/tools_sfe/ambiq/ambiq_bin2board.py --bin "BUILD/SFE_ARTEMIS_THING_PLUS/GCC_ARM/mbed-os-example-blinky.bin" --load-address-blob 0x20000 --magic-num 0xCB -o "." --version 0x0 --load-address-wired 0xC000 -i 6 --options 0x1 -b 115200 -port "COM4" -r 2 -v (using the option --load-address-wired 0x10000 the board will not start running the firmware).

I already tried the same before without success, so i guess there might have been a bug in that has been hunted since my last trial.

nseidle commented 4 years ago

Good to know! Glad to hear it's working for you.