Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
ed57048
docker-compose: dispatcher: Add /run/udev/control for libudev
galak May 7, 2019
c788949
contrib/usb-passthrough: Script to pass usb devices to container
May 2, 2019
6692f51
Add LITE specific dispatcher
galak May 2, 2019
1617b45
docker-compose: comment out /dev/kvm
galak May 2, 2019
618231d
contrib/LAVA.rules: Example udev rule file for usb-passthrough
galak May 2, 2019
2ccf267
ser2net: setup for running ser2net in a container
galak May 2, 2019
7db776f
docker-compose: ser2net make it a bind mount
galak May 9, 2019
fdcaeb6
frdm-k64f.jinja2 update device type support
galak May 2, 2019
850fa6b
lava-server: settings.conf: Update to allow access beyond local
galak May 2, 2019
9d44acf
board-setup-helper.py: script to help setup stuff for a new board
galak May 2, 2019
3dbc646
examples
galak May 2, 2019
70101a7
lite-lava-dispatcher: Update libudev1 version
galak May 7, 2019
666b838
add initial cut of udev-forward.py based on C implementation
galak May 8, 2019
e679a44
docker-compose: Add example for development
galak May 9, 2019
eb79f65
Fix pyocd boot action method to print out version of binary used
vanti May 8, 2019
afd717d
Install vim automatically into the dispatcher image
vanti May 8, 2019
6ae7201
udev-forward.py: add copyright header/license
galak May 10, 2019
700cbe2
udev-forward.py: setting logging in debug mode
galak May 10, 2019
c16b6f9
udev-forward.py: Move init of udev observer
galak May 10, 2019
5f03e81
udev-forward.py: Use a queue for passing work
galak May 10, 2019
b044717
udev-forward.py: handle container lifecycle
galak May 10, 2019
21f1880
udev-forward.py: Move netns fd into sendMsgThread
galak May 10, 2019
bdbe413
udev-forward.py: remove some cruft
galak May 10, 2019
30022d7
udev-forward.py: support multiple instances
galak May 10, 2019
8a78490
udev-forward.py: rename instance var to name
galak May 10, 2019
deae023
udev-forward.py: Replace Murmur pyhash with pure python version
galak May 11, 2019
b0bc1fc
udev-forward.py: Fix nameerror for get_errno
galak May 13, 2019
9e6bf57
lite-lava-dispatcher: add Segger jlink
galak May 15, 2019
f78e623
lite-lava-dispatcher: adds symlink for JLinkExe to /usr/local/bin
galak May 17, 2019
4332eed
lite-lava-dispatcher: Add openocd from Zephyr SDK
galak May 17, 2019
15a73eb
lite-lava-dispatcher: Update Zephyr SDK version
galak Jun 6, 2019
45fbf7b
lite-lava-dispatcher: Update how we get zephyr sdk
galak Jun 18, 2019
dd0038e
contrib/udev-forward.py: Typo fix in option description.
pfalcon Jun 13, 2019
2661cfa
Makefile: Add "install" target to install host-side files.
pfalcon Jun 13, 2019
d7ec483
Makefile: install: It's mandatory to reload udev rules after updates.
pfalcon Jun 20, 2019
ced1227
lite-lava-dispatcher: Update to tip of pyOCD
galak Jun 24, 2019
124d44b
Makefile: lava-setup: Automate setup of LAVA users.
pfalcon Jun 14, 2019
673c6f1
Makefile: lava-user: Actually open webpage in browser using xdg-open …
pfalcon Jun 14, 2019
8ff4a84
docker-compose.yaml: Add overlays for OpenOCD boot action method
vanti Jun 24, 2019
692b805
Makefile: lava-boards: Target to configure test boards.
pfalcon Jun 14, 2019
f032d3e
Makefile, devices: lava-boards: Create qemu-01 device.
pfalcon Jun 19, 2019
6e75b68
Makefile: Add explicit "stop" target.
pfalcon Jun 14, 2019
085eb61
Makefile: testjob: Target to quickly post a test job to LAVA.
pfalcon Jun 14, 2019
68e635e
Makefile: Start/stop udev-forward.py tool together with composed setup.
pfalcon Jun 14, 2019
8a897d5
docker-compose: Add overlay sample lines
d3zd3z Jun 25, 2019
961b11f
board-setup-helper.py: For frdm-k64f, use "resets_after_flash = false".
pfalcon Jun 25, 2019
8f55499
Makefile: Add "dispatcher-shell" target.
pfalcon Jun 20, 2019
8e73db7
Add a local dir for test images
galak Jun 26, 2019
0b4fe9d
boards: musca_a board support
microbuilder Jun 25, 2019
816ea7f
Makefile: lava-boards: Add musca_a devicep-type.
pfalcon Jun 26, 2019
4ad917c
Bump version to 2019.05post1
galak Jun 25, 2019
d75bd05
Upgrade to the latest LAVA release
ivoire Jun 28, 2019
e5c027c
docker-compose: Sync with 2019.06
ivoire Jun 28, 2019
e326f75
Makefile: Add "board-configs" target.
pfalcon Jun 20, 2019
cb7af2b
Makefile: Add "build" target to prepare for and build docker-compose …
pfalcon Jul 2, 2019
5499965
example/micropython-interactive.job: Example job for "qemu" device type.
pfalcon Jul 2, 2019
9672771
Makefile: testjob: Switch to micropython-interactive.job.
pfalcon Jul 2, 2019
d0f0c48
lite-lava-dispatcher: Update debug tools
galak Aug 23, 2019
5af63e6
Bump version to 2019.09
fboudra Sep 7, 2019
e5caeee
lite-lava-dispatcher: Add ykushcmd
galak Sep 17, 2019
78e791e
lava-master: listen to lava-publisher events
ivoire Sep 10, 2019
4abdce4
Upgrade to 2019.10
ivoire Oct 23, 2019
fb926cf
docker-compose.yaml: Allow to use docker inside lava-dispatcher.
pfalcon Nov 13, 2019
caf824b
device: Add "docker-01" of type "docker".
pfalcon Nov 13, 2019
9895446
example/docker-busybox.job: A job showing how to boot a docker image.
pfalcon Nov 13, 2019
269426f
example/micropython-interactive.job: Make "job_name" field be first.
pfalcon Nov 20, 2019
d9da870
devices/qemu-zephyr-01: QEMU device using Zephyr's QEMU.
pfalcon Nov 18, 2019
edb4686
micropython-interactive-qemu-zephyr.job: Example of using device tags
pfalcon Nov 20, 2019
3d4e62e
devices: Add second docker device.
pfalcon Nov 22, 2019
fd43dfa
example/docker-busybox: Actually consume and check output.
pfalcon Nov 22, 2019
e8097ea
Upgrade to lava 2019.11
ivoire Nov 13, 2019
8f8599d
Upgrade postgres to 12
ivoire Nov 13, 2019
888822b
lite-lava-dispatcher/Dockerfile: Update for LAVA 2019.11/Debian Buster
pfalcon Nov 21, 2019
eb6bd5d
docker-compose: lava-server: Bind ../lava/lava_scheduler_app
pfalcon Nov 28, 2019
c4e4f8a
Makefile: Add convenience "server-shell" target.
pfalcon Nov 29, 2019
2aa672d
example/micropython-interactive: Add name's to command's
pfalcon Nov 29, 2019
82e01f7
example/micropython-interactive: Update download URLs.
pfalcon Nov 29, 2019
4d1645a
example/micropython-interactive: More precise response matches.
pfalcon Nov 29, 2019
d0cce7c
lite-lava-dispatcher: Install and start lava-coordinator.
pfalcon Nov 25, 2019
5a524bb
Upgrade to lava 2019.12
ivoire Dec 10, 2019
f8f3185
example: Add test job for OpenAMP echo_test using edmooring/qemu dock…
pfalcon Nov 25, 2019
a9b50c6
example: Add job for multinode net ping testing.
pfalcon Dec 13, 2019
f91d016
example/docker-xilinx-qemu-openamp-echo_test: Bump timeouts to 10min.
pfalcon Jan 6, 2020
7328c51
README: Add lite-lava-docker-compose specific header.
pfalcon Jan 16, 2020
f4f0d49
docker-xilinx-qemu-openamp-echo_test.job: Use docker with Internet ac…
pfalcon Feb 11, 2020
8845580
Makefile: Assign tags to docker devices, following lite.v.l.o.
pfalcon Feb 11, 2020
e177518
lite-lava-dispatcher/Dockerfile: Don't check cert when downloading JL…
pfalcon Feb 11, 2020
d91ef3d
Upgrade to LAVA 2020.01
ivoire Jan 29, 2020
c1aa73e
docker-test-images/xilinx-openamp-build: Docker image to build OpenAMP
pfalcon Feb 17, 2020
f5f46c3
Makefile: lava-user: Better password prompt.
pfalcon Mar 3, 2020
5126eda
Upgrade to LAVA 2020.02
ivoire Feb 26, 2020
147bf8e
Makefile: lava-boards: Add "zephyr-net" tag for frdm-k64f-01.
pfalcon Mar 6, 2020
021bca3
zephyr-net-ping-frdm_k64f.job: Update for production usage.
pfalcon Mar 6, 2020
5d0a744
example: Add zephyr-net-http-ab-frdm_k64f.job
pfalcon Mar 24, 2020
ee67de3
docker-test-images: Add "linaro-lava-net-test" test image.
pfalcon Mar 24, 2020
82b2627
zephyr-net-ping-frdm_k64f: Switch to linaro-lava-net-test docker image
pfalcon Mar 25, 2020
6a2db89
linaro-lava-net-test: Update image for big_http_download testing.
pfalcon Apr 6, 2020
cbb17cc
devices/docker-01: Export HTTP port from container to host.
pfalcon Apr 7, 2020
7a6552b
example/zephyr-net-big_http_download-frdm_k64f: Job for big_http_down…
pfalcon Apr 16, 2020
5913b05
Forward static handling to lava-server-gunicorn
ivoire Feb 26, 2020
904f88e
Upgrade to lava 2020.04
ivoire Apr 24, 2020
c03237a
zephyr-net-ping-frdm_k64f.job: Define host first.
pfalcon May 7, 2020
7827c69
Makefile: lava-boards: Ignore errors when setting frdm-k64f-01 device…
pfalcon May 19, 2020
fe8927e
Upgrade to LAVA 2020.05
ivoire May 14, 2020
82c15f0
Makefile: all: Add workaround for sudo passwd prompt in background co…
pfalcon May 28, 2020
1ef2be6
zephyr-net-http-ab-frdm_k64f.job: Define host first.
pfalcon Jun 1, 2020
1d1bc37
Makefile: Add clean-env target to clean host environment for LAVA setup.
pfalcon Jun 14, 2019
45e53e3
Makefile: lava-user: Give hint that lava user is actually called "adm…
pfalcon Jun 15, 2020
41c8967
example/multinode-qemu-docker: Multinode test job.
pfalcon Jun 15, 2020
1218d51
Backup LAVA.rules and deal with multiple boards
vanti Jun 15, 2020
9d338a0
Makefile: lava-user: Add more detailed instructions.
pfalcon Jun 16, 2020
29781bb
Makefile: add cc3220SF and cc13x2-launchpad to 'make board-configs'
vanti Jun 15, 2020
f92b74b
connect only one serial port when multiple are available
vanti Jun 15, 2020
4cefeba
Makefile: lava-boards: Restructure device list.
pfalcon Jun 17, 2020
6db4509
Makefile: Use "lava-docker" as idenity name for lavacli.
pfalcon Jun 22, 2020
27f3f52
devices/qemu-01.jinja2: Don't set netdevice='tap' by default.
pfalcon Jun 22, 2020
c7cf598
docker-compose: Expose more udev for docker test action
galak Jun 25, 2020
c813126
docker-compose: Add additional dir mount for lava-dispatcher for dev
galak Jun 25, 2020
d5a83ac
board-setup-helper.py: Add setting device_info
galak Jun 25, 2020
dbcc4eb
devices/qemu-zephyr-01.jinja2: Set netdevice to "user" for now.
pfalcon Jun 26, 2020
d014a15
docker-compose.yaml: Mount dispatcher tmp dir for transitive access
pfalcon Jun 26, 2020
11ad93c
Makefile: Rephrase board-configs invite
erwango Jun 30, 2020
0cf0874
Makefile: lava-boards: Elaborate comment about hardware boards setup.
pfalcon Jun 30, 2020
ff44c98
Upgrade to 2020.06
ivoire Jun 17, 2020
37cca67
Makefile: add disco-l475-iot1 to lava-boards target
Jun 30, 2020
6da2ed3
examples: Add example for running QEMU from a Docker image.
pfalcon Jul 1, 2020
5edfb89
Makefile: Use "docker-compose exec" instead of "docker exec".
pfalcon Jun 30, 2020
bb272f9
devices/qemu*: Don't hardcode "memory" parameter.
pfalcon Jul 7, 2020
b132ba8
test-images: TF-M: Add QEMU-based TF-M test support
microbuilder Jun 16, 2020
3c1a81a
example: Add TF-M Regression test job
microbuilder Jul 7, 2020
7c6b0c8
docs: Update docs to point to DockerHub images
microbuilder Jul 7, 2020
e4f4b87
example: Set SRAM and device loader for QEMU
microbuilder Jul 7, 2020
bcbc8ba
examples/multinode-2-dockers-sync.job: Example multinode sync job
pfalcon Jul 14, 2020
20443c9
zephyr-net-ping-frdm_k64f.job: Switch to multinode synchronization
pfalcon Jul 15, 2020
fe31e3e
zephyr-net-http-ab-frdm_k64f.job: Switch to multinode sync.
pfalcon Jul 15, 2020
7f6062c
zephyr-net-http-ab-frdm_k64f.job: Fix YAML indentation.
pfalcon Jul 16, 2020
ddd3ca7
Upgrade to 2020.07
galak Jul 14, 2020
5e942e2
Makefile: Add a workaround for deploying custom device type
pfalcon Jul 22, 2020
56177d8
Makefile: *-shell: Use "docker-compose exec" instead of "docker exec".
pfalcon Jul 23, 2020
7fc503b
example/lava-docker: example job for using a docker shell for testing
galak Aug 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DC_POSTGRES_IMAGE=postgres:11.2-alpine
DC_SERVER_IMAGE=lavasoftware/lava-server:2019.04
DC_DISPATCHER_IMAGE=lavasoftware/lava-dispatcher:2019.04
DC_POSTGRES_IMAGE=postgres:12-alpine
DC_SERVER_IMAGE=lavasoftware/lava-server:2020.07
DC_DISPATCHER_IMAGE=lavasoftware/lava-dispatcher:2020.07
139 changes: 139 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,145 @@
# Host address on which LAVA is accessible.
LAVA_HOST = localhost
# LAVA user to create/use.
LAVA_USER = admin
# lavacli "identity" (cached credentials name) for the above user,
# to submit jobs, etc.
LAVA_IDENTITY = lava-docker


