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
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -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
|
||||
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.
|
||||
appropriate firmware, put the board into DFU mode and deploy it.
|
||||
|
||||
The scripts should be run as your normal user and can proceed without user
|
||||
interaction.
|
||||
|
@ -79,8 +77,9 @@ Close and restart the terminal session before running the scripts.
|
|||
|
||||
### 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.
|
||||
This checks the attached pyboard. If it's a V1.0, V1.1 or Lite it or a Pyboard
|
||||
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
|
||||
all files produced by the previous build before proceeding.
|
||||
|
|
|
@ -7,20 +7,7 @@
|
|||
MPDEVICE='/dev/pyboard'
|
||||
|
||||
# Determine board type
|
||||
BOARD=""
|
||||
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
|
||||
BOARD=$(pyb_check $MPDEVICE)
|
||||
|
||||
# Check for user override of frozen directory
|
||||
if [ $FROZEN_DIR ]
|
||||
|
@ -32,6 +19,7 @@ fi
|
|||
|
||||
if [ $BOARD ]
|
||||
then
|
||||
echo Building for $BOARD
|
||||
cd $MPDIR/ports/stm32
|
||||
if [ $# -eq 1 ] && [ $1 = "--clean" ]
|
||||
then
|
||||
|
@ -40,13 +28,11 @@ then
|
|||
if make -j 8 BOARD=$BOARD FROZEN_MPY_DIR=$FROZEN_DIR && pyb_boot $MPDEVICE
|
||||
then
|
||||
sleep 1
|
||||
make BOARD=$BOARD FROZEN_MPY_DIR=$FROZEN_DIR deploy
|
||||
cd -
|
||||
sleep 1
|
||||
rshell
|
||||
make PYTHON=python3 BOARD=$BOARD deploy
|
||||
else
|
||||
echo Build failure
|
||||
fi
|
||||
cd -
|
||||
else
|
||||
echo Incorrect board type
|
||||
fi
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Called from buildpyb
|
||||
# Arg: expected board type
|
||||
# exit status 0 if hardware matches board type else 1
|
||||
# Arg: device (e.g. '/dev/pyboard')
|
||||
|
||||
import sys
|
||||
import os, os.path
|
||||
|
@ -11,26 +10,24 @@ mp = os.getenv('MPDIR')
|
|||
sys.path.append(''.join((mp, '/tools')))
|
||||
import pyboard
|
||||
|
||||
errmsg = 'Must supply board type PYBV10 PYBV11 PYBLITEV10'
|
||||
d = {'PYBV11' : b'PYBv1.1', 'PYBV10' : b'PYBv1.0', 'PYBLITEV10' : b'PYBLITEv1.0'}
|
||||
|
||||
device = os.getenv('MPDEVICE')
|
||||
|
||||
errmsg = 'Usage pyb_check device'
|
||||
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'}
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print(errmsg)
|
||||
print(errmsg, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
device = sys.argv[1]
|
||||
if not os.path.exists(device):
|
||||
print('Device {} does not exist'.format(device), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
pybd = pyboard.Pyboard(device)
|
||||
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 hardware in d:
|
||||
print(d[hardware])
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Ładowanie…
Reference in New Issue