-
-
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.
git clone 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
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:
-v
build verbose (show some info during build)
-V
be more verbose
-jN
build using multiple threads, if set, the build will be much faster (N
=2~8)
Here is example of clone session:
boris@UbuntuMate:~$ git clone https://github.com/loboris/MicroPython_K210_LoBo.git
Kloniranje u 'MicroPython_K210_LoBo'...
remote: Enumerating objects: 112, done.
remote: Counting objects: 100% (112/112), done.
remote: Compressing objects: 100% (103/103), done.
remote: Total 2232 (delta 9), reused 53 (delta 6), pack-reused 2120
Primanje objekata: 100% (2232/2232), 36.72 MiB | 7.63 MiB/s, završeno.
Razrješavanja delta: 100% (812/812), završeno.
boris@UbuntuMate:~$ cd MicroPython_K210_LoBo/k210-freertos
boris@UbuntuMate:~/MicroPython_K210_LoBo/k210-freertos$ ./BUILD.sh
Downloading kendryte-toolchain, please wait ...
Unpacking kendryte-toolchain
'kendryte-toolchain' prepared, ready to build
===[ 'mklfs' created ]===
===[ BUILDING MicroPython FIRMWARE ]===
.
.
===[ Creating 'MaixPy.kfpkg' ]===
===[ kfpkg created ]===
------------------------------------------------
text data bss dec hex filename
1400486 45745 4007272 5453503 5336bf MaixPy
------------------------------------------------
============================
====== Build finished ======
version: 1.11.5
Firmware file size: 1454080
Flash FS starts at: 4194304
============================
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.
boris@UbuntuMate:~/MicroPython_K210_LoBo/k210-freertos$ ./BUILD.sh -V
===[ 'mklfs' created ]===
===[ BUILDING MicroPython FIRMWARE ]===
.
.
-----[ source k210_env ... ]-----
-----[ k210_env export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/boris/MicroPython_K210_LoBo/k210-freertos/../kendryte-toolchain/bin/ ... ]------
=====[ PLATFORM_MK ./mpy_support/k210.mk ./platform/drivers/k210.mk ./third_party/k210.mk ./third_party/spiffs/k210.mk ./k210.mk ]=====
=====[ Compiling docs mpy_support platform third_party ... ]=====
=====[ compile docs mpy_support platform third_party . ]=====
=====[ AllDirs ... ]======
=====[ drivers/ ]======
=====[ sdk/ ]======
=====[ CUR_DIR ... ]=====
-- Check for RISCV toolchain ...
-- Using /home/boris/MicroPython_K210_LoBo/k210-freertos/../kendryte-toolchain/bin RISCV toolchain
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/boris/MicroPython_K210_LoBo/k210-freertos/platform/sdk/build
Scanning dependencies of target hal
[ 3%] Built target hal
Scanning dependencies of target lwipcore
[ 65%] Built target lwipcore
...
...
=====[ update mk file ... ]=====
=====[ CUR_DIR ... ]======
GEN build/genhdr/mpversion.h
GEN build/genhdr/moduledefs.h
GEN build/genhdr/qstr.i.last
GEN build/genhdr/qstr.split
GEN build/genhdr/qstrdefs.collected.h
QSTR updated
GEN build/genhdr/qstrdefs.generated.h
CC ../../micropython/py/mpstate.c
CC ../../micropython/py/nlr.c
CC ../../micropython/py/nlrx86.c
CC ../../micropython/py/nlrx64.c
CC ../../micropython/py/nlrthumb.c
CC ../../micropython/py/nlrxtensa.c
CC ../../micropython/py/nlrsetjmp.c
CC ../../micropython/py/malloc.c
CC ../../micropython/py/gc.c
...
...
CC ../../micropython/lib/netutils/netutils.c
CC ../../micropython/lib/timeutils/timeutils.c
CC ../../micropython/lib/utils/sys_stdio_mphal.c
/home/boris/MicroPython_K210_LoBo/k210-freertos/../kendryte-toolchain/bin/riscv64-unknown-elf-objcopy --output-format=binary MaixPy MaixPy.bin
/home/boris/MicroPython_K210_LoBo/k210-freertos/../kendryte-toolchain/bin/riscv64-unknown-elf-size MaixPy
text data bss dec hex filename
1400486 45745 4007272 5453503 5336bf MaixPy
===[ Creating 'MaixPy.kfpkg' ]===
===[ kfpkg created ]===
------------------------------------------------
text data bss dec hex filename
1400486 45745 4007272 5453503 5336bf MaixPy
------------------------------------------------
============================
====== Build finished ======
version: 1.11.5
Firmware file size: 1454080
Flash FS starts at: 4194304
============================
boris@UbuntuMate:~/MicroPython_K210_LoBo/k210-freertos$
To flash the built firmware to your K210 board, run:
./kflash.py -p /dev/ttyUSB0 -b 2000000 -t MaixPy.bin
Change /dev/ttyUSB0 to the port used to connect to the your board if needed.
With -t
option, the MPyTerm
terminal emulator will be started and the board reseted after successful flash.
M (1371) [MAIXPY]: Configuration loaded from flash
M (9298) [MAIXPY]: Heaps: FreeRTOS=3840 KB (1196 KB free), MPy=2560 KB, other=379 KB
__ __ _____ __ __ _____ __ __
| \/ | /\ |_ _| \ \ / / | __ \ \ \ / /
| \ / | / \ | | \ V / | |__) | \ \_/ /
| |\/| | / /\ \ | | > < | ___/ \ /
| | | | / ____ \ _| |_ / . \ | | | |
|_| |_| /_/ \_\ |_____| /_/ \_\ |_| |_|
------------------------------------------------------
MaixPy-FreeRTOS by LoBo v1.11.4
-------------------------------
MicroPython 1.11.4 (ac4b72e-dirty) built on 2019-07-09; Sipeed_board with Kendryte-K210
Type "help()" for more information.
>>> help('modules')
__main__ io sys upip_utarfile
_thread json time upysh
array machine ubinascii urandom
binascii math ucollections ure
board microWebSocket ucryptolib uselect
builtins microWebSrv uctypes usocket
cmath microWebTemplate uerrno usqlite3
collections micropython uftpserver ustruct
display network uhashlib utime
font10 os uheapq utimeq
font6 pye uio uzlib
framebuf re ujson writer
freesans20 socket uos ymodem
gc ssd1306 upip
Plus any modules on the filesystem
>>>
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import _thread, utime, machine, gc, micropython, os
===
=== def test(led, sleep_time=3000):
=== notif_exit = 4718
=== ld = machine.Pin(led, machine.Pin.OUT)
=== ld.value(1)
=== while 1:
=== notif = _thread.getnotification()
=== if notif == notif_exit:
=== print("[{}] Exiting".format(_thread.getSelfName()))
=== ld.value(1)
=== utime.sleep_ms(100)
=== return
=== elif notif == 777:
=== print("[{}] Forced EXCEPTION".format(_thread.getSelfName()))
=== ld.value(1)
=== utime.sleep_ms(1000)
=== zz = 234 / 0
=== utime.sleep_ms(sleep_time)
=== ld.value(0)
=== utime.sleep_ms(200)
=== ld.value(1)
===
=== th1 = _thread.start_new_thread("Test1", test, (machine.Pin.LEDR, 2000))
=== #utime.sleep_ms(1000)
=== th2 = _thread.start_new_thread("Test2", test, (machine.Pin.LEDG, 2500))
=== #utime.sleep_ms(1000)
=== th3 = _thread.start_new_thread("Test3", test, (machine.Pin.LEDB, 3300))
===
>>>
>>> _thread.list()
Total system run time: 144.678 s, number of tasks running: 7
MicroPython threads:
-------------------------------------------------------------------------------------------------------------------
ID(handle) Proc Name State Stack Used MaxUsed PyStack Used Type Priority Run time (s) (%)
-------------------------------------------------------------------------------------------------------------------
2148930632 0 Test3 running 8192 3216 3464 4096 128 PYTHON 8 0.346 0.24
2148915528 0 Test2 running 8192 3216 3464 4096 128 PYTHON 8 0.353 0.24
2148900424 0 Test1 running 8192 3216 3576 4096 128 PYTHON 8 0.363 0.25
2151627528 0 MainThread* running 32768 2080 2664 4096 64 MAIN 8 0.709 0.49
FreeRTOS tasks running:
-------------------------------------------------------------------------------
ID(handle) Proc Name State MinStack Priority Run time (s) (%)
-------------------------------------------------------------------------------
2151627528 0 main_mp_task Running 30104 15 0.709 0.49
2148915528 0 Test2 Ready 4728 8 0.353 0.24
2148900424 0 Test1 Ready 4616 8 0.363 0.25
2148930632 0 Test3 Ready 4728 8 0.346 0.24
2152821640 0 IDLE Ready 7416 0 142.885 98.76
2152823752 1 IDLE Ready 7416 0 0.000 0.00
2148967032 0 hal_tick_task Blocked 7432 1 0.001 0.00
-------------------------------------------------------------------------------
FreeRTOS heap: Size: 3932160, Free: 1210808, Min free: 1189024
>>>
>>> machine.mpy_config()
Current MicroPython configuration:
----------------------------------
MPy version code: 011103
Two MPy instances: False
PyStack used: True
MPy#1 heap size: 2560 KB
MPy#2 heap size: 0 KB
PyStack size: 4096 B
MPy stack size: 32768 B
CPU frequency: 400 MHz
REPL baudrate: 115200 bd
But menu pin: 17
Default log level: 2 (LOG_WARN)
VM divisor: 32
(False, True, 2621440, 0, 4096, 32768, 400000000, 115200, 17, 2, 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