2021-12-06 23:06:23 +08:00
2021-11-24 11:10:16 +08:00
2021-12-06 09:50:46 +08:00
2021-12-05 23:39:22 +08:00
2021-12-06 22:56:07 +08:00
2021-11-29 17:10:21 +08:00
2021-11-28 22:29:25 +08:00
2021-09-26 09:10:22 +08:00
2021-10-05 12:23:46 +08:00
2021-11-16 08:40:53 +08:00
2021-11-26 00:00:41 +08:00
2021-12-05 22:13:32 +08:00
2021-12-04 10:22:35 +08:00
2021-12-05 15:24:22 +08:00
2021-12-06 23:06:23 +08:00

logo

PikaScript

Cross platform ultra lightweight embedded Python engine

中文页 | Forum | Documents | Videos | Package Manager

1. Abstract

PikaScript is an ultra-lightweight Python engine with zero dependencies and zero-configuration, that can run with 4KB of RAM and 32KB of flash (such as STM32G030C8 and STM32F103C8).

It's very easy to bind C function to python module with the help of Pika Pre-compiler.

【Video】PikaScript hand by hand

Get PikaScript:

Use Pika package manager PikaPackage.exe

  1. Run the PikaPackage.exe directly, then the pikascript repo would be downloaded auto in the /tmp/pikascript folder of your current disc partition.

  2. Add requestment.txt to the same folder of PikaPackage.exe then run PikaPackage.exe. The run-time core, pre-compiler and moudles would be installed in the current folder.

  3. Released modulespackages.toml

Quick Start

You can use simulation project to quick start without hardwareor use the out-of-the-box develop board Pika-Pi—Zero.

image

The board based on STM32G030C8T6 MCU, only 64kB Flash, 8kB RAM can run PikaScript with total peripheral device (GPIO、TIME、IIC、RGB、KEY、LCD、RGB). CH340 is deployed to support USB to serial with Type-C USB, support download python script py serial, there are 4 RGB on the board and support the LCD.

Document

1. PikaScript-Quick start within 3 minutes

2. PikaScript-Architecture and principle

3. PikaScript-Deploy within 10 minutes

4. PikaScript-Standard develop workflow

5. PikaScript-Demo show

6. Arm-2D simulation

Folders

src - core code

bsp - mcu/board support

port - OS support

document - developt document

examples - example scripts

package - packages and moudles

pikaCompiler - pre-compiler write by Rust, used to bind C function to python moudle.

pikaPackageManager - pacakge manager

2.Platform support

MCU/Board bsp gpio uart pwm adc i2c spi rgb lcd arm-2d
PikaPi Zero
stm32g030c8
stm32g070cB
stm32f103c8
ch32v103r8t6
QEMU
cm32m101a
w801
apm32f030r8
apm32e103vb
bl-706

3.Characteristic

(1)Run environment

Support run in mcu without OS or file system. Can run in everywhere with RAM ≥ 4kB and FLASH ≥ 32kBsuch as stm32g030, stm32f103c8t6esp8266.

(2)Develop enviroment

Support run and program python scripts by serial.

微信交流群

Support IDEs like Keil, IAR, rt-thread studio and segger embedded studio to develop C moudle.

Support build tools like CMake, makeFile and Scons.

Zero dependencies, zero configuration, out-of-the-box, easy to integrated into privious C projcet.

Eazy to extern customized C moudles.

Support linux.

(3)Syntax

Support subaggregate of python 3 standard syntax.

Support class and method define, encapsulation-inheritance-polymorphism and moudles in compile time - Based on Pika Pre-compiler.

Support method invoke, argument define, new object, free object, control flow(if\while) and operator ( + - * / < == > ). - Based on Pika Runtime Core.

Syntax Compile-Time Run-Time
Class Define
Class Inherit
Method Define
Method Override
Method Invoke
Module Import
Argument Define
Argument Assignment
Object New
Object Free
Object Nest

Operator

+ - * / == > < >= <= % ** // != & >> << and or not += -= *= /=

Control flow

if while for else elif break continue

(4)Develop standard.

Readability first, nearly never use macro function and global argument.

Complete unit testes based on google test.

4.Both talk and show the code

E-mail: liang6516@outlook.com

Tencent QQ 645275593

5.Contribute

Content Contributer
QEMU simulation with ARM-2D liuduanfei
DonateGD32E103TB muc 2 pic 信息牛(WeChat)
Rt-thread bsp template Meco Jianting Man
DonateEC600S-CN 4G module 移远模块
DonateBL706 board 博流智能 bouffalolab
DonateCM32M101A board 孟巍(WeChat)
DonateAPM32F030R8 board 极海半导体 陈成
DonateAPM32E103VB board 极海半导体 陈成
DonateAPEX-Link debugger 极海半导体 陈成
format codeadd gitattribute Meco Jianting Man
demo/simulation-keil 千帆(WeChat)
demo/stm32f103zet6/demo01-led-stm32f103zet6 甜航
demo/stm32f103zet6/demo02-led-stm32f103zet6_tworoot 甜航
demo/stm32f407zgt/demo01-led-stm32f407vgt 甜航

6.Test and develop Core

Test core in linux(ubuntu20.04 is recommend)

step1: Clone the repo

git clone https://github.com/pikastech/pikascript
cd pikascript/port/linux

step2: Compile the project

sh init.sh # Only nedded in the first time.
sh make.sh # Compile the project.

step3: Run the unit tests.

sh gtest.sh

step4: Run the banchmark

sh test-banchmark.sh

step5: Run the demo

./build/src/boot/demo06-pikamain/pikascript_demo06-pikamain

7.Demo

The scripts in demos are in the examples folder.

Demo 01 GPIO

mmexport1631351506111

Hnet-image (2)

Demo 02 USART

mmexport1631351902469

Hnet-image (3)

Demo 03 ADC

mmexport1631351527609

mmexport1631351523907

Demo 04 PWM output

image

Demo 05 RGB

image

The maximum RAM usage of these demos is only 3.56K, which is 4.56K if the 1K stack is included, and the maximum Flash usage is 30.4K. Refer to the 20K RAM and 64K Flash of STM32F103C8T6, less than 25% RAM and less than 50% Flash are used.

A quick comparison can be made between the microPython chip STM32F405RG and the PikaScript chip STM32G070CB.

RAM resource comparison

image

Flash Resource Comparison

image

Reference price comparison (take the selling price of 10 pieces in Lichuang Mall on September 11, 2021 as reference)

image

About the custom extern module

In addition to device drivers, developing custom Python modules for MCU is very easy. The following two demos are extensions of the custom module, which developed python interfaces for the ARM-2D image driver library.

Boxes~

Hnet-image (7)

Rotating suns~

Hnet-image (6)

Description
No description provided
Readme MIT 277 MiB
Languages
C 97.9%
Assembly 0.9%
Python 0.6%
C++ 0.2%
Shell 0.1%
Other 0.1%