pytest-embedded-nuttx

class pytest_embedded_nuttx.app.NuttxApp(file_extension='.bin', **kwargs)

Bases: App

NuttX App class for Espressif devices. Evaluates binary files (firmware and bootloader) and extract information required for flashing.

file_extension

app binary file extension.

Type:

str

class pytest_embedded_nuttx.dut.NuttxDut(*args, **kwargs)

Bases: Dut

Generic DUT class for use with NuttX RTOS.

PROMPT_NSH = 'nsh>'
PROMPT_TIMEOUT_S = 30
reset_to_nsh(ready_prompt: str = 'nsh>') None

Resets the board and waits until the Nuttshell prompt appears. Defaults to ‘nsh>’.

Parameters:

ready_prompt (str) – string on prompt that signals completion.

Returns:

None

return_code(timeout: int = 30) int

Matches the ‘echo $?’ response and extracts the integer value corresponding to the last program return code.

The first regex option on expect is for serial interface, while the second will match QEMU.

Returns:

return code.

Return type:

int

write(data: str) None

Write to NuttShell and sleep for a few hundred milliseconds to ensure there is time for Nuttshell prompt appear again.

Parameters:

data (str) – data to be passed on to Nuttshell.

Returns:

None.

write_and_return(data: str, timeout: int = 2) AnyStr

Writes to Nuttshell and returns all available serial data until the timeout. This is useful when parsing and reusing the data is required, and pexect is not enough.

Parameters:
  • data (str) – data to be passed on to Nuttshell.

  • timeout (int) – how long to wait for an answer in seconds.

Returns:

AnyStr

class pytest_embedded_nuttx.dut.NuttxSerialDut(*args, **kwargs)

Bases: SerialDut, NuttxDut

DUT class for serial ports connected to generic boards running NuttX with NuttX RTOS.

reset() None

Reset the DUT by toggling the DTR line.

class pytest_embedded_nuttx.serial.NuttxEspDut(*args, **kwargs)

Bases: NuttxSerialDut

DUT class for serial ports connected to Espressif boards which are flashed with NuttX RTOS.

reset() None

Resets the board.

class pytest_embedded_nuttx.serial.NuttxSerial(app: NuttxApp, **kwargs)

Bases: EspSerial

NuttX serial DUT class.

MCUBOOT_PRIMARY_SLOT_OFFSET = 131072
SERIAL_BAUDRATE = 115200
VIRTUAL_EFUSE_OFFSET = 65536
binary_offsets: ClassVar[dict[str, int]] = {'esp32': 4096, 'esp32c3': 0, 'esp32c6': 0, 'esp32h2': 0, 'esp32p4': 8192, 'esp32s2': 4096, 'esp32s3': 0}
flash(virtual_efuse_offset: int = 65536, mcuboot_primary_slot_offset: int = 131072) None

Flash the binary files to the board.