Create Project - nxp-mcuxpresso/vscode-for-mcux GitHub Wiki
PROJECTS view provides a suite of posibilities for creating or importing an application. Also, this view is responsible to manage the created projects in order to add/remove components, build, debug, remove existing ones.
Import a project from source repository
Once a source repository is available in MCUXpresso for VS Code, you can create your own application by importing an example from the repository.
You have several options to open the wizard to create a project:
- Select the desired available repository within "Installed Repositories" view, right-click on it and select "Import Example Application from an Installed Repository" or
- From PROJECTS view (in case it has no projects yet) press "Import Example from Repository" button or
- From PROJECTS view toolbar select "Import Example Application from an Installed Repository" option.
Selecting one of the above options will open a wizard with few steps to follow until the project can be generated.
You then have to fulfill some required fields:
- Choose a repository - select from the installed source repository (can be MCUXpresso, Zephyr, Open-CMSIS-Pack or a custom one)
- Choose a toolchain - select one of the already installed toolchains
- Choose a board - select one listed here (the ones available within the selected repository)
- Choose a template - this is the list of available project templates for selected repository/board from above
- Application type - (for Zephyr only) choose "Repository application" if you want to use the application directly in the repository folder (example's sources will not be copied), "Freestanding application" if you want to keep the application in the MCUXpresso's workspace (example's sources will be copied) or "Workspace application" if you want to generate the project in the repository workspace (see Zephyr Application Development for details); check with Zephyr on MCUXpresso for VS Code for mode details on the additional wizard fields
- Name - project name. This will be further referred in the workspace. If the project's name already exists, an error will indicate this
- Location - path for the project. The path will be created if not exists
- Open readme file after project is imported - this option will open existing example readme in case it exists (when the project will be created, after pressing "Create" button); this option is unchecked by default
Import an existing project
Import an existing MCUXpresso project by selecting one of the following options:
- From PROJECTS view (in case it has no projects yet) press "Import MCUXpresso for VS Code Project" button or
- From PROJECTS view toolbar select "Import MCUXpresso for VS Code Project" option.
From the wizard, select the existing project (choose from archived, folder project options or executable; choosing an executable file will result in creating a new project that will allow debugging and accessing the available binary tools options for that executable).
You have to fill the required fields:
- Import path - select the project archive path
- Destination - select the path where the project will be imported
- Choose a repository - select one of the already installed repositories which are compatible with the imported project type. Pick a suitable one or use Add repository path option from the combobox
- Choose a toolchain - select one of the already installed toolchains. Pick a suitable one or use Add toolchain path option from the combobox
Import a project based on an existing executable file
To import a project from an existing executable press the "Executable" button from the import project wizard, choose the executable file and fill in the required information ( destination, toolchain).
Since the newly created project won't contain any source files this project won't have the option to build/rebuild the project or to create any build configuration. However, the project can be debbuged once a device target is associated with the project. This can be done by either associating a repository with the project or by simply starting a debug session and providing the necessary information.
For example, on LinkServer the extension will first present a list of all the supported devices.
A project resulted from importing an executable file has the existing binary tools support: Image Info options and the tools from "Binary utilities" menu are avaiblable.
Export a project
An existing project can be exported to an archive. This can be achieved by selecting a project, open context menu and select Project -> Export MCUXpresso Project Archive.
You'll be asked then to provide a path where the archive will be generated. The default is the path where the project is located.
Move a project from one machine to another
A project can be moved from one machine to another by using the export and import project features.
First you need to export the desired project using Export MCUXpresso Project Archive option. After that, you need to copy the generated project archive to the other machine.
Once the project archive is available on the second machine, you can use the Import Project Wizard feature to import the project.
After importing the project, the repository and toolchain paths are updated acording to the values selected in the Import Project Wizard.
The extension reports all paths in project settings files (files in .vscode
project directory) that could not be automatically resolved. In this case, the user needs to manually udpate them.
Build configuration
The PROJECTS view displays all available build configurations for each project. One is selected by default, any other can be selected using "Set as Default" option.
Additionally, you can add, duplicate, edit or delete a build configuration.
Build project
The next step is to build the executable file. Use Build Selected option from toolbar or right click on the desired project and select Build selected. This will start building the selected build configuration. The output generated files can be found in the VS Code Explorer view.
Changing toolchain
One important aspect is the toolchain management. This extension is able to identify existing MCUXpresso SDK or Zephyr installed toolchains, depending on the selected repository type, or new ones can be identified. A user can select the desired toolchain when creating a new project or adding a new toolchain.
Once the project is created, the toolchain selection is preserved in project settings, in JSON format in the file mcux_include.json
. This file contains all variables for the CMakePresets.json
file.
From this point, the toolchain can be manually updated in this json file or using the MCUXpresso for VS Code: Add/update build tool from the command palette.
Variables Reference
Variable substitution is supported in mcuxpresso-tools.json for defining paths (like: toolchainPath, sdk.path).
You can use environment variables, like:
"toolchainPath": "%HOMEPATH%/.mcuxpressotools/arm-gnu-toolchain-12.2.rel1-mingw-w64-i686-arm-none-eabi"
.
The following predefined variables are supported:
${userHome}
- the path of the user's home folder${workspaceFolder}
- the path of the current project${workspaceFolderBasename}
- the name of the current project${pathSeparator}
- the path separator used by the operating system