2.2 VSCode development environment

1. Tools needed to compile K210

We are building the K210 development environment through the VSCode editor with the Win10 system. The following are the tools we need.

1-CMake.

2-Toolchain.

3-VSCode.

4-K210-SDK.

5-flash.

2. Install CMake

2.1 Download CMake

CMake official download URL: https://cmake.org/download/

Here is the win10 64-bit system as an example, click to download cmake-3.19.1-win64-x64.msi

 

2.2 Double-click to run and install cmake.

 

 

You must choose to add CMake to the system environment variables.

2.3 The fourth is to create a desktop icon. If you need a desktop icon, please tick it.

 

2.4 Choose install path.

 

2.5 Click “Install”.

 

2.6 The installation is complete.

 

2.7 Check and verify CMake

Open the CMD command interface, enter cmake -version, you can see the CMake version number you installed, it means the installation is successful.

3. Install the cross compiler Toolchain

3.1 We have provided this tool, please download tool from this link -> [K210 Tools ].

3.2 Extract toolchain.zip file

 

Move the extracted kendryte-toolchain folder to the k210 directory on the c drive.

(If you move to another path, you must remember that path)

 

 

3.3 Add camke and toolchain to system environment variables.

Right-click the desktop “this computer” icon, click “Properties”.

 

Click “Advanced System Settings”-->“Environment Variables”.

 

 

Double-click “Path” and add your own CMakebin and kendryte-toolchainbin path to the environment variables.

 

 

Eg, my path is C:k210CMakebin and C:k210kendryte-toolchainbin

 

3.4 New create make program

Enetr kendryte-toolchainbin path. Find mingw32-make.exe, copy and paste this .exe file. You will obtain a mingw32-make-copy.exe file.

Then, rename the mingw32-make-copy.exe to make.exe.

!Tips:

If your computer system didn’t open the display suffix name of file, you will see mingw32-make. Copy and paste and rename the copy to make in the same way.

 

3.5 Verify cross compiler toolchain

Re-start the CMD command line interface and enter make -v.

If you can see the GNU Make version, which means the installation is successful.

 

4. Install VSCode editor

4.1 Download VSCode editor

VSCode official download address: https://code.visualstudio.com/Download

According to your own system version, you can choose version. I choose [System Installer 64bit], and downloaded .exe file.

Then, we can install it directly, it can be used by all users.

 

4.2 Install VSCode

Double-click to install the VSCode installation package file.

 

!!! You must check the options shown in the figure below to continue the installation.

 

 

Click “Finish” to complete installation.

5. Download K210 software SDK

K210 official provide two SDK.

Bare machine version SDK and freertos SDK

Eg: we use a Bare machine version SDK

5.1 Download K210 Bare machine version SDK

Download link:

https://github.com/kendryte/kendryte-standalone-sdk

Click “Clone or download”---> click “Download ZIP” download SDK.

We have provide this file, please click [Tools] to download this file.

 

5.2 After download is complete. Move SDK file to C:k210SDK and extract this file.

 

6. Compile program

6.1 Open kendryte-standalone-sdk-develop file by VSCode. As shown below.

 

 

6.2 View the main.c file of the hello_world project in the src folder. When we run the modified program, it will print out the data from the USB serial port. 

As shown below.

 

6.3 Open VSCode terminal, click “Terminal”-->”New Terminal”. You will see following interface.

 

6.4 Create build folder

Enter the following command in the VSCode terminal to create the build folder. 

Enter the build. The build folder is used to save the files generated by cmake compilation, and it is also the save path of the write firmware.

mkdir build

cd build

 

6.5 CMake compile program

cmake .. -DPROJ=hello_world -G "MinGW Makefiles"

If you see following content, which means compile successfully.

 

 

6.6 make compile program

 

6.7 Input command ls to View the generated file.

7. Write program into K210 board

7.1 Download write tool -- kflash.

Download link:

https://github.com/kendryte/kendryte-flash-windows/releases

Select the latest version to download, the current latest version is v0.4.1.

(We have provide this tool, you can click Tools to get this it.)

 

7.2 After download is complete, extract this zip file. Then, you can get a K-Flash.exe file.

 

7.3 Double-click to open K-Flash.exe, and connect the computer to the K210 development board through the Type-C data cable. And open the power switch of K210 board.

Device: selects the serial port number of your K210 development board.

Baud rate: selects the baud rate (115200).

Chip: In-chip .

If you choose in-Memory, it will be write to SRAM and will not be saved after power off.

Firmware: selects the program firmware (.bin file), we select hello_world.bin.

Checking Open terminal after flash means that the terminal will be opened automatically after the programming is completed.

Click “Flash” to start burning the firmware.

  

7.4 After the writing is completed, the terminal will be opened automatically and the following information will be printed.


เสร็จสิ้นและไปบทถัดไป