diff --git a/README.md b/README.md index cb00316..38e8ae2 100644 --- a/README.md +++ b/README.md @@ -29,13 +29,28 @@ Raise an exception if a firmware build is earlier than a given date. 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. +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. +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 diff --git a/fastbuild/buildpyb b/fastbuild/buildpyb new file mode 100755 index 0000000..cd0c564 --- /dev/null +++ b/fastbuild/buildpyb @@ -0,0 +1,41 @@ +#! /bin/bash +# Detect pyboard variant build and deploy +# requires pyb_check +# Also requires the pyboard utility to be on the path + +BOARD="" +if pyb_check PYBV11 +then + BOARD="PYBV11" +fi +if pyb_check PYBV10 +then + BOARD="PYBV10" +fi +if pyb_check PYBLITEV10 +then + BOARD="PYBLITEV10" +fi +echo $BOARD + +if [ $BOARD ] +then + cd /mnt/qnap2/data/Projects/MicroPython/micropython/stmhal + if [ $# -eq 1 ] && [ $1 = "--clean" ] + then + make BOARD=$BOARD clean + fi + if make -j 8 BOARD=$BOARD FROZEN_MPY_DIR=modules && pyb_boot + then + sleep 1 + sudo make BOARD=$BOARD deploy + cd - + sleep 1 + rshell + else + echo Build failure + fi +else + echo Incorrect board type +fi + diff --git a/fastbuild/pyb_check b/fastbuild/pyb_check new file mode 100755 index 0000000..223a4aa --- /dev/null +++ b/fastbuild/pyb_check @@ -0,0 +1,31 @@ +#! /usr/bin/python3 +# -*- coding: utf-8 -*- + +# Called from buildpyb +# Arg: expected board type +# exit status 0 if hardware matches board type else 1 + +import sys +import os, os.path +import pyboard +device = '/dev/pyboard' +errmsg = 'Must supply board type PYBV10 PYBV11 PYBLITEV10' +d = {'PYBV11' : b'PYBv1.1', 'PYBV10' : b'PYBv1.0', 'PYBLITEV10' : b'PYBLITEv1.0'} +def main(): + if len(sys.argv) < 2: + print(errmsg) + sys.exit(1) + if not os.path.exists(device): + sys.exit(1) + pybd = pyboard.Pyboard('/dev/pyboard') + pybd.enter_raw_repl() + hardware = pybd.exec('import os; print(os.uname()[4].split(' ')[0])').strip() + pybd.exit_raw_repl() + board = d[sys.argv[1]] + if board == hardware: + sys.exit(0) + sys.exit(1) + +if __name__ == "__main__": + main() +