Skip to content

Telink VS Code Extension User Guide


Telink VS Code Extension can convert TelinkIoTStudio projects into CMake projects that can be used in VS Code, and it also supports SDK development for Telink TL32 and TC32 series chips within VS Code.

In VS Code, open the Extension Manager (default shortcut: Ctrl + Shift + X), search for Telink, and install the Telink VS Code Extension(hereinafter referred to as Telink Extension).

Search for Telink Extension

After installing the Telink Extension, click the Telink icon to open the extension's Treeview. Before developing the Telink SDK, it is necessary to install or specify the required development tools.

Install Required Development Tools in DEVELOPMENT TOOLS

Expand DEVELOPMENT TOOLS to view all supported Telink development tools. The tools supporting user-customized installation include: CMake, Toolchain, BDT, ICE Driver, ICEman, OpenOCD, and Jtag_burn.

For the above tools or toolchains, users can selectively install based on actual needs. Right-click the tool or toolchain and click the Install button to start the installation.

Note

  • CMake and the toolchain required by the current project are mandatory.

Install the Tools

Install the BDT tool if users require BDT functionality. Install tools such as Jtag_burn, ICE Driver, ICEman, and OpenOCD if users require JTAG programming and debugging capabilities.

The above approach of selectively installing tools via DEVELOPMENT TOOLS is the recommended solution. Users may install the latest versions of tools as needed.

Users can also download the Telink Tools Installer offline package for installation. For details, refer to the section Telink Tools Installer.

If users install Telink Toolchain or other Telink development tools, it is possible to specify the toolchain or development tools to the local path. For specific configuration, refer to the section Software Installation and Configuration.

Quick Start: Build, Burn, and Debug

Open the Telink SDK in VS Code and click the Telink Extension icon to view the current project structure in PROJECT OUTLINE. Different SDKs may have different directory structures, and some SDKs may contain multiple projects. If the current project is a TelinkIoTStudio project rather than one directly supported by Telink Extension, refer to the section Convert TelinkIoTStudio Projects to CMake Projects to convert it to a CMake project.

Build and Debug

In the PROJECT OUTLINE, select the project to be built and its corresponding Target, then click the Build button on the right to start the build process.

Start Building

After the build completes, output files (*.elf, *.bin, *.lst) are generated. The ELF files are used for debugging, and the BIN files are used for burning.

As shown in the figure below, click the download button to the right of the bin file. (Prerequisite: Ensure the BDT software is installed and all relevant parameters are properly configured. For details, see the Software Installation and Configuration section.)

BDT Quick Download

Hover over the ELF file, click the Debug button on the right to open the debug page. After creating a new debug configuration, the Telink Extension automatically populates the necessary settings. After checking Enable JTAG Burn, the Telink Extension burns the program to the chip before debugging. After ensuring all settings are correct, click the Debug button at the bottom to perform burning and debugging.

Debug Button

The Telink Extension supports the Telink TLSR9118 Wi-Fi SDK, and its usage method is slightly different from that of other SDKs.

First, open the Telink TLSR9118 Wi-Fi SDK folder and ensure that the KConfig file is located in the top-level directory.

In the Wi-Fi DEVELOPMENT, users can configure, build, and burn the TLSR9118 Wi-Fi SDK.

Wi-Fi SDK Development

In Select Targets, click the target to be built. After the .config file is successfully generated, click the all in Build Targets to build.

After the build completes, click the FlashTool to launch the Wi-Fi SDK burning tool for burning.

For detailed descriptions of the Telink Extension features, please refer to the subsequent sections.

Convert TelinkIoTStudio Project to CMake Project

Run the conversion feature if the repository has not been used before.

Open an SDK directory in VS Code workspace, convert the TelinkIoTStudio project to CMake project, and select the project to convert.

Start Conversion

After conversion, it can be viewed through project - target - source in PROJECT OUTLINE.

Finish Conversion

To convert multiple projects, repeat the above steps and select other projects.

For SDK parameter notes, please refer to the section TelinkIoTStudio Parameters.

CMake Building

When running build commands, the extension automatically executes the configuration by default.

Build

The development environment must have CMake and Toolchain installed. Refer to the section Software Installation and Configuration for the required software installation.

