kopia lustrzana https://github.com/peterhinch/micropython-samples
Build script buildpyb and pyb_check updated for Pyboard D
rodzic
508c7d2b32
commit
2632a4c1d9
|
@ -11,7 +11,7 @@ to simplify installation for users of official MicroPython firmware.
|
||||||
# Fastbuild
|
# Fastbuild
|
||||||
|
|
||||||
Scripts for building MicroPython for various target hardware types and for
|
Scripts for building MicroPython for various target hardware types and for
|
||||||
updating your local source. See [docs](./fastbuild/README.md)
|
updating your local source. Now detects and builds for Pyboard D. See [docs](./fastbuild/README.md)
|
||||||
|
|
||||||
# PicoWeb
|
# PicoWeb
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,7 @@ These scripts are intended to speed and simplify rebuilding firmware from
|
||||||
source notably where pyboards of different types are in use, or when
|
source notably where pyboards of different types are in use, or when
|
||||||
frozen bytecode necessitates repeated compilation and deployment. In
|
frozen bytecode necessitates repeated compilation and deployment. In
|
||||||
particular `buildpyb` will detect the attached Pyboard type, build the
|
particular `buildpyb` will detect the attached Pyboard type, build the
|
||||||
appropriate firmware, put the board into DFU mode and deploy it, before
|
appropriate firmware, put the board into DFU mode and deploy it.
|
||||||
launching `rshell`. The latter step may be removed if `rshell` is not in
|
|
||||||
use.
|
|
||||||
|
|
||||||
The scripts should be run as your normal user and can proceed without user
|
The scripts should be run as your normal user and can proceed without user
|
||||||
interaction.
|
interaction.
|
||||||
|
@ -79,8 +77,9 @@ Close and restart the terminal session before running the scripts.
|
||||||
|
|
||||||
### Build script: `buildpyb`
|
### Build script: `buildpyb`
|
||||||
|
|
||||||
This checks the attached pyboard. If it's a V1.0, V1.1 or Lite it builds the
|
This checks the attached pyboard. If it's a V1.0, V1.1 or Lite it or a Pyboard
|
||||||
correct firmware and deploys it. Otherwise it produces an error message.
|
D series 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
|
Optional argument `--clean` - if supplied does a `make clean` to delete
|
||||||
all files produced by the previous build before proceeding.
|
all files produced by the previous build before proceeding.
|
||||||
|
|
|
@ -7,20 +7,7 @@
|
||||||
MPDEVICE='/dev/pyboard'
|
MPDEVICE='/dev/pyboard'
|
||||||
|
|
||||||
# Determine board type
|
# Determine board type
|
||||||
BOARD=""
|
BOARD=$(pyb_check $MPDEVICE)
|
||||||
if pyb_check $MPDEVICE PYBV11
|
|
||||||
then
|
|
||||||
BOARD="PYBV11"
|
|
||||||
fi
|
|
||||||
if pyb_check $MPDEVICE PYBV10
|
|
||||||
then
|
|
||||||
BOARD="PYBV10"
|
|
||||||
fi
|
|
||||||
if pyb_check $MPDEVICE PYBLITEV10
|
|
||||||
then
|
|
||||||
BOARD="PYBLITEV10"
|
|
||||||
fi
|
|
||||||
echo Building for $BOARD
|
|
||||||
|
|
||||||
# Check for user override of frozen directory
|
# Check for user override of frozen directory
|
||||||
if [ $FROZEN_DIR ]
|
if [ $FROZEN_DIR ]
|
||||||
|
@ -32,6 +19,7 @@ fi
|
||||||
|
|
||||||
if [ $BOARD ]
|
if [ $BOARD ]
|
||||||
then
|
then
|
||||||
|
echo Building for $BOARD
|
||||||
cd $MPDIR/ports/stm32
|
cd $MPDIR/ports/stm32
|
||||||
if [ $# -eq 1 ] && [ $1 = "--clean" ]
|
if [ $# -eq 1 ] && [ $1 = "--clean" ]
|
||||||
then
|
then
|
||||||
|
@ -40,13 +28,11 @@ then
|
||||||
if make -j 8 BOARD=$BOARD FROZEN_MPY_DIR=$FROZEN_DIR && pyb_boot $MPDEVICE
|
if make -j 8 BOARD=$BOARD FROZEN_MPY_DIR=$FROZEN_DIR && pyb_boot $MPDEVICE
|
||||||
then
|
then
|
||||||
sleep 1
|
sleep 1
|
||||||
make BOARD=$BOARD FROZEN_MPY_DIR=$FROZEN_DIR deploy
|
make PYTHON=python3 BOARD=$BOARD deploy
|
||||||
cd -
|
|
||||||
sleep 1
|
|
||||||
rshell
|
|
||||||
else
|
else
|
||||||
echo Build failure
|
echo Build failure
|
||||||
fi
|
fi
|
||||||
|
cd -
|
||||||
else
|
else
|
||||||
echo Incorrect board type
|
echo Incorrect board type
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Called from buildpyb
|
# Called from buildpyb
|
||||||
# Arg: expected board type
|
# Arg: device (e.g. '/dev/pyboard')
|
||||||
# exit status 0 if hardware matches board type else 1
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os, os.path
|
import os, os.path
|
||||||
|
@ -11,26 +10,24 @@ mp = os.getenv('MPDIR')
|
||||||
sys.path.append(''.join((mp, '/tools')))
|
sys.path.append(''.join((mp, '/tools')))
|
||||||
import pyboard
|
import pyboard
|
||||||
|
|
||||||
errmsg = 'Must supply board type PYBV10 PYBV11 PYBLITEV10'
|
errmsg = 'Usage pyb_check device'
|
||||||
d = {'PYBV11' : b'PYBv1.1', 'PYBV10' : b'PYBv1.0', 'PYBLITEV10' : b'PYBLITEv1.0'}
|
d = {b'PYBv1.1' : 'PYBV11', b'PYBv1.0' : 'PYBV10', b'PYBLITEv1.0' : 'PYBLITEV10',
|
||||||
|
b'PYBD-SF2W' : 'PYBD_SF2', b'PYBD-SF3W' : 'PYBD_SF3', b'PYBD-SF6W' : 'PYBD_SF6'}
|
||||||
device = os.getenv('MPDEVICE')
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print(errmsg)
|
print(errmsg, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
device = sys.argv[1]
|
||||||
if not os.path.exists(device):
|
if not os.path.exists(device):
|
||||||
|
print('Device {} does not exist'.format(device), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
pybd = pyboard.Pyboard(device)
|
pybd = pyboard.Pyboard(device)
|
||||||
pybd.enter_raw_repl()
|
pybd.enter_raw_repl()
|
||||||
hardware = pybd.exec('import os; print(os.uname()[4].split(' ')[0])').strip()
|
hardware = pybd.exec('import os; print(os.uname()[4].split(' ')[0])').strip()
|
||||||
pybd.exit_raw_repl()
|
pybd.exit_raw_repl()
|
||||||
board = d[sys.argv[1]]
|
if hardware in d:
|
||||||
if board == hardware:
|
print(d[hardware])
|
||||||
sys.exit(0)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Ładowanie…
Reference in New Issue