2.2. Use BSP project
2.2.1. create project
Enter pikascript official website http://pikascript.com Select the platform, module, and click “Start Build”. (The default module will be automatically selected after selecting the platform)
2.2.2. The source of the project
The transplanted bare metal MCU project is in the pikascript/bsp directory, and each folder in it is a transplanted bare metal project.
Each project is independent and can be copied out of the pikascript repository for separate use.
(simulation-keil-dev and pico-dev are not listed. These two bsp can only be used in the warehouse and are used to develop the kernel.)
2.2.3. Support list
In the README.md in the bsp folder, the current platform support and the usage of bsp are marked.
(The table below is not up-to-date)
You can help PikaPython extend this table by contributing driver modules or bsp, please refer to the New Platform Porting Guide, Module Development and Package Management in the documentation for details.
2.2.4. Projcet structure
Taking CH32V103 as an example, a PikaPython project includes the following parts.
The first is the part of the BSP folder except the PikaPython folder. This part is the real BSP, including the basic peripheral library provided by the manufacturer, CMSIS and other common libraries on some platforms. You can get it sorted.
The above part is the launcher of PikaPython, including the main.c entry file, the pika_config.c configuration file, and the *.s assembly startup file. The launcher is responsible for supporting printf, stack settings, the startup of PikaPython, as well as some functions such as interactive operation, serial port download of Python, etc.
pika_config.c is used to support some advanced functions such as downloading Python through serial port. PikaPython can still run without this file.
The above is the main part of PikaPython, which is divided into two parts: the kernel and the module. The kernel is the file in pikascript/src. You can choose a version and add it to compile. No modification is required.
Module part can be developed by yourself, or pulled from the warehouse, PikaStdLib standard library module is required. Other modules are optional.
For how to use modules and how to make modules, please refer to the Module Development section, and for how to contribute modules to the PikaPython reference, please refer to the How to contribute PikaPython modules section.
The top layer is the Python script that the PikaPython project can support. The Python script can be directly interpreted and run. There are various ways to load the script, including pre-compiled into firmware, interactive operation, serial port download of Python scripts, etc., pre-compiled For firmware, please refer to the Module Development section, and for interactive operation and serial port download, please refer to the New Platform Porting section.
Only modules imported in main.py will be compiled into the firmware, so main.py can also play the role of trimming modules.
2.2.5. module management
Launchers, kernels and modules can all be managed using the package manager.
Therefore, the PikaPython folder in the BSP only contains the package manager pikaPackage.exe itself, the requestment.txt module description file and the main.py sample script three files.
requestment.txt uses the same module description syntax as general python. Running pikaPackage.exe directly can identify requestment.txt in the current folder and pull the corresponding module.
Taking requestment.txt in the bsp of stm32g030 as an example, the pulled modules are:
Standard library: PikaStdLib
Peripheral module: STM32G0 PikaPiZero PikaStdDevice
pikascript-core==v1.10.0 PikaStdLib PikaStdDevice==v1.6.0 STM32G0==v1.2.0 PikaPiZero==v1.1.3
The pulled module needs to be precompiled, just run rust-msc-latest-win10.exe directly.
Keil version strongly recommended not lower than 5.36