Click the rocket icon next to the target to start building.

The CMake build process consists of two steps: cmake configure and cmake build. Clicking the rocket button merges these two steps. To manually run cmake configure, simply right-click on the project and select the corresponding option.

The CMake supports different generators. For usage instructions, please refer to Configure Generator.

Start Build

After building, the built artifacts and logs can be viewed.

Finish Build

Clean

Right-click the target, select Clean Target, or the clean button below.

Clean

CMake Project Structure

(1) CMakeLists.txt: The CMake project function, used globally across the SDK.

(2) cmake_configs: SDK config file (*_cmake.json). Do not manually modify this file, it may cause failures since the CMakeLists.txt reads the configuration to generate projects.

(3) cmake_builds: Intermediate project compile file (.o file, output file).

Cmake Output

Project Management

Add/Delete Project and Target

The + signs next to the PROJECT OUTLINE and project name nodes correspond to Add Project, Add target.

Enter new names in the input box and choose:

  • Create blank project/target
  • Copy from an old project/target (select the corresponding project name )

The advantage of copying an old project over creating a blank one is that similar project can be added with simple modifications.

Add Project

Project File Operations

Add/Delete Files

Right-click the corresponding folder, enter new name in the input box.

File Operation

Import/Remove References

Import Reference: Import existing file to target source (no actual file creation).

Remove Reference: Remove reference from target source (no actual file deletion).

Import and Remove References

Compiler Options Configuration

Right-click the target and select Properties to enter the configuration page, which is the same as TelinkIoTStudio.

Properties Parameter Configuration

Enable CPP Support

Most projects only contain C and ASM languages. If CPP language has already been added to the target, right-click the target and select Enable CPP. The extension automatically copies some compilation options to the project configuration.

enable_cpp

Users can modify the corresponding CPP compilation options in Target Properties.

cpp_properties

Burn and Debug

In Telink Extension, there are two burning methods available for users to choose from:

  • BDT

  • JTAG

BDT

Installation: Right-click BDT and select Install / Browse. In Browse mode, follow the file selection prompt to choose the corresponding software.

This feature requires the BDT tool on Windows and Linux.

Quick Download

After building, click the download button to the right of the bin file to burn the firmware to the target development board.

BDT Quick Download

Click the arrow on right of the BDT toolbar to open the BDT tool page and burn the firmware.

BDT Tool Download

View Flash/SRAM Data

BDT Memory View

For SRAM, which supports byte-level operations, users can modify data at specific addresses and click WriteBack to save changes to the target development board.

BDT Writing Data

JTAG

After program burning completes, users can debug through the JTAG interface and GDB tools, including single-step debugging, breakpoint debugging, viewing variables / stack / registers / memory / assembly, and more.

ICE Libusb Driver Installation

JTAG Prerequisite: Driver Installation

Check prompt for corresponding driver installation:

ice_driver_check_install

(1) Windows

ice_driver_install_windows

Click and run Install_driver.

ice_driver_install_folder_windows

(2) Linux

After clicking install, it switches to running an installation command. Enter the password to obtain root privileges and run it.

ice_driver_install_linux

After the installation is completed, click the refresh button next to DEVELOPMENT TOOLS to update the status.

Burn

After compilation is completed, click Development Tools -> Jtag_burn

JTAG Burn

On the Telink JTAG Burn With ICEman page, users can configure the paths for ICEman and Jtag_Burn, chip type and burning start address:

JTAG Burn Config 1

Users can also configure the connection method and port for ICEman:

JTAG Burn Config 2

Then click the Start ICEman button to start ICEman. After clicking, users need to select the startup mode:

  • Default mode: JTAG uses the default four-wire connection method.
  • SDP 2-wire mode: ICEman starts with -I aice_sdp.cfg added. The JTAG uses a 2-wire connection method and hardware support must be ensured.
  • -H mode: ICEman starts with the -H option added. After successful connection, performs a reset-and-hold operation on the chip.

Generally, if there is no need for the latter two modes, it is recommended to choose Default mode.

Start ICEman

In ICEman's log, if the message ICEman is ready to use appears, it indicates a successful connection.

ICEman Log

Then users can configure the parameters for Jtag_Burn execution and click the Burn button to start burning.

Start Burning

