twister: Allow baud rates other than 115200
Fixes #38046 Document the changes in twister.rst Add baud rate to debug message in twister Add baud parameter to twister's add_device function Set the twister baud rate from input parameters Use 115200 as the default baud rate if not specified Add baud to the hwmap-schema.yaml file Add --device-serial-baud to twister arguments Fix compliance issues Fix mistake in parameter name from device-baud to device-serial-baud Refactoring of the code in orded to simplify the logic and clear multiple definitions of the default baud rate. Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no> Signed-off-by: Dennis Ruffer <daruffer@gmail.com>
This commit is contained in:
parent
18f26b843c
commit
c714c78743
4 changed files with 37 additions and 14 deletions
|
@ -41,8 +41,8 @@ To run the script in the local tree, follow the steps below:
|
||||||
$ source zephyr-env.sh
|
$ source zephyr-env.sh
|
||||||
$ ./scripts/twister
|
$ ./scripts/twister
|
||||||
|
|
||||||
If you have a system with a large number of cores, you can build and run
|
If you have a system with a large number of cores and plenty of free storage space,
|
||||||
all possible tests using the following options:
|
you can build and run all possible tests using the following options:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
|
@ -512,21 +512,24 @@ Executing tests on a single device
|
||||||
To use this feature on a single connected device, run twister with
|
To use this feature on a single connected device, run twister with
|
||||||
the following new options::
|
the following new options::
|
||||||
|
|
||||||
scripts/twister --device-testing --device-serial /dev/ttyACM0 -p \
|
scripts/twister --device-testing --device-serial /dev/ttyACM0 \
|
||||||
frdm_k64f -T tests/kernel
|
--device-serial-baud 9600 -p frdm_k64f -T tests/kernel
|
||||||
|
|
||||||
The ``--device-serial`` option denotes the serial device the board is connected to.
|
The ``--device-serial`` option denotes the serial device the board is connected to.
|
||||||
This needs to be accessible by the user running twister. You can run this on
|
This needs to be accessible by the user running twister. You can run this on
|
||||||
only one board at a time, specified using the ``--platform`` option.
|
only one board at a time, specified using the ``--platform`` option.
|
||||||
|
|
||||||
|
The ``--device-serial-baud`` option is only needed if your device does not run at
|
||||||
|
115200 baud.
|
||||||
|
|
||||||
|
|
||||||
Executing tests on multiple devices
|
Executing tests on multiple devices
|
||||||
===================================
|
===================================
|
||||||
|
|
||||||
To build and execute tests on multiple devices connected to the host PC, a
|
To build and execute tests on multiple devices connected to the host PC, a
|
||||||
hardware map needs to be created with all connected devices and their
|
hardware map needs to be created with all connected devices and their
|
||||||
details such as the serial device and their IDs if available. Run the following
|
details such as the serial device, baud and their IDs if available.
|
||||||
command to produce the hardware map::
|
Run the following command to produce the hardware map::
|
||||||
|
|
||||||
./scripts/twister --generate-hardware-map map.yml
|
./scripts/twister --generate-hardware-map map.yml
|
||||||
|
|
||||||
|
@ -558,12 +561,16 @@ this example we are using a reel_board and an nrf52840dk_nrf52840::
|
||||||
product: DAPLink CMSIS-DAP
|
product: DAPLink CMSIS-DAP
|
||||||
runner: pyocd
|
runner: pyocd
|
||||||
serial: /dev/cu.usbmodem146114202
|
serial: /dev/cu.usbmodem146114202
|
||||||
|
baud: '9600'
|
||||||
- connected: true
|
- connected: true
|
||||||
id: 000683759358
|
id: 000683759358
|
||||||
platform: nrf52840dk_nrf52840
|
platform: nrf52840dk_nrf52840
|
||||||
product: J-Link
|
product: J-Link
|
||||||
runner: nrfjprog
|
runner: nrfjprog
|
||||||
serial: /dev/cu.usbmodem0006837593581
|
serial: /dev/cu.usbmodem0006837593581
|
||||||
|
baud: '9600'
|
||||||
|
|
||||||
|
The baud entry is only needed if not running at 115200.
|
||||||
|
|
||||||
If the map file already exists, then new entries are added and existing entries
|
If the map file already exists, then new entries are added and existing entries
|
||||||
will be updated. This way you can use one single master hardware map and update
|
will be updated. This way you can use one single master hardware map and update
|
||||||
|
|
|
@ -733,7 +733,7 @@ class DeviceHandler(Handler):
|
||||||
else:
|
else:
|
||||||
serial_device = hardware.serial
|
serial_device = hardware.serial
|
||||||
|
|
||||||
logger.debug("Using serial device {}".format(serial_device))
|
logger.debug("Using serial device {} @ {} baud".format(serial_device, hardware.serial_baud))
|
||||||
|
|
||||||
if (self.suite.west_flash is not None) or runner:
|
if (self.suite.west_flash is not None) or runner:
|
||||||
command = ["west", "flash", "--skip-rebuild", "-d", self.build_dir]
|
command = ["west", "flash", "--skip-rebuild", "-d", self.build_dir]
|
||||||
|
@ -790,7 +790,7 @@ class DeviceHandler(Handler):
|
||||||
try:
|
try:
|
||||||
ser = serial.Serial(
|
ser = serial.Serial(
|
||||||
serial_device,
|
serial_device,
|
||||||
baudrate=115200,
|
baudrate=hardware.serial_baud,
|
||||||
parity=serial.PARITY_NONE,
|
parity=serial.PARITY_NONE,
|
||||||
stopbits=serial.STOPBITS_ONE,
|
stopbits=serial.STOPBITS_ONE,
|
||||||
bytesize=serial.EIGHTBITS,
|
bytesize=serial.EIGHTBITS,
|
||||||
|
@ -3926,10 +3926,12 @@ class Gcovr(CoverageTool):
|
||||||
["-o", os.path.join(subdir, "index.html")],
|
["-o", os.path.join(subdir, "index.html")],
|
||||||
stdout=coveragelog)
|
stdout=coveragelog)
|
||||||
|
|
||||||
|
|
||||||
class DUT(object):
|
class DUT(object):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
id=None,
|
id=None,
|
||||||
serial=None,
|
serial=None,
|
||||||
|
serial_baud=None,
|
||||||
platform=None,
|
platform=None,
|
||||||
product=None,
|
product=None,
|
||||||
serial_pty=None,
|
serial_pty=None,
|
||||||
|
@ -3940,6 +3942,9 @@ class DUT(object):
|
||||||
runner=None):
|
runner=None):
|
||||||
|
|
||||||
self.serial = serial
|
self.serial = serial
|
||||||
|
self.serial_baud = 115200
|
||||||
|
if serial_baud:
|
||||||
|
self.serial_baud = serial_baud
|
||||||
self.platform = platform
|
self.platform = platform
|
||||||
self.serial_pty = serial_pty
|
self.serial_pty = serial_pty
|
||||||
self._counter = Value("i", 0)
|
self._counter = Value("i", 0)
|
||||||
|
@ -4031,8 +4036,8 @@ class HardwareMap:
|
||||||
self.detected = []
|
self.detected = []
|
||||||
self.duts = []
|
self.duts = []
|
||||||
|
|
||||||
def add_device(self, serial, platform, pre_script, is_pty):
|
def add_device(self, serial, platform, pre_script, is_pty, baud=None):
|
||||||
device = DUT(platform=platform, connected=True, pre_script=pre_script)
|
device = DUT(platform=platform, connected=True, pre_script=pre_script, serial_baud=baud)
|
||||||
|
|
||||||
if is_pty:
|
if is_pty:
|
||||||
device.serial_pty = serial
|
device.serial_pty = serial
|
||||||
|
@ -4052,6 +4057,7 @@ class HardwareMap:
|
||||||
id = dut.get('id')
|
id = dut.get('id')
|
||||||
runner = dut.get('runner')
|
runner = dut.get('runner')
|
||||||
serial = dut.get('serial')
|
serial = dut.get('serial')
|
||||||
|
baud = dut.get('baud', None)
|
||||||
product = dut.get('product')
|
product = dut.get('product')
|
||||||
fixtures = dut.get('fixtures', [])
|
fixtures = dut.get('fixtures', [])
|
||||||
new_dut = DUT(platform=platform,
|
new_dut = DUT(platform=platform,
|
||||||
|
@ -4059,6 +4065,7 @@ class HardwareMap:
|
||||||
runner=runner,
|
runner=runner,
|
||||||
id=id,
|
id=id,
|
||||||
serial=serial,
|
serial=serial,
|
||||||
|
serial_baud=baud,
|
||||||
connected=serial is not None,
|
connected=serial is not None,
|
||||||
pre_script=pre_script,
|
pre_script=pre_script,
|
||||||
post_script=post_script,
|
post_script=post_script,
|
||||||
|
|
|
@ -30,6 +30,9 @@ sequence:
|
||||||
"serial":
|
"serial":
|
||||||
type: str
|
type: str
|
||||||
required: false
|
required: false
|
||||||
|
"baud":
|
||||||
|
type: int
|
||||||
|
required: false
|
||||||
"post_script":
|
"post_script":
|
||||||
type: str
|
type: str
|
||||||
required: false
|
required: false
|
||||||
|
|
|
@ -214,7 +214,7 @@ logger.setLevel(logging.DEBUG)
|
||||||
def size_report(sc):
|
def size_report(sc):
|
||||||
logger.info(sc.filename)
|
logger.info(sc.filename)
|
||||||
logger.info("SECTION NAME VMA LMA SIZE HEX SZ TYPE")
|
logger.info("SECTION NAME VMA LMA SIZE HEX SZ TYPE")
|
||||||
for i in range(len(sc.sections)):
|
for i in enumerate(sc.sections):
|
||||||
v = sc.sections[i]
|
v = sc.sections[i]
|
||||||
|
|
||||||
logger.info("%-17s 0x%08x 0x%08x %8d 0x%05x %-7s" %
|
logger.info("%-17s 0x%08x 0x%08x %8d 0x%05x %-7s" %
|
||||||
|
@ -621,6 +621,10 @@ structure in the main Zephyr tree: boards/<arch>/<board_name>/""")
|
||||||
"-X", "--fixture", action="append", default=[],
|
"-X", "--fixture", action="append", default=[],
|
||||||
help="Specify a fixture that a board might support")
|
help="Specify a fixture that a board might support")
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--device-serial-baud", action="store", default=None,
|
||||||
|
help="Serial device baud rate (default 115200)")
|
||||||
|
|
||||||
serial = parser.add_mutually_exclusive_group()
|
serial = parser.add_mutually_exclusive_group()
|
||||||
serial.add_argument("--device-serial",
|
serial.add_argument("--device-serial",
|
||||||
help="""Serial device for accessing the board
|
help="""Serial device for accessing the board
|
||||||
|
@ -927,7 +931,9 @@ def main():
|
||||||
hwm.add_device(options.device_serial,
|
hwm.add_device(options.device_serial,
|
||||||
options.platform[0],
|
options.platform[0],
|
||||||
options.pre_script,
|
options.pre_script,
|
||||||
False)
|
False,
|
||||||
|
baud=options.device_serial_baud
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
hwm.add_device(options.device_serial_pty,
|
hwm.add_device(options.device_serial_pty,
|
||||||
options.platform[0],
|
options.platform[0],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue