1

I'm trying to run the demo described here: https://blog.adacore.com/ada-on-the-microbit

I followed the tutorial's directions carefully. I did install the 2019 versions of the software instead of the 2018 versions. GPS seems to be installed and working on my windows 7 machine. The project builds but pyocd-flashtool can't seem to recognize my microbit. It reports it as a "generic cortex_m" and throws an exception.

Here's the output:

gprbuild --target=arm-eabi -d -PC:\Domains\ada\microbit_scrolling_text_demo\microbit_example.gpr
C:\Domains\ada\microbit_scrolling_text_demo\src\main.adb -largs -Wl,-Map=map.txt
Compile
   [Ada]          main.adb
Bind
   [gprbind]      main.bexch
   [Ada]          main.ali
Link
   [link]         main.adb

[2019-09-21 18:40:29] process terminated successfully, elapsed time: 02.57s

Retrieving the load address.

arm-eabi-objdump C:\Domains\ada\microbit_scrolling_text_demo\obj\main -h

Load address is: 0x00000000

Creating the binary (flashable) image.

arm-eabi-objcopy -O binary C:\Domains\ada\microbit_scrolling_text_demo\obj\main C:\Domains\ada\microbit_scrolling_text_demo\obj\main.bin

Flashing image to board...

pyocd-flashtool -a 0x00000000 C:\Domains\ada\microbit_scrolling_text_demo\obj\main.bin

WARNING:root:Unsupported board found 9901

INFO:root:DAP SWD MODE initialised

INFO:root:ROM table #0 @ 0xf0000000 cidr=b105100d pidr=2007c4001

INFO:root:[0]<e00ff000: cidr=b105100d, pidr=4000bb471, class=1>

INFO:root:ROM table #1 @ 0xe00ff000 cidr=b105100d pidr=4000bb471

INFO:root:[0]<e000e000:SCS-M0+ cidr=b105e00d, pidr=4000bb008, class=14>

INFO:root:[1]<e0001000:DWT-M0+ cidr=b105e00d, pidr=4000bb00a, class=14>

INFO:root:[2]<e0002000:BPU cidr=b105e00d, pidr=4000bb00b, class=14>

INFO:root:[1]<f0002000: cidr=b105900d, pidr=4000bb9a3, class=9, devtype=13, devid=0>

INFO:root:CPU core is Cortex-M0

INFO:root:4 hardware breakpoints, 0 literal comparators

INFO:root:2 hardware watchpoints

Traceback (most recent call last):

  File "C:\GNAT\2019\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)

  File "C:\GNAT\2019\lib\runpy.py", line 72, in _run_code
    exec code in run_globals

  File "C:\GNAT\2019\bin\pyocd-flashtool.exe\__main__.py", line 9, in <module>

  File "C:\GNAT\2019\lib\site-packages\pyOCD\tools\flash_tool.py", line 214, in main fast_verify=args.fast_program)

  File "C:\GNAT\2019\lib\site-packages\pyOCD\flash\flash.py", line 286, in flashBlock flash_start = self.getFlashInfo().rom_start

  File "C:\GNAT\2019\lib\site-packages\pyOCD\flash\flash_cortex_m.py", line 44, in getFlashInfo raise Exception("Unsupported flash operation on generic cortex_m")

Exception: Unsupported flash operation on generic cortex_m

Could not flash the executable.

[workflow stopped]

Anyone know what could be wrong?

Blaine Osepchuk
  • 1,067
  • 1
  • 9
  • 17
  • Any chance you can investigate that **WARNING:root:Unsupported board found 9901** ? – LoneWanderer Sep 22 '19 at 01:24
  • Found this link https://github.com/makerdiary/nrf52832-mdk/issues/11 that might be of use ? – LoneWanderer Sep 22 '19 at 01:31
  • Thanks. I had found that already. There's a list of supported boards in C:\GNAT\2019\site-packages\pyOCD\board\mbed_board.py. The microbit is listed there but I'm not sure why it's not being detected. There's lots of python to trace through. I think I'd rather try installing the 2018 version and see if that magically works before I try to debug all that python. Thoughts? – Blaine Osepchuk Sep 22 '19 at 01:57
  • IIRC, on my Linux laptop, the micro:bit mounts as a usb drive and I had to manually copy the binary over to it. – egilhh Sep 22 '19 at 08:31
  • Likewise on Mac - just dropped binaries on the micro:bit drive. Of course you can’t then debug it if things go wrong – Simon Wright Sep 22 '19 at 17:07
  • Question for Egilhh and Simon Wright. Did you get the same (or a similar) error as the one I got? Are you on 2018, 2019, or something else? – Blaine Osepchuk Sep 22 '19 at 18:26
  • Actually you have to convert the binary to hex for it to be droppable. In the `obj` folder, `arm-eabi-objcopy -O ihex main main.hex` and then copy `main.hex` to the `MICROBIT:\ ` (guessing what it’ll look like on Windows). After that it worked (though not easy to read the scrolling text). Also, afraid I don’t have `pyocd` configured, it just says 'no board connected' – Simon Wright Sep 23 '19 at 14:38
  • Actually, I dragged the binary file to the microbit, which is mounted as a drive and it worked without first converting it to a hex file. I'm not sure why it worked but it did (maybe something to do with installing the mbed drivers for the microbit?) – Blaine Osepchuk Sep 24 '19 at 01:11
  • I’ve just found that the reason pyOCD couldn’t connect to the microbit was that I had this [alternative firmware](https://forward-in-code.blogspot.com/2019/02/using-gdb-with-bbc-microbit.html) installed. I re-installed the official firmware (`0253_kl26z_microbit_0x8000.hex`) and GPS connected & loaded the demo just fine. I have both 9900 and 9901 in `mbed_board.py`. – Simon Wright Mar 03 '20 at 17:31

1 Answers1

1

In C:\GNAT\2019\lib\site-packages\pyOCD\board\mbed_board.py (or the equivalent location on your platform), add this line and it will work.

"9901": BoardInfo( "Microbit", "nrf51", "l1_microbit.bin", ),

Blaine Osepchuk
  • 1,067
  • 1
  • 9
  • 17
Amine Amri
  • 26
  • 1
  • Here are some guidelines for [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). This provided answer may be correct, but it could benefit from an explanation. Code only answers are not considered "good" answers. – Trenton McKinney Sep 24 '19 at 00:34
  • I already have that line with 9900: does this difference correspond to board revisions? – Simon Wright Sep 24 '19 at 08:39
  • Added this edit: no change! (i.e. GPS won’t flash the board; ’no board connected'). – Simon Wright Sep 24 '19 at 10:13
  • Yes, the difference corresponds to a new board revision. In your last comment you said that you have "no board connected". Does it mean that you no longer have "WARNING:root:Unsupported board found 9901" message as in your first question? – Amine Amri Sep 24 '19 at 19:51