Skip to content

Commit

Permalink
Update Risc-V toolchains, and add picotool version selection (current…
Browse files Browse the repository at this point in the history
…ly hidden, as only one version works)
  • Loading branch information
will-v-pi committed Sep 2, 2024
1 parent 77c7b7b commit 33b637c
Show file tree
Hide file tree
Showing 14 changed files with 487 additions and 423 deletions.
787 changes: 400 additions & 387 deletions data/0.16.0/github-cache.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions data/0.16.0/supportedToolchains.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ darwin_arm64 = https://armkeil.blob.core.windows.net/developer/Files/downloads/g
darwin_x64 = https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz
linux_x64 = https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz
linux_arm64 = https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-eabi.tar.xz
[RISCV_RPI_2_0_0_1]
win32_x64 = https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-1/riscv-toolchain-14-x64-win.zip
darwin_arm64 = https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-1/riscv-toolchain-14-arm64-mac.zip
darwin_x64 = https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-1/riscv-toolchain-14-x64-mac.zip
linux_x64 = https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-1/riscv-toolchain-14-x86_64-lin.tar.gz
linux_arm64 = https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-1/riscv-toolchain-14-aarch64-lin.tar.gz
[RISCV_13_3]
win32_x64 = https://buildbot.embecosm.com/job/riscv32-gcc-win64-release/24/artifact/riscv32-embecosm-win64-gcc13.2.0.zip
darwin_arm64 = https://buildbot.embecosm.com/job/riscv32-gcc-macos-arm64-release/10/artifact/riscv32-embecosm-macos-gcc13.3.0.zip
Expand Down
5 changes: 4 additions & 1 deletion data/0.16.0/versionBundles.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"ninja": "v1.12.1",
"cmake": "v3.28.6",
"picotool": "2.0.0",
"toolchain": "12_3_Rel1",
"riscvToolchain": "NONE"
},
Expand All @@ -18,6 +19,7 @@
},
"ninja": "v1.12.1",
"cmake": "v3.28.6",
"picotool": "2.0.0",
"toolchain": "13_2_Rel1",
"riscvToolchain": "NONE"
},
Expand All @@ -29,7 +31,8 @@
},
"ninja": "v1.12.1",
"cmake": "v3.28.6",
"picotool": "2.0.0",
"toolchain": "13_2_Rel1",
"riscvToolchain": "RISCV_COREV_MAY_24"
"riscvToolchain": "RISCV_RPI_2_0_0_1"
}
}
3 changes: 2 additions & 1 deletion scripts/genCache.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
for _ in stuff.GithubRepository:
num_repos += 0.5
num_repos = int(num_repos)
assert num_repos == 4
assert num_repos == 5
print("Num repos", num_repos)


Expand All @@ -51,6 +51,7 @@
["v3.28.6", "v3.29.6"],
["v1.12.1"],
["v1.5.1-0", "v2.0.0-0"],
["2.0.0"]
]

