-
-
Notifications
You must be signed in to change notification settings - Fork 24
build
Building on Windows
The build system is designed and tested to run on Linux (Ubuntu 18.04)
If you want/need to run on Windows, you have two choices:
- Install Linux distribution (Ubuntu 18.04 recommended) in virtual machine
- On Windows 10 64-bit, instal WSL (Windows Subsystem for Linux) (Ubuntu 18.04 recommended).
It was tested and runs very good.
This is recommended way of running the build on Windows.
Building on arm (Linux) platforms is supported.
Building on Mac OSX is supported.
Some prerequisities are required, you may run OSX_pre.sh
to get them.
To enable using the boards USB->UART adapter as regular user it is recommended to create udev rules for USB2UART adapters.
In /etc/udev/rules.d
create new rules file, for example, 90-usbuart.rules
and put the following content in it:
# Rules for USB->UART adapters
# CP210X USB UART
SUBSYSTEMS=="usb", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE:="0666"
# FT232R USB UART
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE:="0666"
# FT231XS USB UART
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", MODE:="0666"
# Prolific Technology, Inc. PL2303 Serial Port
SUBSYSTEMS=="usb", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", MODE:="0666"
# QinHeng Electronics HL-340 USB-Serial adapter
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:="0666"
To apply the new rules immediatelly execute:
sudo udevadm control --reload-rules && udevadm trigger
git clone https://github.com/loboris/MicroPython_K210_LoBo.git
If you don't need all the repository history, you can use
--depth=1
option to download only the latest commits.
This will result in much smaller cloned repository size:git clone --depth=1 https://github.com/loboris/MicroPython_K210_LoBo.git
You can also download the repository as a zip file using Clone or download
button on the first repository page and unpack it to some directory.
You will not be able to use git pull
to update the repository, but otherwise the building process is the same.
Depending on your Linux installation, you may need to install some additional packages:
sudo apt install git cmake build-essential xz-utils python3 python3-serial wget zip libncurses5-dev
Kendryte toolchain will be automatically downloaded and unpacked on first run of BUILD.sh script.
It can take some time on slow Internet connection (~32 MB will be downloaded).
kendryte-freertos-sdk is included in the repository.
Change the working directory to MicroPython_K210_LoBo/k210-freertos.
To build the MicroPython firmware, run:
./BUILD.sh
BUILD.sh
accepts some arguments:
Argument | Description |
---|---|
-v , --verbose
|
build verbose (show some info during build) |
-V , --VERBOSE
|
be more verbose |
-jN |
build using multiple threads, if set, the build will be much faster (N =2~16) |
-m --menuconfig
|
start menuconfig interactive system to configure MicroPython build options |
-n --nofsimage
|
do not include filesystem image in MicroPython.kfpkg
|
boris@UbuntuMate:$ git clone https://github.com/loboris/MicroPython_K210_LoBo.git
Kloniranje u 'MicroPython_K210_LoBo'...
remote: Enumerating objects: 260, done.
remote: Counting objects: 100% (260/260), done.
remote: Compressing objects: 100% (245/245), done.
remote: Total 3180 (delta 26), reused 89 (delta 9), pack-reused 2920
Primanje objekata: 100% (3180/3180), 135.92 MiB | 8.03 MiB/s, završeno.
Razrješavanja delta: 100% (1274/1274), završeno.
boris@LoBo2_Razno/K210_razvoj/testiranje$
boris@UbuntuMate:$ cd MicroPython_K210_LoBo/k210-freertos
boris@UbuntuMate:MicroPython_K210_LoBo/k210-freertos$ ./BUILD.sh
=====[ BUILD: Building on Linux UbuntuMate 5.3.0-28-generic #30~18.04.1-Ubuntu SMP Fri Jan 17 06:14:09 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Downloading kendryte-toolchain (kendryte-toolchain_v2a.tar.xz), please wait ...
Unpacking kendryte-toolchain
'kendryte-toolchain' prepared, ready to build
=====[ BUILD: compiling 'menuconfig' files
=====[ BUILD: OK
=====[ BUILD: Creating 'k210.config.h'
=====[ BUILD: Configuration files created.
=====[ BUILD: compiling 'mklfs'
=====[ BUILD: ok.
=====[ BUILD: File system image created
=====[ BUILD: compiling 'mpy-cross'
=====[ BUILD: ok.
=====[ BUILD: 3 MB firmware
=====[ BUILD: UPDATE mk files
===========================================
=====[ BUILD: BUILDING MicroPython FIRMWARE
===========================================
=====[ BUILD: Creating 'MicroPython.kfpkg'
=====[ BUILD: kfpkg created
---------------------------------------------------
text data bss dec hex filename
1723890 48349 174384 1946623 1db3ff MicroPython
---------------------------------------------------
=============================
====== Build finished =======
version: 1.12.01
Firmware file size: 1777664
Firmware CRC32: 877d8696
Flash FS starts at: 5242880
=============================
boris@UbuntuMate:/MicroPython_K210_LoBo/k210-freertos$
The build process by default runs silently. If you wont to see more messages run with the -v
option.
To flash the built firmware to your K210 board, run:
./ktool.py -p /dev/ttyUSB0 -b 2000000 -t MicroPython.bin
Change /dev/ttyUSB0 to the port used to connect to the board if needed.
With -t
option, the MPyTerm
terminal emulator will be started and the board reseted after successful flash.
MicroPython session example (OTA firmware):
* Find applications in MAIN parameters
0: ' MicroPython', @ 0x00010000, size=1794048, not checked, NOT ACTIVE
1: ' MicroPython', @ 0x00280000, size=1789952, App ok, ACTIVE
* Loading app from flash at 0x00280000 (1789952 B)
* Starting at 0x80000000 ...
M (3678) [K210_MAIN]: Default flash configuration set
M (8453) [K210_MAIN]: OTA used: loaded firmware from 0x00280000, size=1789952
RISC-V Kendryte ---------------------------------------------
_ _ _____ _ ______ ___ ___ ______ _ _
( ) / ) (___ ) ( ) ( __ ) ( \ / ) ( __ ) ( ) ( )
| |_/ / ___| | | | | | | | | |\ \ /| | | |__| | \ \_/ /
| _ ) ( ____) | | | | | |**| | \_/ | | | ____) \ /
| | \ \ | |___ | | | |__| | | | | | | | | |
(_) \_) (_____) (_) (______) (_) (_) (_) (_)
-------------------------------------------------------------
MicroPython-FreeRTOS by LoBo v1.12.01
-------------------------------------
MicroPython 1.12.01 (9d99740-dirty) built on 2020-02-06; Sipeed_board with Kendryte-K210
Type "help()" for more information.
>>> help('modules')
__main__ json time upip_utarfile
_thread machine uarray upysh
binascii math ubinascii urandom
board microWebSocket ucollections ure
builtins microWebSrv ucryptolib uselect
camera microWebTemplate uctypes usocket
cmath micropython uerrno ussl
collections network uftpserver ustruct
display os uhashlib utime
font10 ota uheapq utimeq
font6 pye uio uzlib
framebuf re ujson writer
freesans20 socket ulab ymodem
gc ssd1306 uos
io sys upip
Plus any modules on the filesystem
>>> import machine, _thread
>>> _thread.list()
Total system run time: 153.008 s, number of tasks running: 4
MicroPython threads:
-------------------------------------------------------------------------------------------------------------------
ID(handle) Proc Name State Stack Used MaxUsed PyStack Used Type Priority Run time (s) (%)
-------------------------------------------------------------------------------------------------------------------
2150748512 0 MainThread* running 32768 1024 2680 4096 64 MAIN 8 0.571 0.37
FreeRTOS tasks running:
-------------------------------------------------------------------------------
ID(handle) Proc Name State MinStack Priority Run time (s) (%)
-------------------------------------------------------------------------------
2150748512 0 main_mp_task Running 30088 15 0.571 0.37
2149279736 0 IDLE Ready 7416 0 152.421 99.62
2149281848 1 IDLE Ready 7416 0 0.000 0.00
2150713248 0 hal_tick_task Blocked 7432 1 0.001 0.00
-------------------------------------------------------------------------------
FreeRTOS heap: Size: 5238784, Free: 862616, Min free: 795280
System heap: Free: 777216
>>> machine.state()
PLL0: 988000000, PLL1: 806000000, PLL2: 45066666, SPI3clk: 494000000
APB0: 247000000, APB1: 247000000, ACLK: 494000000, HCLK: 494000000
CPU: 494000000, KPU: 403000000
SRAM0: 494000000 (ACLK/1)
SRAM1: 494000000 (ACLK/1)
Current SPI Flash speed: 35285714 Hz
RAM buffer of 4096 bytes at 0x80300000
OTA used: loaded firmware from 0x00280000, size=1789952
Heaps: FreeRTOS=5116 KB (842 KB free), MPy=4220 KB, other=759 KB
>>>
>>> machine.mpy_config()
MicroPython configuration:
--------------------------
MPy version code: 011112
Two MPy instances: False
PyStack used: True
Available heap size: 4220 KB
MPy heap size: 4220 KB
PyStack size: 4096 B
MPy stack size: 32768 B
CPU frequency: 400 MHz
REPL baudrate: 115200 bd
Boot menu pin: 15
Default log level: 2 (LOG_WARN)
Use log colors: 1 (True)
VM divisor: 32 bytecodes
(False, True, 4321280, 4321280, 0, 4096, 32768, 400000000, 115200, 15, 2, True, 32)
>>>
>>>
>>> machine.reset_reason()
(8, 'External pin reset')
>>>
>>>
--[mpTerm command: synctime
OK.
back to device ]--
>>> os.mkdir('/flash/www')
>>>
--[mpTerm command: senddir mpy_support/examples/webserver/www /flash/www
Sending local file mpy_support/examples/webserver/www/index.html to /flash/www/index.html
--> 100.00%
OK, took 0.271 seconds, 4.040 KB/s
Sending local file mpy_support/examples/webserver/www/pdf-sample.pdf to /flash/www/pdf-sample.pdf
--> 100.00%
OK, took 1.884 seconds, 4.118 KB/s
Sending local file mpy_support/examples/webserver/www/pdf.png to /flash/www/pdf.png
--> 100.00%
OK, took 1.060 seconds, 4.192 KB/s
Sending local file mpy_support/examples/webserver/www/style.css to /flash/www/style.css
--> 100.00%
OK, took 0.025 seconds, 18.044 KB/s
Sending local file mpy_support/examples/webserver/www/wstest.html to /flash/www/wstest.html
--> 100.00%
OK, took 0.539 seconds, 3.858 KB/s
Sending local file mpy_support/examples/webserver/www/test.pyhtml to /flash/www/test.pyhtml
--> 100.00%
OK, took 0.044 seconds, 14.650 KB/s
Sending local file mpy_support/examples/webserver/www/python.ico to /flash/www/python.ico
--> 100.00%
OK, took 1.049 seconds, 3.991 KB/s
Sending local file mpy_support/examples/webserver/www/favicon.ico to /flash/www/favicon.ico
--> 100.00%
OK, took 0.455 seconds, 4.801 KB/s
back to device ]--
>>>
--[mpTerm command: ls /flash/www
List of directory '/flash/www/':
--------------------------------
favicon.ico <file> 2238 2019-07-03 14:47:24
index.html <file> 1122 2019-07-03 14:47:10
pdf-sample.pdf <file> 7945 2019-07-03 14:47:11
pdf.png <file> 4551 2019-07-03 14:47:14
python.ico <file> 4286 2019-07-03 14:47:22
style.css <file> 457 2019-07-03 14:47:17
test.pyhtml <file> 666 2019-07-03 14:47:20
wstest.html <file> 2128 2019-07-03 14:47:18
back to device ]--
>>> os.listdir('/flash/www')
['favicon.ico', 'index.html', 'pdf-sample.pdf', 'pdf.png', 'python.ico', 'style.css', 'test.pyhtml', 'wstest.html']
>>>
- Maix-M1 schematic
- Maix-Bit schematic
- Maix-Go schematic
- Kendryte K210 datasheet
- RISC-V ISA Design
- RISC-V ISA Manual
- Forum
- MicroPython documentation
If you find this project useful, you can contribute by making a donation