Skip to content

Commit e11a2c5

Browse files
microbit-markmicrobit-carlos
authored andcommitted
docs: dev guide updates (bbcmicrobit#711)
Completes and merges build and flash pages. Adds V2 info. Removes outdated FAQ page. Adds WebUSB info to REPL page. Rebase update: Keeps and updates the flashing paragraph in flashfirmware page.
1 parent 0dcd7a6 commit e11a2c5

File tree

4 files changed

+98
-186
lines changed

4 files changed

+98
-186
lines changed

docs/devguide/devfaq.rst

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/devguide/flashfirmware.rst

Lines changed: 89 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,116 @@
11
.. _flashfirmware:
22

3-
=================
4-
Flashing Firmware
5-
=================
3+
===========================
4+
Build and flash MicroPython
5+
===========================
66

7-
Building firmware
8-
-----------------
9-
Use yotta to build.
7+
micro:bit V1
8+
============
109

11-
Use target bbc-microbit-classic-gcc-nosd::
10+
This applies to MicroPython for the micro:bit V1, the source of which can be
11+
found here: `bbcmicrobit/micropython <https://github.com/bbcmicrobit/micropython>`_.
1212

13-
yotta target bbc-microbit-classic-gcc-nosd
13+
Dependencies
14+
------------
15+
- `cMake <https://cmake.org/>`_
16+
- `Arm gcc <https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads>`_
17+
- `git <https://git-scm.com/>`_
18+
- `ninja <https://ninja-build.org/>`_
19+
- `python <https://www.python.org/downloads/>`_
20+
- `srecord <http://srecord.sourceforge.net/>`_
21+
- `yotta <http://docs.yottabuild.org//>`_
1422

15-
Run yotta update to fetch remote assets::
23+
The `yotta
24+
<http://docs.yottabuild.org//>`_ tool is used to build MicroPython, but before
25+
that takes place additional files have to be generated by the Makefile in
26+
preparation for the build, and additional data is added to the hex file after.
1627

17-
yotta up
28+
Clone the repository and change directory to it::
1829

19-
Start the build with either yotta::
30+
$ git clone https://github.com/bbcmicrobit/micropython
2031

21-
yotta build
32+
$ cd micropython
2233

23-
...or use the Makefile::
34+
Configure yotta to use the micro:bit target::
2435

25-
make all
36+
yotta target bbc-microbit-classic-gcc-nosd@https://github.com/lancaster-university/yotta-target-bbc-microbit-classic-gcc-nosd
2637

27-
The result is a microbit-micropython hex file (i.e. ``microbit-micropython.hex``)
28-
found in the build/bbc-microbit-classic-gcc-nosd/source from the root of the
29-
repository.
38+
Run yotta update to fetch remote assets::
3039

31-
The Makefile does some extra preprocessing of the source, which is needed only
32-
if you add new interned strings to ``qstrdefsport.h``. The Makefile also puts
33-
the resulting firmware at build/firmware.hex, and includes some convenience
34-
targets.
40+
yotta up
41+
42+
Start the build using the makefile::
43+
44+
make all
45+
46+
The resulting ``firmware.hex`` can be found in the ``build/``
47+
directory which can then be copied to the micro:bit.
3548

3649
Preparing firmware and a Python program
3750
---------------------------------------
3851

39-
A script in the following location, called using the following syntax, should
40-
help::
52+
Using ``tools/makecombinedhex.py`` you can combine the MicroPython firmware
53+
with a Python script and produce a hex file ready for uploading to the
54+
micro:bit.::
4155

42-
tools/makecombinedhex.py <firmware.hex> <script.py> [-o <combined.hex>]
56+
./makecombinedhex.py <firmware.hex> <script.py> [-o <combined.hex>]
4357

4458
The script will output to ``stdout`` if no output option (``-o``) is provided.
4559

46-
Flashing to the micro:bit
47-
-------------------------
60+
Using ``tools/hexlify.py`` you can turn a Python script into Intel HEX format
61+
to be concatenated at the end of the MicroPython firmware.hex. A simple header
62+
is added to the script.::
63+
64+
./hexlifyscript.py <script.py>
65+
66+
It also accepts data on standard input.
67+
68+
69+
micro:bit V2
70+
============
4871

49-
The Microbit mounts itself as a mass storage device over USB. When it detects
50-
that a .hex file has been uploaded to the internal mass storage device, it will
51-
flash itself with the bytecode representation, and start running the program.
72+
This applies to MicroPython for the micro:bit V2, the source of which can be
73+
found here: `microbit-foundation/micropython-microbit-v2 <https://github.com/microbit-foundation/micropython-microbit-v2>`_.
5274

53-
This means that uploading a .hex file should result in the Microbit running your
54-
code.
75+
The repository also contains a history of
76+
`MicroPython firmware builds <https://github.com/microbit-foundation/micropython-microbit-v2/actions>`_.
5577

78+
Dependencies
79+
------------
5680

81+
- `Arm gcc <https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads>`_
82+
- `gcc <http://gcc.gnu.org/install/>`_
83+
- `cMake <https://cmake.org/>`_
84+
- `git <https://git-scm.com/>`_
85+
- `ninja <https://ninja-build.org/>`_
86+
- `python <https://www.python.org/downloads/>`_
5787

58-
**Installation Scenarios**
88+
Clone the repository and change directory to it::
89+
90+
$ git clone https://github.com/microbit-foundation/micropython-microbit-v2
91+
$ cd micropython-microbit-v2
92+
93+
Update the submodules::
94+
95+
$ git submodule update --init
96+
97+
Then build the MicroPython cross-compiler::
98+
99+
$ make -C lib/micropython/mpy-cross
100+
101+
After setting up, go to the src/ directory and build::
102+
103+
$ cd src
104+
105+
$ make
106+
107+
The resulting firmware will be ``MICROBIT.hex`` in the ``src/``
108+
directory which can be copied to the micro:bit.
109+
110+
111+
Flashing to the micro:bit
112+
=========================
59113

60-
* :ref:`Windows <microbit-windows>`
61-
* :ref:`OS X <microbit-osx>`
62-
* :ref:`Linux <microbit-linux>`
63-
* :ref:`Debian and Ubuntu <microbit-debian-ubuntu>`
64-
* :ref:`Red Hat Fedora/CentOS <microbit-redhat>`
65-
* :ref:`Raspberry Pi <microbit-rpi>`
114+
The micro:bit mounts itself as a USB mass storage device named ``MICROBIT``.
115+
When it detects that a .hex file has been copied to the USB drive, it will
116+
flash itself, and start running the program.

docs/devguide/hexformat.rst

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,15 @@ found here: `microbit-foundation/micropython-microbit-v2 <https://github.com/mic
121121
This is a port of MicroPython to the micro:bit which uses CODAL as the
122122
underlying target platform.
123123

124-
After cloning this repository update the submodules::
125-
126-
$ git submodule update --init
127-
128-
Then build the MicroPython cross-compiler::
129-
130-
$ make -C lib/micropython/mpy-cross
131-
132-
After setting up, go to the src/ directory and build::
133-
134-
$ cd src
135-
136-
$ make
137-
138-
That will build both ``libmicropython.a`` (from source in ``src/codal_port/``) and the
139-
CODAL app (from source in ``src/codal_app/``). The resulting firmware will be
140-
``MICROBIT.hex`` in the ``src/`` directory which can be copied to the micro:bit.
124+
Running the ``make`` command executes the following steps:
125+
126+
- Create build output directory, run cmake, and make sure codal libraries
127+
exist (via cmake).
128+
- Build both ``libmicropython.a`` (from source in ``src/codal_port/``) and the
129+
CODAL app (from source in ``src/codal_app/``).
130+
- Run ``addlayouttable.py`` to add the layout table to the .hex file
131+
- Create the microbit-micropython firmware as ``MICROBIT.hex`` in the ``src/``
132+
directory, which can be copied to the micro:bit.
141133

142134
Including a user script
143135
-----------------------

docs/devguide/installation.rst

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)