Skip to content
74 changes: 37 additions & 37 deletions manifest/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 20,
"version": 22,
"win32": [
{
"arch": "x64",
Expand All @@ -19,27 +19,27 @@
{
"name": "ninja",
"filename": "ninja-win.zip",
"url": "https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip",
"sha256": "bbde850d247d2737c5764c927d1071cbb1f1957dcabda4a130fa8547c12c695f"
"url": "https://github.com/ninja-build/ninja/releases/download/v1.13.2/ninja-win.zip",
"sha256": "07fc8261b42b20e71d1720b39068c2e14ffcee6396b76fb7a795fb460b78dc65"
},
{
"name": "cmake",
"filename": "cmake-3.22.0-windows-x86_64.zip",
"url": "https://github.com/Kitware/CMake/releases/download/v3.22.0/cmake-3.22.0-windows-x86_64.zip",
"sha256": "fcce74d1d7eaf825234c036702df3f0874dcd3cee8fdf90b56d0c7bfedd29465",
"suffix": "cmake-3.22.0-windows-x86_64\\bin"
"filename": "cmake-3.31.12-windows-x86_64.zip",
"url": "https://github.com/Kitware/CMake/releases/download/v3.31.12/cmake-3.31.12-windows-x86_64.zip",
"sha256": "0c4baa40f28b3f8225eb3fdf6946c987b4fe901403b4eaf2fbbd9378100aaa0c",
"suffix": "cmake-3.31.12-windows-x86_64\\bin"
},
{
"name": "probe-rs",
"filename": "probe-rs-tools-x86_64-pc-windows-msvc.zip",
"url": "https://github.com/probe-rs/probe-rs/releases/download/v0.29.1/probe-rs-tools-x86_64-pc-windows-msvc.zip",
"sha256": "a1e220225cd09c9474fdf2db219adff4030074e6bdaf6e4f669ff97661d55413"
"url": "https://github.com/probe-rs/probe-rs/releases/download/v0.32.0/probe-rs-tools-x86_64-pc-windows-msvc.zip",
"sha256": "56fc0564cc23d604b27dc2d57606194159c49f951999f3e47bd2cbffcba64103"
},
{
"name": "recovery",
"filename": "recovery-x86_64-windows.zip",
"url": "https://github.com/circuitdojo/recovery/releases/download/v0.2.2/recovery-x86_64-windows.zip",
"sha256": "f45e0d1d557c40db298e0401c1b79c91315d129174b2f2829f8303bb8ea7ad4f"
"url": "https://github.com/circuitdojo/recovery/releases/download/v0.2.3/recovery-x86_64-windows.zip",
"sha256": "660990687ddfb716a35d8454dd0d6adcd8fc2471be64166bd7f0a52d1214cb64"
}
],
"toolchains": [
Expand Down Expand Up @@ -169,21 +169,21 @@
{
"name": "ninja",
"filename": "ninja-mac.zip",
"url": "https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-mac.zip",
"sha256": "6fa359f491fac7e5185273c6421a000eea6a2f0febf0ac03ac900bd4d80ed2a5"
"url": "https://github.com/ninja-build/ninja/releases/download/v1.13.2/ninja-mac.zip",
"sha256": "c99048673aa765960a99cf10c6ddb9f1fad506099ff0a0e137ad8960a88f321b"
},
{
"name": "cmake",
"filename": "cmake-3.22.0-macos-universal.tar.gz",
"url": "https://github.com/Kitware/CMake/releases/download/v3.22.0/cmake-3.22.0-macos-universal.tar.gz",
"sha256": "84526401d8cc0a0b0551f2f899164e2fbc2c69cbc8573b67bfa7441bae7ad051",
"suffix": "cmake-3.22.0-macos-universal/CMake.app/Contents/bin"
"filename": "cmake-3.31.12-macos-universal.tar.gz",
"url": "https://github.com/Kitware/CMake/releases/download/v3.31.12/cmake-3.31.12-macos-universal.tar.gz",
"sha256": "799af7fd545db9bf1b9cfe72f8095880e727a2d4e0df0e3dffc3bc7b95c2d3b0",
"suffix": "cmake-3.31.12-macos-universal/CMake.app/Contents/bin"
},
{
"name": "probe-rs",
"filename": "probe-rs-tools-x86_64-apple-darwin.tar.xz",
"url": "https://github.com/probe-rs/probe-rs/releases/download/v0.29.1/probe-rs-tools-x86_64-apple-darwin.tar.xz",
"sha256": "b6b8ccfd367ddf0ddcd04a23bc0e440087d49c333472b259fe79340fb63e119e",
"url": "https://github.com/probe-rs/probe-rs/releases/download/v0.32.0/probe-rs-tools-x86_64-apple-darwin.tar.xz",
"sha256": "e23d117a29909a389c92234ac3ebafcc5ec24d8969d1ec5d70eece622827f778",
"suffix": "probe-rs-tools-x86_64-apple-darwin/"
}
],
Expand Down Expand Up @@ -271,23 +271,23 @@
},
{
"name": "cmake",
"filename": "cmake-3.22.0-macos-universal.tar.gz",
"url": "https://github.com/Kitware/CMake/releases/download/v3.22.0/cmake-3.22.0-macos-universal.tar.gz",
"sha256": "84526401d8cc0a0b0551f2f899164e2fbc2c69cbc8573b67bfa7441bae7ad051",
"suffix": "cmake-3.22.0-macos-universal/CMake.app/Contents/bin"
"filename": "cmake-3.31.12-macos-universal.tar.gz",
"url": "https://github.com/Kitware/CMake/releases/download/v3.31.12/cmake-3.31.12-macos-universal.tar.gz",
"sha256": "799af7fd545db9bf1b9cfe72f8095880e727a2d4e0df0e3dffc3bc7b95c2d3b0",
"suffix": "cmake-3.31.12-macos-universal/CMake.app/Contents/bin"
},
{
"name": "probe-rs",
"filename": "probe-rs-tools-aarch64-apple-darwin.tar.xz",
"url": "https://github.com/probe-rs/probe-rs/releases/download/v0.29.1/probe-rs-tools-aarch64-apple-darwin.tar.xz",
"sha256": "74af375061589671644cdfb7fd406b0346da736001f97f33f74d229d7fe5ef6f",
"url": "https://github.com/probe-rs/probe-rs/releases/download/v0.32.0/probe-rs-tools-aarch64-apple-darwin.tar.xz",
"sha256": "c39631679b83d0c94dc442d05cc4ca974a87c02907a6ddbfce46746ed503152c",
"suffix": "probe-rs-tools-aarch64-apple-darwin/"
},
{
"name": "recovery",
"filename": "recovery-aarch64-macos.tar.gz",
"url": "https://github.com/circuitdojo/recovery/releases/download/v0.2.2/recovery-aarch64-macos.tar.gz",
"sha256": "888ab9ddd8c2b6ce8be9049ee534ad86ca0a979309db11bc7f5ce9cb11a20365"
"url": "https://github.com/circuitdojo/recovery/releases/download/v0.2.3/recovery-aarch64-macos.tar.gz",
"sha256": "5d1a99222bde4ae0a3affe88011d0c9710ec5c9aa2befc100a28a53af53b7fde"
}
],
"toolchains": [
Expand Down Expand Up @@ -409,28 +409,28 @@
{
"name": "ninja",
"filename": "ninja-linux.zip",
"url": "https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip",
"sha256": "763464859c7ef2ea3a0a10f4df40d2025d3bb9438fcb1228404640410c0ec22d"
"url": "https://github.com/ninja-build/ninja/releases/download/v1.13.2/ninja-linux.zip",
"sha256": "5749cbc4e668273514150a80e387a957f933c6ed3f5f11e03fb30955e2bbead6"
},
{
"name": "cmake",
"filename": "cmake-3.22.0-linux-x86_64.tar.gz",
"url": "https://github.com/Kitware/CMake/releases/download/v3.22.0/cmake-3.22.0-linux-x86_64.tar.gz",
"sha256": "dc73115520d13bb64202383d3df52bc3d6bbb8422ecc5b2c05f803491cb215b0",
"suffix": "cmake-3.22.0-linux-x86_64/bin"
"filename": "cmake-3.31.12-linux-x86_64.tar.gz",
"url": "https://github.com/Kitware/CMake/releases/download/v3.31.12/cmake-3.31.12-linux-x86_64.tar.gz",
"sha256": "0dc2e9a6860f06bf10bd8fadc03e35d9eeb4df46e33763a7e480e987758f385c",
"suffix": "cmake-3.31.12-linux-x86_64/bin"
},
{
"name": "probe-rs",
"filename": "probe-rs-tools-x86_64-unknown-linux-gnu.tar.xz",
"url": "https://github.com/probe-rs/probe-rs/releases/download/v0.29.1/probe-rs-tools-x86_64-unknown-linux-gnu.tar.xz",
"sha256": "f2ccb2ee5058559d663a3a4d1947ca1ce80802546aadd48cf355455126ae9758",
"url": "https://github.com/probe-rs/probe-rs/releases/download/v0.32.0/probe-rs-tools-x86_64-unknown-linux-gnu.tar.xz",
"sha256": "c2ccc46049e52a5d403ef212078cd637ecda55b662708327960558f83e851ff5",
"suffix": "probe-rs-tools-x86_64-unknown-linux-gnu/"
},
{
"name": "recovery",
"filename": "recovery-x86_64-linux.tar.gz",
"url": "https://github.com/circuitdojo/recovery/releases/download/v0.2.2/recovery-x86_64-linux.tar.gz",
"sha256": "e2322587ff9e783cd640fc00a2023a32605f29200be49e87d13cb141d61b9891"
"url": "https://github.com/circuitdojo/recovery/releases/download/v0.2.3/recovery-x86_64-linux.tar.gz",
"sha256": "1800f0c2cc97dc0e050f7fdd90d405a1fb4687ca91866357bf05227a7c19b67b"
}
],
"toolchains": [
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
"@types/node": "^25.9.1",
"@types/node-7z": "^2.1.11",
"@types/vscode": "~1.101.0",
"@vscode/test-electron": "^2.5.2",
"@vscode/test-electron": "^3.1.0",
"esbuild": "^0.28.1",
"eslint": "^10.4.1",
"glob": "^13.0.6",
Expand Down
106 changes: 62 additions & 44 deletions src/build/build-assets-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import * as vscode from "vscode";
import * as fs from "fs-extra";
import * as path from "path";
import * as yaml from "yaml";
import { ProjectConfig } from "../types";
import { isSysbuildMergedHex } from "./flash-hex";

export interface BuildAssetInfo {
name: string;
Expand Down Expand Up @@ -37,11 +39,6 @@ export class BuildAssetsManager {
displayName: "Manifest",
location: "root" as const,
},
{
name: "merged.hex",
displayName: "Merged Hex",
location: "root" as const,
},
{
name: "zephyr.elf",
displayName: "Zephyr ELF",
Expand All @@ -68,11 +65,23 @@ export class BuildAssetsManager {
let hasAssets = false;
let lastBuild: Date | undefined;

const candidates: Array<{ name: string; displayName: string; path: string | null }> = [];
for (const assetDef of this.ASSET_DEFINITIONS) {
const assetPath = await this.findAssetPath(buildPath, assetDef.name, assetDef.location);
const assetInfo: BuildAssetInfo = {
candidates.push({
name: assetDef.name,
displayName: assetDef.displayName,
path: await this.findAssetPath(buildPath, assetDef.name, assetDef.location),
});
}
for (const hexPath of await this.findMergedHexPaths(buildPath)) {
candidates.push({ name: path.basename(hexPath), displayName: "Merged Hex", path: hexPath });
}

for (const candidate of candidates) {
const assetPath = candidate.path;
const assetInfo: BuildAssetInfo = {
name: candidate.name,
displayName: candidate.displayName,
path: assetPath || "",
exists: false,
};
Expand Down Expand Up @@ -121,48 +130,57 @@ export class BuildAssetsManager {
}

/**
* Find a build asset file under the build path.
* Zephyr build output structure varies (sysbuild vs non-sysbuild, chip qualifiers),
* so we search for the file rather than computing a fixed path.
* Find a build asset file under the build path. "zephyr" assets come from
* the application image: the default sysbuild domain from domains.yaml, or
* the build root for non-sysbuild builds. Other sysbuild images (b0,
* mcuboot, ...) have their own zephyr/ directories and must not shadow it.
*/
private static async findAssetPath(buildPath: string, assetName: string, location: "root" | "zephyr"): Promise<string | null> {
if (location === "root") {
const candidate = path.join(buildPath, assetName);
if (await fs.pathExists(candidate)) {
return candidate;
}
return null;
const dir = location === "root" ? buildPath : path.join(await this.getAppImageDir(buildPath), "zephyr");
const candidate = path.join(dir, assetName);
if (await fs.pathExists(candidate)) {
return candidate;
}
return null;
}

// For "zephyr" location, search for */zephyr/{assetName} under buildPath
// Covers: build/{board}/zephyr/ (non-sysbuild) and build/{board}/{app}/zephyr/ (sysbuild)
try {
const entries = await fs.readdir(buildPath, { withFileTypes: true });
for (const entry of entries) {
if (!entry.isDirectory()) {continue;}
// Direct: {subdir}/zephyr/{asset}
const direct = path.join(buildPath, entry.name, "zephyr", assetName);
if (await fs.pathExists(direct)) {
return direct;
}
// One level deeper: {subdir}/{sub2}/zephyr/{asset}
try {
const subEntries = await fs.readdir(path.join(buildPath, entry.name), { withFileTypes: true });
for (const sub of subEntries) {
if (!sub.isDirectory()) {continue;}
const nested = path.join(buildPath, entry.name, sub.name, "zephyr", assetName);
if (await fs.pathExists(nested)) {
return nested;
}
}
} catch {
// subdirectory not readable, skip
}
/**
* Directory of the application image: build/<board>/<default domain> for
* sysbuild, build/<board> otherwise.
*/
private static async getAppImageDir(buildPath: string): Promise<string> {
const domainsPath = path.join(buildPath, "domains.yaml");
if (!(await fs.pathExists(domainsPath))) {
return buildPath;
}
const domains: { default?: string } | null = yaml.parse(await fs.readFile(domainsPath, "utf8"));
if (!domains?.default) {
return buildPath;
}
return path.join(buildPath, domains.default);
}

/**
* Merged hex files in the build: merged.hex (Partition Manager) and/or
* merged_<board_target>.hex (sysbuild, NCS 3.5+).
*/
private static async findMergedHexPaths(buildPath: string): Promise<string[]> {
if (!(await fs.pathExists(buildPath))) {
return [];
}
const found: string[] = [];
for (const legacy of [path.join(buildPath, "merged.hex"), path.join(buildPath, "zephyr", "merged.hex")]) {
if (await fs.pathExists(legacy)) {
found.push(legacy);
}
} catch {
// build path not readable
}
return null;
const entries = await fs.readdir(buildPath, { withFileTypes: true });
for (const entry of entries) {
if (entry.isFile() && isSysbuildMergedHex(entry.name)) {
found.push(path.join(buildPath, entry.name));
}
}
return found;
}

/**
Expand Down Expand Up @@ -232,7 +250,7 @@ export class BuildAssetsManager {
const patterns = [
'build/**/zephyr.elf',
'build/**/zephyr.hex',
'build/**/merged.hex',
'build/**/merged*.hex',
'build/**/dfu_application.zip',
'build/**/dfu_application.zip_manifest.json',
'build/**/log_dictionary.json'
Expand Down
Loading
Loading