Code Monkey home page Code Monkey logo

maixpy-v1's Introduction




Master branch build status master build firmware Latest release version License
Good first issues Bug issues Enhancement issues

中文



Let's Sipeed up, Maximize AI's power!

MaixPy, makes AIOT easier!

Maixpy is designed to make AIOT programming easier, based on the Micropython syntax, running on a very powerful embedded AIOT chip K210.

There are many things you can do with MaixPy, please refer to here

K210 brief:

  • Image Recognition with hardware AI acceleration
  • Dual core with FPU
  • 8MB(6MB+2MB) RAM
  • 16MB external Flash
  • Max 800MHz CPU freq (see the dev board in detail, usually 400MHz)
  • Microphone array(8 mics)
  • Hardware AES SHA256
  • FPIOA (Periphrals can map to any pins)
  • Peripherals: I2C, SPI, I2S, WDT, TIMER, RTC, UART, GPIO etc.

maix bit

Simple code

Find I2C devices:

from machine import I2C

i2c = I2C(I2C.I2C0, freq=100000, scl=28, sda=29)
devices = i2c.scan()
print(devices)

Take picture:

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)

Use AI model to recognize object:

import KPU as kpu
import sensor

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((224, 224))

model = kpu.load("/sd/mobilenet.kmodel")  # load model
while(True):
    img = sensor.snapshot()               # take picture by camera
    out = kpu.forward(task, img)[:]       # inference, get one-hot output
    print(max(out))                       # print max probability object ID

please read doc before run it

Release

See Releases page

Get latest commit firmware: master firmware

Custom your firmware, see build or use online custom tool

Documentation

Doc refer to maixpy.sipeed.com

Examples

MaixPy_scripts

Build From Source

See build doc

The historic version see historic branch (No longer maintained, just keep commit history)

Use online compilation tools to customize firmware

Go to maixhub.com to use online compilation to customize the functions you need

Model hub: Maixhub.com

Find more models on Maixhub.com

License

See LICENSE file

Other: As C SDK for C developers

In addition to the source code of the MaixPy project, since MaixPy exists as a component, it can be configured to not participate in compilation, so this repository can also be developed as C SDK. For the usage details, see Building Documentation, which can be started by compiling and downloading projects/hello_world.

The compilation process is briefly as follows:

wget http://dl.cdn.sipeed.com/kendryte-toolchain-ubuntu-amd64-8.2.0-20190409.tar.xz
sudo tar -Jxvf kendryte-toolchain-ubuntu-amd64-8.2.0-20190409.tar.xz -C /opt
cd projects/hello_world
python3 project.py menuconfig
python3 project.py build
python3 project.py flash -B dan -b 1500000 -p /dev/ttyUSB0 -t

maixpy-v1's People

Contributors

chahatdeep avatar chegewara avatar ganhailin avatar h1msk avatar happyme531 avatar hugoender avatar hwang215 avatar jepler avatar junhuanchen avatar kartben avatar lbuque avatar lixin7 avatar lowlevel-1989 avatar marstechhan avatar mongonta0716 avatar mtikekar avatar neutree avatar nongxiaoming avatar sanxml avatar smuehlst avatar strfarfar avatar takeru avatar trekmax avatar usthzhanglu avatar valerio-vaccaro avatar vamoosebbf avatar vowstar avatar xelll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maixpy-v1's Issues

canny edge error: core dump, breakpoint

Problem

use find_edges() function, the error message core dump: breakpoint appear occasionally.

Dev Environment

  • MaixPy Firmware: v0.2.4
  • MaixPy Board: Dan Dock
  • OS: Ubuntu 18.04

Test Code

import sensor
import image
import lcd
import time

# Init LCD
lcd.init()
# Init Sensor
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
# resolution: 320 * 240
sensor.set_framesize(sensor.QVGA)
sensor.run(1)

while True:
    img=sensor.snapshot()
    img_gray = img.to_grayscale(copy=True)
    img_gray.find_edges(image.EDGE_CANNY, threshold=(0,100))
    lcd.display(img_gray)

Error Message

