Commit a2e4d72e authored by Jeremiah Foster's avatar Jeremiah Foster
Browse files

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
......@@ -43,14 +43,23 @@ Each voltage is measured against ground (green circle in above image)
| 5 | white |
| 6 | n/c |
PIN 1 is the one closest to the volume button while PIN6 is the one closest to the power button.
PIN 1 is the one closest to the volume button while PIN6 is the one closest to
the power button.
* Power on/off
If the user holds the power button for ~2 seconds then a power down/reboot dialog would pop up; a quick press & release would turn the display on/off. If the button is held for ~5 seconds the SoC triggers an event to shut down, pressing it again for ~2 seconds will turn it back on. The button is also attached to the charge controller's QON# pin, which when held for ~15 seconds is able to put the dev kit into a "shipping mode" where the charge controller is completely off, or holding it for ~18 seconds will cause it to perform a complete power cycle.
If the user holds the power button for ~2 seconds, a power down/reboot dialog
would pop up; a quick press & release would turn the display on/off.
If the button is held for ~5 seconds, the SoC triggers an event to shut down,
pressing it again for ~2 seconds will turn it back on.
The button is also attached to the charge controller's QON# pin, which, when
held for ~15 seconds, is able to put the dev kit into a "shipping mode" where
the charge controller is turned completely off, or holding it for ~18 seconds
will cause it to perform a complete power cycle.
* Booting via nfsroot
The SOM comes with a pre flashed u-boot so you can connect the USB-to-UART-Debug cable and boot the device.
Breaking into uboot you can boot using a nfsroot filesystem via
The SOM comes with a pre flashed u-boot so you can connect the
USB-to-UART-Debug cable and boot the device.
Breaking into uboot, you can boot using a nfsroot filesystem via:
#+BEGIN_SRC
setenv nfsrootboot "setenv bootargs ${args_common} debug root=/dev/nfs ip=:::::eth0:dhcp nfsrootdebug nfsroot=<nfsserverip>:<nfsrootpath>,v3,tcp; dhcp ${loadaddr} Image-librem5-devkit; dhcp ${fdt_addr} librem5-devkit.dtb; booti ${loadaddr} - ${fdt_addr}"
......@@ -63,11 +72,12 @@ You need to fill in *nfsrootpath* and *nfsserverip* above. At
*nfsrootpath* there needs to be a armhf or arm64 root filesystem which
you can e.g. create via Debian's deboostrap.
For that to work the *BOOT MODE* switch needs to be set to *eMMC* (instead of *USB*).
For that to work, the *BOOT MODE* switch needs to be set to *eMMC*
(instead of *USB*).
* Installing a minimal Linux the eMMC
* Installing a minimal Linux to the eMMC
You can dd a prebuilt image on there or you can just debootstrap from
scratch, this can be useful if you don't want that many services
scratch. This can be useful if you don't want that many services
starting up by default:
#+BEGIN_SRC sh
......@@ -76,8 +86,8 @@ mount /dev/mmcblk0p2 /mnt
debootstrap --arch=arm64 buster /mnt
#+END_SRC
Back in u-boot we can switch to using the rootfs on the eMMC then (we're still
pulling kernel and device tree via tftp though:
Back in u-boot, we can switch to using the rootfs on the eMMC then (we're still
pulling kernel and device tree via tftp though):
#+BEGIN_SRC
setenv emmcboot "setenv bootargs ${args_common} debug root=/dev/mmcblk0p2; dhcp ${loadaddr} Image-librem5-devkit; dhcp ${fdt_addr} librem5-devkit.dtb; booti ${loadaddr} - ${fdt_addr}"
......@@ -86,7 +96,8 @@ setenv emmcboot "setenv bootargs ${args_common} debug root=/dev/mmcblk0p2; dhcp
* Install uuu
** By hand
The NXP mfgtool uuu is required to boot a board that has no bootloader or is otherwise "bricked". Either download, build and install uuu :
The NXP mfgtool uuu is required to boot a board that has no bootloader or is
"bricked" in another way. To download, build, and install uuu:
#+BEGIN_SRC
git clone https://github.com/NXPmicro/mfgtools
......@@ -102,9 +113,43 @@ sudo make install
scripts/build_uuu.sh -i
#+END_SRC
* Udev Rules
If you want to run *uuu* as non-root, add the following udev rules
#+BEGIN_SRC sh
cat <<EOF > /etc/udev/rules.d/99_librem5_devkit.rules
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"
EOF
sudo udevadm control -R
sudo adduser <youruser> plugdev
newgrp plugdev
#+END_SRC
Make sure you replug the serial cable in case you have plugged it in
already. With the above rules, you can skip the =sudo= in front of the
uuu invocations below.
* Flash the test image
The eMMC file used for flashing is files/devkit-test.img.
Put the "Boot Mode" switch in the USB position.
THIS WILL ERASE EVERYTHING ON YOUR eMMC.
#+BEGIN_SRC
scripts/get_image.sh
sudo uuu uuu_scripts/flash_librem5-devkit-test.lst
#+END_SRC
* Download Target Binaries
You can manually download or build the required binaries. There is also a convenience script to download prebuilt binaries from the Purism servers.
You can manually download or build the required binaries. There is also a
convenience script to download prebuilt binaries from the Purism servers.
#+BEGIN_SRC
scripts/fetch_latest.sh -xk
......@@ -113,13 +158,14 @@ scripts/fetch_latest.sh -xk
* Flash uboot
** Using SDP
The uboot that gets flashed is files/u-boot-devkit-recovery.imx . Put the "Boot Mode" switch in the USB position.
The uboot file used for flashing is files/u-boot-devkit-recovery.imx.
Put the "Boot Mode" switch in the USB position.
#+BEGIN_SRC
sudo uuu uuu_scripts/u-boot_flash_librem5-devkit.lst
#+END_SRC
You can also just boot to u-boot without flashing anything
You can also just boot to u-boot without flashing anything:
#+BEGIN_SRC
sudo uuu uuu_scripts/u-boot_librem5-devkit.lst
......@@ -127,7 +173,7 @@ sudo uuu uuu_scripts/u-boot_librem5-devkit.lst
** From u-boot using tftp
You must have a tftp server setup for this
You must have a tftp server setup for this.
#+BEGIN_SRC
setenv ipaddr <tftp server ip>
......@@ -138,16 +184,17 @@ mmc write 0x43000000 0x42 0x800
** From the kernel command line
Download the u-boot binary u-boot-devkit-recovery.imx
Download the u-boot binary u-boot-devkit-recovery.imx.
#+BEGIN_SRC
dd if=u-boot-devkit-recovery.imx of=/dev/mmcblk0 bs=1024 seek=33
#+END_SRC
* Flash eMMC
* Flash eMMC
** Using SDP
The eMMC that gets flashed is files/devkit.img . Put the "Boot Mode" switch in the USB position.
The eMMC file used for flashing is files/devkit.img.
Put the "Boot Mode" switch in the USB position.
THIS WILL ERASE EVERYTHING ON YOUR eMMC.
......@@ -174,7 +221,9 @@ The kernel needs to be extracted from the deb for the SDP boot.
** Build the test filesystem tarball
This will create a minimal debian rootfs tarball to be used to create an initramfs. If you need additional packages you can add them to the packages variable in the script.
This will create a minimal debian rootfs tarball that is used for creating an
initramfs. If you need additional packages, you can add them to the packages
variable in the script.
#+BEGIN_SRC
./scripts/create_tarball.sh
......@@ -182,13 +231,14 @@ This will create a minimal debian rootfs tarball to be used to create an initram
** Create the initramfs
This will take the tarball created above and customize it to be able to flash the RS9116 module and also adds some test scripts.
This will take the tarball created above and customize it to be able to flash
the RS9116 module and also adds some test scripts.
#+BEGIN_SRC
./scripts/create_initramfs.sh -t build/test_rootfs.tgz -o files/test_initramfs.img
#+END_SRC
You can include a locally generated kernel, modules and devicetree as well
You can include a locally generated kernel, modules, and devicetree as well:
#+BEGIN_SRC
./scripts/create_initramfs.sh -t build/test_rootfs.tgz -o files/test_initramfs.img -i <path to kernel>
......@@ -196,7 +246,9 @@ You can include a locally generated kernel, modules and devicetree as well
** Boot the initramfs
The initramfs can be booted on a board with an empty eMMC for testing and RS9116 flashing. Ensure the boot mode switch is switched to USB boot. Run the command below and then plug in the USB C port of the devkit.
The initramfs can be booted on a board with an empty eMMC for testing and
RS9116 flashing. Ensure the boot mode switch is switched to USB boot. Run
the command below and then plug in the USB-C port of the devkit.
#+BEGIN_SRC
sudo uuu uuu_scripts/test_librem5.lst
......@@ -204,9 +256,14 @@ sudo uuu uuu_scripts/test_librem5.lst
** Reflash the RS9116
By default no rsi_* modules get loaded. The modules without firmware are in "/lib/modules/<kernel_ver>/drivers/net/wireless/rsi" . The create_initramfs script above adds the rsi firmware and reflash modules in "/usr/src".
By default, no rsi_* modules get loaded. The modules without firmware are in
"/lib/modules/<kernel_ver>/drivers/net/wireless/rsi". The create_initramfs
script above adds the rsi firmware and reflashes the modules in "/usr/src".
There is a convenience script "flash_rsi.sh" that wiil perform the necessary steps. What the script does is it backs up the rsi modules in /lib/modules, copies the firmware into lib firmware and the modprobes the rsi flashing modules. It replaces the original modules when it's done.
There is a convenience script "flash_rsi.sh" that will perform the necessary
steps. The script backs up the rsi modules in /lib/modules, copies the firmware
into /lib/firmware and the modprobes for the rsi flashing modules.
It replaces the original modules when it's done.
Run the script on the target to reflash.