Instructions for installing MicroPython on the Sipeed Maix range of RISC-V 64 boards.
These feature the Kendryte K210 processor – DualCore RV64 IMAFDC, 8MB SRAM, Neural Network Processor(0.25~0.5TOPS, support TensorFlow Lite), APU, hardcore FFT.
The easiest way to get up and running with MicroPython is to flash the newest binary from the releases page: https://github.com/sipeed/MaixPy/releases
If you want to compile from source then read on…
These instructions utilise Ubuntu running in the Windows Subsystem for Linux. This is a neat way of being able to run a Linux distribution ‘inside’ your Windows installation without using a virtual machine.
WSL and Ubuntu Setup
First you should install WSL following the instructions here: https://docs.microsoft.com/en-us/windows/wsl/install-win10. I choose Ubuntu from the Windows Store.
When it’s installed and the shell opens run the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install python3.6
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo apt-get install unzip
sudo apt-get install zip
MaixPy Download and Setup
Create a directory in your C drive. in the following examples the directory is called abc – replace this with your directory name.
Run the following commands:
git clone --recursive https://github.com/sipeed/MaixPy.git
make -C mpy-cross
Download v8.2 RISC-V 64bit toolchain for Kendryte K210_ubuntu_amd64 from https://kendryte.com/downloads/
Copy it to the C:\abc\MaixPy directory
Run the following commands in the Linux shell:
tar -xf /mnt/c/abc/maixPy/kendryte-toolchain-ubuntu-amd64-8.2.0.tar.gz
In a text editor create the file: C:\abc\MaixPy\ports\k210-freertos\config.conf
add this line to set the toolchain path:
I’m having to copy some files for it to compile for me at the moment. Search the MaixPy directory and subfolders for:
and copy them to: MaixPy\ports\k210-freertos\mpy_support\standard_lib\include\
Run the following commands to compile:
chmod +x build.sh
You’ll find a new binary called maixpy.bin in C:\abc\MaixPy\ports\k210-freertos\output\
Connect your device to USB
In Windows, download K-Flash from https://kendryte.com/downloads/ , unzip and run K-Flash.exe
In K-Flash select the device’s port
For the Firmware – navigate to C:\abc\MaixPy\ports\k210-freertos\output\maixpy.bin
I use Putty for the serial monitor. Connect using the settings below:
Press the reset button on the device. You should boot into MicroPython and see something like this:
Viewing Camera Output on the LCD
Copy and paste all the code below at the >>> prompt in Putty and press enter a few times and you will see the camera image on the LCD.
import sensor import image import lcd lcd.init() sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.run(1) while True: img=sensor.snapshot() lcd.display(img)
This part appears to have disappeared from the current build.
At the MicroPython prompt in the serial monitor, type or paste the following:
>>> camera = machine.ov2640 () ; >>> camera.init () ; >>> lcd = machine.st7789 () ; >>> lcd.init () ; >>> demo = machine.face_detect () ; >>> demo.init () ; >>> image = bytearray ( 320*240*2 ) ; >>> while( 1 ) : >>> camera.get_image ( image ) ; >>> demo.process_image ( image ) ; >>> lcd.draw_picture_default ( image ) ;
Press enter a few times and you should see the face detection start up:
If you have problems, try pressing TAB when you enter code to see possible commands you can enter.
MaixPy on Github: https://github.com/sipeed/MaixPy
Sipeed Homepage: https://sipeed.com/#/
Releases including binary: https://github.com/sipeed/MaixPy/releases
Face detection binaries: http://bbs.lichee.pro/d/170-maix-py-lichee-dan-sipeed-m1-mpy-bin/6
MaixPy port: https://github.com/loboris/MicroPython_K210_LoBo
If I've saved you some time and you want to say 'Thanks!' you can buy me a coffee here...