core dump: breakpoint
Cause 0x0000000000000003, EPC 0x00000000800d21d8
reg[00](zero ) = 0x0000000000000000, reg[01](ra   ) = 0x00000000800d2048
reg[02](sp   ) = 0x000000008039e580, reg[03](gp   ) = 0x00000000801c42a0
reg[04](tp   ) = 0x0000000000000000, reg[05](t0   ) = 0x000000000000005a
reg[06](t1   ) = 0x00000000000000df, reg[07](t2   ) = 0x0000000000000087
reg[08](s0/fp) = 0x000000008042b650, reg[09](s1   ) = 0x000000008039e880
reg[10](a0   ) = 0x00000000000000de, reg[11](a1   ) = 0x00000000000000dd
reg[12](a2   ) = 0x00000000000116b8, reg[13](a3   ) = 0x0000000000000138
reg[14](a4   ) = 0x000000000000ffff, reg[15](a5   ) = 0x0000000000000000
reg[16](a6   ) = 0x0000000000011580, reg[17](a7   ) = 0x0000000000000138
reg[18](s2   ) = 0x0000000000011580, reg[19](s3   ) = 0x0000000000000064
reg[20](s4   ) = 0x0000000000000140, reg[21](s5   ) = 0x000000000000ffff
reg[22](s6   ) = 0x0000000080471130, reg[23](s7   ) = 0x0000000000000138
reg[24](s8   ) = 0x00000000801c6fa8, reg[25](s9   ) = 0x0000000000000000
reg[26](s10  ) = 0x000000000000001d, reg[27](s11  ) = 0x0000000000012980
reg[28](t3   ) = 0x000000000000007b, reg[29](t4   ) = 0x00000000000000de
reg[30](t5   ) = 0x000000000000002d, reg[31](t6   ) = 0xffffffffffffffff
freg[00](ft0 ) = 0x0000000000000000(), freg[00]() = 0x00000000801bb818()
freg[02](ft2 ) = 0x0000000000000000(), freg[00]() = 0x00000000801bb828()
freg[04](ft4 ) = 0x0000000000000000(), freg[00]() = 0x00000000801bb838()
freg[06](ft6 ) = 0x0000000000000000(), freg[00]() = 0x00000000801bb848()
freg[08](fs0 ) = 0x0000000043340000(), freg[00]() = 0x00000000801bb870()
freg[10](fa0 ) = 0x3f80000000000000(), freg[00]() = 0x00000000801bb8a0()
freg[12](fa2 ) = 0x3f80000000000000(), freg[00]() = 0x00000000801bb8c8()
freg[14](fa4 ) = 0x4000000093c42d18(), freg[00]() = 0x00000000801bb8d8()
freg[16](fa6 ) = 0x4000000000000000(), freg[00]() = 0x00000000801bb8e8()
freg[18](fs2 ) = 0x0000000000000000(), freg[00]() = 0x00000000801bb910()
freg[20](fs4 ) = 0x0000000000000000(), freg[00]() = 0x00000000801bb920()
freg[22](fs6 ) = 0x0000000000000000(), freg[00]() = 0x00000000801bb930()
freg[24](fs8 ) = 0x0000000000000000(), freg[00]() = 0x00000000801bb940()
freg[26](fs10) = 0x0000000000000000(), freg[00]() = 0x00000000801bb950()
freg[28](ft8 ) = 0x0000000000000000(), freg[00]() = 0x00000000801bb978()
freg[30](ft10) = 0x0000000000000000(), freg[00]() = 0x00000000801bb988()
W (542489468919) SYSCALL: sys_exit called by core 0 with 0x539

Illegal instruction when connecting to network

When I try and connect to a wireless network, I get an illegal instruction, which crashes the K210 dumping registers and a hard reset is required.

This is using the 0.1.1 prerelease from github. Code below illustrates the problem:

