@@ -14,6 +14,8 @@ Initialise a File System instance with a MicroPython Intel Hex string and start
14
14
``` js
15
15
// Create a new FileSystem instance passing the MicroPython Intel Hex string
16
16
var micropythonFs = new microbitFs.MicropythonFsHex (IntelHexStr);
17
+ // There are some options available in the constructor
18
+ micropythonFs = new microbitFs.MicropythonFsHex (IntelHexStr, { maxFsSize: 20 * 1024 });
17
19
18
20
// Import files from a different MicroPython hex file with filesystem
19
21
var addedFilenames = micropythonFs .importFilesFromIntelHex (UploadedHexWithUserFiles);
@@ -45,7 +47,31 @@ var intelHexStrWithFs = micropythonFs.getIntelHex();
45
47
var intelHexBytesWithFs = micropythonFs .getIntelHexBytes ();
46
48
```
47
49
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.
49
75
50
76
### Append and extract Python code from known flash location
51
77
To add and remove the Python code using the old format:
@@ -57,16 +83,18 @@ if (microbitFs.isAppendedScriptPresent(finalHexStr)) {
57
83
}
58
84
```
59
85
60
- ### Read UICR data
86
+ ### Read Device Memory Info data
61
87
62
88
``` 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 );
72
100
```
0 commit comments