Skip to content

Commit c8d43bf

Browse files
docs: Update the Quick Guide.
1 parent 16aee25 commit c8d43bf

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ nav_order: 1
99
# micro:bit Filesystem
1010
{: .fs-9 }
1111

12-
<img alt="microbit-fs logo" src="img/microbit-fs-logo.png" style="max-height: 100px; float: left; padding-right: 16px;">
12+
<img alt="microbit-fs logo" src="img/microbit-fs-logo.png" style="max-height: 125px; float: left; padding-right: 16px;">
1313

1414
Manipulate files in a micro:bit MicroPython Intel Hex file.
1515
{: .fs-6 .fw-300 }

docs/quick-guide.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Initialise a File System instance with a MicroPython Intel Hex string and start
1414
```js
1515
// Create a new FileSystem instance passing the MicroPython Intel Hex string
1616
var micropythonFs = new microbitFs.MicropythonFsHex(IntelHexStr);
17+
// There are some options available in the constructor
18+
micropythonFs = new microbitFs.MicropythonFsHex(IntelHexStr, { maxFsSize: 20 * 1024});
1719

1820
// Import files from a different MicroPython hex file with filesystem
1921
var addedFilenames = micropythonFs.importFilesFromIntelHex(UploadedHexWithUserFiles);
@@ -45,7 +47,31 @@ var intelHexStrWithFs = micropythonFs.getIntelHex();
4547
var intelHexBytesWithFs = micropythonFs.getIntelHexBytes();
4648
```
4749

48-
Public interface can be found in the `src/fs-interface.ts` file.
50+
Using multiple MicroPython Intel Hex files to generate a Universal Hex:
51+
52+
```js
53+
// Create a new FileSystem instance passing the MicroPython Intel Hex string
54+
var micropythonFs = new microbitFs.MicropythonFsHex([
55+
{ hex: uPy1HexFile, boardId: 0x9900 },
56+
{ hex: uPy2HexFile, boardId: 0x9903 },
57+
]);;
58+
59+
// Import files from a different MicroPython Intel hex file with filesystem
60+
var addedFilenames = micropythonFs.importFilesFromIntelHex(UploadedHexWithUserFiles);
61+
addedFilenames = micropythonFs.importFilesFromIntelHex(UploadedHexWithUserFiles, {overwrite: false, formatFirst: false});
62+
63+
// Generate a new Intel hex string or Uint8Array with MicroPython and the files
64+
var uPy1IntelHexStrWithFs = micropythonFs.getIntelHex(0x9900);
65+
var uPy1IntelHexBytesWithFs = micropythonFs.getIntelHexBytes(0x9900);
66+
var uPy2IntelHexStrWithFs = micropythonFs.getIntelHex(0x9903);
67+
var uPy2IntelHexBytesWithFs = micropythonFs.getIntelHexBytes(0x9903);
68+
69+
// Generate a new Universal hex string with all MicroPython+files data
70+
var universalHexStrWithFs = micropythonFs.getUniversalHex();
71+
```
72+
73+
The `MicropythonFsHex` class public interface can be found in the
74+
`src/fs-interface.ts` file.
4975

5076
### Append and extract Python code from known flash location
5177
To add and remove the Python code using the old format:
@@ -57,16 +83,18 @@ if (microbitFs.isAppendedScriptPresent(finalHexStr)) {
5783
}
5884
```
5985

60-
### Read UICR data
86+
### Read Device Memory Info data
6187

6288
```js
63-
var uicrData = getIntelHexUicrData(IntelHexStr);
64-
console.log('Flash Page Size:' + uicrData.flashPageSize);
65-
console.log('Flash Size:' + uicrData.flashSize);
66-
console.log('Runtime Start Page:' + uicrData.runtimeStartPage);
67-
console.log('Runtime Start Address:' + uicrData.runtimeStartAddress);
68-
console.log('Runtime End Used:' + uicrData.runtimeEndUsed);
69-
console.log('Runtime End Address:' + uicrData.runtimeEndAddress);
70-
console.log('Version Address:' + uicrData.versionAddress);
71-
console.log('Version: ' + uicrData.version);
89+
var deviceMemInfoData = getIntelHexDeviceMemInfo(IntelHexStr);
90+
console.log('Flash Page Size:' + deviceMemInfoData.flashPageSize);
91+
console.log('Flash Size:' + deviceMemInfoData.flashSize);
92+
console.log('Flash Start Address:' + deviceMemInfoData.flashStartAddress);
93+
console.log('Flash End Address:' + deviceMemInfoData.flashEndAddress);
94+
console.log('Runtime Start Address:' + deviceMemInfoData.runtimeStartAddress);
95+
console.log('Runtime End Address:' + deviceMemInfoData.runtimeEndAddress);
96+
console.log('Filesystem Start Address:' + deviceMemInfoData.fsStartAddress);
97+
console.log('Filesystem End Address:' + deviceMemInfoData.fsEndAddress);
98+
console.log('MicroPython Version:' + deviceMemInfoData.uPyVersion);
99+
console.log('Device Version: ' + deviceMemInfoData.deviceVersion);
72100
```

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export * from './micropython-appended';
22
export * from './micropython-fs-hex';
3-
export * from './uicr';
3+
export * from './hex-mem-info';

0 commit comments

Comments
 (0)