And determine whether burning is successful through the log.

JTAG Burn Log

Debug

After compilation is completed, hover the mouse over the generated ELF file. At this point, a debug button appears. Click it to open the debug configuration interface.

Debug Button

Telink Extension supports single-core or dual-core debugging, and also supports two types of Servers: ICEman or J-Link. Users can configure this here. It's important to note that the J-Link debugging tool kit is not provided. For J-Link debugging, the full path to JLinkGDBServer is required.

Debug Configuration

Users can also configure the file to be debugged (ELF format file), GDB path and the initCommand to be executed after GDB starts. In general, the default settings can be used. To view peripheral registers, select the corresponding SVD file based on the chip type. If using J-Link for debugging, users also need to select the chip core type (D25F or N22). Additionally, if the program hasn't been downloaded in advance, users can enable the Jtag_burn function to download the program before debugging.

Debug Configuration

Click Debug in the lower right corner to start debugging. At the same time, a launch.json file is generated in the .vscode folder, containing debug configurations. If needed, users can modify objects where 'type' is 'tlkTarget'.

The debug page can be roughly divided into four areas as shown in the following figure:

(1) Debug control area: Provides debug control functions including continue, interrupt, step over, step into, step out, restart, and disconnect.

(2) Variables and Core Registers: Provides access to variables currently in the active scope and displays all core registers of the chip.

(3) Peripheral Registers: If the SVD file is correctly specified, users can view the chip's peripheral registers here and read or write them based on permissions.

(4) Debugger Console: This displays GDB output information during debugging. Enter commands in the input box below using the format >Command, then the GDB executes the command and return the result. For example, >info br.

Debug View

When debugging dual-core systems, the main interface functions remain consistent with single-core mode. Additionally, users can switch the core currently active in the debugging session at the location indicated in the following figure:

Dual-core Debug View

Advanced Breakpoint Usage

During debugging, for standard breakpoints, right-click Edit Breakpoint to modify breakpoint properties. As shown below, four functions are available to choose:

Edit Breakpoint

Expression Breakpoint

  • Expression: Customize an expression. The breakpoint triggers when the expression evaluates to true. Variables in the expression must be visible in the current scope.
  • Hit Count: The breakpoint triggers when the specified number of hits is reached.
  • Log Message: Customize a string that is printed in the Debug Console when the breakpoint is triggered.
  • Wait for Breakpoint: Specify another breakpoint in the program; the current breakpoint only triggers when the specified breakpoint is hit.

Software Installation and Configuration

Multiple software installation methods to build environment are available:

(1) Telink Tools Installer: After installation, the extension automatically detects the Tools path. For instructions on using the installation package, please refer to the section Telink Tools Installer. (Suitable for environments without TelinkIoTStudio installed, approximately 2GB, includes commonly used software such as CMake, Make, Toolchain, etc.)

(2) Local Configuration: If TelinkIoTStudio is already installed, users can reuse the toolchains and other software within it by right-clicking and selecting "Browse". (Saves installation time)

(3) Online Installation: Right-click and select Install. (Download speed may be limited by network speed and file size, requiring some time; the advantage is that only the software actually needed is installed.)

The software list is displayed under DEVELOPMENT TOOLS, where users can right-click to select Install or Browse. Users may proactively pre-install tools before compilation or install them during the build process as prompted.

tool_install

The build requires two essential software components: CMake and Toolchain.

Local Toolchain Configuration

If the corresponding Toolchain is missing during the build process, a selection box pops up on the lower right side.

Click Configure, then follow the prompts in the file selection box to select the gcc file under the corresponding toolchain path: riscv32-elf-gcc or tc32-elf-gcc.

Click 'Configure'

Select the 'gcc' File

If the version browsed is incorrect, the following prompt appears:

toolchian_browse_check_version

CMake Software Installation and Configuration

Right-click to install or browse. Currently, it is recommended to choose install to use a specified version of CMake.

Configure CMake Software Path

Configure the Quantity of Threads

The more threads are available, the faster the build process is.

Configure the Quantity of Build Threads

Configure Generator

Windows supports switching between UNIX makefiles, Ninja, and MinGW makefiles. On Windows, Ninja and MinGW makefiles offer improved build and compilation performance compared to UNIX makefiles.

