Play with K210 on Mac [Unofficial]

  • This is an unofficial step-by-step tutorial for Mac user to play with K210.

    Have fun.

    Compile riscv-gnu-toolchain

    • Create a folder to hold all files.
    mkdir ~/K210
    cd ~/K210/
    • Build toolchain from source. Check here for details.
    git clone --recursive
    cd riscv-gnu-toolchain
    • Install prerequisites. If you do not have Homebrew, check its homepage to install first.
    brew install gawk gnu-sed gmp mpfr libmpc isl zlib expat
    • Do some patch to the file /riscv-gcc/gcc/graphite.h. Include two more header.
    diff --git a/riscv-gcc/gcc/graphite.h b/riscv-gcc/gcc/graphite.h
    index 4e0e58c..be0a22b 100644
    --- a/riscv-gcc/gcc/graphite.h
    +++ b/riscv-gcc/gcc/graphite.h
    @@ -37,6 +37,8 @@ along with GCC; see the file COPYING3.  If not see
     #include <isl/schedule.h>
     #include <isl/ast_build.h>
     #include <isl/schedule_node.h>
    +#include <isl/id.h>
    +#include <isl/space.h>
     typedef struct poly_dr *poly_dr_p;
    • Configure and compile. Need to add--with-cmodel=medany. ,otherwise there will be some link problem when compile the sdk for k210.
    ./configure --prefix=/usr/local/riscv --with-cmodel=medany
    sudo make -j8

    Set up Kendryte K210 standalone SDK

    • Download the SDK
    git clone
    cd kendryte-standalone-sdk
    • Build it
    mkdir build && cd build
    cmake .. -DTOOLCHAIN=/usr/local/riscv/bin -DPROJ=hello_world
    make -j8

    Install CH340 Drvier

    Upload code

    • Install Python3
    brew install python
    • Install python Libraries
    pip3 install pyserial
    pip3 install pycrypto
    • Download Upload script
    cd ..
    //Sipeed M1:
    • Upload the bin file. You can change the serial port /dev/cu.usbserial-* by yourself.
    cd build
    python3 ../ -d /dev/cu.usbserial-* -b 1500000 *.bin
    //Sipeed M1:
    python3 ../ -d /dev/cu.usbserial-* -b 1500000 *.bin

    Test hello_world

    • Connect via screen
    screen /dev/cu.usbserial-* 115200
    • Press reset button. The following message would be received:
    Core 0 Hello world
                      Core 1 Hello world
    • Press CTRL+A CTRL+K to exit the screen mode. You can also using the following command to kill screen
    killall SCREEN

    Build OpenOCD

    • Git Clone from Kendryte repository
    git clone --recursive
    • Install dependency
    brew install automake libtool libusb wget gcc
    • Compile and Install
    make -j8
    sudo make install
    • Verify the Installation
    openocd -v
    • The output should be:
    Kendryte Open On-Chip Debugger For RISC-V v0.1.3 (20180912)
    Licensed under GNU GPL v2

    Upload code into RAM using Jlink

    • Keep in mind that all the code will be lost if reset the board or reconnect the serial port via screen.
    • Get a J-link debugger. This article uses J-Link EDU.
    • Short the J96 connector on KD233 near the JTAG port.
    • Connect the J-link to KD233.
    • Open a new Terminal and connect via screen first (See Test hello_world section for details )
    • Goto folder in SDK
    cd ~/K210/kendryte-standalone-sdk
    • Download the upload script
    • Goto build folder && upload the image
    cd build
    ./../ *.bin
    • You will now see the result in screen.
    Core 0 Hello world
                      Core 1 Hello world


    Any help or feedback will be appreciated.

    To Kendryte Team

    More Human Care for Mac users.

    Fond of this project.

    Keep going.

  • @vowstar me too

  • @AngeloQiao Thank you for the tutorial- it just worked perfectly. I was afraid to switch to the Mac for K210 development based on the possible troubles. After this initial success, I've now decided to continue on the Mac.
    0_1541259883600_Screenshot 2018-11-03 at 16.36.12.png

  • Staff

    In order to test the tools under MAC, I bought a MAC book pro.