Skip to content

Directly load and inspect a HEX with a filesystem #45

@CSharperMantle

Description

@CSharperMantle

I am new to this package so feel free to correct me at any point :D

Currently the docs says that to construct a class MicropythonFsHex, we need a plain MicroPython HEX image without a filesystem. That being said, if we need to inspect the filesystem a given HEX image with a filesystem already included, we need yet another HEX image with no filesystem, load that first, then import the HEX-to-inspect into the loaded image.

Is there a shortcut? From the importing feature I think this package has complete features already present to inspect filesystems in a HEX string. Perhaps exposing such a direct-inspect API would be of more convenient to at least a fraction of users.


After a bit of digging the internals I have found that there are indeed functions present and documented as said above, like this:

/**
* Reads the filesystem included in a MicroPython Intel Hex string or Map.
*
* @throws {Error} When multiple files with the same name encountered.
* @throws {Error} When a file chunk points to an unused chunk.
* @throws {Error} When a file chunk marker does not point to previous chunk.
* @throws {Error} When following through the chunks linked list iterates
* through more chunks and used chunks (sign of an infinite loop).
*
* @param intelHex - The MicroPython Intel Hex string or MemoryMap to read from.
* @returns Dictionary with the filename as key and byte array as values.
*/
function getIntelHexFiles(
intelHex: string | MemoryMap
): { [filename: string]: Uint8Array } {

However these are not exported in index.ts:

export * from './micropython-appended';
export * from './micropython-fs-hex';
export * from './hex-mem-info';

Adding a single line will solve this issue, but it will add a lot of public APIs to the module. Still, given that all these functions have been properly documented, it could still be a reasonable choice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions