kopia lustrzana https://github.com/peterhinch/micropython-samples
Improvements to fastbuild scripts
rodzic
4fccd6763c
commit
978de56438
85
README.md
85
README.md
|
@ -1,6 +1,65 @@
|
|||
# micropython-samples
|
||||
A place for assorted code ideas for MicroPython. Most are targeted at the Pyboard variants.
|
||||
|
||||
## fastbuild - Pull and build Pyboard firmware under Linux
|
||||
These scripts are intended to speed and simplify rebuilding firmware from
|
||||
source notably where pyboards of different types are in use, or when
|
||||
frozen bytecode necessitates repeated compilation and deployment. In
|
||||
particular ``buildpyb`` will detect the attached Pyboard type, build the
|
||||
appropriate firmware, put the board into DFU mode and deploy it, before
|
||||
launching ``rshell``. The latter step may be removed if ``rshell`` is not
|
||||
in use.
|
||||
|
||||
Includes udev rules to avoid jumps from ``/dev/ttyACM0`` to ``/dev/ttyACM1``
|
||||
by ensuring Pyboards of all types appear as ``/dev/pyboard``. Rules are also
|
||||
offered for USB connected WiPy (V1.0) and FTDI USB/serial adaptors.
|
||||
|
||||
These scripts use Python scripts ``pyb_boot`` to put the Pyboard into DFU mode
|
||||
and ``pyb_check`` to determine the type of attached board. These use the
|
||||
``pyboard.py`` module in the source tree to execute scripts on the attached
|
||||
board.
|
||||
|
||||
### Edits
|
||||
|
||||
``buildnew`` and ``buildpyb`` will need editing to point to your micropython
|
||||
directory.
|
||||
|
||||
In the ``buildpyb`` script you may wish to edit the ``-j 8`` argument to ``make``.
|
||||
This radically speeds build on a multi core PC. Empirically 8 gave the fastest
|
||||
build on my core i7 4/8 core laptop: adjust to suit your PC. You may also want
|
||||
to alter the call to ``rshell``.
|
||||
|
||||
The script assumes a frozen modules directory ``stmhal/modules``. You may wish
|
||||
to change this. A recent update enabled the directory for frozen to be located
|
||||
anywhere in the filesystem.
|
||||
|
||||
In ``buildpyb`` you may wish to delete the unix make commands.
|
||||
|
||||
### Dependencies
|
||||
|
||||
Python3.x
|
||||
pyserial ``apt-get install python3-serial``.
|
||||
Verify that ``pyboard.py`` in the tools directory of the source tree works
|
||||
(tests in comments at the start of the code).
|
||||
Copy ``49-micropython.rules`` to (on most distros) ``/etc/udev/rules.d``.
|
||||
|
||||
### Build script: ``buildpyb``
|
||||
This checks the attached pyboard. If it's a V1.0, V1.1 or Lite it builds the
|
||||
correct firmware and deploys it. Otherwise it produces an error message.
|
||||
|
||||
Optional argument ``--clean`` - if supplied does a ``make clean`` to delete
|
||||
all files produced by the previous build before proceeding.
|
||||
|
||||
### Update source: ``buildnew``
|
||||
|
||||
Report state of master branch, update sources and issue ``make clean`` for cross
|
||||
compiler, Pyboard variants, and ESP8266. Builds cross compiler and unix port.
|
||||
|
||||
### ESP8266 Build
|
||||
|
||||
``buildesp`` A script to build and deploy ESP8266 firmware. Accepts optional
|
||||
``--clean`` argument.
|
||||
|
||||
## ssd1306
|
||||
|
||||
A means of rendering multiple larger fonts to the SSD1306 OLED display
|
||||
|
@ -28,30 +87,6 @@ Raise an exception if a firmware build is earlier than a given date.
|
|||
## timed_function
|
||||
Time a function's execution using a decorator
|
||||
|
||||
## fastbuild - Pyboard use under Linux
|
||||
Build MicroPython with your frozen bytecode, put the Pyboard into DFU mode, and
|
||||
deploy the build to the board with a single command. Takes just over 60 seconds
|
||||
on a fast PC. Note the use of make's j argument to use mutliple cores.
|
||||
Empirically 8 gave the fastest build on my core i7 4/8 core laptop: adjust to
|
||||
suit your PC.
|
||||
|
||||
Includes udev rules to avoid jumps from /dev/ttyACM0 to /dev/ttyACM1: ensures
|
||||
Pyboards of all types appear as /dev/pyboard. Also rules for USB connected WiPy
|
||||
and FTDI USB/serial adaptor.
|
||||
|
||||
Improved build script: ``buildpyb``
|
||||
This checks the attached pyboard. If it's a V1.0, V1.1 or Lite it builds the
|
||||
correct firmware and deploys it. Otherwise it produces an error message. It uses
|
||||
the supplied ``pyb_check`` utility which depends on ``pyboard.py`` being on the
|
||||
path. Install (from micropython/tools) and test first.
|
||||
|
||||
Optional argument ``--clean`` - if supplied does a ``make clean``. Strongly
|
||||
recommended after pulling new sourcecode.
|
||||
|
||||
There are a couple of site specifics here. ``pyb_check`` assumes the udev rule
|
||||
above is applied to put the device on ``/dev/pyboard``. ``buildpyb`` assumes a
|
||||
frozen modules directory ``stmhal/modules``. Modify to suit.
|
||||
|
||||
## ESP8266
|
||||
benchmark.py Tests the performance of MQTT by periodically publishing while subscribed to
|
||||
the same topic. Measures the round-trip delay. Adapt to suit your server address and desired
|
||||
|
@ -76,7 +111,7 @@ to provide a pull up or pull down as required.
|
|||
|
||||
Any code placed here is released under the MIT License (MIT).
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2015 Peter Hinch
|
||||
Copyright (c) 2016 Peter Hinch
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#! /bin/bash
|
||||
# Detect pyboard variant build and deploy
|
||||
# Detect attached pyboard variant build and deploy
|
||||
# Assumes only one device attached and that this will appear as /dev/pyboard (udev rule)
|
||||
# requires pyb_check
|
||||
# Also requires the pyboard utility to be on the path
|
||||
# Also requires the pyboard.py utility to be on the path (micropython/tools/pyboard.py)
|
||||
|
||||
DIRECTORY='/mnt/qnap2/data/Projects/MicroPython/micropython/stmhal'
|
||||
BOARD=""
|
||||
if pyb_check PYBV11
|
||||
then
|
||||
|
@ -16,11 +18,11 @@ if pyb_check PYBLITEV10
|
|||
then
|
||||
BOARD="PYBLITEV10"
|
||||
fi
|
||||
echo $BOARD
|
||||
echo Building for $BOARD
|
||||
|
||||
if [ $BOARD ]
|
||||
then
|
||||
cd /mnt/qnap2/data/Projects/MicroPython/micropython/stmhal
|
||||
cd $DIRECTORY
|
||||
if [ $# -eq 1 ] && [ $1 = "--clean" ]
|
||||
then
|
||||
make BOARD=$BOARD clean
|
||||
|
|
Ładowanie…
Reference in New Issue