# sudo echo below is guaranteedly get a sudo password prompt and provide input
# (may be problematic in 2nd command with "&").
all:
sudo echo
sudo contrib/udev-forward.py -i lava-dispatcher &
docker-compose up

stop:
-sudo pkill udev-forward.py
docker-compose stop

clean:
-sudo pkill udev-forward.py
docker-compose rm -vsf
docker volume rm -f lava-server-pgdata lava-server-joboutput lava-server-devices lava-server-health-checks

# Clean host environment to let LAVA setup run w/o issues. As an example,
# stop ModemManager on Ubuntu, which grabs any new serial device and may
# interfere with commnication on it.
clean-env:
-sudo service apache2 stop
-sudo service ModemManager stop

# Create various board configs for connected board(s). Supposed to be done
# before "install" target.
board-configs:
@echo "Note: you should have *all* of your boards connected to USB before running this."
@echo "Press Ctrl+C to break if not, or Enter to continue. Review results carefully afterwards."
@read dummy
-mv ser2net/ser2net.conf ser2net/ser2net.conf.old
touch ser2net/ser2net.conf
@echo
-mv contrib/LAVA.rules contrib/LAVA.rules.old
contrib/make-board-files.sh devices

# Make any preparation steps (currently none) and build docker-compose images.
build:
docker-compose build