Linux supports switching between UNIX makefiles and Ninja.

Select Cmake Generator

When using different generators, check if the corresponding software in tool/toolchain is installed. Different generators require different build tools; right-click to install:

  • UNIX makefiles require no additional installation; the toolchain already includes them.

  • MinGW makefiles: MinGW make.

  • Ninja: Ninja.

Check Cmake Generator Tools

When switching generators, delete the cmake_builds directory before recompiling.

TelinkIoTStudio Parameters

The parameter usages affect project conversion effects.

${ConfigName} ${ProjName} is expanded to actual values during project conversion.

${workspace_loc:/${ProjName}} paths are converted to ${CMAKE_CURRENT_SOURCE_DIR}.

Below is an example of a shell statement

${workspace_loc:/${ProjName}}/../../../tools/tl_check_fw_tool/tl_check_fw.sh   ${ConfigName}   ${ProjName}

>>> after converted >>>

${CMAKE_CURRENT_SOURCE_DIR}/project/tlsr_riscv/B92/../../../tools/tl_check_fw_tool/tl_check_fw.sh   UART_Demo   TL_PLATFORM_SDK_B92

Similar to -I, -L path parameter, the recommended format in TelinkIoTStudio is${workspace_loc:/${ProjName}}.

Custom Script (Pre/Post Build)

The Telink extension supports executing custom scripts during the pre/post-build phase.

However, it should be noted that there are differences in the project structure between TelinkIoTStudio and VS Code, and relative paths cannot be directly used in commands.

If the current project is a TelinkIoTStudio project and users want to execute pre/post-build normally after conversion, then do not directly use the format like ../../, use ${workspace_loc:/${ProjName}} instead to replace the project's root directory.

For example, a script is rewritten as below.

Original Script:

"../../../tools/tl_link_load.sh" "../../../platform/boot/tl321x/boot_tl321x.link" "${workspace_loc:/${ProjName}}/boot.link"

Rewrite as follows:

"${workspace_loc:/${ProjName}}/../../tools/tl_link_load.sh" "${workspace_loc:/${ProjName}}/../../platform/boot/tl321x/boot_tl321x.link" "${workspace_loc:/${ProjName}}/boot.link"

SDK Downloader

The SDK Downloader feature can be used to obtain all SDKs supported by the current Telink VS Code Extension. Users can open SDK Downloader in the following two ways:

  • Click to open in Telink Extension TreeView:

Open SDKDownloader

  • Enter "Open sdkDownloader" in the VS Code command palette to open:

Open sdkDownloader

After opening SDK Downloader, users can see the Git repository list of all supported SDKs. Users can choose to clone the SDK directly from Gitee or GitHub to local computer, or click the Fetch tags list button to get all tags of the repository. Clone the required tags to the local computer, as shown below:

Clone or Fetch tags(Branch)

If users click Fetch tags list, they can then click the download button next to each tag to clone the specified tag to the local computer. Besides, users can click the switch button on the right, its function is to switch the current tag list to the branch list:

Checkout Tags or Branch

Note

  • This feature actually clones the repository to local computer and then checks out the tag or branch users specified, so what users obtain is also the Git repository of the specified SDK.

After the download is completed, users can choose to directly open the newly acquired SDK.

Open SDK

Wi-Fi SDK Development

Telink Extension provides support for Telink TLSR9118 Wi-Fi SDK: (When using, it is recommended to open the SDK folder containing the top-level Makefile and Kconfig in VS Code).

In the Wi-Fi SDK DEVELOPMENT section, there are the following features:

  • Select Targets: This displays all targets defined in configs.
  • Build Targets: This provides make commands required for building, including make all, make clean, make menuconfig. For menuconfig, it is recommended using guiconfig. Click to open the fully graphical QConfig program.
  • Build Files: Display all files generated by the build.
  • Tools and Settings: Here users can specify tools needed for Wi-Fi SDK development. Similarly, right-click on the required tool to choose download. Among these, click FlashTool to open sctool_gui for burning program.

Wi-Fi SDK Development

Environment Configuration

(1) Check if the toolchain is installed or configured. Right-click to select Install or Browse.

wifi_check_toolchain

(2) Python Environment Installation

