K210 Blinky

So you want to develop your own C code on the K210, you can do it all on the Raspberry PI without any external programmer or debuggers. Follow through this tutorial to find out how you can easily do that.

 

Install VS CodeĀ 

Installing VS Code on the Raspberry PI using the following command.

sudo apt update
sudo apt install code

Once installed you can start the VS Code from the menu.

Install Platform IO Plugin

The Platform IO is a plugin for VS Code and is the IDE we will be using to develop our C code for K210. Follow the steps below to install the plugin.

  1. Click on the Plugin icons and you will be presented with a list of plugins to install
  2. Type "platformio" in the search area and you will see the Platorm IO IDE plugin.
  3. Click on install. It will take a couple of minutes and you will be asked to restart VS Code.

Install XaLogic Platform

To simplify configuration of the project, we had prepared a custom platform so you can get all the necessary tools and SDK needed to develop the code in C. You only need to do this once and the next time you create a new project, all the tools and packages will be available.

The follow steps will help you get familiarize with the Platform IO and install the custom platform.

  1. Click on this "Home" icon to show the Platform IO Home page. On the home page you will be able to create new projects etc.
  2. Click on this Platform IO Plugin icon and you will be presented with the command panel where you can build, upload binary to the board and open up a terminal.
  3. Click on the "New Terminal" link and you will be presented with a PIO terminal.
  4. Finally at the terminal execute the following command to install all the necessary packages.
    pio platform install https://github.com/xalogic-open/platform-kendryte210.git#XA1-v1.2.4

Create Project

Now we can finally create our project. We will create a simple Hello World project to blink an LED.

  1. Click on "Create Project" in the Platform IO Home and you will be presented this pop up window.
  2. Enter a project name and type "xalogic" in the Board selection and you will see the "XaLogic K210 AI Accelerator" board. Click on it.
  3. You can keep the "Use default location". Mouse over the ? icon and you will see the default location.
  4. Click Finish and your project will be created.

 

Create Source code

  1. Click on the file Navigation Icon.
  2. Right click on the "src" folder of the project you just created.
  3. Select new file

In the new file, you copy and paste the following code which will blink an LED on the board.

Build and Upload

  1. Click on the Platform IO Plugin icon
  2. You can either build first or you could simply click on upload which will automatically do a build if necessary.
  3. Once completed you will see the "success" status in the terminal.

If all goes well this is what you will see on the board.