1.2. Demo show

I want to run a Python with a microcontroller, I have to use linux virtual machine + cross-compilation tool chain + command line compile micropython firmware, but also have to use the DfuSe tool to burn the firmware, burned also can not use the C debugger to debug.

I want to expand a C module of my own, but I have to learn to use some completely unintelligible macro functions, and I have to register them manually, and I have to write makeFile, and I can’t debug C after compilation.

I am poor, can not afford to buy STM32F4, want to buy a STM32F103C8T6 micropython development board, Taobao a search, seems not.

Now the C8T6 is also expensive, I still want to use F0, use G0, with domestic chips, can it work?

It seems that it is not very easy to port micropython to G0.

So? Is there another way to play?

In other words, I want to develop with Keil, debug with Keil, and I want to use the cheapest microcontroller, and it’s very easy to develop C modules.

How about trying PikaScript?

What is PikaScript?

PikaScript provides extremely easy to deploy and extend Python scripting support for resource-constrained mcu. It doesn’t require an OS, it runs bare metal, and it doesn’t require a filesystem.

PikaScript supports bare-metal operation, at least for mcu with RAM ≥ 4kB and FLASH ≥ 32kB, the recommended configuration is RAM ≥ 10kB and FLASH ≥ 64kB, such as stm32f103c8t6 and stm32g070RBT6, which have no pressure at all and even meet the recommended configuration.

And support Keil, IAR, RT-Thread studio, segger embedded studio and other IDE development, zero dependencies, zero configuration, out-of-the-box, extremely easy to integrate into the existing C project.

These are all demos of STM32G070RBT6.

1.2.1. Demo 01 Light up

import PikaStdLib
import machine

mem = PikaStdLib.MemChecker()
io1 = machine.GPIO()
time = machine.Time()


print('hello pikascript')

while True:

Look at the script, it’s all Python3 standard syntax.

The light is flashing.


1.2.2. Demo 02 Serial port test

import PikaStdLib
import machine

time = machine.Time()
uart = machine.UART()

while True:
    readBuff = uart.read(2)
    print('read 2 char:')

Open a serial port and try to read two characters


very smooth

1.2.3. Demo 03 Try reading an ADC

import PikaStdLib
import machine

time = machine.Time()
adc1 = machine.ADC()


while True:
    val = adc1.read()
    print('adc1 value:')

Again a few lines of script fixes it.


This is the output result.

The maximum value of RAM occupied by these demos is only 3.56K, including the 1K stack is also 4.56K, the maximum Flash occupation is 30.4K, using the STM32F103C8T6’s 20K RAM and 64K Flash as the standard, RAM is only used up less than 25%, Flash is only used up less than 50%, simply more resources do not know how to spend. This is a lot of resources.

Also running Python, we can briefly compare the common chip STM32F405RG for micropython and the chip STM32G070CB for PikaScript.

1.2.4. RAM resource comparison


1.2.5. Flash resource comparison


1.2.6. Reference price comparison (take the price of 10 pieces of Lichuang Mall on September 11, 2021 as a reference)


1.2.7. How about the expansion ability?

In addition to device drivers, developing custom python script bindings for mcu is very easy with the pikascript development framework. The following two demos are custom C module extensions that develop some python script interfaces based on the ARM-2D image driver library.

1.2.8. A few small squares~


1.2.9. Several rotating suns~


1.2.10. So, is PikaScript open source?

Of course, this is the github home page of PikaScript: https://github.com/pikasTech/pikascript

1.2.11. Is it difficult to develop?

PikaScript has prepared rich demos and development guides from shallow to deep for developers, and the guides will continue to be improved and maintained.

1.2.12. Can it be commercialized?

Of course! PikaScript uses the MIT protocol and allows modifications and commercialization, but be careful to keep the original author’s byline.