nxp-mcuxpresso / vscode-for-mcux

Support for NXP Visual Studio Code for MCUXpresso Extension project.
13 stars 0 forks source link

Create a project for a custom board #14

Open escherstair opened 9 months ago

escherstair commented 9 months ago

I see that this project has a lot of nice features, and simplifies the process of working with NXP SDK. I wonder what is the expected way to use it to create a project based on one of the templates, but for a custom board (designed starting from one of the evaluation boards). I meean, which files/folder should I create, and where. And which changes to the .json files inside .vscode are needed.

Thanks

cristitep-nxp commented 9 months ago

Hi,

We'll plan to have this process automated in a wizard, till then, below is the list of steps to switch to a custom board:

1. Generate a new debug configuration for your custom board. I suppose you want to derive from an existing board (let's use iMX RT1064 as an example):

2. Project. The easiest way to have a "template" project is to start from an example of the MCUXpresso SDK. So also supposing you use iMX RT1064:

escherstair commented 9 months ago

Hi @cristitep-nxp thank you for your detailed steps. In my case I would like customizing evkmimx8mp board (i.MX 8MQuad Evaluation Kit) - Cortex-M7. Does LinkServer support this device too? It's not listed in C:\nxp\LinkServer_1.2.45>linkserver devices

cristitep-nxp commented 9 months ago

Hi,

Unfortunately, LinkServer doesn't have support for Cortex-M from iMX processors in this moment. You can try to use Segger connection instead. Similarly, you should edit mcuxpresso-tools.json but for Segger connection, in "segger": {"device": "", "interface": "JTAG"}. The device name can be found looking in the Segger installation layout, starting JLink.exe , then issuing ExpDevList c:/temp/t.txt and looking into the generated txt file for your desired device. For more info regarding jlink connection see https://wiki.segger.com/J-Link_Commander.

Regards, Cristian

escherstair commented 9 months ago

Hi, thank you again. This is quite clear for the debugging. But, for building (compiling and linking) should I change the sdk section inside mcuxpresso-tools.json ?

 "sdk": {
    "version": "2.14.0",
    "path": "d:\\repos\\NXP_SDK",
    "boardId": "evkmimx8mp",
    "deviceId": "MIMX8ML8xxxKZ",
    "coreId": "cm7_MIMX8ML8xxxKZ",
    "manifestId": "SDK_2.x_EVK-MIMX8MP_manifest_v3_13"
  }

I imagine, at least "boardId". But where should I place my "board" source code? I imagine that the VS code extension has some automatic steps that rely over some conventions.

escherstair commented 9 months ago

Hi @cristitep-nxp I tried changing "boardId": "custom_board" but now I see the following <not found> immagine I imagine that the extension searches "the board" inside SDK path core/boards I imagine. Is this the case? But since it's a custom board, I don't think that the best location is inside the SDK itself. Is there a parameter that can be used to specify where the extension should search for custom board files?

Thanks

DragosMiloiuNXP commented 9 months ago

Hi @escherstair,

The board, core, device and manifest identifiers are defined by the SDK itself. They are used by the extension for things like determining information necessary for connecting and using GDB servers, identifying peripheral definitions, filtering components applicable for the current project, etc. Modifying the board identifier would require changes in the manifest.xml (SDK metadata information) and it is quite difficult. Our recommendation would be not to change that ID. So, apart from having a board name in the UI that reflects the actual name of your custom board, do you want to change this for other reasons?

Source code used by the project are not influenced by the boardID from the JSON file. They can be added/removed by changing CMakeLists.txt. In case of MCUXpresso SDK, board specific files are present in the project folder.

Thanks.

escherstair commented 9 months ago

Hi @DragosMiloiuNXP

So, apart from having a board name in the UI that reflects the actual name of your custom board, do you want to change this for other reasons?

Source code used by the project are not influenced by the boardID from the JSON file. They can be added/removed by changing CMakeLists.txt. In case of MCUXpresso SDK, board specific files are present in the project folder.

I thought that the extension generates automatically the proper CMakeLists.txt based on the values set in mcuxpresso-tools.json (when it updates the MCU section in the UI). But you explanation says that this is not the case and no source file is modified under the hood by the extension. If this is the case, I can safely edit manually all the relavant files and the extension will never change/overwrite them.

Can you confirm this, please?

DragosMiloiuNXP commented 8 months ago

Hi @escherstair,

Modifications in mcuxpresso-tools.json do not trigger changes in CMake files (like CMakeLists.txt, flags.cmake, etc.). More, the CMake files are not generated or regenerated by the extension. So, any change you make to the CMake files will be preserved.

As a side note, the only changes the extension makes to the CMake files are:

Please note that inside cmake-kits.json there are settings that impact the CMake/build behavior (like "DEBUG_CONSOLE": "UART" tells CMake to link and use the UART libraries). These do not modify the CMake files, they are used to construct the command-line arguments passed to CMake.

Regards.