Reading out .hex files

A method to read out the .hex file on the micro:bit

Overview

There may be occasions when you want to take a look at the programming that is running on the micro:bit or if you have misplaced the original program. This method reads out the .hex file on the micro:bit to a file in your working directory.

Pre-requisites

In order to complete this task you will require some additional tools and libraries:

The method described here has been tested on Mac OS using Homebrew as a package manager, but should work on Linux. Additional steps are linked to, but it is outside the scope of this article to go through setup.

Procedure

  1. Attach micro:bit via USB
  2. Open two terminal windows/tabs
  3. In the first terminal start a GDB server by running pyocd-gdbserver --persist -t nrf51 -bh -r
  4. In the second terminal window/tab run arm-none-eabi-gdb to open gdb
  5. In the same terminal run target remote :3333 to connect to the GDB server
  6. Now run dump ihex memory out.hex 0x000 0x3E800 to write ‘out.hex’ to your working directory

For any issues or advice contact micro:bit Support