Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ You should continue using this extension for running & debugging, and we recomme

Unfortunately, the Zephyr project requires numerous external dependencies. Most of these are covered automatically, but for `wget` we were not able to identify a reliable upstream source that provides official binaries for all three supported platforms.

We recommend using package managers such as winget (Windows), Homebrew or MacPorts (macOS), or your system package manager on Linux to install `wget` or consult the [Zephyr documentation](https://docs.zephyrproject.org/latest/getting_started/index.html) for more information.
We recommend using package managers such as winget (Windows), Homebrew or MacPorts (macOS), or your system package manager on Linux to install `wget` or consult the [Zephyr documentation](https://docs.zephyrproject.org/latest/develop/getting_started/index.html) for more information.

For further context, see this discussion in the Zephyr project: https://github.com/zephyrproject-rtos/sdk-ng/pull/1016

Expand All @@ -107,11 +107,23 @@ For further context, see this discussion in the Zephyr project: https://github.c

* **wget** - Required for sdk-ng to download toolchains.

### Windows only

* Must allow PowerShell script execution to activate the virtual environment - this can be done by running the following commands from an Administrator PowerShell:
```
Set-ExecutionPolicy RemoteSigned -Scope LocalMachine
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
```

### Linux and macOS only

* **7-Zip** - Required for sdk-ng to extract toolchains. Install via your package manager (e.g., `brew install p7zip` on macOS or `sudo apt install p7zip-full` on Debian based Linux distributions) or download from [7-zip.org](https://www.7-zip.org/).
* **python3-venv** - Required to create isolated Python environments. Install via your package manager (e.g., `sudo apt install python3-venv` on Debian based Linux distributions).

#### Linux only

* **\[Strongly Recommended\]** Python 3.12 - Zephyr states that using a newer Python release may fail on some systems, so strongly recommends using Python 3.12

## VS Code Profiles

If you work with multiple microcontroller toolchains, consider installing this extension into a [VS Code Profile](https://code.visualstudio.com/docs/editor/profiles) to avoid conflicts with other toolchains. Follow these steps:
Expand Down
24 changes: 24 additions & 0 deletions no_internet.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/src/utils/downloadHelpers.mts b/src/utils/downloadHelpers.mts
index ce370cc..2510966 100644
--- a/src/utils/downloadHelpers.mts
+++ b/src/utils/downloadHelpers.mts
@@ -170,6 +170,7 @@ export async function unxzFile(
* @returns True if the internet connection is available, false otherwise.
*/
export async function isInternetConnected(): Promise<boolean> {
+ return false;
return new Promise<boolean>(resolve => {
const options = {
host: "pages.github.com",
diff --git a/src/utils/githubREST.mts b/src/utils/githubREST.mts
index 0883564..d928d40 100644
--- a/src/utils/githubREST.mts
+++ b/src/utils/githubREST.mts
@@ -141,6 +141,7 @@ async function makeAsyncGetRequest<T>(
headers: { etag?: string };
}> {
return new Promise((resolve, reject) => {
+ reject("Failing all APIs for testing");
const urlObj = new URL(url);
const options: RequestOptions = {
method: "GET",
5 changes: 5 additions & 0 deletions src/utils/cmakeUtil.mts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ export async function configureCmakeNinja(
for (const snippet of snippets) {
zephyrCommand += ` -S ${snippet}`;
}
if (snippets.length > 0) {
zephyrCommand +=
` -- -DSNIPPET_ROOT=` +
`"${folder.fsPath.replaceAll("\\", "/")}"`;
}
}

await new Promise<void>((resolve, reject) => {
Expand Down
21 changes: 10 additions & 11 deletions src/utils/download.mts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ import {
HTTP_STATUS_UNAUTHORIZED,
ownerOfRepository,
repoNameOfRepository,
WINDOWS_ARM64_PYTHON_DOWNLOAD_URL,
WINDOWS_X86_PYTHON_DOWNLOAD_URL,
} from "./sharedConstants.mjs";
import { compareGe } from "./semverUtil.mjs";
import LastUsedDepsStore from "./lastUsedDeps.mjs";
Expand Down Expand Up @@ -1257,7 +1255,8 @@ function _runCommand(
* @returns
*/
export async function downloadEmbedPython(
progressCallback?: (progress: Progress) => void
progressCallback?: (progress: Progress) => void,
version: string = CURRENT_PYTHON_VERSION
): Promise<string | undefined> {
if (
// even tough this function supports downloading python3 on macOS arm64
Expand All @@ -1274,9 +1273,9 @@ export async function downloadEmbedPython(
return;
}

const targetDirectory = buildPython3Path(CURRENT_PYTHON_VERSION);
const targetDirectory = buildPython3Path(version);
const settingsTargetDirectory =
`${HOME_VAR}/.pico-sdk` + `/python/${CURRENT_PYTHON_VERSION}`;
`${HOME_VAR}/.pico-sdk` + `/python/${version}`;

// Check if the Embed Python is already installed
if (
Expand All @@ -1297,16 +1296,16 @@ export async function downloadEmbedPython(
// select download url
// process.platform === "darwin" ? versionBundle.python.macos : versionBundle.python.windowsAmd64;
const downloadUrl = new URL(
process.arch === "arm64"
? WINDOWS_ARM64_PYTHON_DOWNLOAD_URL
: WINDOWS_X86_PYTHON_DOWNLOAD_URL
`https://www.python.org/ftp/python/${version}/python-${version}-embed-${
process.arch === "arm64" ? "arm64" : "amd64"
}.zip`
);

const tmpBasePath = join(tmpdir(), "pico-sdk");
await mkdir(tmpBasePath, { recursive: true });
const archiveFilePath = join(
tmpBasePath,
`python-${CURRENT_PYTHON_VERSION}.zip`
`python-${version}.zip`
);

const result = await downloadFileGot(
Expand Down Expand Up @@ -1416,7 +1415,7 @@ export async function downloadEmbedPython(
await workspace.fs.createDirectory(Uri.file(dllDir));

// Write to *._pth to allow use of installed packages
const versionAppend = CURRENT_PYTHON_VERSION.split(".")
const versionAppend = version.split(".")
.slice(0, 2)
.join("");
const pthFile = `${targetDirectory}/python${versionAppend}._pth`;
Expand Down Expand Up @@ -1461,7 +1460,7 @@ export async function downloadEmbedPython(

await LastUsedDepsStore.instance.record(
"embedded-python",
CURRENT_PYTHON_VERSION
version
);

return pythonExe;
Expand Down
15 changes: 10 additions & 5 deletions src/utils/projectGeneration/projectZephyr.mts
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,14 @@ async function generateVSCodeConfig(
// If console is USB, use the local snippet
if (data.console === "USB") {
westArgs.push("-S", "usb_serial_port");
westArgs.push("-DSNIPPET_ROOT=${workspaceFolder}");
westArgs.push("-D", "SNIPPET_ROOT=${workspaceFolder}");
}

westArgs.push(
"--",
`-DOPENOCD=\${command:${extensionName}.${GET_OPENOCD_ROOT}}/openocd`,
`-DOPENOCD_DEFAULT_PATH=\${command:${extensionName}.${GET_OPENOCD_ROOT}}/scripts`
"-D",
`OPENOCD=\${command:${extensionName}.${GET_OPENOCD_ROOT}}/openocd`,
"-D",
`OPENOCD_DEFAULT_PATH=\${command:${extensionName}.${GET_OPENOCD_ROOT}}/scripts`
);

const tasks = {
Expand Down Expand Up @@ -357,7 +358,11 @@ async function generateVSCodeConfig(
kind: "build",
},
command: `"\${command:${extensionName}.${GET_WEST_PATH}}"`,
args: ["flash", "--build-dir", '"${workspaceFolder}/build"'],
args: [
"flash",
"--build-dir",
'"${workspaceFolder}/build"',
],
options: {
cwd: `\${command:${extensionName}.${GET_ZEPHYR_WORKSPACE_PATH}}`,
},
Expand Down
12 changes: 7 additions & 5 deletions src/utils/pyenvUtil.mts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ export async function setupPyenv(): Promise<boolean> {
return true;
}

export async function pyenvInstallPython(): Promise<string | undefined> {
export async function pyenvInstallPython(
version: string = CURRENT_PYTHON_VERSION
): Promise<string | undefined> {
const targetDirectory = buildPyenvPath();
const binDirectory = joinPosix(targetDirectory, "bin");
const command = `${binDirectory}/pyenv install -s ${CURRENT_PYTHON_VERSION}`;
const command = `${binDirectory}/pyenv install -s ${version}`;

const customEnv = { ...process.env };
customEnv["PYENV_ROOT"] = targetDirectory;
Expand All @@ -46,8 +48,8 @@ export async function pyenvInstallPython(): Promise<string | undefined> {
}${customEnv[process.platform === "win32" ? "Path" : "PATH"]}`;

const settingsTarget =
`${HOME_VAR}/.pico-sdk/python` + `/${CURRENT_PYTHON_VERSION}/python.exe`;
const pythonVersionPath = buildPython3Path(CURRENT_PYTHON_VERSION);
`${HOME_VAR}/.pico-sdk/python` + `/${version}/python.exe`;
const pythonVersionPath = buildPython3Path(version);

if (existsSync(pythonVersionPath)) {
return settingsTarget;
Expand All @@ -62,7 +64,7 @@ export async function pyenvInstallPython(): Promise<string | undefined> {
const versionFolder = joinPosix(
targetDirectory,
"versions",
CURRENT_PYTHON_VERSION
version
);
const pyBin = joinPosix(versionFolder, "bin");
mkdirSync(pythonVersionPath, { recursive: true });
Expand Down
Loading
Loading