PHiLIP PAL (PHiLIP Protocol Abstraction Layer)

Description

A set of python modules that abstract away and standardize shell based command for bare metal memory map access. PHiLIP PAL is used to interface to a memory map specified from a csv or by the device. It handles the parsing of offsets, sizes, etc. of the device.

To use this interface a memory must be provided, by default the package contains the PHiLIP memory map for all the versions. If a development version of PHiLIP is used and a memory map has not been released, the memory map can be scanned from the device.

PHiLIP PAL provides a philip_shell which developers can use for manual tests and interacting with PHiLIP.

For automated scripts, a Phil() class is provided.

PHiLIP PAL Installation

To interface to PHiLIP first install the philip_pal for python3.

sudo pip3 install philip_pal

Running PHiLIP PAL Shell

First connected PHiLIP to the computer so a serial port connection is available.

This script handles interfacing to the PHiLIP device. It parses data and exposes from the PhilipExtIf class to be run in a shell.

Usage

usage: philip_shell.py  [-h]
                        [--loglevel {debug,info,warning,error,fatal,critical}]
                        [--port PORT]
                        [--filter-data]

optional arguments:
  -h, --help            show this help message and exit
  --loglevel {debug,info,warning,error,fatal,critical}
                        Python logger log level (default: warning)
  --port, -p
                        Specify the serial port
  --data_only, -do
                        Filters data from philip responses to only display
                        what is needed (default: False)

Upon starting the shell use the help command to see what functionality is available.

See the main page for more getting started and examples.

Running PHiLIP PAL from CLI

Besides the full PHiLIP PAL Shell there is also CLI mode for simple one-shot access to PHiLIP interface functions. It allows to reset the PHiLIP MCU and the connected DUT.

After connecting PHiLIP simply run python3 -m philip_pal --help to get the following full usage description:

usage: python3 -m philip_pal [-h] [--verbose] [--dut_reset] [--reset] [port]

positional arguments:
  port         PHiLIP serial port

optional arguments:
  -h, --help   show this help message and exit
  --verbose    Enable more output
  --dut_reset  Reset device-under-test (DUT)
  --reset      Reset PHiLIP MCU

To get output use --verbose, otherwise commands will silently be executed.

mm_pal (Memory Map Protocol Abstraction Layer)

Python package for providing an runtime access to embedded devices based on a memory map type interface.

Device connection such as serial and parsers such as json are used to get standard output.

Concept

Embedded devices are generally constrained and communication with runtime parameters can take up lots of resources. Since many users of microcontroller are familiar with the concept of a memory map or register map the Memory Map Manager can be used as and lightweight way of coordinating a single memory map for documentation, C structures, and python interface. The mm_pal provides the building blocks for a custom interface. All common functions related to connecting to the device, parsing output of the registers, and reading/writing to the registers are handled and only application specific functionality needs to be implemented. This can make development easier, especially when the registers are changing frequently.

Architecture

┏━━━━━━━━━━━┓       ┏━━━━━━━━━┓
┃ developer ┃       ┃ script  ┃
┗━━━━━▲━━━━━┛       ┗━━━━▲━━━━┛
      ┃                  ┃
 ┏━━━━┸━━━━┓       ┏━━━━━┸━━━━━┓
 ┃ my_cli  ◄━━━━━━━┫ my_app_if ┃
 ┗━━━━▲━━━━┛       ┗━━━━━▲━━━━━┛
      ┃    ┌────────┐    ┃
      ┃    │ mm_pal │    ┃
┌─────╂────┴────────┴────╂────────┐
│┏━━━━┸━━━┓          ┏━━━┸━━━┓    │
│┃ mm_cmd ◄━━━━━━━━━━┫ mm_if ┃    │
│┗━━━━━━━━┛          ┗━━━▲━━━┛    │
│                        ┃        │
│                ┏━━━━━━━┸━━━━━━━┓│
│                ┃ serial_driver ┃│
│                ┗━━━━━━━▲━━━━━━━┛│
└────────────────────────╂────────┘
                         ┃
              ┏━━━━━━━━━━▼━━━━━━━━━━┓
              ┃ my_embedded_device  ┃
              ┗━━━━━━━━━━━━━━━━━━━━━┛

The mm_cmd is based on the cmd2 module is probably worth reading the documentation.

Special thanks to riotctrl as it served as a great example.

memory_map_manager

Manages memory map generation in C, python and documentation written in python3.

Installation

Install from pip

Stable versions can be installed with:

pip install memory-map-manager

Usage

Installing the package comes with a console command generate_map.

generate_map --help
usage: generate_map [-h] [--config-path CONFIG_PATH] [--output-config OUTPUT_CONFIG] [--output-dir OUTPUT_DIR] [--output-csv OUTPUT_CSV]
                    [--reset-config] [--only-update-config] [--print-date] [--print-config]
                    [--loglevel {debug,info,warning,error,fatal,critical}]

optional arguments:
  -h, --help            show this help message and exit
  --config-path CONFIG_PATH, -P CONFIG_PATH
                        The path to the config file or directory
  --output-config OUTPUT_CONFIG, -c OUTPUT_CONFIG
                        The path and name of the output config file
  --output-dir OUTPUT_DIR, -D OUTPUT_DIR
                        The path for all generated output
  --output-csv OUTPUT_CSV, -o OUTPUT_CSV
                        The path for the csv memory map
  --reset-config, -r    Do not copy previous non-generated mem map values
  --only-update-config, -u
                        Only updates config file without generating files
  --print-date, -d      prints the date in all headers
  --print-config, -p    Prints the config to stdout
  --loglevel {debug,info,warning,error,fatal,critical}
                        Python logger log level, defaults to "info"