>>> import network
>>> network.ESP8285.connect("ssid", "password")
core dump: illegal instruction
Cause 0x0000000000000002, EPC 0x0000000000000000
reg[00](zero ) = 0x0000000000000004, reg[01](ra   ) = 0x000000008007a138
reg[02](sp   ) = 0x00000000804c43b0, reg[03](gp   ) = 0x000000008014f068
reg[04](tp   ) = 0x00000000804bcbc0, reg[05](t0   ) = 0x0000000000000002
reg[06](t1   ) = 0x0000000080013c0c, reg[07](t2   ) = 0x0000000000000000
reg[08](s0/fp) = 0x0000000000000010, reg[09](s1   ) = 0x0000000000000000
reg[10](a0   ) = 0x0000000000000000, reg[11](a1   ) = 0x0000000080146a20
reg[12](a2   ) = 0x000000000000000a, reg[13](a3   ) = 0x00000000804c45bc
reg[14](a4   ) = 0x0000000000000000, reg[15](a5   ) = 0x0000000000000000
reg[16](a6   ) = 0x00000000800acf40, reg[17](a7   ) = 0x0000000000000002
reg[18](s2   ) = 0x0000000000000000, reg[19](s3   ) = 0x0000000000000000
reg[20](s4   ) = 0x00000000000000c0, reg[21](s5   ) = 0x0000000000000001
reg[22](s6   ) = 0x00000000000000b0, reg[23](s7   ) = 0x00000000800a88f0
reg[24](s8   ) = 0x0000000080158901, reg[25](s9   ) = 0x0000000000000000
reg[26](s10  ) = 0x0000000000000000, reg[27](s11  ) = 0x0000000000000000
reg[28](t3   ) = 0x0000000000000003, reg[29](t4   ) = 0x0000000000000002
reg[30](t5   ) = 0x0000000000000000, reg[31](t6   ) = 0x000000000000022a
freg[00](ft0 ) = 0x0000000000000000(), freg[00]() = 0x0000000080149420()
freg[02](ft2 ) = 0x0000000000000000(), freg[00]() = 0x0000000080149430()
freg[04](ft4 ) = 0x0000000000000000(), freg[00]() = 0x0000000080149440()
freg[06](ft6 ) = 0x0000000000000000(), freg[00]() = 0x0000000080149450()
freg[08](fs0 ) = 0x0000000000000000(), freg[00]() = 0x0000000080149478()
freg[10](fa0 ) = 0x4000000000000000(), freg[00]() = 0x00000000801494a8()
freg[12](fa2 ) = 0x41d8054ac0000000(), freg[1610612736]() = 0x00000000801494d0()
freg[14](fa4 ) = 0x41d8054ac0000000(), freg[1610612736]() = 0x00000000801494e0()
freg[16](fa6 ) = 0x0000000000000000(), freg[00]() = 0x00000000801494f0()
freg[18](fs2 ) = 0x0000000000000000(), freg[00]() = 0x0000000080149518()
freg[20](fs4 ) = 0x0000000000000000(), freg[00]() = 0x0000000080149528()
freg[22](fs6 ) = 0x0000000000000000(), freg[00]() = 0x0000000080149538()
freg[24](fs8 ) = 0x0000000000000000(), freg[00]() = 0x0000000080149548()
freg[26](fs10) = 0x0000000000000000(), freg[00]() = 0x0000000080149558()
freg[28](ft8 ) = 0x0000000000000000(), freg[00]() = 0x0000000080149580()
freg[30](ft10) = 0x0000000000000000(), freg[00]() = 0x0000000080149590()
W (9313734513) SYSCALL: sys_exit called by core 0 with 0x539

uos的文件路径问题

在文档里有说:
http://maixpy.sipeed.com/exploreMaixPy/uos/uos.html

“/”非常重要,记得写文件名的时候记得加入

实际上不加也可以, 在打开写入文件的时候, 文件路径不加”/“也可以, 感觉有点冗余。根路径下的文件操作不必要以/开头。或者是说固件已经解决了这个问题,文档还没更新?

name 'fm' isn't defined - when starting through boot.py

Try this simple code directly in console and it works fine

from Maix import GPIO
fm.register(board_info.LED_B, fm.fpioa.GPIO0)
led_r=GPIO(GPIO.GPIO0,GPIO.OUT)
led_r.value(0)

But when using this code in the boot.py, you get:

NameError: name 'fm' isn't defined

Using Maix Go and MicroPython v0.3.0-dirty on 2019-04-19

Small issue with ANSI colors

There is a small bug in using ANSI colors in Makefile files in test-offical-standardalone-dev branch.
In function mod_echo_func @echo -e "\033.... should be used, not @echo "\033.....
Also the @echo in the function should end with reseting the color with "\033[;0m".

BTW, very nice work on this branch.

How to flip the video?

When I mount the camera on the back the video on the screen seems reversed. When I pan right the video on screen moves left. Is there a way to flip the video at the driver level to correct for this? Oddly the same thing still happens even when I add sensor.set_hmirror(1). I think there's some funky accelerometer based flipping going on because when I rotate the screen the image orientation remains fixed. This is clever, but I think it needs a way to flip this logic when the camera is mounted on the back...

Also, the flipping is needed for face recognition to work. Normally face recognizer models do not work on upside down people. And you can see this happening. If I add a call to sensor.set_vflip(1) then the recognition starts working, but the image on the screen is flipped. So I have to flip twice, once before giving to recognizer, then again before display...

How to generate the "cfg.bin" and the "model.bin" file?

I'd like to try detecting other visual objects by replacing the model-related portion of the machine.face_detect() implementation. I saw that the "cfg.bin" and the "model.bin" data will be read in the init function in the "face_detect.c" file. I've tried Kendryte's model compiler and it can output an "model.bin" file. However, I don't know how to create the "cfg.bin" file. Could you tell me the correct way to generate these files?

OSERROR "boot.py" "init.py"

My platform is Sipeed M1W and its LCD display white screen after I burned the demo.
Then I built and compiled MaixPy and burned micropython.bin to the board but it's still white and display following message on the terminal.

Official Site:http://www.sipeed.com/
Wiki:http://maixpy.sipeed.com/
[MAIXPY]Pll0:freq:320666666
[MAIXPY]Pll1:freq:159714285
[MAIXPY]Flash:0xc8:0x17
[MAIXPY]:Spiffs Mount successful 
Traceback (most recent call last):
  File "boot.py", line 14, in <module>
  File "init.py", line 4, in <module>