pip install pycryptodome
pip install imgtool
pip install PyYAML

Ensure installed Python tools are accessible via system environment variables.

Build Target

Click the corresponding configuration to generate .config.

wifi_config

Click "all" to complete compilation.

wifi_build_all

Configure

Modify configurations using either of the following tools.

(1) MenuConfig

MenuConfig

(2) GuiConfig

GuiConfig

Introduction

The Telink Tools Installer is used to install development tools required for Telink SDK development. These tools must be installed before using the Telink Extension in VS Code for development.

This installer package includes the following components:

  • Toolchains

    • TC32-GCC Toolchain
    • TL32 ELF MCULIB V5F GCC12.2
    • TL32 ELF MCULIB V5 GCC12.2
    • TL32 ELF MCULIB V5F GCC10.3
    • TL32 ELF MCULIB V5F GCC7.4
  • Download and Debug Tools

    • ICEman
    • Jtag_burn
    • Telink BDT (Windows)
    • Telink libusb BDT (Linux)
  • Other Tools

    • CMake: The SDK developed using the Telink Extension is based on the CMake build system.

Use the Installer

With sufficient disk space available (approximately 5.2 GB required), it is recommended to follow the installer's default behavior during installation. Simply double-click to run the installer, then click the Install button in the bottom-right corner. The tools are installed in the {User_Dir}/.Telink_Tools folder.

Select Installation Path

If users prefer not to use the default folder, they can choose a custom installation path. The installer checks if the selected path has sufficient disk space.

Select Path

Remaining Space

Installation Process

The installation progress is displayed in the Installation Log window. During installation, users can click Cancel (to the right of Install) to pause the process. The installer completes the current tool installation before stopping. If users need to exit during installation, use Cancel instead of closing the window directly.

Install Log

After successful installation, users can see the following prompt. Confirm to exit the program.

Install Successfully

Installation Completed

After installation is complete, on Linux systems, users need to execute the following commands in the terminal according to the Installer's instructions to finalize the configuration:

sudo cp /home/wang/.Telink_Tools/udev/99-libtlink.rules /etc/udev/rules.d/
cd /home/wang/.Telink_Tools/udev; chmod a+x install_linux_package.sh; sudo ./install_linux_package.sh
cd /home/wang/.Telink_Tools/udev; chmod a+x change-udev-usb-mode.sh; sudo ./change-udev-usb-mode.sh

Note

  • The path /home/wang/.Telink_Tools/ in the above commands is an example. During the actual installation process, please execute the commands according to the prompts from the Installer.

On Windows system, after installation is complete, the Installer pops up a window asking whether to install the aice_libusb_driver. It is recommended to select and install it.

Known Bug

(1) Configuration options may not be fully converted, as some settings are not explicitly defined in the .cproject file but are controlled by default IDE behavior.

Currently only VS Code Remote (workspace) mode is supported (workspace mode: the extension runs on the remote system, and UI operations are displayed on the local computer). For related concepts, refer to the VS Code Remote Development section.

Architecture of VS Code Remote

Remote mode enables developers to quickly switch between different environments for efficient development.

Remote Extension Installation

The following example demonstrates Windows remote to Linux. The Linux remote to Windows requires further verification and testing. After entering Remote mode, establish a remote connection.

After completing the remote connection, open the Extensions Marketplace to install the extension for Remote. As shown below, the Remote icon appears in the bottom-right corner of the extension icon, indicating the extension is installed in the Remote environment.

Remote Install

Configuration Check

If users already have previously used the extension on the Remote system (e.g., Linux), launching the extension in Remote mode will synchronize the corresponding extension configurations from the Remote environment, allowing users to start using them quickly.

(1) After installation, first check that the software path is the correct Remote-specific path.

Check Remote Path

(2) If this is the first installation on the remote system, on the local environment (e.g., Windows), reconfigure the relevant Remote extension settings as shown below:

Remote Setting

If reconfiguration is not performed, the local path configuration will be used, and the extension may not function properly. This is because development environment configurations vary across different computers.

After completing the configuration, if the UI still displays the old path, click the Refresh button.

Refresh Remote Tool

Development

All file operations in this mode are performed on the remote computer.

Remote Development

Notes

The Show File is unavailable in Remote mode.