This is the documentation for the latest development branch of MicroPython and may refer to features that are not available in released versions.

If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

Installing MicroPython

To support the MicroPython PSoC6™ port installation the mpy-psoc6 utility script is provided for Windows and Linux. Additionally, a python script is available also cross-platform for Linux and Windows.

Warning

The plan is to replace the native bash and cmd line scripts for Linux and Windows by executable programs generated for each OS (including MacOS) from the python script in future releases. New features in the installation utility will be only added to the executable and python script versions, as the native OS scripts will be deprecated in the future.

You can easily download them terminal with the following command:

Download the mpy-psoc6 utility script:

curl -s -L https://raw.githubusercontent.com/infineon/micropython/ports-psoc6-main/tools/psoc6/mpy-psoc6.py > mpy-psoc6.py

Make sure you have a recent version on Python3.x installed and the pip package installer. Then install the following packages:

pip install requests

Find all the available commands and options by running the script with the command help:

python mpy-psoc6.py --help

Quick Start

With the mpy-psoc6 utility script downloaded, the fastest way to get you up and running with micropython is to run the quick-start command of the script:

python mpy-psoc6.py quick-start

The command will take care of the following:

  • Install all required software to work with MicroPython

  • Deploy the latest version of MicroPython PSoC6 firmware on your board

  • Launch Arduino Lab MicroPython IDE

This command is supporting the getting started tutorial for the first time. Once you get familiar with MicroPython and its environment, the device-setup command will be more appropriate to install MicroPython on PSoC6™ boards, and upgrade your device with the latest firmware.

Device setup

In order to setup MicroPython in a PSoC6™ board, the device-setup command of the mpy-psoc6 can be executed. Follow the instructions to select the target PSoC6™ board, and deploy the latest MicropPython firmware version:

python mpy-psoc6.py device-setup

You can run any command any time you want to upgrade to the latest MicroPython firmware version. This command will take care of the following steps:

  • Download and install fw-loader, which will be used to update the board flasher firmware.

  • Download and install openocd, which is the software required to deploy a firmware file on PSoC6™ controllers

  • Download the latest .hex file for your select board

  • Deploy the latest version of MicroPython firmware on your board

Install a previous version

If you want to setup the device with a previous firmware version, you can check the list of available release in the GitHub release section.

The device-setup command can as well assist you with this process. In this case the board and the desired version need to be passed as arguments.

python mpy-psoc6.py device-setup -b CY8CPROTO-062-4343W -v v0.1.1

Warning

Be sure to provide the board name as shown in the device-setup command when run in interactive mode. Equally, provide a valid tag existing in the release section with the format v.x.y.z. No fail safe mechanisms or error verifications are (yet) implemented on the mpy-psoc6 utility, and the script will fail to retrieve the necessary firmware file.

Updating the flasher firmware

The evaluation PSoC6™ boards include an integrated hardware programmer tool using KitProg firmware. Some older boards will come preflashed with KitProg version 2. In MicroPython PSoC6™ port it is required to use KitProg version 3, and the setup process will fail for version 2.

By default, the device setup automatically updates the flasher firmware, ensuring compatibility with the rest of the flashing tools. If you want to skip the KitProg firmware update step, you can use the flag -s or --skip-fw-update during the device-setup process.

python mpy-psoc6.py device-setup -s

Warning

This option is only available in the python script utility.

Direct binary flashing

Another alternative to program the board is to directly provide the binary file. The firmware-deploy command is enabling this option. The board needs to be specified, and the path and name of the .hex file:

python mpy-psoc6.py firmware-deploy -b CY8CPROTO-062-4343W -f pathtodir/mpy-psoc6_CY8CPROTO-062-4343W.hex

Erasing the device (external) file system

Some PSoC6™ boards include an external flash memory which is used by the MicroPython file system. This memory will not be erased when reprogramming or erasing MicroPython firmware via device-setup or firmware-deploy. Use the device-erase command to erase of the external memory of your PSoC6™ device:

python mpy-psoc6.py device-erase

Warning

This command flashes the PSoC6™ controller with a custom program to delete the external memory. Thus, MicroPython will be removed from the microcontroller. Use any of the script commands described above to reinstall MicroPython.

Getting the firmware

The binary .hex files are available in the GitHub release section. All PSoC6™ firmware versions for each of the supported boards can be found there.

GitHub MicroPython Releases

Other installation methods

Cypress Programmer

Alternatively, you can use directly flash the firmware binary file with the Cypress Programmer It allows to program the PSoC6™ microcontrollers family in a few clicks from your Windows, Linux or Mac OS machine. Follow the instructions on the provided link to download and install the tool.

After that, select the downloaded MicroPython firmware .hex file to be deployed on the PSoC6™. Then, in the upper menu, select the connected Probe/Kit, click on Connect, and finally click on Program. The log section will show the progress and inform when the firmware deployment on the controller is completed.

Cypress Programmer GUI

For a detailed description on how to use the Cypress Programmer tool, please consult the Cypress Programmer User Guide.