OSError: [Errno 5] EIO

MicroPython d58620d on 2018-12-11; Sipeed_M1 with kendryte-k210
Type "help()" for more information.
>>> 

How to fix it?

image.binary() doesn't support rgb565 image

Problem

image.binary support grayscale image, but not support rgb565 image format.

Error Message

Traceback (most recent call last):
  File "<stdin>", line 35, in <module>
TypeError: function missing 1 required positional arguments

Code

import sensor
import image
import lcd
import time

BACKGROUND_COLOR = (61, 84, -8, 25, -12, 11)

# Init LCD
lcd.init()
# Init Sensor
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
# resolution: 320 * 240
sensor.set_framesize(sensor.QVGA)
sensor.run(1)

while True:
    img=sensor.snapshot()
    img_gray = img.to_grayscale(copy=True)
    img.binary(thresholds=[BACKGROUND_COLOR])
    lcd.display(img_gray)

Missing library 'time'

'import time' doesn't work.

This is a very important core module and makes me worried about what else is missing!

You can't do 'help("modules")' to get a list of what is there.

This is a nice board to use, but it is a problem if it does not have the functions I used to use.

MicroPython开发规范-machine模块

MicroPython的machine模块是为了兼容不同的硬件,提供统一的一套API,弱化不同硬件的差异。
machine模块应该只存放基础的硬件操作的API, 其他maixpy特有的功能硬件资源, 可以考虑单独创建一个模块叫做 maixpy

另外人脸检测的部分也不适合放在里面

module uos: Some file operations fail:

This is about the /flash file system:
uos.getcwd(): returns "/flash/flash" instead "/flash"
uos.stat("./boot.py"):

>>> os.stat("./boot.py")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 2] ENOENT

Version:
MicroPython v0.2.4 on 2019-04-05; Sipeed_M1 with kendryte-k210
Type "help()" for more information.

Couldn't compile: assesmbler error

Compiling breaks with a long list of errors, which start as follows:

