Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 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
33d159a
add script to monitor test-images directory for new test images
vanti Jul 3, 2019
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
4 changes: 2 additions & 2 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_SERVER_IMAGE=lavasoftware/lava-server:2019.06
DC_DISPATCHER_IMAGE=lavasoftware/lava-dispatcher:2019.06
68 changes: 68 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,74 @@
# Host address on which LAVA is accessible.
LAVA_HOST = localhost
# LAVA user to create/use.
LAVA_USER = admin
# lavacli "identity" (cached credential name) for the above user, to submit jobs
# "dispatcher" is legacy name from the original instructions.
LAVA_IDENTITY = dispatcher


all:
contrib/monitor-images.sh $(LAVA_IDENTITY) &
sudo contrib/udev-forward.py -i lava-dispatcher &
docker-compose up

stop:
pkill -f monitor-images.sh
-sudo pkill udev-forward.py
docker-compose stop

clean:
pkill -f monitor-images.sh
-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

# 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. Review results carefully afterwards."
@read dummy
-mv ser2net/ser2net.conf ser2net/ser2net.conf.old
touch ser2net/ser2net.conf
@echo
contrib/make-board-files.sh devices

install:
sudo cp contrib/LAVA.rules /etc/udev/rules.d/
sudo cp contrib/usb-passthrough /usr/local/bin/
sudo udevadm control --reload

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

lava-user:
@echo -n "Input LAVA admin user passwd: "; \
read passwd; \
test -n "$$passwd" && docker exec -it lava-server lava-server manage users add $(LAVA_USER) --superuser --staff --passwd $$passwd || true
@echo
@echo "Now login at http://$(LAVA_HOST)/accounts/login/?next=/api/tokens/ and create an auth token (long sequence of chars)"
-xdg-open http://$(LAVA_HOST)/accounts/login/?next=/api/tokens/

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

lava-boards:
-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) 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) device-types add musca_a
lavacli -i $(LAVA_IDENTITY) device-types template set musca_a device-types/musca_a.jinja2

testjob:
lavacli -i dispatcher jobs submit example/lava.job

dispatcher-shell:
docker exec -it lava-dispatcher bash
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"
118 changes: 118 additions & 0 deletions contrib/board-setup-helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/usr/bin/python3

# Copyright 2019 Linaro Limited
# Author: Kumar Gala <kumar.gala@linaro.org>

# 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
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)

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:
board_jinja.write("{%% set connection_command = 'telnet ser2net %d' %%}\n" % port)
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
41 changes: 41 additions & 0 deletions contrib/monitor-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Usage: ./monitor-images.sh <your LAVA identity>
#
# This script monitors the 'test-images' directory for any file that is
# dropped into it. It assumes the directory layout is
# test-images/<device-type>, and upon detecting a new file, uses the
# corresponding job template in job-templates/lava_<device-type>.job
# to submit the job with the provided LAVA identity.
#
# '<test_image>' in the template is automatically substituted with the
# actual path to the test image.

contrib_dir=`dirname $0`
dir=test-images
template_dir=job-templates

cd $contrib_dir/..

inotifywait -r -m "$dir" -e close_write --format '%w%f' |
while IFS=' ' read -r fname
do
IFS='/'
read -ra path <<< "$fname"
template="$template_dir"/lava_"${path[1]}".job
if [ ! -f "$template" ]
then
#if no template found for the device-type, do nothing
continue
fi

echo "Using template for device type ${path[1]}:"
echo " $template"

# Replace <test_image> with actual path to test image
sed_cmd=s/\<test_image\>/"file:\/\/\/${fname//\//\\\/}"/g

tmp_file=$(mktemp)
echo "Submitting job for $fname"
[ -f "$fname" ] && sed "$sed_cmd" "$template" > "$tmp_file" && lavacli -i $1 jobs submit "$tmp_file" && rm "$tmp_file"
done
Loading