headers = {
Expand Down
3 changes: 0 additions & 3 deletions scripts/pico-vscode.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@ else()
endif()
if(PICO_TOOLCHAIN_PATH MATCHES "RISCV")
set(PICO_PLATFORM rp2350-riscv CACHE STRING "Pico Platform")
if(PICO_TOOLCHAIN_PATH MATCHES "COREV")
set(PICO_COMPILER pico_riscv_gcc_zcb_zcmp)
endif()
endif()
endif()
6 changes: 2 additions & 4 deletions src/commands/switchBoard.mts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ export default class SwitchBoardCommand extends Command {
}

const armToolchain = versionBundle?.toolchain;
let riscvToolchain = versionBundle?.riscvToolchain;
if (process.platform === "linux" && process.arch === "arm64") {
riscvToolchain = "RISCV_RPI";
}
const riscvToolchain = versionBundle?.riscvToolchain;

const chosenToolchainVersion = useRiscV ? riscvToolchain : armToolchain;

Expand Down Expand Up @@ -183,6 +180,7 @@ export default class SwitchBoardCommand extends Command {
workspaceFolder.uri,
versions[0],
selectedToolchain.version,
versions[2],
false
);
progress.report({
Expand Down
5 changes: 4 additions & 1 deletion src/commands/switchSDK.mts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ export default class SwitchSDKCommand extends Command {
selectedSDK.label.replace("v", "")
);

const selectedPicotool = versionBundle?.picotool;

const configureAdvancedOptions = await window.showQuickPick(["No", "Yes"], {
title: "Switch Tools",
placeHolder: "Configure advanced options?",
Expand Down Expand Up @@ -445,7 +447,8 @@ export default class SwitchSDKCommand extends Command {
const cmakeUpdateResult = await cmakeUpdateSDK(
workspaceFolder.uri,
selectedSDK.sdk,
selectedToolchain.toolchain.version
selectedToolchain.toolchain.version,
selectedPicotool ?? "2.0.0"
);

if (!cmakeUpdateResult) {
Expand Down
8 changes: 2 additions & 6 deletions src/extension.mts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import NewProjectCommand from "./commands/newProject.mjs";
import Logger from "./logger.mjs";
import {
CMAKE_DO_NOT_EDIT_HEADER_PREFIX,
cmakeGetSelectedBoard,
cmakeGetSelectedToolchainAndSDKVersions,
configureCmakeNinja,
Expand Down Expand Up @@ -54,7 +55,6 @@ import { getSupportedToolchains } from "./utils/toolchainUtil.mjs";
import {
NewProjectPanel,
getWebviewOptions,
picotoolVersion,
openOCDVersion,
} from "./webview/newProjectPanel.mjs";
import GithubApiCache from "./utils/githubApiCache.mjs";
Expand All @@ -72,10 +72,6 @@ import { pyenvInstallPython, setupPyenv } from "./utils/pyenvUtil.mjs";
import NewExampleProjectCommand from "./commands/newExampleProject.mjs";
import SwitchBoardCommand from "./commands/switchBoard.mjs";

export const CMAKE_DO_NOT_EDIT_HEADER_PREFIX =
// eslint-disable-next-line max-len
"== DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work ==";

export async function activate(context: ExtensionContext): Promise<void> {
Logger.log("Extension activated.");

Expand Down Expand Up @@ -225,7 +221,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
SDK_REPOSITORY_URL
)) ||
!(await downloadAndInstallTools(selectedToolchainAndSDKVersions[0])) ||
!(await downloadAndInstallPicotool(picotoolVersion))
!(await downloadAndInstallPicotool(selectedToolchainAndSDKVersions[2]))
) {
Logger.log(
"Failed to install project SDK " +
Expand Down
17 changes: 11 additions & 6 deletions src/utils/cmakeUtil.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import { rimraf, windows as rimrafWindows } from "rimraf";
import { homedir } from "os";
import which from "which";
import { compareLtMajor } from "./semverUtil.mjs";
import { picotoolVersion } from "../webview/newProjectPanel.mjs";
import { CMAKE_DO_NOT_EDIT_HEADER_PREFIX } from "../extension.mjs";
import { buildCMakeIncPath } from "./download.mjs";

export const CMAKE_DO_NOT_EDIT_HEADER_PREFIX =
// eslint-disable-next-line max-len
"== DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work ==";

export async function getPythonPath(): Promise<string> {
const settings = Settings.getInstance();
if (settings === undefined) {
Expand Down Expand Up @@ -304,6 +306,7 @@ export async function cmakeUpdateSDK(
folder: Uri,
newSDKVersion: string,
newToolchainVersion: string,
newPicotoolVersion: string,
reconfigure: boolean = true
): Promise<boolean> {
// TODO: support for scaning for seperate locations of the CMakeLists.txt file in the project
Expand Down Expand Up @@ -337,7 +340,7 @@ export async function cmakeUpdateSDK(
"endif()\n" +
`set(sdkVersion ${newSDKVersion})\n` +
`set(toolchainVersion ${newToolchainVersion})\n` +
`set(picotoolVersion ${picotoolVersion})\n` +
`set(picotoolVersion ${newPicotoolVersion})\n` +
`include(${buildCMakeIncPath(false)}/pico-vscode.cmake)\n` +
// eslint-disable-next-line max-len
"# ===================================================================================="
Expand Down Expand Up @@ -399,7 +402,7 @@ export async function cmakeUpdateSDK(
* Extracts the sdk and toolchain versions from the CMakeLists.txt file.
*
* @param cmakeFilePath The path to the CMakeLists.txt file.
* @returns An tupple with the [sdk, toolchain] versions or null if the file could not
* @returns An tupple with the [sdk, toolchain, picotool] versions or null if the file could not
* be read or the versions could not be extracted.
*/
export async function cmakeGetSelectedToolchainAndSDKVersions(
Expand Down Expand Up @@ -437,10 +440,12 @@ export async function cmakeGetSelectedToolchainAndSDKVersions(
}

Logger.log("Updating extension lines in CMake file");
await cmakeUpdateSDK(folder, versionMatch[1], versionMatch2[1]);
await cmakeUpdateSDK(
folder, versionMatch[1], versionMatch2[1], versionMatch[1]
);
Logger.log("Extension lines updated");

return [versionMatch[1], versionMatch2[1], picotoolVersion];
return [versionMatch[1], versionMatch2[1], versionMatch[1]];
} else {
return null;
}
Expand Down
9 changes: 9 additions & 0 deletions src/utils/githubREST.mts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum GithubRepository {
cmake = 1,
ninja = 2,
tools = 3,
picotool = 4,
}

export type GithubReleaseResponse = {
Expand Down Expand Up @@ -46,6 +47,8 @@ export function ownerOfRepository(repository: GithubRepository): string {
return "ninja-build";
case GithubRepository.tools:
return "raspberrypi";
case GithubRepository.picotool:
return "raspberrypi"
}
}

Expand All @@ -59,6 +62,8 @@ export function repoNameOfRepository(repository: GithubRepository): string {
return "ninja";
case GithubRepository.tools:
return "pico-sdk-tools";
case GithubRepository.picotool:
return "picotool"
}
}

Expand Down Expand Up @@ -211,6 +216,10 @@ export async function getSDKReleases(): Promise<string[]> {
return getReleases(GithubRepository.picoSDK);
}

export async function getPicotoolReleases(): Promise<string[]> {
return getReleases(GithubRepository.picotool);
}

export async function getNinjaReleases(): Promise<string[]> {
return getReleases(GithubRepository.ninja);
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/versionBundles.mts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface VersionBundle {
};
ninja: string;
cmake: string;
picotool: string;
toolchain: string;
riscvToolchain: string;
}
Expand Down
10 changes: 5 additions & 5 deletions src/utils/vscodeConfigUtil.mts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ async function updateCppPropertiesFile(
config.compilerPath =
"${userHome}/.pico-sdk/toolchain" +
`/${newToolchainVersion}/bin/${
// "arm-none-eabi-gcc" should work on all platforms no need for extension on Windows
/*process.platform === "win32"
? "arm-none-eabi-gcc.exe"
: "arm-none-eabi-gcc"*/
"arm-none-eabi-gcc"
newToolchainVersion.includes("RISCV")
? newToolchainVersion.includes("COREV")
? "riscv32-corev-elf-gcc"
: "riscv32-unknown-elf-gcc"
: "arm-none-eabi-gcc"
}`;
});

Expand Down
33 changes: 24 additions & 9 deletions src/webview/newProjectPanel.mts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
SDK_REPOSITORY_URL,
getCmakeReleases,
getNinjaReleases,
getPicotoolReleases,
getSDKReleases,
} from "../utils/githubREST.mjs";
import {
Expand Down Expand Up @@ -63,12 +64,12 @@ import {
export const NINJA_AUTO_INSTALL_DISABLED = false;
// process.platform === "linux" && process.arch === "arm64";

export const picotoolVersion = "2.0.0";
export const openOCDVersion = "0.12.0+dev";

interface ImportProjectMessageValue {
selectedSDK: string;
selectedToolchain: string;
selectedPicotool: string;
ninjaMode: number;
ninjaPath: string;
ninjaVersion: string;
Expand Down Expand Up @@ -495,10 +496,7 @@ export class NewProjectPanel {
message.value as string
);
// change toolchain version on arm64 linux, as Core-V not available for that
let riscvToolchain = versionBundle?.riscvToolchain;
if (process.platform === "linux" && process.arch === "arm64") {
riscvToolchain = "RISCV_RPI";
}
const riscvToolchain = versionBundle?.riscvToolchain;
// return result in message of command versionBundleAvailableTest
await this._panel.webview.postMessage({
command: "versionBundleAvailableTest",
Expand Down Expand Up @@ -741,6 +739,7 @@ export class NewProjectPanel {
const selectedToolchain = this._supportedToolchains?.find(
tc => tc.version === data.selectedToolchain.replaceAll(".", "_")
);
const selectedPicotool = data.selectedPicotool.slice(0);

if (!selectedToolchain) {
void window.showErrorMessage("Failed to find selected toolchain.");
Expand Down Expand Up @@ -857,7 +856,7 @@ export class NewProjectPanel {
)) ||
!(await downloadAndInstallToolchain(selectedToolchain)) ||
!(await downloadAndInstallTools(selectedSDK)) ||
!(await downloadAndInstallPicotool(picotoolVersion))
!(await downloadAndInstallPicotool(selectedPicotool))
) {
this._logger.error(
`Failed to download and install toolchain and SDK.`
Expand Down Expand Up @@ -1086,7 +1085,7 @@ export class NewProjectPanel {
toolchainPath: buildToolchainPath(selectedToolchain.version),
sdkVersion: selectedSDK,
sdkPath: buildSDKPath(selectedSDK),
picotoolVersion: picotoolVersion,
picotoolVersion: selectedPicotool,
openOCDVersion: openOCDVersion,
},
ninjaExecutable,
Expand All @@ -1110,7 +1109,7 @@ export class NewProjectPanel {
toolchainPath: buildToolchainPath(selectedToolchain.version),
sdkVersion: selectedSDK,
sdkPath: buildSDKPath(selectedSDK),
picotoolVersion: picotoolVersion,
picotoolVersion: selectedPicotool,
openOCDVersion: openOCDVersion,
},
ninjaExecutable,
Expand All @@ -1130,7 +1129,7 @@ export class NewProjectPanel {
toolchainPath: buildToolchainPath(selectedToolchain.version),
sdkVersion: selectedSDK,
sdkPath: buildSDKPath(selectedSDK),
picotoolVersion: picotoolVersion,
picotoolVersion: selectedPicotool,
openOCDVersion: openOCDVersion,
},
ninjaExecutable,
Expand Down Expand Up @@ -1243,6 +1242,7 @@ export class NewProjectPanel {
// TODO: add offline handling - only load installed ones
let toolchainsHtml = "";
let picoSDKsHtml = "";
let picotoolsHtml = "";
let ninjasHtml = "";
let cmakesHtml = "";

Expand All @@ -1257,6 +1257,7 @@ export class NewProjectPanel {
const supportedToolchains = await getSupportedToolchains();
const ninjaReleases = await getNinjaReleases();
const cmakeReleases = await getCmakeReleases();
const picotoolReleases = await getPicotoolReleases();

if (availableSDKs.length === 0 || supportedToolchains.length === 0) {
this._logger.error(
Expand All @@ -1282,6 +1283,14 @@ export class NewProjectPanel {
}>v${sdk}</option>`;
});

picotoolReleases
.sort((a, b) => compare(b, a))
.forEach(picotool => {
picotoolsHtml += `<option ${
picotoolsHtml.length === 0 ? "selected " : ""
}value="${picotool}">${picotool}</option>`;
});

supportedToolchains.forEach(toolchain => {
toolchainsHtml += `<option ${
toolchainsHtml.length === 0 ? "selected " : ""
Expand Down Expand Up @@ -1608,6 +1617,12 @@ export class NewProjectPanel {
${toolchainsHtml}
</select>
</div>
<div hidden>
<label for="sel-picotool" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Select picotool version</label>
<select id="sel-picotool" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
${picotoolsHtml}
</select>
</div>
</div>
<div class="grid gap-6 md:grid-cols-${
process.platform === "darwin" ||
Expand Down
Loading

0 comments on commit 33b637c

Please sign in to comment.