Skip to content

Commit 4c61be4

Browse files
v1.0.0: Tweats to the text and recommend 16 bytes long data records.
This spec was released almost 4 years ago and used ever since, so we should finally release it as v1.0.0.
1 parent ef8a68d commit 4c61be4

File tree

2 files changed

+42
-21
lines changed

2 files changed

+42
-21
lines changed

spec/format-deprecated.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ is needed in the future, but currently its use is discouraged.
1313
> **This format is for future use only. The "512 Byte Aligned Sections" format should be used instead**.
1414
1515
Grouping the Universal Hex records into self-contained 512-byte blocks overcomes issues arising from receiving file blocks out of order.
16-
Furthermore, by making the first part of each 512-byte block contain header metadata, DAPLink can parse this information right and ‘throw away’ irrelevant blocks for its target.
16+
Furthermore, by making the first part of each 512-byte block contain header metadata, DAPLink can parse this information on every block and ‘throw away’ irrelevant blocks for its target.
1717

1818
Unfortunately all version of DAPLink (up to version 0254 at the time of writing) will try to validate the first line of the Intel Hex file. If the record type in that line does not correspond to a valid Intel Hex record type (`0x00` to `0x05`), it will fail validation and the file won't be processed.
1919
For this reason the first record of each block will be an Extended Linear Address record (`0x04`), and the second record will contain the block metadata in the Block start record.
@@ -22,7 +22,7 @@ For this reason the first record of each block will be an Extended Linear Addres
2222

2323
> **This format is for future use only. The "512 Byte Aligned Sections" format should be used instead**.
2424
25-
Conventional Intel Hex for micro:bit v1 or v2:
25+
Conventional Intel Hex for micro:bit V1 or V2:
2626