/home/robert/Downloads/MicroPython/MaixPy/ports/k210-freertos/platform/sdk/kendryte-standalone-sdk/lib/bsp/crt.S: Assembler messages:
/home/robert/Downloads/MicroPython/MaixPy/ports/k210-freertos/platform/sdk/kendryte-standalone-sdk/lib/bsp/crt.S:79: Error: unrecognized opcode `fmv.d.x f0,x0'
/home/robert/Downloads/MicroPython/MaixPy/ports/k210-freertos/platform/sdk/kendryte-standalone-sdk/lib/bsp/crt.S:80: Error: unrecognized opcode `fmv.d.x f1,x0'
/home/robert/Downloads/MicroPython/MaixPy/ports/k210-freertos/platform/sdk/kendryte-standalone-sdk/lib/bsp/crt.S:81: Error: unrecognized opcode `fmv.d.x f2,x0'
/home/robert/Downloads/MicroPython/MaixPy/ports/k210-freertos/platform/sdk/kendryte-standalone-sdk/lib/bsp/crt.S:82: Error: unrecognized opcode `fmv.d.x f3,x0'
/home/robert/Downloads/MicroPython/MaixPy/ports/k210-freertos/platform/sdk/kendryte-standalone-sdk/lib/bsp/crt.S:83: Error: unrecognized opcode `fmv.d.x f4,x0'

I am using the most recent toolchain. Debian 9,
using an older copy of the toolchain, I get linker errors, starting with:

/home/robert/Downloads/MicroPython/kendryte-toolchain/bin/../lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: ./platform/api/lib_mic.a(lib_mic.c.obj): can't link hard-float modules with soft-float modules
/home/robert/Downloads/MicroPython/kendryte-toolchain/bin/../lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file ./platform/api/lib_mic.a(lib_mic.c.obj)
/home/robert/Downloads/MicroPython/kendryte-toolchain/bin/../lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: ./platform/api/lib_mic.a(lib_mic.c.obj): in function `mult_conj_norm':
/home/xel/Share/K210/kendryte-standalone-sdk/src/mic_array_lib/i2s/lib_mic.c:876: undefined reference to `__floatsidf'
/home/robert/Downloads/MicroPython/kendryte-toolchain/bin/../lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /home/xel/Share/K210/kendryte-standalone-sdk/src/mic_array_lib/i2s/lib_mic.c:877: undefined reference to `__floatsidf'
/home/robert/Downloads/MicroPython/kendryte-toolchain/bin/../lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /home/xel/Share/K210/kendryte-standalone-sdk/src/mic_array_lib/i2s/lib_mic.c:882: undefined reference to `__muldf3'

Face detector demo not working

the face detector demo from this page is not working on Maix Go.

>>> task=kpu.load(0xd00000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: [MAIXPY]kpu: load error -2

but the yolo demo works great, so I know my devkit is running ok.

sys.stdin.read() does not work as expected

sys.stdin.read(1) should return one char from the console when a key is pushed. Instead it returns a null-byte immediately. Similar, sys.stdin.read(n) returns a string of n null-bytes. This affects all related functions like sys.stdin.readline(), sys.stdin.readlines(), sys.stdin.readint() too.
input() also fails.

network模块的实现

建议使用network模块, 待大佬实现。
文档里wifi对象的创建是跟esp8285模块耦合的, 能不能通过network
创建呢? 弱化esp8285

wifi=machine.esp8285()
wifi.init("your_ssid","your_password")# 连接wifi。

ps: 文档里这两行错位了

core dump: misaligned load

Problem

When I try to use img.get_statistics() function,those error message appear occasionally.

Error Message

core dump: misaligned load
Cause 0x0000000000000004, EPC 0x00000000800fb2e4
reg[00](zero ) = 0x00000000801f8ea9, reg[01](ra   ) = 0x00000000800fb2cc
reg[02](sp   ) = 0x00000000803a8470, reg[03](gp   ) = 0x00000000801c8688
reg[04](tp   ) = 0x0000000000000000, reg[05](t0   ) = 0x0000000000000002
reg[06](t1   ) = 0x0000000000040000, reg[07](t2   ) = 0x0000000000000000
reg[08](s0/fp) = 0x00000000803a8fd0, reg[09](s1   ) = 0x0000000080435870
reg[10](a0   ) = 0x00000000801c74b8, reg[11](a1   ) = 0x000000000000043c
reg[12](a2   ) = 0x0000000080435c9c, reg[13](a3   ) = 0x0000000080435860
reg[14](a4   ) = 0x0000000000000001, reg[15](a5   ) = 0x000000000000043c
reg[16](a6   ) = 0x0000000080436080, reg[17](a7   ) = 0x000000000000006a
reg[18](s2   ) = 0x00000000801f7cb0, reg[19](s3   ) = 0x00000000803a8778
reg[20](s4   ) = 0x0000000000000001, reg[21](s5   ) = 0x00000000801f7b48
reg[22](s6   ) = 0x0000000000000002, reg[23](s7   ) = 0x0000000000002000
reg[24](s8   ) = 0x0000000000000000, reg[25](s9   ) = 0x00000000801f8558
reg[26](s10  ) = 0x0000000000000000, reg[27](s11  ) = 0x0000000000000000
reg[28](t3   ) = 0x000000000000010b, reg[29](t4   ) = 0x0000000000000000
reg[30](t5   ) = 0x0000000000003f40, reg[31](t6   ) = 0x0000000000001720
freg[00](ft0 ) = 0x3f80000100000000(), freg[00]() = 0x00000000801bf9c0()
freg[02](ft2 ) = 0x42c8000000000000(), freg[00]() = 0x00000000801bf9d0()
freg[04](ft4 ) = 0x461c400000000000(), freg[00]() = 0x00000000801bf9e0()
freg[06](ft6 ) = 0x418b6a7900000000(), freg[-1610612736]() = 0x00000000801bf9f0()
freg[08](fs0 ) = 0x467c040000000000(), freg[00]() = 0x00000000801bfa18()
freg[10](fa0 ) = 0x437f000040c00000(), freg[00]() = 0x00000000801bfa48()
freg[12](fa2 ) = 0x3ebd3e1e3ce38e3a(), freg[00]() = 0x00000000801bfa70()
freg[14](fa4 ) = 0x000000004068c7b3(), freg[-536870912]() = 0x00000000801bfa80()
freg[16](fa6 ) = 0x0000000000000000(), freg[00]() = 0x00000000801bfa90()
freg[18](fs2 ) = 0x44c5af5000000000(), freg[-536870912]() = 0x00000000801bfab8()
freg[20](fs4 ) = 0x432cb23600000000(), freg[-2147483648]() = 0x00000000801bfac8()
freg[22](fs6 ) = 0x425a082200000000(), freg[00]() = 0x00000000801bfad8()
freg[24](fs8 ) = 0x3b149b9300000000(), freg[-1073741824]() = 0x00000000801bfae8()
freg[26](fs10) = 0x3f80000000000000(), freg[00]() = 0x00000000801bfaf8()
freg[28](ft8 ) = 0x3f80000000000000(), freg[00]() = 0x00000000801bfb20()
freg[30](ft10) = 0x0000000000000000(), freg[00]() = 0x00000000801bfb30()
W (195642323830) SYSCALL: sys_exit called by core 0 with 0x539

Dev Environment

  • MaixPy Firmware: v0.3.0
  • MaixPy Board: Dan Dock
  • OS: Ubuntu 18.04

Code

'''
根据背景颜色阈值L通道,筛选出色块.
识别画面中不同颜色的色块及坐标.
把色块从画布坐标系转换为工作台坐标系.


连接maixpy 进入repl
 sudo picocom -b 115200 /dev/ttyUSB0
'''
import sensor
import image
import lcd
import time

# 注1:因为背景是白色,根据白色反射光的原理
# 通过LAB色彩空间的L通道(亮度)对色块进行筛选
# 注2:测试的时候需要外部灯光补光以获得更好的效果.
NOT_BACKGROUND_COLOR = (0, 32, -128, 127, -128, 127)

# BLOCK FEATURE : L_MEAN, A_MEAN, B_MEAN
REF_COLOR_BLOCK_STAT = {
    'GRAY': (41, 10, 6),
    'GREEN': (32, 6, 5),
    'RED': (43, 32, 11),
}
# Init LCD
lcd.init()
# Init Sensor
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
# resolution: 320*240
sensor.set_framesize(sensor.QVGA)
sensor.run(1)

while True:
    img=sensor.snapshot()
    # 设置ROI区域, 不识别Sipeed色块容器
    blobs = img.find_blobs([NOT_BACKGROUND_COLOR], merge=False, area_threshold=400, roi=(0, 0, 320, 180))
    if blobs:
        cnt = 0
        for b in blobs:
            cnt += 1
            print('\n\nBlob: {}\n'.format(cnt))
            # print(b)
            # if b.w()<30 or b.w()>40 or b.h()<30 or b.h()>40 or b.pixels() < 400:
            #     continue
            stat = img.get_statistics(roi=b[0:4])
            print("MEAN VALUE : L:{} A:{} B:{}".format(stat.l_mean(), stat.a_mean(), stat.b_mean()))
            print("MEDIAN VALUE : L:{} A:{} B:{}".format(stat.l_median(), stat.a_median(), stat.b_median()))
            print("MAX VALUE : L:{} A:{} B:{}".format(stat.l_max(), stat.a_max(), stat.b_max()))
            print("MIN VALUE : L:{} A:{} B:{}".format(stat.l_min(), stat.a_min(), stat.b_min()))
            tmp=img.draw_rectangle(b[0:4]) 
            tmp=img.draw_cross(b[5], b[6]) 
            c=img.get_pixel(b[5], b[6])
    lcd.display(img)

* [bug] ESP8285 connect/isConnected function do not work.

See below:

# MicroPython c23571e-dirty on 2019-03-03; Sipeed_M1 with kendryte-k210
import network
from machine import UART
fm.register(board_info.WIFI_RX,fm.fpioa.UART2_TX)
fm.register(board_info.WIFI_TX,fm.fpioa.UART2_RX)
uart = UART(UART.UART2,115200,timeout=1000, read_buf_len=4096)
nic=network.ESP8285(uart)
nic.connect("your_ssid","your_password.")
# report error: OSError: could not connect to ssid=yourssid, key=your-password
# but it's already successful.
nic.ifconfig()
# ('192.168.0.200', '255.255.255.0', '192.168.0.1', '0', '0', '00:16:17:7A:0B:0A', 'your-ssid')
# the ifconfig has alread get the ip.
nic.isconnected()
# false

os.stat('/flash/boot.py') returns ENOENT

I'm trying to get rshell working on th maixpy and I ran into the following issue.

I built the firmware following the instructions in the README.

Pressing Control-D at the REPL reports:

[MaixPy]: soft reboot
heap0=8012bdb0
[MaixPy] sd_init | SD_CMD0 is FF

 __  __              _____  __   __  _____   __     __
|  \/  |     /\     |_   _| \ \ / / |  __ \  \ \   / /
| \  / |    /  \      | |    \ V /  | |__) |  \ \_/ /
| |\/| |   / /\ \     | |     > <   |  ___/    \   /
| |  | |  / ____ \   _| |_   / . \  | |         | |
|_|  |_| /_/    \_\ |_____| /_/ \_\ |_|         |_|

Official Site : https://www.sipeed.com
Wiki          : https://maixpy.sipeed.com

MicroPython v0.1.1-114-g094cbf618 on 2019-03-18; Sipeed_M1 with kendryte-k210
Type "help()" for more information.

Here's a transcript from the REPL:

>>> import os
>>> os.listdir('/flash')
['/logo.bin', '/demo_pwm.py', '/demo_cam.py', '/demo_gpio.py', '/demo_lcd.py', '/PT.py', 'boot.py', '/demo_timer.py', '/init.py']
>>> os.stat('/flash/init.py')
(32768, 0, 0, 0, 0, 0, 723, 0, 0, 0)
>>> os.stat('/flash/boot.py')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 2] ENOENT

So the question is why does os.stat('/flash/boot.py') return ENOENT when os.listdir indicates that the file is actually there?

os.listdir()的问题

运行os.listdir()会有一些问题,但是增加了一个os.ls()命令,它的结果是正常的。能不能把这两个合二为一,只保留一个标准的os.listdir()。

change maixpy ide binary file name

Firstly, MaixPy IDE binary file should change from 'openmvide' to maixpyide.
After I install Maixpy IDE , OpenMV IDE examples has gone. So I think it's necessary to change file path.

machine.GPIO修改为machine.Pin

创建管脚的时候 类名建议与micropython兼容, 改用”Pin“

另外maixpy的board_info存放了一些管脚的映射, 这个是自定义的么?MicroPython的话, 建议放在Pin下。

Yolo Demo works great

I found this demo on your Chinese kph page, would be nice to get that on your English pages also. I saved this to flash using the MicroEditor:

from pye_mp import 
pye pye("demo.py")

and paste in the following, hit CTRL+S to save:

import sensor
import image
import lcd
import KPU as kpu


class YoloDemo():
    def run(self):
        lcd.init()
        sensor.reset()
        sensor.set_pixformat(sensor.RGB565)
        sensor.set_framesize(sensor.QVGA)
        sensor.run(1)
        self.task = kpu.load(0x00300000)
        anchor = (1.889, 2.5245, 2.9465, 3.94056, 3.99987,
                  5.3658, 5.155437, 6.92275, 6.718375, 9.01025)
        kpu.init_yolo2(self.task, 0.5, 0.3, 5, anchor)

        while(True):
            img = sensor.snapshot()
            code = kpu.run_yolo2(self.task, img)
            if code:
                for i in code:
                    print(i)
                    img.draw_rectangle(i.rect())
            lcd.display(img)

    def stop(self):
        kpu.deinit(self.task)

Then to run it do this:

import demo
d = demo.YoloDemo()
d.run()

Press Ctrl+C to stop it then run this to free up the memory:

d.stop()

image

Maix Go with putty on windows doesn't works

I using putty on windows to terminal to Maix Go with baudrate 115200N81 but when open port the LCD display on Maix Go it cleared the welcome message ("Welcome to MaixPy") then i cannot type any command on putty.

while if i upgrade the firmware with K-Flash finished it will automatically open serial port terminal, that i can use it to key any command such as help().

How can i fixed it to works with putty?

Add RNN layers

I want to use Maix board for some time series data analysis. Is there any plan to add RNN layers such as LSTM to MaixPy? That would be great.

Undefined reference to `pthread_setcancelstate'

