Instructions for installing MicroPython on the Sipeed Maix range of RISC-V 64 boards.
I bought an M1w dock suit to test from an Indiegogo campaign. They are now available on Seeed and Banggood.
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:
cd /mnt/c/abc/
git clone --recursive https://github.com/sipeed/MaixPy.git
cd /mnt/c/abc/MaixPy/
make -C mpy-cross
Compiling
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:
cd /mnt/c/abc/MaixPy/
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:
toolchain_path=/mnt/c/abc/MaixPy/kendryte-toolchain
I’m having to copy some files for it to compile for me at the moment. Search the MaixPy directory and subfolders for:
spiffs.h
spiffs_config.h
spiffs_configport.h
spiffs-port.h
and copy them to: MaixPy\ports\k210-freertos\mpy_support\standard_lib\include\
Run the following commands to compile:
cd /mnt/c/abc/MaixPy/ports/k210-freertos
chmod +x build.sh
./build.sh
You’ll find a new binary called maixpy.bin in C:\abc\MaixPy\ports\k210-freertos\output\
Flashing Binaries
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
Click Flash
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)
Face Detection
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.
References
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
Buy Me A Coffee
If you found something useful above please say thanks by buying me a coffee here...
there is a typo in your demo code:
demo=machine.demo_face_detect()
is correct. it tool me hours to find out.
demo = machine.face_detect () ;
worked for me. You can see it in the screen capture of the console.
Are you working with the .kfpkg file? Maybe something has changed in the source files. You can always press TAB to see possible commands.
So far the best tutorial available for this board!
Is it possible to have a video with the whole process?
I’ve managed to replicate all steps up to the serial connection, but didn’t manage to connect to maixpy.
Just want to be sure I’m doing everything correct.
What do you see in Device Manager for ports when you connect the device?
Im using Maix Go, and what I get is CMSIS-DAP CDC with failed drivers. https://pasteboard.co/I11PJ3r.jpg
On win 8.1. Got CH340 and CP210X drivers installed from other boards.
I believe GO uses STM32 as an interface? https://pasteboard.co/I11Vcqr.jpg
Tried this: https://www.st.com/en/development-tools/stsw-stm32102.html, this https://armmbed.github.io/DAPLink/ (doesn’t instal, it says no device is connected). No luck!
This was on my PC. I’ve borrowed my sons’ PC that is Win10, got all working beside serial connection to the board (Putty). Firmware upload on win10 works fine.
What do you see in K-Flash for the Device?
Just to be clear, I have 2 issues:
1. Running the tutorial on win 10 works fine untill MaixPy login that just shows random chars
on Win10 the Device shows: “USB Serial port (COM3)”
2. On win7 and win8.1 can’t connect, because COM driver fails.
on Win7 no connection (Got some COM listed from Bluetooth adapter)
I do believe might be something with Go board serial driver on systems that are lower than win10.
So far no luck from the telegram group…I guess I’ll wait until this gets more matured until I dive into this board.
If the the USB to serial chip is new it probably won’t support older OS. I’m following the telegram group and there was a discussion about this. You could try different speeds (baud rate) but it’s a shot in the dark. You could also try https://www.netsarang.com/en/xshell/
Some more settings I have: https://imgur.com/a/VYN34P6
But like you say.. sometiimes with these things it’s better to work on something else.
If you get https://github.com/kendryte/kendryte-flash-windows/blob/develop/src/Canaan.Kendryte.Flash.Shell/Assets/plink.exe.gz and use this command, you’ll be able to connect to the GO.
start plink -serial COM3 -sercfg 115200,8,1,N,N
Hi, i manage to complete all the steps without errors until the build.sh it says
../../../py/mkrules.mk:47: recipe for target ‘build/.//omv/py/py_cpufreq.o’ failed
make[1]: *** [build/.//omv/py/py_cpufreq.o] Error 1
make[1]: Leaving directory ‘/mnt/c/maixpy/MaixPy/ports/k210-freertos/mpy_support’
Makefile:41: recipe for target ‘subcompile’ failed
make: *** [subcompile] Error 2
any ideas?
I just ran through the tutorial again to check the latest files and it all worked OK for me. Which board do you have?