install:
sudo cp contrib/LAVA.rules /etc/udev/rules.d/
sudo cp contrib/usb-passthrough /usr/local/bin/
sudo udevadm control --reload
# This dir gets bind-mounted to dispatcher container and sub-containers
# it runs, to allow access to downloaded images across them.
sudo mkdir -p /var/lib/lava/dispatcher/tmp/

lava-setup: lava-user lava-identity lava-boards

lava-user:
@echo -n "Input password for the LAVA 'admin' user to be created: "; \
read passwd; \
test -n "$$passwd" && docker-compose exec lava-server lava-server manage users add $(LAVA_USER) --superuser --staff --passwd $$passwd || true
@echo
@echo "Now login with username: admin, passwd: (entered above) at:"
@echo "http://$(LAVA_HOST)/accounts/login/?next=/api/tokens/"
@echo "and create an auth token (long sequence of chars)."
@echo "(Trying to open this link in browser for you.)"
-xdg-open http://$(LAVA_HOST)/accounts/login/?next=/api/tokens/

lava-identity:
@echo
@echo -n "Enter the auth token that you created: "; \
read token; \
test -n "$$token" && lavacli identities add --username $(LAVA_USER) --token $$token --uri http://$(LAVA_HOST)/RPC2 $(LAVA_IDENTITY) || true
lavacli -i $(LAVA_IDENTITY) system version

lava-boards:
# Start with creating "virtual devices", which work in any setup,
# without additional hardware.

-lavacli -i $(LAVA_IDENTITY) device-types add qemu
-lavacli -i $(LAVA_IDENTITY) devices add --type qemu --worker lava-dispatcher qemu-01
lavacli -i $(LAVA_IDENTITY) devices dict set qemu-01 devices/qemu-01.jinja2

-lavacli -i $(LAVA_IDENTITY) devices add --type qemu --worker lava-dispatcher qemu-zephyr-01
lavacli -i $(LAVA_IDENTITY) devices dict set qemu-zephyr-01 devices/qemu-zephyr-01.jinja2
lavacli -i $(LAVA_IDENTITY) devices tags add qemu-zephyr-01 qemu-zephyr

-lavacli -i $(LAVA_IDENTITY) device-types add docker
-lavacli -i $(LAVA_IDENTITY) devices add --type docker --worker lava-dispatcher docker-01
lavacli -i $(LAVA_IDENTITY) devices dict set docker-01 devices/docker-01.jinja2
lavacli -i $(LAVA_IDENTITY) devices tags add docker-01 zephyr-net
-lavacli -i $(LAVA_IDENTITY) devices add --type docker --worker lava-dispatcher docker-02
lavacli -i $(LAVA_IDENTITY) devices dict set docker-02 devices/docker-generic.jinja2
lavacli -i $(LAVA_IDENTITY) devices tags add docker-02 inet

# Now create LAVA device types/device for real hardware boards. Note
# that these require actual device configuration files for specific
# boards, which are different from a developer to developer, and
# thus are not included in the common "lite" branch. You're expected to
# generate these files locally, and ideally, store in a personal fork
# of the repository. See the wiki page,
# https://collaborate.linaro.org/pages/viewpage.action?pageId=118293253#GettingStartedwithLAVA,Docker,andaFRDMK64F:-Capturinglocalboardconfigurationforsemi-automatedsetup
# for more info.
# Note that if you run directly from the "lite" branch, the setup will
# still succeed (because various commands below are prefixed with "-"
# to make them non-fatal). In this case, you will be able to use
# virtual devices above, but not hardware boards below.

-lavacli -i $(LAVA_IDENTITY) device-types add musca_a
lavacli -i $(LAVA_IDENTITY) device-types template set musca_a device-types/musca_a.jinja2
# Workaround: device-type template should be on both lava-server and lava-master, but currently
# ends up only on lava-server after "lavacli device-types template set" above. So, we copy it
# to lava-master manually.
# Upstream issue: https://git.lavasoftware.org/lava/pkg/docker-compose/-/issues/4
docker cp device-types/musca_a.jinja2 lava-master:/etc/lava-server/dispatcher-config/device-types/

-lavacli -i $(LAVA_IDENTITY) device-types add frdm-k64f
-lavacli -i $(LAVA_IDENTITY) devices add --type frdm-k64f --worker lava-dispatcher frdm-k64f-01
-lavacli -i $(LAVA_IDENTITY) devices dict set frdm-k64f-01 devices/frdm-k64f-01.jinja2
lavacli -i $(LAVA_IDENTITY) devices tags add frdm-k64f-01 zephyr-net

-lavacli -i $(LAVA_IDENTITY) device-types add cc3220SF
-lavacli -i $(LAVA_IDENTITY) devices add --type cc3220SF --worker lava-dispatcher cc3220SF-01
-lavacli -i $(LAVA_IDENTITY) devices dict set cc3220SF-01 devices/cc3220SF-01.jinja2
lavacli -i $(LAVA_IDENTITY) devices tags add cc3220SF-01 zephyr-net

-lavacli -i $(LAVA_IDENTITY) device-types add cc13x2-launchpad
-lavacli -i $(LAVA_IDENTITY) devices add --type cc13x2-launchpad --worker lava-dispatcher cc13x2-launchpad-01
-lavacli -i $(LAVA_IDENTITY) devices dict set cc13x2-launchpad-01 devices/cc13x2-launchpad-01.jinja2
lavacli -i $(LAVA_IDENTITY) devices tags add cc13x2-launchpad-01 zephyr-net

-lavacli -i $(LAVA_IDENTITY) device-types add disco-l475-iot1
-lavacli -i $(LAVA_IDENTITY) devices add --type disco-l475-iot1 --worker lava-dispatcher disco-l475-iot1-01
-lavacli -i $(LAVA_IDENTITY) devices dict set disco-l475-iot1-01 devices/disco-l475-iot1-01.jinja2
lavacli -i $(LAVA_IDENTITY) devices tags add disco-l475-iot1-01 zephyr-net

testjob:
lavacli -i $(LAVA_IDENTITY) jobs submit example/micropython-interactive.job

dispatcher-shell:
docker-compose exec lava-dispatcher bash

server-shell:
docker-compose exec lava-server bash
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
lite-lava-docker-compose
========================

This is a Linaro LITE customized fork of LAVA dockerized setup. Instructions
for it are available in the
[wiki](https://collaborate.linaro.org/pages/viewpage.action?pageId=118293253).

Below is the original README.

-------

docker-compose
==============

Expand Down
10 changes: 10 additions & 0 deletions contrib/LAVA.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Example LAVA.rules for USB passthrough to container
#
# Assumes that usb-passthrough script is installed in
# /usr/local/bin/passthrough

# Pass all usb devices (TTY, block, CDC) to lava-dispatcher container
# FRDM-K64F
ACTION=="add", ENV{ID_SERIAL_SHORT}=="MYSERIALNUM", RUN+="/usr/local/bin/usb-passthrough -a -d %E{ID_SERIAL_SHORT} -i lava-dispatcher"
# Pass TTY through to lava-ser2net container
ACTION=="add", SUBSYSTEM=="tty", ENV{ID_SERIAL_SHORT}=="MYSERIALNUM", RUN+="/usr/local/bin/usb-passthrough -a -d %E{ID_SERIAL_SHORT} -i lava-ser2net"
121 changes: 121 additions & 0 deletions contrib/board-setup-helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/usr/bin/python3

# Copyright 2019 Linaro Limited
# Author: Kumar Gala <[email protected]>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

import pyudev
import argparse
import os
import pprint

def ser2net(dev, ser2net_file):
ser2net = {}
port_num = 5001

with open(ser2net_file, 'r') as fd:
for line in fd:
line = line.strip()
values = line.split(':')
port = int(values.pop(0))
ser2net[port] = values

if len(ser2net):
port_num = max(ser2net.keys()) + 1

new_device = True

for k in ser2net:
if dev in ser2net[k][2]:
new_device = False
print("WARNING: device %s already exists in %s on port %d" % (dev, ser2net_file, k))
port_num = k

if new_device:
with open(ser2net_file, 'a') as fd:
fd.write("%d:telnet:0:%s:115200 8DATABITS NONE 1STOPBIT LOCAL max-connections=10\n" % (port_num, dev))

return port_num

def get_device_numbers(serial_no, dev_type, board_file, ser2net_file):
result = None, None
found_tty = False
context = pyudev.Context()

devices = context.list_devices()

board_jinja = open(board_file, 'w')

board_jinja.write("{%% extends '%s.jinja2' %%}\n" % dev_type)
board_jinja.write("{%% set board_id = '%s' %%}\n" % serial_no)
board_jinja.write("{%% set device_info = [{'board_id': '%s'}] %%}\n" % serial_no)

for device in devices:
serial = device.attributes.get("serial")
if serial is not None and serial_no in serial.decode("utf-8"):
child = device.children
for c in child:
if (c.subsystem == "block"):
for l in c.device_links:
if "by-id" in l:
board_jinja.write("{%% set usb_mass_device = '%s' %%}\n" % l)

if (c.subsystem == "tty"):
for l in c.device_links:
if "by-id" in l:
port = ser2net(l, ser2net_file)
if (port and not found_tty):
board_jinja.write("{%% set connection_command = 'telnet ser2net %d' %%}\n" % port)
found_tty = True #If there are multiple serial ports, connect to the first one
break

if dev_type == "frdm-k64f":
board_jinja.write("{% set resets_after_flash = false %}\n")


def main():
parser = argparse.ArgumentParser(description='LAVA board helper', add_help=False)

parser.add_argument("-d", "--device_serial_num", type=str, required=True,
help="Devices serial number")

parser.add_argument("-t", "--device_type", type=str, required=True,
help="Devices type")

parser.add_argument("-s", "--ser2net_conf", type=str, required=False,
default = "./ser2net/ser2net.conf",
help="ser2net configuration file")

parser.add_argument("-u", dest='udev', default=False, action='store_true')

parser.add_argument("-b", "--board_file", type=str, required=False,
default = "board.jinja2",
help="board jinja file")

options = parser.parse_args()

get_device_numbers(options.device_serial_num, options.device_type,
options.board_file, options.ser2net_conf)

if (options.udev):
print('ACTION=="add", ENV{ID_SERIAL_SHORT}=="%s", RUN+="/usr/local/bin/usb-passthrough -a -d %%E{ID_SERIAL_SHORT} -i lava-dispatcher"' % options.device_serial_num)
print('ACTION=="add", SUBSYSTEM=="tty", ENV{ID_SERIAL_SHORT}=="%s", RUN+="/usr/local/bin/usb-passthrough -a -d %%E{ID_SERIAL_SHORT} -i lava-ser2net"' % options.device_serial_num)



if __name__ == '__main__':
main()
13 changes: 13 additions & 0 deletions contrib/make-board-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

if [ -z "$1" ]; then
echo "Usage: $0 <devices_dir>"
exit 1
fi

for ser in $1/*.serial; do
echo "Processing: $ser"
devname=$(basename $ser .serial)
devtype=$(echo $devname | python -c "import sys; print(sys.stdin.readline().rsplit('-', 1)[0])")
contrib/board-setup-helper.py -d $(cat $ser) -t $devtype -b $1/$devname.jinja2 -u >>contrib/LAVA.rules
done
Loading