During the compilation of the port, I get this error and I have no idear of how to solve it. I have used kendryte-gnu-toolchain and the official kendryte-toolchain-8.2 and I get the same error.

Do you have any idear of where this is comming from?

LINK micropython /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/libc.a(lib_a-vfiprintf.o): in function .L13':
vfprintf.c:(.text._vfiprintf_r+0x32): undefined reference to pthread_setcancelstate' /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/libc.a(lib_a-vfiprintf.o): in function .L15':
vfprintf.c:(.text._vfiprintf_r+0x76): undefined reference to pthread_setcancelstate' /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/libc.a(lib_a-vfiprintf.o): in function .L16':
vfprintf.c:(.text._vfiprintf_r+0x9a): undefined reference to pthread_setcancelstate' /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/libc.a(lib_a-vfiprintf.o): in function .L0 ':
vfprintf.c:(.text._vfiprintf_r+0x858): undefined reference to pthread_setcancelstate' /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/libc.a(lib_a-fflush.o): in function .L47':
fflush.c:(.text._fflush_r+0x24): undefined reference to pthread_setcancelstate' /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/kendryte-toolchain/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/libc.a(lib_a-fflush.o):fflush.c:(.text._fflush_r+0x3a): more undefined references to pthread_setcancelstate' follow
collect2: error: ld returned 1 exit status
`

CTRL-D crashes MaixPy

CTRL-D should do a soft reset of the board, and restart the code. Instead, I get the following report:

prower off
W (2100756768) SYSCALL: sys_exit called by core 0 with 0x0

And then the board hangs.

Couldn't compile k210-freertos: -latomic

I couldn't compile the port for k210-freertos because the compiler couldn't find '-latomic'. After some web searches it appears that this library isn't explicitly needed. Thus in the file MaixPy/ports/k210-freertos/k210.mk the reference to atomic can be removed. Then it compiles.

Compile instructions error

I think there is a small error in in compile instructions in README.md.

The Kendryte compiler path should be added to the $PATH & $LD_LIBRARY_PATH, like this

export PATH=$PATH:<path_to_kendryte-toolchain/bin>
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<path_to_kendryte-toolchain/bin>

Than make can be run with:

make CROSS_COMPILE=riscv64-unknown-elf-

Or the CROSS_COMPILE can also be exported: export CROSS_COMPILE=riscv64-unknown-elf-

At least, for me it works only this way. A simple bash file can be created for compiling:

#!/bin/bash
export PATH=$PATH:<path_to_kendryte-toolchain/bin>
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<path_to_kendryte-toolchain/bin>
export CROSS_COMPILE=riscv64-unknown-elf-
make

Trial image with some fixes

First of all: This is no bug report, just a hint!
In the past days I have commented to quite a few issues, and also made some patches to these issues. The changed code parts are available here: https://github.com/robert-hh/K210-Stuff
For those who do not like to build their own image, I also uploaded the latest image with these changes.
Flashing can be done following these instructions:
"In Windows, download K-Flash from https://kendryte.com/downloads/ , unzip and run K-Flash.exe
In K-Flash select the device’s port"
In Linux, use the command kflash.py from https://github.com/kendryte/kflash.py and https://github.com/kendryte/kendryte-flash-windows/blob/develop/src/Canaan.Kendryte.Flash/Resources/isp_flash.bin
' ./kflash.py -p /dev/ttyUSB0 -b 2000000 -l isp_flash.bin sipeedm1.kfpkg'

Restrict commits to k210-related port

It would be very helpful to keep this repository clean with only k210-related additions so it is possible to keep it in sync with the upstream.

The commit 12a5258 contains tons of code related to other ports (e.g. ports/esp32) which is unnecessary and annoying.

Relocation truncated during linking

The linking process fails after compiling using gcc:

LINK micropython
/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d/libm.a(lib_a-ef_exp.o): in function `.L4':
ef_exp.c:(.text+0x44): relocation truncated to fit: R_RISCV_HI20 against `.LC0'
/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d/libm.a(lib_a-s_asinh.o): in function `.L2':
s_asinh.c:(.text+0x32): relocation truncated to fit: R_RISCV_HI20 against `.LC0'
/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d/libm.a(lib_a-s_atan.o): in function `.L4':
s_atan.c:(.text+0x42): relocation truncated to fit: R_RISCV_HI20 against `.LC1'
/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d/libm.a(lib_a-s_ceil.o): in function `ceil':
s_ceil.c:(.text+0x2a): relocation truncated to fit: R_RISCV_HI20 against `.LC0'
/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d/libm.a(lib_a-s_erf.o): in function `erf':
s_erf.c:(.text+0x40): relocation truncated to fit: R_RISCV_HI20 against `.LC0'
/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d/libm.a(lib_a-s_expm1.o): in function `.L22':
s_expm1.c:(.text+0x4e): relocation truncated to fit: R_RISCV_HI20 against `.LC4'
/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d/libm.a(lib_a-s_floor.o): in function `floor':
s_floor.c:(.text+0x2a): relocation truncated to fit: R_RISCV_HI20 against `.LC0'
/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d/libm.a(lib_a-sf_nan.o): in function `nanf':
sf_nan.c:(.text+0x0): relocation truncated to fit: R_RISCV_HI20 against `.LC0'
/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d/libm.a(lib_a-s_frexp.o): in function `frexp':
s_frexp.c:(.text+0x30): relocation truncated to fit: R_RISCV_HI20 against `.LC0'
/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d/libm.a(lib_a-s_log1p.o): in function `log1p':
s_log1p.c:(.text+0x26): relocation truncated to fit: R_RISCV_HI20 against `.LC0'
/opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/8.2.0/../../../../riscv64-unknown-elf/lib/rv64imafdc/lp64d/libm.a(lib_a-s_log2.o): in function `log2':
s_log2.c:(.text+0x8): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Makefile:242: recipe for target 'micropython' failed
make[1]: *** [micropython] Error 1
make[1]: Leaving directory '/home/duranda/devel/kendryte/MaixPy/ports/k210-standalone'
Makefile:239: recipe for target 'all' failed
make: *** [all] Error 2

I use the latest official riscv-gnu-toolchain. I am supposed to use the kendryte-gnu-toolchain instead?

Cannot use rshell or ampy

This version of MicroPython is somehow not compatible with rshell nor ampy. These are tools for interacting with MicroPython's filesystem.

This might be related to non-standard debug output that confuse these tools.

If this issue should not be resolved, what is the most practical way to upload scripts to MaixPy?

有关board_info的问题

逐条语句进行输入的时候board_info.可以正常使用,但是在文件中使用就会出现NameError: name 'board_info' isn't defined,代码参考PWM的例程1

可以在MaixPy中編譯c/cpp的程式碼

剛接觸這塊領域不是很確定能不能問這類問題,
在MaixPy目錄底下有看到sdk想問是能直接編譯c語言的意思嗎?
如果可以的話想問問編譯方式或指令之類的

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.