2727
```
2828
Extended Linear Address record (optional if the data starts at address 0x0000_xxxx)

spec/index.md

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,36 @@ lang: en
1010

1111
# 🌌 micro:bit Universal Hex Format Specification
1212

13-
Specification version 0.4.0.
13+
Specification version 1.0.0.
14+
15+
- [Goal](#goal)
16+
- [Definitions and Rationale](#definitions-and-rationale)
17+
- [Requirements](#requirements)
18+
- [DAPLink Versions Previously Shipped](#daplink-versions-previously-shipped)
19+
- [Intel Hex and Universal Hex relationship](#intel-hex-and-universal-hex-relationship)
20+
- [Universal Hex New Record Types](#universal-hex-new-record-types)
21+
- [Universal Hex Block/Section Format](#universal-hex-blocksection-format)
22+
- [Doc Updates](#doc-updates)
1423

1524

1625
## Goal
1726

18-
The goal of a micro:bit Universal Hex is to be able to create a single-file format that can be flashed into a micro:bit V1 and a micro:bit V2 successfully.
27+
The goal of the micro:bit Universal Hex specification is to enable the creation of a single hex file that can be flashed into a micro:bit V1 and a micro:bit V2 successfully.
1928

2029

2130
## Definitions and Rationale
2231

2332
<img align="right" src="https://tech.microbit.org/docs/software/spec-universal-hex/spec/img/universal-hex.png" alt="universal hex">
2433

25-
Universal Hex is a superset of the Intel Hex file format to be able to contain binary code for multiple micro:bit boards or subsystems.
34+
Universal Hex is a superset of the Intel Hex file format to be able to contain data for multiple micro:bit boards or subsystems.
2635

2736
The microcontroller used in the micro:bit V2 (nRF52) is different than the microcontroller used in micro:bit V1 (nRF51), with a different architecture (Arm Cortex M0+ vs Cortex M4), slightly different peripherals, and different hardware components on the board.
2837

29-
The micro:bit V1 and V2 boards use an interface chip with the DAPLink firmware to flash the target microcontroller. DAPLink is responsible for processing the files dropped into the micro:bit MSD drive and any new file format has to be implemented in that project.
38+
The micro:bit V1 and V2 boards use an interface chip with the DAPLink firmware to flash the target microcontroller. DAPLink is responsible for processing the files dropped into the `MICROBIT` MSD drive and any new file format has to be implemented in this project.
3039

31-
To easily support our users, we want the online editors to generate a single file that will work in both micro:bit V1 and micro:bit V2.
40+
To easily support the micro:bit users, the online editors should generate a single file that will work in both micro:bit V1 and micro:bit V2.
3241

33-
Therefore, a micro:bit Universal Hex is a file that contains the binary data for both micro:bit V1 and micro:bit V2, in a format that the DAPLink can process to only write to memory the data relevant to its board.
42+
Therefore, a micro:bit Universal Hex is a file that contains the user programmes for both micro:bit V1 and micro:bit V2, in a format that DAPLink can process to only write to memory the data relevant to its board.
3443

3544

3645
## Requirements
@@ -44,7 +53,7 @@ Therefore, a micro:bit Universal Hex is a file that contains the binary data for
4453
5. The micro:bit v2 DAPLink interface shall also consume ‘standard’ Intel Hex and bin files for micro:bit V2 (eg produced by Mbed or other tools)
4554

4655

47-
## DAPLink Interface Versions Shipped
56+
## DAPLink Versions Previously Shipped
4857

4958
- 0234: Version shipped in the original BBC drop, over 800K units with this version
5059
- 0241: Version shipped in the v1.3B retail version
@@ -71,7 +80,7 @@ Conclusions about DAPLink versions:
7180

7281
The micro:bit Universal Hex format is a superset of the [Intel Hex file format](https://en.wikipedia.org/wiki/Intel_HEX) designed to be able to include data for multiple targets into a single file.
7382

74-
In all the DAPLink versions we’ve tested DAPLink ignores any Intel Hex record with an unrecognised record type.
83+
In all the DAPLink versions tested DAPLink ignores any Intel Hex record with an unrecognised record type.
7584
The only exception is the first line of the hex file, which needs to be a valid Intel Hex record, otherwise the entire file is discarded.
7685

7786
This can be used to our advantage to pack micro:bit V2 data within unused record types that will be ignored in the deployed versions of DAPLink for micro:bit V1, and will be correctly processed in DAPLink for micro:bit V2.
@@ -97,10 +106,10 @@ The data field for this record has a minimum size of 2 bytes. The valid values f
97106

98107
| Hex Code | Data Type | Description |
99108
|----------|--------------|-------------|
100-
| `0x9900` | micro:bit V1 | Contains data for micro:bit V1 |
101-
| `0x9903` | micro:bit V2 | Contains data for micro:bit V2 |
109+
| `0x9900` | micro:bit V1 | Section/block contains data, in data records (`0x00`), for micro:bit V1 |
110+
| `0x9903` | micro:bit V2 | Section/blopck contains data, in custom data records (`0x0D`), for micro:bit V2 |
102111

103-
Additional data bytes can be included but will be ignored by DAPLink.
112+
Including additional data bytes in this record will currently be ignored by DAPLink, but are reserved for future development.
104113

105114

106115
## Universal Hex Block/Section Format
@@ -110,9 +119,9 @@ There are two valid formats for packing the V1 and V2 records:
110119
- 512 Byte Blocks
111120
- 512 Byte Aligned Sections (recommended format)
112121

113-
USB packs and sends data in blocks of 512 bytes. As the DAPLink MSD drive could receive the hex file blocks out-of-order, it would be useful to create a format that contains self-contained 512-byte blocks with metadata.
122+
USB packs and sends data in blocks of 512 bytes. As the DAPLink MSD drive could receive the hex file blocks out-of-order, it is useful to create a format that contains self-contained 512-byte blocks with metadata.
114123

115-
Previous versions of this specification only defined the format described in the "512 Byte Blocks" section, but testing showed DAPLink 0234 was significantly slower to process this format.
124+
Previous versions of this specification only defined the "512 Byte Blocks" format, but testing showed DAPLink 0234 was significantly slower to process these files.
116125
For this reason the "512 Byte Aligned Sections" format was introduced and **is the currently recommended format**.
117126

118127
Receiving blocks out-of-order has not been an issue yet, but in case this becomes a problem in the future (e.g. an operating system update introduces this change), DAPLink will remain compatible with the "512 Byte Blocks" format, so that any online editors could switch to it without having to update the micro:bit firmware.
@@ -123,7 +132,7 @@ In both formats a Universal Hex must contain data for at least 2 targets, one fo
123132

124133
> **This format is for future use only. The "512 Byte Aligned Sections" format should be used instead**.
125134
126-
This format can be found in the [format-deprecated.md](https://github.com/microbit-foundation/spec-universal-hex/blob/master/spec/format-deprecated.md) document, and while it is supported by DAPLink, it use is discouraged.
135+
This format can be found in the [format-deprecated.md](https://github.com/microbit-foundation/spec-universal-hex/blob/master/spec/format-deprecated.md) document, and while it is supported by DAPLink, its use is discouraged.
127136

128137
### 512 Byte Aligned Sections
129138

@@ -141,8 +150,8 @@ So, each target section:
141150
- Is 512-byte aligned
142151
- Starts with an Extended Linear Address record
143152
- Followed by a Block Start custom record (`0x0A`)
144-
- This record type includes the target metadata in the Data field
145-
- Then it includes all the data and Extended Linear Address (`0x04`) records for the target
153+
- This record includes "Data Type" in the Data field to identified the targetted micro:bit version
154+
- Then it includes all the Data (`0x00`) or Custom Data (`0x0D`), and Extended Linear Address (`0x04`) records for the target
146155
- micro:bit V1 data uses the standard Intel Hex data record (`0x00`)
147156
- Data for any other board, like the micro:bit V2, uses the Custom Data record type (`0x0D`)
148157
- Extended Segment Address records (`0x03`) are converted to Extended Linear Address (`0x04`) records
@@ -155,12 +164,13 @@ So, each target section:
155164
Note that the End Of File record is excluded from the sections, only one EoF record is include as the last record of the file.
156165

157166
It is also recommended to:
158-
- Use Data or Custom Data records with 32 bytes in the Data field
167+
- Use Data or Custom Data records with 16 bytes in the Data field
159168
- The most common Data field sizes are 16 and 32 bytes
160169
- Although the Intel Hex format does not limit the data field length, DAPLink has a max length of 32 bytes
161-
- Having longer records reduces the overall file size and save up over a second of flashing time
170+
- Having longer records reduces the overall file size and saves up over a second of flashing time
171+
- However, there is an [issue](https://github.com/ARMmbed/DAPLink/pull/936) with 32 byte records and DAPLink versions 0256 and older
162172
- Place the micro:bit V1 Section first, followed by the micro:bit V2 Section
163-
- DAPLink versions < 255 only halt the target microcontroller when the first flash operation starts, so in the opposite order micro:bit V1 would flash the DAPLink LED a couple of seconds before the user program on the micro:bit stops running
173+
- DAPLink versions < 0255 only halt the target microcontroller when the first flash operation starts, so in the opposite order micro:bit V1 would flash the DAPLink LED a couple of seconds before the user program on the micro:bit stops running
164174

165175
#### Section Format In A Hex File
166176

@@ -289,3 +299,14 @@ Will transform into this Universal Hex:
289299
:00000001FF <- End Of File record with a new line
290300
291301
```
302+
303+
304+
## Doc Updates
305+
306+
| Version | Changes |
307+
|--------------|---------|
308+
| 0.4.0 | Initial release, as implemented in DAPLink 0255. |
309+
| [1.0.0][100] | Changed recommendation from 32 bytes per data record to 16. |
310+
| | Other minor tweaks in the text and content without changing the specification. |
311+
312+
[100]: https://github.com/microbit-foundation/spec-universal-hex/commit/xxxxxxx

0 commit comments

Comments
 (0)