scripts: bossac: Support flashing at an offset.
The Adafruit SAMD51 boards use a combined BOSSA / U2F bootloader that resides in the first 16 KiB. Add support for pulling the application partition offset from the configuration and using that to offset where the binary gets flashed. Signed-off-by: Michael Hope <mlhx@google.com> Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
0f7456c3a0
commit
bde3224c91
1 changed files with 11 additions and 3 deletions
|
@ -4,9 +4,10 @@
|
||||||
|
|
||||||
'''bossac-specific runner (flash only) for Atmel SAM microcontrollers.'''
|
'''bossac-specific runner (flash only) for Atmel SAM microcontrollers.'''
|
||||||
|
|
||||||
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
from runners.core import ZephyrBinaryRunner, RunnerCaps
|
from runners.core import ZephyrBinaryRunner, RunnerCaps, BuildConfiguration
|
||||||
|
|
||||||
DEFAULT_BOSSAC_PORT = '/dev/ttyACM0'
|
DEFAULT_BOSSAC_PORT = '/dev/ttyACM0'
|
||||||
|
|
||||||
|
@ -14,10 +15,12 @@ DEFAULT_BOSSAC_PORT = '/dev/ttyACM0'
|
||||||
class BossacBinaryRunner(ZephyrBinaryRunner):
|
class BossacBinaryRunner(ZephyrBinaryRunner):
|
||||||
'''Runner front-end for bossac.'''
|
'''Runner front-end for bossac.'''
|
||||||
|
|
||||||
def __init__(self, cfg, bossac='bossac', port=DEFAULT_BOSSAC_PORT):
|
def __init__(self, cfg, bossac='bossac', port=DEFAULT_BOSSAC_PORT,
|
||||||
|
offset=0):
|
||||||
super(BossacBinaryRunner, self).__init__(cfg)
|
super(BossacBinaryRunner, self).__init__(cfg)
|
||||||
self.bossac = bossac
|
self.bossac = bossac
|
||||||
self.port = port
|
self.port = port
|
||||||
|
self.offset = offset
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def name(cls):
|
def name(cls):
|
||||||
|
@ -31,13 +34,17 @@ class BossacBinaryRunner(ZephyrBinaryRunner):
|
||||||
def do_add_parser(cls, parser):
|
def do_add_parser(cls, parser):
|
||||||
parser.add_argument('--bossac', default='bossac',
|
parser.add_argument('--bossac', default='bossac',
|
||||||
help='path to bossac, default is bossac')
|
help='path to bossac, default is bossac')
|
||||||
|
parser.add_argument('--offset', default=0,
|
||||||
|
help='start erase/write/read/verify operation '
|
||||||
|
'at flash OFFSET; OFFSET must be aligned '
|
||||||
|
' to a flash page boundary')
|
||||||
parser.add_argument('--bossac-port', default='/dev/ttyACM0',
|
parser.add_argument('--bossac-port', default='/dev/ttyACM0',
|
||||||
help='serial port to use, default is /dev/ttyACM0')
|
help='serial port to use, default is /dev/ttyACM0')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, cfg, args):
|
def create(cls, cfg, args):
|
||||||
return BossacBinaryRunner(cfg, bossac=args.bossac,
|
return BossacBinaryRunner(cfg, bossac=args.bossac,
|
||||||
port=args.bossac_port)
|
port=args.bossac_port, offset=args.offset)
|
||||||
|
|
||||||
def do_run(self, command, **kwargs):
|
def do_run(self, command, **kwargs):
|
||||||
if platform.system() != 'Linux':
|
if platform.system() != 'Linux':
|
||||||
|
@ -48,6 +55,7 @@ class BossacBinaryRunner(ZephyrBinaryRunner):
|
||||||
'ospeed', '1200', 'cs8', '-cstopb', 'ignpar', 'eol', '255',
|
'ospeed', '1200', 'cs8', '-cstopb', 'ignpar', 'eol', '255',
|
||||||
'eof', '255']
|
'eof', '255']
|
||||||
cmd_flash = [self.bossac, '-p', self.port, '-R', '-e', '-w', '-v',
|
cmd_flash = [self.bossac, '-p', self.port, '-R', '-e', '-w', '-v',
|
||||||
|
'-o', '%s' % self.offset,
|
||||||
'-b', self.cfg.bin_file]
|
'-b', self.cfg.bin_file]
|
||||||
|
|
||||||
self.check_call(cmd_stty)
|
self.check_call(cmd_stty)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue