How to Compile TLSR9 SDK Example Projects on Linux

Introduction

All the Telink SDKs for TLSR9 series (e.g. Driver SDK) are created by Telink RDS IDE. The SDK example projects cannot be compiled directly on Linux using the free RISC-V GNU compiler toolchain. This application note explains how to compile them with some tricks on Linux. It is assumed that you already know how to use the Telink RDS IDE or CMake.

Make sure the Telink RDS IDE is correctly installed on your Windows PC.

RISC-V GNU compiler toolchain

Make sure the Telink RISC-V Linux Toolchain is correctly installed on your Linux PC.

Example code

We will use the TLSR9 Driver SDK as an example. Download it and extract its content into a folder in your Windows PC.

Generating makefiles

Launch the Telink RDS IDE and import the Driver SDK. You should see a project named “B91_Driver_Demo” appear in the Project Explorer section.

Select the “B91_Driver_Demo” project. Click the hammer icon and select a configuration to build with. Let’s select “UART_Demo” in this example.

You will soon see that the build process starts and a new folder titled “UART_Demo” is created after the build process finishes. The new folder is populated with

• all make files required for the build (makefile and various *.mk files).

• the object files and dependency files generated during the build.

• the final executable file (UART_Demo.adx).

• the binary executable file, ready to be programmed in flash (UART_Demo.bin).

• a symbol listing file, with all symbols and their associated addresses (symbol.txt).

Right-click on the “B91_Driver_Demo” project and and click “Clean Project” in the pop-down menu.

Copy all the contents of the Driver SDK to your Linux machine.

Compiling the example project on Linux

Open the makefile file in the UART_Demo folder and find following two path strings highlighted below. They are no longer valid on your Linux machine and therefore we need to fix them.

Apply the quick fix below.

Launch a shell and navigate to the folder where the UART_Demo is located. Run the command line below to start compilation.

   make


If everything goes well, you should see something like:

Go to the output folder and you can see the demo project is built successfully.

Setting up the environment (using the CMake)

RISC-V GNU Compiler Toolchain

Make sure the Telink RISC-V Linux Toolchain is correctly installed on your Linux PC.

Example Code

We will use the TLSR9 Driver SDK as an example. Download it and extract its content into a folder in a Linux machine.

NOTE: The Linux machine is running a 64-bit Ubuntu 18.04 LTS in the example below.

CMake

Run the following command in a Linux shell to install the CMake on your Linux machine.

sudo apt install cmake


Compiling the Example Project on Linux

Let’s assume we want to build UART_Demo example.

1. Download the example CMakeLists.txt and put it into the root of the SDK project.
2. Create a new folder named “build”.

1. Launch a shell and navigate to the build folder. Run the command line below to generate a makefile.
   cmake ../


If everything goes well, you should see something like:

1. Run the following command line and you can see the demo project is built successfully.
   make


NOTE: Changes need to be made to the CMakeLists.txt file if you want to build other demo examples included in the Driver SDK.

To continue the burning and debugging procedures, please check Burning and Debugging Tools for TLSR9 Series in Linux.