Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directly load and inspect a HEX with a filesystem #45

Open
CSharperMantle opened this issue Aug 7, 2024 · 0 comments
Open

Directly load and inspect a HEX with a filesystem #45

CSharperMantle opened this issue Aug 7, 2024 · 0 comments

Comments

@CSharperMantle
Copy link

CSharperMantle commented Aug 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant