[Microbit-Python] Starting up with the Microbit

M.-A. Lemburg mal at egenix.com
Wed Dec 30 17:21:41 EST 2015


On 29.12.2015 14:12, Nicholas H.Tollervey wrote:
> Hi Marc-Andre,
> 
> To flash Python scripts onto the device try uflash
> (http://uflash.readthedocs.org/en/latest/) from the command line.
> 
> To connect to the REPL, try this:
> 
> picocom /dev/ttyACM0 -b 115200
> 
> ...or microrepl:
> 
> https://github.com/ntoll/microrepl
> 
> There will be a native editor available soon that should "just work"
> (tm) - once it'd finished (that's my "Christmas holiday fun project" for
> this year...).
> 
> Documentation for the microbit API is here:
> 
> http://microbit-micropython.readthedocs.org/en/latest/
> 
> ;-)

Thanks, I had already found the micropython docs, but
nothing on how to get the board up and running.

Turns out that simply plugging in the USB connector does
the trick (life can be simple ;-)). I also learned that
powering up the device via the pins GND and 3V does not
appear to work.

On Windows, this allows accessing the flash drive and
after you install the serial driver for mbed:

https://developer.mbed.org/handbook/Windows-serial-configuration

it's also possible to access the serial console and REPL
using Tera Term:

https://www.microbit.co.uk/td/serial-library

Now, another FAQ: How can I run a Python script which I
copy to the flash drive ?

The os module doesn't appear to be available in MicroPython,
import doesn't look on the flash drive (it seems), sys.path
is not available either.

Looking at tools/pyboard.py, this sends the raw data over the wire
and your blog post suggests that Python scripts are only
automatically run when embedded into the firmware hex file:

http://ntoll.org/article/story-micropython-on-microbit

e.g. using your uflash tool.

Would it be possible to have MicroPython automatically
detect a main.py file in the flash memory and run
this when the board is reset ?

BTW: While researching into how this could be done I found
DAPLink (which handles the USB connection on the board) and
from there the nRF51822-mKIT, which appears to have *very*
similar hardware details to the microbit:

https://www.mbed.com/en/development/hardware/prototyping-production/daplink/daplink-on-kl26z/
https://www.mbed.com/en/development/hardware/boards/nordic/nrf51822/

The SDK is open source (Apache), so perhaps there are some
things to learn from it. E.g. that board uses pyOCD for development,
flashing and debugging:

https://github.com/NordicSemiconductor/pyOCD

which uses Python USB/HID interfaces for connecting. Perhaps
this allows for a more reliable way of connecting to the board
than relying on mounting and finding the flash drive ?!

Here's the code they use for the interfacing:

https://github.com/NordicSemiconductor/pyOCD/tree/master/pyOCD/interface

Back to the above question: Perhaps we could ask Sam Grove
who implemented the DAPLink feature for some hints as how
to make this work ?!

https://developer.mbed.org/handbook/cmsis-dap-interface-firmware
https://ch.linkedin.com/in/samgrove


> N.
> 
> On 29/12/15 12:22, M.-A. Lemburg wrote:
>> Hello everyone,
>>
>> I received a microbit from Angus just before Christmas and
>> would like to start playing with it this week:
>>
>> http://microworldtour.github.io/microbit/monifa.html
>>
>> Unfortunately, I'm a bit lost how to start, since the information
>> about basic things like how to connect and power up the device
>> seems to be well hidden somewhere on the net ;-)
>>
>> The board has pins saying "3V" and "GND" and there's
>> a battery connector on it as well (but without indication
>> of which pin is + and which is ground (*)). Would it be enough to
>> connect a power supply to the pins or do I need to
>> find a plug for the battery connector ?
>>
>> Also: I've seen a serial console being used to drive the
>> REPL, but there don't appear to be serial con pins on the
>> device. Is the USB port used for this ? The README seems to
>> imply this ("Upon reset you will have a REPL on the USB CDC
>> serial port").
>>
>> Lastly: For flashing the device, is it possible to mount
>> the flash drive using the USB port or do I need to send the
>> image over the serial port ?
>>
>> Lots of question and I assume that most of these are FAQs :-)
>>
>> I will probably drive to an electronics shop to get some
>> cables and perhaps a battery pack today.
>>
>> (*) It may be useful to add some text to the board to
>> help kids and teachers with this.
>>
>> Thanks,


-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Dec 30 2015)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...           http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...           http://zope.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/
                      http://www.malemburg.com/



More information about the Microbit mailing list