|
2 | 2 |
|
3 | 3 |
|
4 | 4 | > This MicroPython port is now in a stable phase, but some bugs and issues can be expected, please report<br>
|
5 |
| -> All standard MicroPython functionality and modules are implemented, as well as advanced thread support, file system support and display module.<br> |
| 5 | +> All standard MicroPython functionality and modules are implemented, as well as advanced thread support, file system support, display module, nettwork, enhanced K210 peripheral support ...<br> |
6 | 6 | > *Modules providing support for still unsupported K210 peripherals will be implemented soon*
|
7 | 7 | >
|
8 | 8 |
|
9 |
| -<br> |
| 9 | +*** |
| 10 | + |
| 11 | +> For discussion about this MicroPython port please wisit the [dedicated Forum](https://loboris.eu/forum/forumdisplay.php?fid=17) |
| 12 | +
|
| 13 | + |
| 14 | +*** |
| 15 | + |
| 16 | +This implementation was based on Sipeed [**MaixPy**](https://github.com/sipeed/MaixPy), but it deverged from it and is now a completely independent project.<br> |
10 | 17 |
|
11 |
| -This implementation is based on [**MaixPy**](https://github.com/sipeed/MaixPy)<br> |
12 |
| -Based on *kendryte-freertos-sdk* (modified to include some needed features not yet implemented) it brings many new features: |
| 18 | +### Main features: |
13 | 19 |
|
14 |
| -* MicroPython core based on latest release build from [main Micropython repository](https://github.com/micropython/micropython), unchanged except for the thread support and other changes needed to work with 64-bit RISC-V. |
15 |
| -* Running **two** independent Micropython instances on two K210 cores is supported.<br>Data exchange between instances is supported. |
| 20 | +* Based on **kendryte-freertos-sdk**, modified to include some needed features not yet implemented and enhenced drivers support |
| 21 | +* **MicroPython core** based on **latest release** build from [main Micropython repository](https://github.com/micropython/micropython)<br>Unchanged except for the *thread* support and other changes needed to work with 64-bit RISC-V. |
| 22 | +* Running **two** independent **Micropython instances** on **two K210 cores** is supported.<br>Rich set of functions for data exchange between instances is provided. |
16 | 23 | * Refactored **_thread** module with many new features, based on my [MicroPython for ESP32](https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/thread) _thread module
|
17 |
| -* Full support for **LittleFS** on internal Flash.<br>SPIFFS is also supported (with directories support) and can be selected when building. |
18 |
| -* Full support for Fat32 file system on external SD Card |
19 |
| -* Full filesystem timestamp support for LittleFS, SPIFFS and Fat32 |
| 24 | +* Full support for **LittleFS** as default file system on internal Flash.<br>SPIFFS is also supported (with directories support) and can be selected when building. |
| 25 | +* Full support for Fat32 file system on **external SD Card** |
| 26 | +* Full **file timestamp** support for LittleFS, SPIFFS and Fat32 |
| 27 | +* **uart** module, compatible with the uart module on my ESP32 port<br>buffered, interrupt based input with callbacks on events |
| 28 | +* **Pin** module, compatible with the Pin module on my ESP32 port |
| 29 | +* **i2c** module, **master** & **slave**, compatible with the i2c module on my ESP32 port<br>SSD1306 module provided as MicroPython frozen module |
| 30 | +* **spi** module, **master** & **slave**, compatible with the spi module on my ESP32 port with added slave support |
| 31 | +* **WS2812** (neopyxel) support, using **spi** module |
20 | 32 | * **ymodem** module for file transfer to/from K210 board using ymodem protocol is provided
|
21 | 33 | * **uhashlib** and **ucryptolib** using K210 hardware AES are implemented
|
22 |
| -* **Display** module ported from my [MicroPython for ESP32] |
23 |
| -(https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/display) display module |
| 34 | +* **Display** module ported from my [MicroPython for ESP32](https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/display) display module<br>Rich set of drawing methods, direct write or **framebuffer**, *jpeg*, *bmp* and *raw* image format<br>Flexible fonts support (fixed width and proportional) with user fonts loadable from file (online *Font creator* provided) |
24 | 35 | * Full **network** support for **WiFi** (based on ESP8266/ESP8285) and **GSM** modules.
|
25 |
| -* **sqlite3** support |
26 |
| -* **pye**, full screen file editor (as python frozen module) is provided |
| 36 | + * My own **ESP8266/ESP8285 firmware** is provided with enhanced features and OTA firmware update support |
| 37 | + * **PPPoS** support for GSM modules |
| 38 | + * full **SMS** support for GSM modules with collbacks on SMS receive |
| 39 | + * flexible and feature rich **AT command** method is provided for both WiFi and GSM modules |
| 40 | + * Full MicroPython **socket module** compatibility, with some additional features. FTP Server and Web Server examples are available. |
| 41 | + * **urequests** module (written in C) supporting all http request methods, http and https ( SSL/TLS, on WiFi, only) |
| 42 | + * Full featured **mqtt module** (written in C) with callbacks on all events |
| 43 | + * **FTP Server** and **Web Server** provided as **frozen modules** |
| 44 | +* **usqlite3** module, data base on internal flash or SD Card, in-memory database supported |
| 45 | +* **Boot menu**, invoked by external pin, is provided which can help solve some issues.<br>Options to prevent loading of *boot.py* and/or *main.py*, force format of the internal file system, load the default configuation ... |
| 46 | +* Many **configuration options** can be configured directly from MicroPython: |
| 47 | + * running two MicroPython instances |
| 48 | + * heap and stack sizes |
| 49 | + * using PyStack |
| 50 | + * default CPU frequency |
| 51 | + * default REPL baudrate |
| 52 | + * boot menu pin |
| 53 | + * default log level |
| 54 | + * using ansi colors |
| 55 | + * MicroPython VM divisor |
| 56 | +* **pye**, full screen file editor (as MicroPython **frozen module**) is provided |
27 | 57 | * **MPyTerm**, serial terminal emulator specially designed for MicroPython is provided.<br>
|
28 | 58 | Included are commands to syncronize MicroPython time from PC, change the REPL baudrate, transfer files to/from MicroPython filesystem (including transfering whole directories).<br>Fast block file transfer is used, protected with CRC.
|
29 |
| -* **Eclipse** project files included.<br>To include it into Eclipse goto `File->Import->Existing Projects into Workspace->Select root directory->[select *MicroPython_K210_LoBo* directory]->Finish`. **Rebuild index**. |
| 59 | +* **Eclipse** project files included.<br>To include it into Eclipse goto:<br> `File->Import->General->Existing Projects into Workspace`<br>`Select root directory` [select *MicroPython_K210_LoBo* directory]<br>`Finish`.<br>Rebuild index<br>Execute `Index->Freshen All Files`. |
30 | 60 | * Many modules from my [MicroPython for ESP32](https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki) port are already ported, porting some others is planned.
|
31 | 61 | * _More to come soon ..._
|
32 | 62 |
|
33 | 63 | <br>
|
34 | 64 |
|
35 |
| -**Wiki pages** with detailed instructions for build and usage are provided.<br>_Missing documentation will be available soon._ |
| 65 | +*** |
36 | 66 |
|
37 |
| ---- |
| 67 | +This MicroPython port was tested on **Sipeed's MAIX** boards.<br> |
| 68 | +Here are some links to the distributors: |
38 | 69 |
|
39 |
| -### How to Build |
| 70 | +[Seed](https://www.seeedstudio.com/sipeed)<br> |
| 71 | +[AnalogLamb](https://www.analoglamb.com/product/sipeed-maix-bit-for-risc-v-aiiot-with-lcdcamera-development-board/)<br> |
| 72 | +[Banggood](https://www.banggood.com/search/sipeed.html?sbc=1) (prices to high)<br><br> |
| 73 | +It should also work on [Kendryte KD233](https://www.analoglamb.com/product/dual-core-risc-v-64bit-k210-ai-board-kendryte-kd233/), probably with some modifications, but it was not tested. |
40 | 74 |
|
41 | 75 | ---
|
42 | 76 |
|
43 |
| -## Clone the MicroPython repository |
44 |
| - |
45 |
| -``` |
46 |
| -git clone https://github.com/loboris/MicroPython_K210_LoBo.git |
47 |
| -``` |
48 |
| - |
49 |
| -<br> |
50 |
| - |
51 |
| -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.<br> |
52 |
| -You will not be able to use `git pull` to update the repository, but otherwise the building process is the same. |
53 |
| -<br><br> |
54 |
| - |
55 |
| -## Build the MicroPython firmware |
56 |
| -<br> |
57 |
| - |
58 |
| -> _**Kendryte toolchain** will be automatically downloaded and unpacked on **first run** of **BUILD.sh** script.<br> It can take some time on slow Internet connection (~32 MB will be downloaded)._<br> |
59 |
| -> _**kendryte-freertos-sdk** is included in the repository._ |
60 |
| -
|
61 |
| - |
62 |
| -Change the working directory to **MicroPython_K210_LoBo/k210-freertos**. |
63 |
| - |
64 |
| -To build the MicroPython firmware, run: |
65 |
| -``` |
66 |
| -./BUILD.sh |
67 |
| -``` |
68 |
| - |
69 |
| -To flash the built firmware to your K210 board, run: |
70 |
| -``` |
71 |
| -./kflash.py -p /dev/ttyUSB0 -b 2000000 -t MaixPy.bin |
72 |
| -``` |
73 |
| - |
74 |
| -Change */dev/ttyUSB0* to the port used to connect to the your board if needed. |
| 77 | +For build instructions see the [Wiki](https://github.com/loboris/MicroPython_K210_LoBo/wiki/build). |
75 | 78 |
|
76 | 79 | ---
|
77 |
| - |
78 |
| -```console |
79 |
| -M (1371) [MAIXPY]: Configuration loaded from flash |
80 |
| -M (9298) [MAIXPY]: Heaps: FreeRTOS=3840 KB (1196 KB free), MPy=2560 KB, other=379 KB |
81 |
| - |
82 |
| - __ __ _____ __ __ _____ __ __ |
83 |
| -| \/ | /\ |_ _| \ \ / / | __ \ \ \ / / |
84 |
| -| \ / | / \ | | \ V / | |__) | \ \_/ / |
85 |
| -| |\/| | / /\ \ | | > < | ___/ \ / |
86 |
| -| | | | / ____ \ _| |_ / . \ | | | | |
87 |
| -|_| |_| /_/ \_\ |_____| /_/ \_\ |_| |_| |
88 |
| ------------------------------------------------------- |
89 |
| - |
90 |
| -MaixPy-FreeRTOS by LoBo v1.11.3 |
91 |
| -------------------------------- |
92 |
| -MicroPython 1.11.3 (c593f64-dirty) built on 2019-07-03; Sipeed_board with Kendryte-K210 |
93 |
| -Type "help()" for more information. |
94 |
| ->>> |
95 |
| ->>> help('modules') |
96 |
| -__main__ io sys upip_utarfile |
97 |
| -_thread json time upysh |
98 |
| -array machine ubinascii urandom |
99 |
| -binascii math ucollections ure |
100 |
| -board microWebSocket ucryptolib uselect |
101 |
| -builtins microWebSrv uctypes usocket |
102 |
| -cmath microWebTemplate uerrno ustruct |
103 |
| -collections micropython uftpserver utime |
104 |
| -display network uhashlib utimeq |
105 |
| -font10 os uheapq uzlib |
106 |
| -font6 pye uio writer |
107 |
| -framebuf re ujson ymodem |
108 |
| -freesans20 socket uos |
109 |
| -gc ssd1306 upip |
110 |
| -Plus any modules on the filesystem |
111 |
| ->>> |
112 |
| ->>> |
113 |
| -paste mode; Ctrl-C to cancel, Ctrl-D to finish |
114 |
| -=== import _thread, utime, machine, gc, micropython, os |
115 |
| -=== |
116 |
| -=== def test(led, sleep_time=3000): |
117 |
| -=== notif_exit = 4718 |
118 |
| -=== ld = machine.Pin(led, machine.Pin.OUT) |
119 |
| -=== ld.value(1) |
120 |
| -=== while 1: |
121 |
| -=== notif = _thread.getnotification() |
122 |
| -=== if notif == notif_exit: |
123 |
| -=== print("[{}] Exiting".format(_thread.getSelfName())) |
124 |
| -=== ld.value(1) |
125 |
| -=== utime.sleep_ms(100) |
126 |
| -=== return |
127 |
| -=== elif notif == 777: |
128 |
| -=== print("[{}] Forced EXCEPTION".format(_thread.getSelfName())) |
129 |
| -=== ld.value(1) |
130 |
| -=== utime.sleep_ms(1000) |
131 |
| -=== zz = 234 / 0 |
132 |
| -=== utime.sleep_ms(sleep_time) |
133 |
| -=== ld.value(0) |
134 |
| -=== utime.sleep_ms(200) |
135 |
| -=== ld.value(1) |
136 |
| -=== |
137 |
| -=== th1 = _thread.start_new_thread("Test1", test, (machine.Pin.LEDR, 2000)) |
138 |
| -=== #utime.sleep_ms(1000) |
139 |
| -=== th2 = _thread.start_new_thread("Test2", test, (machine.Pin.LEDG, 2500)) |
140 |
| -=== #utime.sleep_ms(1000) |
141 |
| -=== th3 = _thread.start_new_thread("Test3", test, (machine.Pin.LEDB, 3300)) |
142 |
| -=== |
143 |
| ->>> |
144 |
| ->>> _thread.list() |
145 |
| - |
146 |
| -Total system run time: 144.678 s, number of tasks running: 7 |
147 |
| -MicroPython threads: |
148 |
| -------------------------------------------------------------------------------------------------------------------- |
149 |
| -ID(handle) Proc Name State Stack Used MaxUsed PyStack Used Type Priority Run time (s) (%) |
150 |
| -------------------------------------------------------------------------------------------------------------------- |
151 |
| -2148930632 0 Test3 running 8192 3216 3464 4096 128 PYTHON 8 0.346 0.24 |
152 |
| -2148915528 0 Test2 running 8192 3216 3464 4096 128 PYTHON 8 0.353 0.24 |
153 |
| -2148900424 0 Test1 running 8192 3216 3576 4096 128 PYTHON 8 0.363 0.25 |
154 |
| -2151627528 0 MainThread* running 32768 2080 2664 4096 64 MAIN 8 0.709 0.49 |
155 |
| - |
156 |
| -FreeRTOS tasks running: |
157 |
| -------------------------------------------------------------------------------- |
158 |
| -ID(handle) Proc Name State MinStack Priority Run time (s) (%) |
159 |
| -------------------------------------------------------------------------------- |
160 |
| -2151627528 0 main_mp_task Running 30104 15 0.709 0.49 |
161 |
| -2148915528 0 Test2 Ready 4728 8 0.353 0.24 |
162 |
| -2148900424 0 Test1 Ready 4616 8 0.363 0.25 |
163 |
| -2148930632 0 Test3 Ready 4728 8 0.346 0.24 |
164 |
| -2152821640 0 IDLE Ready 7416 0 142.885 98.76 |
165 |
| -2152823752 1 IDLE Ready 7416 0 0.000 0.00 |
166 |
| -2148967032 0 hal_tick_task Blocked 7432 1 0.001 0.00 |
167 |
| -------------------------------------------------------------------------------- |
168 |
| -FreeRTOS heap: Size: 3932160, Free: 1210808, Min free: 1189024 |
169 |
| - |
170 |
| ->>> |
171 |
| ->>> machine.mpy_config() |
172 |
| - |
173 |
| -Current MicroPython configuration: |
174 |
| ----------------------------------- |
175 |
| - MPy version code: 011103 |
176 |
| -Two MPy instances: False |
177 |
| - PyStack used: True |
178 |
| - MPy#1 heap size: 2560 KB |
179 |
| - MPy#2 heap size: 0 KB |
180 |
| - PyStack size: 4096 B |
181 |
| - MPy stack size: 32768 B |
182 |
| - CPU frequency: 400 MHz |
183 |
| - REPL baudrate: 115200 bd |
184 |
| - But menu pin: 17 |
185 |
| -Default log level: 2 (LOG_WARN) |
186 |
| - VM divisor: 32 |
187 |
| -(False, True, 2621440, 0, 4096, 32768, 400000000, 115200, 17, 2, 32) |
188 |
| ->>> |
189 |
| ->>> machine.reset_reason() |
190 |
| -(8, 'External pin reset') |
191 |
| ->>> |
192 |
| ->>> |
193 |
| ---[mpTerm command: synctime |
194 |
| -OK. |
195 |
| -back to device ]-- |
196 |
| - |
197 |
| ->>> os.mkdir('/flash/www') |
198 |
| ->>> |
199 |
| ---[mpTerm command: senddir mpy_support/examples/webserver/www /flash/www |
200 |
| -Sending local file mpy_support/examples/webserver/www/index.html to /flash/www/index.html |
201 |
| - |
202 |
| ---> 100.00% |
203 |
| -OK, took 0.271 seconds, 4.040 KB/s |
204 |
| -Sending local file mpy_support/examples/webserver/www/pdf-sample.pdf to /flash/www/pdf-sample.pdf |
205 |
| - |
206 |
| ---> 100.00% |
207 |
| -OK, took 1.884 seconds, 4.118 KB/s |
208 |
| -Sending local file mpy_support/examples/webserver/www/pdf.png to /flash/www/pdf.png |
209 |
| - |
210 |
| ---> 100.00% |
211 |
| -OK, took 1.060 seconds, 4.192 KB/s |
212 |
| -Sending local file mpy_support/examples/webserver/www/style.css to /flash/www/style.css |
213 |
| - |
214 |
| ---> 100.00% |
215 |
| -OK, took 0.025 seconds, 18.044 KB/s |
216 |
| -Sending local file mpy_support/examples/webserver/www/wstest.html to /flash/www/wstest.html |
217 |
| - |
218 |
| ---> 100.00% |
219 |
| -OK, took 0.539 seconds, 3.858 KB/s |
220 |
| -Sending local file mpy_support/examples/webserver/www/test.pyhtml to /flash/www/test.pyhtml |
221 |
| - |
222 |
| ---> 100.00% |
223 |
| -OK, took 0.044 seconds, 14.650 KB/s |
224 |
| -Sending local file mpy_support/examples/webserver/www/python.ico to /flash/www/python.ico |
225 |
| - |
226 |
| ---> 100.00% |
227 |
| -OK, took 1.049 seconds, 3.991 KB/s |
228 |
| -Sending local file mpy_support/examples/webserver/www/favicon.ico to /flash/www/favicon.ico |
229 |
| - |
230 |
| ---> 100.00% |
231 |
| -OK, took 0.455 seconds, 4.801 KB/s |
232 |
| -back to device ]-- |
233 |
| - |
234 |
| ->>> |
235 |
| ---[mpTerm command: ls /flash/www |
236 |
| - |
237 |
| -List of directory '/flash/www/': |
238 |
| --------------------------------- |
239 |
| - favicon.ico <file> 2238 2019-07-03 14:47:24 |
240 |
| - index.html <file> 1122 2019-07-03 14:47:10 |
241 |
| - pdf-sample.pdf <file> 7945 2019-07-03 14:47:11 |
242 |
| - pdf.png <file> 4551 2019-07-03 14:47:14 |
243 |
| - python.ico <file> 4286 2019-07-03 14:47:22 |
244 |
| - style.css <file> 457 2019-07-03 14:47:17 |
245 |
| - test.pyhtml <file> 666 2019-07-03 14:47:20 |
246 |
| - wstest.html <file> 2128 2019-07-03 14:47:18 |
247 |
| -back to device ]-- |
248 |
| - |
249 |
| ->>> os.listdir('/flash/www') |
250 |
| -['favicon.ico', 'index.html', 'pdf-sample.pdf', 'pdf.png', 'python.ico', 'style.css', 'test.pyhtml', 'wstest.html'] |
251 |
| ->>> |
252 |
| - |
253 |
| -``` |
0 commit comments