Commit a2e4d72e authored by Jeremiah Foster's avatar Jeremiah Foster

Merge branch 'master' into 'master'

Master

See merge request !1
parents ce3a69e2 7169ceb0
Pipeline #35299 passed with stages
in 3 minutes and 45 seconds
......@@ -6,3 +6,4 @@ README.html
README.rst
tests/__pycache__
.pytest_cache/
files/
variables:
FLASHDEPS: python3
python3-coloredlogs
python3-jenkins
python3-requests
python3-tqdm
python3-yaml
.tags: &tags
tags:
- librem5
build:docs:
build:deb:
<<: *tags
stage: build
before_script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get -y update
- apt-get -y install org-mode build-essential
- apt-get -y build-dep .
script:
- make
- dpkg-buildpackage -uc -us
- cp ../*.deb .
artifacts:
paths:
- '*.html'
- pics/
- '*.deb'
build:deb:
test:download:deb:
<<: *tags
stage: build
stage: test
before_script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get -y update
- apt-get -y install org-mode build-essential
- apt-get -y build-dep .
- apt-get -y install $FLASHDEPS
script:
- dpkg-buildpackage -uc -us
- cp ../*.deb .
artifacts:
paths:
- '*.deb'
- scripts/librem5-devkit-flash-image --skip-flash --skip-cleanup --dir=download/
- ls -l download/devkit.img download/flash_devkit.lst download/u-boot-devkit-recovery.imx
- rm -rf download
test:download:pip:
<<: *tags
stage: test
before_script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get -y update
- apt-get -y install virtualenv python3-pip
script:
- virtualenv --python=python3 test-download
- source test-download/bin/activate
- pip install -r requirements.txt
- python3 scripts/librem5-devkit-flash-image --skip-flash --skip-cleanup --dir=download/
- ls -l download/devkit.img download/flash_devkit.lst download/u-boot-devkit-recovery.imx
- rm -rf download
This diff is collapsed.
#!/usr/bin/make
DOCS=\
README.html \
$(NULL)
all: check
all: $(DOCS)
check:
flake8
flake8 scripts/librem5-devkit-flash-image
shellcheck test_scripts/librem5-devkit-check
%.html: %.org
emacs --batch -nw $< -f org-html-export-to-html --kill
install:
mkdir -p $(DESTDIR)/etc/modules-load.d/
install -m 0644 etc/modules-load.d/librem5-devkit.conf $(DESTDIR)/etc/modules-load.d/
mkdir -p $(DESTDIR)/etc/modprobe.d/
install -D -m 0644 etc/modprobe.d/librem5-devkit.conf $(DESTDIR)/etc/modprobe.d/
mkdir -p $(DESTDIR)/etc/kernel/postinst.d/
install -D -m 0755 etc/kernel/postinst.d/update-Image $(DESTDIR)/etc/kernel/postinst.d/
# Convert to ReStructuredText
%.rst: %org
pandoc README.org README.rst
Librem5 Devkit Tools
====================
This repository contains flashing script and other tools for the Librem5
devkit. If you just want to flash a new image check the [official
documentation][1].
If you're interested in lower level board-bringup instructions see doc/.
Tests
=====
We have [pytest][] based tests to validate that the kernel probed the
hardware correctly. See the individual files in `pytests/`.
To run the tests from the source tree use:
sudo pytest-3
in the toplevel source directory. You can use *pytests* matching to only run
ceratain tests you're interested in. The tests are built into a Debian package
*librem5-devkit-check* being installed on each devkit by default. You can run
them there via:
sudo librem5-devkit-check
[1]: https://developer.puri.sm/Librem5/Development_Environment/Boards.html
[pytest]: https://pytest.org/en/latest/
librem5-devkit-tools (0.0.2) green; urgency=medium
[ Guido Günther ]
* Add framebuffer test script
* librem5-devkit-check.install: Docment scripts a little
* Install fb-color script
* checks: Depend on python3
* Add package that keeps devkit base config.
This is somewhat similar to librem5-base but keeps devkit specific
configuration. We will later likely introduce a librem5-phone-base
for the phone.
* Add g_serial for USB serial console
* Add Redpine Wifi config
* Add script to automatically unzip newly installed kernels.
Our uboot wants uncompressed kernels. Make sure this happens on kernel
package updates.
* Add uuu_scripts as examples
* Add script to downlaod and flash the latest devkit image
* d/rules: Run checks during build
* librem5-devkit-base: Enable console over USB
* flash-image: Get size from meta data.
This makes sure the progress bar matches the expected image size.
We don't make the lack of meta data fatal yet so we can use this
script on outdated build jobs too for some time.
* flash-image: Validate checksum of downloaded image.
This also uses the meta data provided with the image.
* d/control: Add python3-yaml for meta yaml parsing
[ Dorota Czaplejewicz ]
* get_image: Fix CI build URLs.
The URL for the test and CI image are not built in the same way, coming
from separate branches. This fixes it until it get sorted out in
image-builder.
[ Bob Ham ]
* devkit-base: Add jitterentropy-rngd.
This works around the RNG issue linux-emcraft#2 causing SSH logins to
be inaccessible for five minutes on boot. With this package, SSH is
available immediately.
-- Guido Günther <agx@sigxcpu.org> Thu, 03 Jan 2019 18:14:54 +0100
librem5-devkit-tools (0.0.1) purple; urgency=medium
* Add package for the host side
-- Guido Günther <agx@sigxcpu.org> Fri, 21 Dec 2018 14:09:54 +0100
librem5-devkit-tools (0.0.0) unstable; urgency=medium
* Initial release
......
......@@ -4,8 +4,24 @@ Priority: optional
Maintainer: Guido Günther <agx@sigxcpu.org>
Build-Depends:
debhelper (>= 11),
flake8,
shellcheck,
Standards-Version: 4.1.3
Homepage: https://code.puri.sm/guido.gunther/phosh
Homepage: https://source.puri.sm/Librem5/librem5-devkit-tools/
Package: librem5-devkit-base
Architecture: arm64
Depends:
${misc:Depends},
${shlibs:Depends},
flash-kernel,
jitterentropy-rngd,
mmc-utils,
rfkill,
u-boot-tools,
Description: Basic configuration for the librem5-devkit
This package contains initial configuration for the
librem5 devkits.
Package: librem5-devkit-check
Architecture: all
......@@ -13,10 +29,33 @@ Depends:
${misc:Depends},
${shlibs:Depends},
fbi,
fbset,
i2c-tools,
pytest-3,
python3,
python3-pytest,
python3-evdev,
python3-yaml,
usb-modeswitch,
usbutils,
Description: Check script for the librem5-evk (devkit)
Set of scripts to test the Librem5 devkit.
Package: librem5-devkit-host
Architecture: all
Depends:
${misc:Depends},
${shlibs:Depends},
python3,
python3-coloredlogs,
python3-jenkins,
python3-requests,
python3-tqdm,
python3-yaml,
usbutils,
uuu,
Description: Tools for the librem5 devkit (host side)
Scripts useful to for working with the librem-t5 devkit.
.
These tools are useful on the host side (e.g. the machine
you use to flash the image from). They are not useful on
the devkit itself.
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: phosh
Source: https://code.puri.sm/Librem5/librem5-evk-tools.git
Files: usr/*
Copyright: 2011 Scott Moser <scott.moser@canonical.com>
2019 Purism SPC
License: GPL-3+
Files: *
Copyright: 2018 Guido Günther <agx@sigxcpu.org>
Copyright: 2018, 2019 Purism SPC
License: GPL-3+
License: GPL-3+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -20,3 +26,4 @@ License: GPL-3+
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
[DEFAULT]
debian-tag=v%(version)s
#!/bin/sh
# postinst script for librem5-devkit-base
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
configure)
# Enable serial console over USB
systemctl enable serial-getty@ttyGS0
# Mass storage is required for Ethernet+serial over USB via g_multi
truncate -s 1M /var/lib/mass_storage_dummy
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
#!/bin/sh
# postrm script for librem5-devkit-base
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postrm> `remove'
# * <postrm> `purge'
# * <old-postrm> `upgrade' <new-version>
# * <new-postrm> `failed-upgrade' <old-version>
# * <new-postrm> `abort-install'
# * <new-postrm> `abort-install' <old-version>
# * <new-postrm> `abort-upgrade' <old-version>
# * <disappearer's-postrm> `disappear' <overwriter>
# <overwriter-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
purge)
;;
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
systemctl disable serial-getty@ttyGS0
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
[Unit]
Description=Performs an online resize of an ext2,3,4 rootfs
After=-.mount
[Service]
Type=oneshot
ExecStart=/usr/bin/resize_rootfs
[Install]
WantedBy=local-fs.target
# The pyunit tests
pytests/*.py usr/share/librem5-devkit/check/
# The script that runs the pyunit tests
test_scripts/librem5-devkit-check usr/bin/
# Other helpers
test_scripts/fb-color.py usr/share/librem5-devkit/tools/
test_scripts/vibra_test.py usr/share/librem5-devkit/tools/
test_scripts/power_key.py usr/share/librem5-devkit/tools/
scripts/librem5-devkit-flash-image /usr/bin/
SUBSYSTEM!="usb", GOTO="librem5_devkit_rules_end"
# Devkit USB flash
ATTR{idVendor}=="1fc9", ATTR{idProduct}=="012b", GROUP+="plugdev", TAG+="uaccess"
ATTR{idVendor}=="0525", ATTR{idProduct}=="a4a5", GROUP+="plugdev", TAG+="uaccess"
ATTR{idVendor}=="0525", ATTR{idProduct}=="b4a4", GROUP+="plugdev", TAG+="uaccess"
LABEL="librem5_devkit_rules_end"
......@@ -3,3 +3,12 @@
%:
dh $@
override_dh_installudev:
dh_installudev --name=librem5_devkit
override_dh_installsystemd:
dh_installsystemd --no-start --name=resize_rootfs
override_dh_auto_test:
dh_auto_test
make check
This diff is collapsed.
setenv bootargs "${bootargs} root=/dev/mmcblk0p2"
#!/bin/sh
# see Chapter 8 of Debian Linux Kernel Handbook
set -e
abi="$1"
_vmlinuz="${2:-/boot/vmlinuz-$abi}"
gunzip -c "${_vmlinuz}" > /boot/Image.tmp
mv -f /boot/Image.tmp /boot/Image
options g_multi file=/var/lib/mass_storage_dummy stall=0
# blacklist the mainline redpine driver for now
blacklist rsi_91x
blacklist rsi_sdio
# Redpine WIFI module
options redpine_91x dev_oper_mode=13 rsi_zone_enabled=1 antenna_diversity=1
# Serial console and Ethernet over USB (plus dummy mass storage)
g_multi
allow-hotplug usb0
iface usb0 inet dhcp
# We use this script to set the default source and sink
default-script-file = /etc/pulse/librem5-devkit.pa
.include /etc/pulse/default.pa
set-default-sink alsa_output.platform-sound.VoiceCall__hw_CARD_sgtl5000__sink
set-default-source alsa_input.platform-sound.VoiceCall__hw_CARD_sgtl5000__source
purism ALL=NOPASSWD: ALL
[Service]
Environment=ETNA_MESA_DEBUG=no_supertile
# sysfs related helpers
import glob
def check_content_in_glob(content, pattern):
matches = glob.glob(pattern)
for f in matches:
if content == open(f).read():
return
else:
assert False, "{} not in any of {}".format(content, matches)
import os
import pytest
import subprocess
@pytest.fixture
def tempdir():
import tempfile
with tempfile.TemporaryDirectory() as tmpdir:
yield tmpdir
def test_sgtl5000():
"Check if the sgtl5000 audio codec is there"
out = subprocess.check_output(["aplay", "-l"])
assert b"[sgtl5000]" in out
def test_headphone_detection():
"Check if we registered the headphone detection IRQ"
f = open("/proc/interrupts")
assert " HP_DET" in f.read()
def test_sound_output(tempdir):
out = subprocess.run(["alsabat",
"-D",
"plughw:CARD=sgtl5000,DEV=0",
"-c2",
"--saveplay",
os.path.join(tempdir, 'default_dual.wav'),
"--standalone"],
capture_output=True)
assert(b"Return value is 0" in out.stdout)
assert(out.returncode == 0)
def test_battery_charger():
assert("Good" in open("/sys/class/power_supply/bq25890-charger/health").read())
def test_cpufreq():
assert("1000000" in open("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq").read())
assert("1000000" in open("/sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_min_freq").read())
assert("1000000" in open("/sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_min_freq").read())
assert("1000000" in open("/sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_min_freq").read())
assert("1500000" in open("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq").read())
assert("1500000" in open("/sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_max_freq").read())
assert("1500000" in open("/sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_max_freq").read())
assert("1500000" in open("/sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_max_freq").read())
def test_cpuidle():
assert("WFI\n" == open("/sys/devices/system/cpu/cpu0/cpuidle/state0/name").read())
assert("cpu-sleep\n" == open("/sys/devices/system/cpu/cpu0/cpuidle/state1/name").read())
import os
import subprocess
NODE = '/dev/dri/renderD128'
def udev_props(path):
out = subprocess.check_output(['udevadm', 'info', '-qproperty', path]).decode('utf-8')
props = {}
for line in out.split('\n'):
if not line.strip():
continue
k, v = line.strip().split('=', 1)
props[k] = v
return props
def test_render_node():
"Test if we have a render node"
assert(os.path.exists(NODE))
def test_etnaviv_node():
"Test if the render node is etnaviv"
props = udev_props(NODE)
assert(props['ID_PATH'] == 'platform-etnaviv')
import evdev
def test_gpio_keys():
"Test if we have a evdev named 'gpio-keys'"
devices = [evdev.InputDevice(path).name for path in evdev.list_devices()]
assert("gpio-keys" in devices)
assert("gpio-keys" in devices)
from . import sysfs
def test_gyro():
sysfs.check_content_in_glob('lsm9ds1_magn\n', '/sys/bus/iio/devices/*/name')
import subprocess
def test_modem_usb():
"Test if the modem is visible on the USB bus"
out = subprocess.check_output(["lsusb", "-d", "1e0e:9001"])
assert(b"Qualcom" in out)
def test_modem_modem_manager():
"Test if modem manager picked up the modem"
out = subprocess.check_output(["mmcli", "-m", "0"])
assert(b"model: SIMCOM_SIM7100" in out)
def test_modem_alsa():
"Test if the modem is seen by alsa"
out = subprocess.run(["aplay", "-l"], capture_output=True)
assert(out.returncode == 0)
assert(b": SIM7100 [SIMCom SIM7100]" in out.stdout)
import evdev
def test_panel_brightness():
"Check if current panel brighness is in [0..9]"
f = open("/sys/class/backlight/backlight_dsi/brightness")
assert int(f.read()) in range(0,10)
f = open("/sys/class/backlight/backlight-dsi/brightness")
assert int(f.read()) in range(0, 101)
from . import sysfs
def test_proximity_sysfs_node():
sysfs.check_content_in_glob('vcnl4000\n', '/sys/bus/iio/devices/*/name')
def test_touch_controller():
assert('N: Name="Goodix Capacitive TouchScreen' in open("/proc/bus/input/devices").read())
import subprocess
def test_usb_hub():
out = subprocess.check_output(["lsusb", "-d", "14cd:8601"])
assert(b"Super Top" in out)
......@@ -70,7 +70,7 @@ cd ${DIR}
if [ "${build_initrd}" == 1 ]; then
find . -print0 | cpio --null -o --format=newc | gzip -9 > ${cwd}/build/${BASE}.image
else
fakeroot genext2fs -d . -N 24000 -b 300000 ${cwd}/build/${BASE}.image
fakeroot genext2fs -d . -N 24000 -b 350000 ${cwd}/build/${BASE}.image
fi
#gzip ${cwd}/build/${BASE}.image
......
......@@ -5,7 +5,7 @@
# SPDX-License-Identifier: GPL-3.0+
#
packages="whiptail iperf3 wireless-tools"
packages="whiptail iperf3 wireless-tools network-manager powertop htop scdaemon"
usage() {
echo "Usage : $1 "
......
......@@ -8,27 +8,17 @@
usage() {
echo "Usage : $1 "
echo " -h Display this help message."
echo " -T [ci|unstable] use the artifacts from this build for the image"
echo " -x extract the image for flashing"
echo " -k get the kernel binaries as well"
echo " -T [418|52|next] use the artifacts from this kernel version"
}
build_type=ci
build_type=52
pureos_board=devkit
extract=0
get_kernel=0
while getopts "xkhT:" opt; do
while getopts "hT:" opt; do
case ${opt} in
T)
build_type=$OPTARG
;;
x)
extract=1
;;
k)
get_kernel=1
;;
\?)
echo "Invalid Option: -$OPTARG" 1>&2
usage "$0"
......@@ -43,25 +33,25 @@ done
[ ! -e files ] && mkdir files
base_url=https://storage.puri.sm/librem5/binaries/${build_type}/latest/
wget -N "${base_url}/${pureos_board}.img.xz" -P files/
if [ "${extract}" == 1 ] &&
[ ! -e files/${pureos_board}.img ] ||
[ files/${pureos_board}.img.xz -nt files/${pureos_board}.img ]; then
xz -vdk files/${pureos_board}.img.xz
fi
wget -N "${base_url}/files/uboot-${pureos_board}-recovery/u-boot-${pureos_board}-recovery.imx" -P files/
wget -N "${base_url}/files/uboot-${pureos_board}/u-boot-${pureos_board}.imx" -P files/
wget -N "${base_url}/files/uboot-${pureos_board}/m4.bin" -P files/
if [ "${get_kernel}" == 1 ]; then
wget -r -np -R "index.html*" -N https://arm01.puri.sm/job/Kernel_builds/job/Emcraft_Kernel_CI_build/lastSuccessfulBuild/artifact/files/*zip*/files.zip -nH --cut-dirs=8 -P files
cd files
unzip -oj files.zip
gzip -f rsi_upgrade.tar
gzip -f rsi_firmware.tar
fi
case ${build_type} in
418)
kernel_url=https://arm01.puri.sm/job/Kernel_builds/job/kernel_devkit_linux-emcraft_imx8-4.18-wip/
uboot_url=https://arm01.puri.sm/job/u-boot_builds/job/uboot_418-devkit_build/
;;
52)