Adsense HTML/JavaScript

Showing posts with label how to.Linux. Show all posts
Showing posts with label how to.Linux. Show all posts

Monday, March 8, 2021

Update PyBoard MicroPython firmware, run on Ubuntu 20.10.

Install dfu-util: 

Run in Terminal -

$ sudo apt install dfu-util

Download firmware:

To update MicroPython firmware, visit http://micropython.org/download/, select your board and download firmware for your board. ex. pybv11-20210308-unstable-v1.14-83-g680ce4532.dfu, latest firmware for PYBv1.1 boards.

Flash .dfu to pyboard:

Switch to the downloaded file folder.

Run the command:

$ sudo dfu-util --alt 0 -D <downloaded firmware .dfu> 




Friday, January 22, 2021

Flash CircuitPython to STM32F411, and install Thonny IDE on Ubuntu 20.10

This post show the steps to flash CircuitPython 6.1.0 to STM32F411 dev. board, and install Thonny IDE on Ubuntu 20.10. Tested on VirtualBox 6.1/Windows 10.

The target board is a STM32F411CEU6 minimum development board, it should be compatible with STM32F411CE Black Pill, I guess.

Visit CircuitPython Download page to download CircuitPython match your board. It's "STM32F411CE Black Pill" in my case.

Install dfu-util:
dfu-util is a program that implements the host (computer) side of the USB DFU (Universal Serial Bus Device Firmware Upgrade) protocol. DFU is intended to download and upload firmware to/from devices connected over USB. It ranges from small devices like micro-controller boards to mobile phones. Using dfu-util you can download firmware to your DFU-enabled device or upload firmware from it.

$ sudo apt install dfu-util

You can list the currently attached DFU capable USB devices with -l option:

$ sudo dfu-util -l

Flash downloaded CircuitPython bin to STM32F411:

$ sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D <circuitpython bin file>

After flashed, in my try, have to un-plug and re-plug the USB of the STM32F411 Dev.board, to make it recognized. A new driver "CIRCUITPY" appear.

Install Thonny IDE:

$ sudo apt-get install python3-pip
$ sudo pip3 install thonny
$ sudo apt install python3-tk

And add yourself to the 'dialout' group:

$ sudo usermod -a -G dialout <user>

After installed, you can run thonny by enter "thonny" in Terminal.

cpyHelloSTM32F411.py, the testing circuitpython code run in the video.
import os
import microcontroller
import board
import digitalio
import time

print(os.uname())
print()
print("microcontroller.cpu.frequency:\t\t" + str(microcontroller.cpu.frequency))
print("microcontroller.cpu.temperature:\t" + str(microcontroller.cpu.temperature))
print("microcontroller.cpu.voltage:\t\t" + str(microcontroller.cpu.voltage))

print("\ndir(board):")
print(dir(board))

led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT

while True:
    led.value = True   #LED Off
    time.sleep(0.3)
    led.value = False  #LED On
    time.sleep(0.3)
    led.value = True   #LED Off
    time.sleep(0.3)
    led.value = False  #LED On
    time.sleep(0.3)
    led.value = True   #LED Off
    time.sleep(0.3)
    led.value = False  #LED On
    time.sleep(1.5)


Extra remark about using USB Device Filters for VirtualBox:

You can create filters for specified USB devices. Matched USB devices will be automatically passed to the guest once they are attached to the host. Such that you need not manually pass to guest everytime the USB device attached.





Example of STM32F411/CircuitPython: 

More Exercise of STM32F411/CircuitPython 7:

Tuesday, June 23, 2020

Install Python 2 and pip on Ubuntu 20.04

In 20.04 LTS, the python included in the base system is Python 3.8. Python 2.7 has been moved to universe and is not included by default in any new installs. (ref: Ubuntu 20.04 LTS (Focal Fossa) release notes)


To install Python 2 on Ubuntu 20.04, it's easy as run the command:
$ sudo apt install python

But you cannot install pip using old approach! If you run the "sudo apt install python-pip", you will be report with "E: Unable to locate package python-pip".

To install pip for Python 2 on Ubuntu 20.04:

Visit https://bootstrap.pypa.io/ and download get-pip.py

Install with python:
$ sudo python get-pip.py

Sunday, October 27, 2019

Install Python 3.7 (and IDLE3) on Ubuntu 19.10

This post show how to install Python 3.7 and IDLE (the integrated development environment for Python) on Ubuntu 19.10. Tested on VirtualBox running over Windows 10.

By default, Python 3 is installed on Ubuntu 19.10, currently Python 3.7.5rc1. You can run the command to install it if it's not installed:
$ sudo apt install python3

To run Python 3, simple enter the command:
$ python3


But IDLE is not installed by default. To install it, enter the command:
$ sudo apt install idle3

or

$ sudo apt-get install idle3

After installed, you can run IDLE with the command:
$ idle