Skip to content

Fix load hex file - #175

Draft
StavrosKolliasArm wants to merge 2 commits into
eclipse-cdt-cloud:mainfrom
StavrosKolliasArm:fix-load-hex
Draft

Fix load hex file#175
StavrosKolliasArm wants to merge 2 commits into
eclipse-cdt-cloud:mainfrom
StavrosKolliasArm:fix-load-hex

Conversation

@StavrosKolliasArm

Copy link
Copy Markdown
Contributor

What it does

Fixes the issue
#172

Removes dependancy nrf-intel-hex

How to test

Review checklist

Reminder for reviewers

@jreineckearm jreineckearm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the long delay in the review.
Implementation looks good. See a few questions/suggestions.

How much of the standard does it support? IIRC, other packages we looked at in the past usually missed one or the other part.

Still need to take it for a spin.

const memory = createMemoryFromRead(memoryResponse);
const memoryMap = new MemoryMap({ [Number(memory.address)]: memory.bytes });
await vscode.workspace.fs.writeFile(outputFile, new TextEncoder().encode(memoryMap.asHexString()));
const encodedContent = IntelHEX.encode({ address: memory.address, bytes: memory.bytes });

@jreineckearm jreineckearm Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: maybe rename to hexEncodedContent. Made me look twice seeing it fed into another encoder.

const memoryBlocks = IntelHEX.decode(new TextDecoder().decode(byteContent));
for (const memory of memoryBlocks) {
memoryReference = toHexStringWithRadixMarker(memory.address);
count = memory.bytes.length;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that be accumulated?

Comment thread src/common/intel-hex.ts
return value.toString(16).toUpperCase().padStart(2, '0');
}

function parseHexByte(value: string, context: string): number {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assume it's callers responsibility to ensure it's only two digits? Some commentary would be helpful.

Comment thread src/common/intel-hex.ts
@@ -1,2 +1,2 @@
/********************************************************************************
* Copyright (C) 2024 EclipseSource.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe extend the copyright header with ", Arm Limited and others". This is a significant change to the original implementation from EclipseSource. And this makes it clearer they are not the only point of contact for an implementation that comes from Arm.

Any objections to that, @planger , @martin-fleck-at ?

import { expect } from 'chai';
import { IntelHEX } from './intel-hex';

describe('intel-hex', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could extend the tests with some real world captures and test snapshots. Maybe even generated with the previous implementation as a reference.

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

Successfully merging this pull request may close these issues.

2 participants