You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the BBC micro:bit has hardware capable of allowing the device to work as
5
8
a Bluetooth Low Energy (BLE) device, it only has 16k of RAM. The BLE stack
6
9
alone takes up 12k RAM which means there's not enough memory for MicroPython
7
-
to support Bluetooth.
10
+
to support Bluetooth on a micro:bit V1.
8
11
9
12
.. note::
10
13
MicroPython uses the radio hardware with the :mod:`radio` module. This
@@ -13,3 +16,15 @@ to support Bluetooth.
13
16
14
17
Furthermore, the protocol used in the :mod:`radio` module is a lot simpler
15
18
than BLE, making it far easier to use in an educational context.
19
+
20
+
micro:bit V2
21
+
============
22
+
23
+
The nRF52833 used by the micro:bit V2 has 128k of RAM, allowing Micropython to make
24
+
use of the BLE stack. Currently the only implemented feature is BLE flashing, allowing
25
+
a user to update the firmware on the micro:bit over Bluetooth.
26
+
27
+
At the time that this was written the `Nordic DFU service <https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_bootloader_dfu_process.html>`_ is implemented, and partial flashing is currently working but in
28
+
beta. The Nordic DFU service updates everything in flash and will take a (relatively) long
29
+
time to complete, whereas the partial flashing service only updates the filesystem containing
MAGIC1 VERSION TABLE_LEN NUM_REG PSIZE_LOG2 MAGIC2
67
+
68
+
The values are:
69
+
70
+
ID - 1 byte - region id for this entry, defined by the region
71
+
HT - 1 byte - hash type of the region hash data
72
+
REG_PAGE - 2 bytes - starting page number of the region
73
+
REG_LEN - 4 bytes - length in bytes of the region
74
+
HASH_DATA - 8 bytes - data for the hash of this region
75
+
HT=0: hash data is empty
76
+
HT=1: hash data contains 8 bytes of verbatim data
77
+
HT=2: hash data contains a 4-byte pointer to a string
78
+
79
+
MAGIC1 - 4 bytes - 0x597F30FE
80
+
VERSION - 2 bytes - table version (currently 1)
81
+
TABLE_LEN - 2 bytes - length in bytes of the table excluding this header row
82
+
NUM_REG - 2 bytes - number of regions
83
+
PSIZE_LOG2 - 2 bytes - native page size of the flash, log-2
84
+
MAGIC2 - 4 bytes - 0xC1B1D79D
85
+
86
+
87
+
This layout table is used to communicate the version of MicroPython and the
88
+
current memory layout to a Bluetooth client and enable `partial flashing <https://github.com/microbit-sam/codal-microbit-v2/blob/initial-docs-pf-and-memory-map/docs/bluetooth/MicroBitPartialFlashing.md>`_
89
+
(only updating the Python script, and keeping the existing version of
90
+
MicroPython in flash).
91
+
45
92
Steps to create the firmware.hex file
46
93
-------------------------------------
47
94
95
+
micro:bit V1
96
+
============
97
+
98
+
This applies to MicroPython for the micro:bit V1, the source of which can be
99
+
found here: `bbcmicrobit/micropython <https://github.com/bbcmicrobit/micropython>`_.
100
+
48
101
The yotta tool is used to build MicroPython, but before that takes place
49
102
additional files have to be generated by the Makefile in preparation for the
50
103
build, and additional data is added to the hex file after.
@@ -59,6 +112,33 @@ Running the ``make all`` command executes the following steps:
59
112
- The user can optionally append a script using ``tools/makecombinedhex.py``
60
113
(or other tools)
61
114
115
+
micro:bit V2
116
+
============
117
+
118
+
This applies to MicroPython for the micro:bit V2, the source of which can be
119
+
found here: `microbit-foundation/micropython-microbit-v2 <https://github.com/microbit-foundation/micropython-microbit-v2>`_.
120
+
121
+
This is a port of MicroPython to the micro:bit which uses CODAL as the
122
+
underlying target platform.
123
+
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.
141
+
62
142
Including a user script
63
143
-----------------------
64
144
@@ -73,10 +153,10 @@ add the filesystem to HEX files for MicroPython V1 & V2, and then combine both
73
153
into a `Universal HEX <https://tech.microbit.org/software/hex-format/#universal-hex-files>`_
74
154
file to ensure compatibility with both hardware variants.
75
155
76
-
Appended script format (Deprecated)
77
-
===================================
156
+
Appended script format (Deprecated) V1
157
+
======================================
78
158
79
-
This method of appending the script to the end of MicroPython
159
+
This method of appending the script to the end of MicroPython for micro:bit V1
80
160
is no longer used. Python files are now stored in the
81
161
`filesystem <../filesystem.html>`_ and ``main.py`` is the program entry point.
0 commit comments