From 24b152725f1feae6f8ed3c19b7d23a5951d1e232 Mon Sep 17 00:00:00 2001 From: Andreas Kemnade Date: Mon, 27 Dec 2021 22:41:54 +0100 Subject: [PATCH] tolino-shine2hd: new device (MR 2797) Basic support for the Tolino Shine 2 HD ebook reader. Waveform handling shares the same oddities as for the Kobo Clara HD but the file epdc_E060SCM.fw from the IMX6SL BSP from NXP does also work. The existing waveform from SD card is used. Preferred way to install is to clone the internal SD, keeping the original as a backup, install on that clone. U-Boot is a more recent one than the factory u-boot, so devicetrees are nicely supported. Kernel is the near mainline kernel also used by the Kobo Clara HD. About Wifi: Handling of the configuration file for boards with brcmfmac is not supported yet. [ci:skip-build] already built successfully in CI --- .../testing/device-tolino-shine2hd/APKBUILD | 45 +++++++++++++++++++ .../device-tolino-shine2hd.post-install | 3 ++ .../testing/device-tolino-shine2hd/deviceinfo | 31 +++++++++++++ .../extract-waveform.initd | 21 +++++++++ .../extract-waveform.pl | 24 ++++++++++ .../device-tolino-shine2hd/uboot-script.cmd | 14 ++++++ .../testing/u-boot-tolino-shine2hd/APKBUILD | 37 +++++++++++++++ .../u-boot-tolino-shine2hd/u-boot-env.txt | 2 + 8 files changed, 177 insertions(+) create mode 100644 device/testing/device-tolino-shine2hd/APKBUILD create mode 100644 device/testing/device-tolino-shine2hd/device-tolino-shine2hd.post-install create mode 100644 device/testing/device-tolino-shine2hd/deviceinfo create mode 100644 device/testing/device-tolino-shine2hd/extract-waveform.initd create mode 100644 device/testing/device-tolino-shine2hd/extract-waveform.pl create mode 100644 device/testing/device-tolino-shine2hd/uboot-script.cmd create mode 100644 device/testing/u-boot-tolino-shine2hd/APKBUILD create mode 100644 device/testing/u-boot-tolino-shine2hd/u-boot-env.txt diff --git a/device/testing/device-tolino-shine2hd/APKBUILD b/device/testing/device-tolino-shine2hd/APKBUILD new file mode 100644 index 000000000..ebd2c18ed --- /dev/null +++ b/device/testing/device-tolino-shine2hd/APKBUILD @@ -0,0 +1,45 @@ +# Reference: +pkgname=device-tolino-shine2hd +pkgdesc="Tolino Shine 2 HD" +pkgver=0.1 +pkgrel=0 +url="https://postmarketos.org" +license="MIT" +arch="armv7" +options="!check !archcheck" +depends=" + perl + postmarketos-base + u-boot-tolino-shine2hd + u-boot-tools + linux-kobo-clara-mainline +" +makedepends="devicepkg-dev" +install="$pkgname.post-install" + +source=" + deviceinfo + extract-waveform.initd + extract-waveform.pl + uboot-script.cmd +" + +build() { + devicepkg_build $startdir $pkgname +} + +package() { + devicepkg_package $startdir $pkgname + install -Dm755 "$srcdir"/extract-waveform.pl "$pkgdir"/usr/sbin/extract-waveform.pl + install -Dm755 "$srcdir"/extract-waveform.initd "$pkgdir"/etc/init.d/extract-waveform + mkimage -A arm -O linux -T script -n postmarketOS \ + -d "$srcdir/uboot-script.cmd" "$srcdir/boot.scr" + install -Dm644 "$srcdir/boot.scr" "$pkgdir/boot/boot.scr" +} + +sha512sums=" +e4888a03a32e4543cb05b6ff1ecc04ad4ab521c11a39207243166e125a6553b373d19b890c09e3787785bc2929ef07d2434a8cc9b2e6def97b2ced96693a53b1 deviceinfo +c68e4e41d73a1f9d08aeed95743d5a3ae6831d36d0259ba96ceca297479fef01b78c2b569c376c5b24b4ee24ea7d3cb44d6e97730f44d81fd67e9f0586c4911a extract-waveform.initd +34475b314e45135c84e4abdc769d3aba9df56e37814c7f689d5e1aca5af060b2e028c01e871c3863534fede0be7c79aaebe0a1ff4f2bfab2ee974489119005cf extract-waveform.pl +3b5c33ffa9b81d55451fd4fa0c9ed69149304b88fb85752cead4d34b5467112029cc4883a91e7daa38f8cba55d90a814711b2c55a8d462d115b62f752ce311b7 uboot-script.cmd +" diff --git a/device/testing/device-tolino-shine2hd/device-tolino-shine2hd.post-install b/device/testing/device-tolino-shine2hd/device-tolino-shine2hd.post-install new file mode 100644 index 000000000..eef41e601 --- /dev/null +++ b/device/testing/device-tolino-shine2hd/device-tolino-shine2hd.post-install @@ -0,0 +1,3 @@ +#!/bin/sh + +rc-update add extract-waveform default diff --git a/device/testing/device-tolino-shine2hd/deviceinfo b/device/testing/device-tolino-shine2hd/deviceinfo new file mode 100644 index 000000000..5057f541e --- /dev/null +++ b/device/testing/device-tolino-shine2hd/deviceinfo @@ -0,0 +1,31 @@ +# Reference: +# Please use double quotes only. You can source this file in shell +# scripts. + +deviceinfo_format_version="0" +deviceinfo_name="Tolino Shine 2HD" +# tolino was bought by Kobo, "about" pages on device list Kobo +# but to not add too much confusion, simply specify Tolino here +# Mainline kernel uses kobo as vendor-prefix for the model name compatible +deviceinfo_manufacturer="Tolino" +deviceinfo_codename="tolino-shine2hd" +deviceinfo_year="2015" +deviceinfo_arch="armv7" +deviceinfo_dtb="imx6sl-tolino-shine2hd" + +# Device related +deviceinfo_chassis="tablet" +deviceinfo_keyboard="false" +deviceinfo_external_storage="true" +deviceinfo_screen_width="1072" +deviceinfo_screen_height="1448" + +# Bootloader related +deviceinfo_flash_method="none" +deviceinfo_boot_part_start="49152" +deviceinfo_getty="ttymxc0;115200" +deviceinfo_generate_legacy_uboot_initfs="true" +deviceinfo_no_framebuffer="true" + +deviceinfo_sd_embed_firmware_step_size="512" +deviceinfo_sd_embed_firmware="u-boot/tolino-shine2hd/u-boot.imx:2,u-boot/tolino-shine2hd/u-boot-env.bin:1536" diff --git a/device/testing/device-tolino-shine2hd/extract-waveform.initd b/device/testing/device-tolino-shine2hd/extract-waveform.initd new file mode 100644 index 000000000..bfd46ced8 --- /dev/null +++ b/device/testing/device-tolino-shine2hd/extract-waveform.initd @@ -0,0 +1,21 @@ +#!/sbin/openrc-run + +description="Extract EPD waveform blob to /lib/firmware" + +depend() { + after root +} + +start() +{ + # Only run once + rm -f /etc/runlevels/*/$RC_SVCNAME + + dir="/lib/firmware/imx/epdc" + + ebegin "Copying EPD waveform to /lib/firmware..." + mkdir -p "$dir" && cd "$dir" \ + && extract-waveform.pl /dev/mmcblk0 epdc_PENG060D.fw \ + && ln -sf epdc_PENG060D.fw epdc.fw + eend $? +} diff --git a/device/testing/device-tolino-shine2hd/extract-waveform.pl b/device/testing/device-tolino-shine2hd/extract-waveform.pl new file mode 100644 index 000000000..9d9e86dda --- /dev/null +++ b/device/testing/device-tolino-shine2hd/extract-waveform.pl @@ -0,0 +1,24 @@ +#!/usr/bin/env perl +# SPDX-License-Identifier: GPL-2.0+ +# (c) 2020, Andreas Kemnade + +sub usage { + print "Usage: $0 disk epdc.fw\ndisk is the Kobo/Toline disk (image) containing a waveform\n"; + exit(1); +} + +&usage unless $#ARGV == 1; + +open IMGFILE, '<:raw', @ARGV[0] or die "cannot open @ARGV[0]"; +seek IMGFILE, 0x700000-16, 0; +read IMGFILE, $magic, 8; +(unpack("x0 H16", $magic) eq "fff5afff78563412") or die "invalid magic"; + +seek IMGFILE, 0x700000-8, 0; +read IMGFILE, $lengthbytes, 4; +$length = unpack("x0 V", $lengthbytes) or die "invalid length"; +print $length . " bytes\n" ; +seek IMGFILE, 0x700000, 0 or die "seek failed, file too short?"; +open OUTFILE, '>:raw', @ARGV[1] or die "cannot open @ARGV[1]"; +read IMGFILE, $waveform, $length; +print OUTFILE $waveform; diff --git a/device/testing/device-tolino-shine2hd/uboot-script.cmd b/device/testing/device-tolino-shine2hd/uboot-script.cmd new file mode 100644 index 000000000..4e7544f28 --- /dev/null +++ b/device/testing/device-tolino-shine2hd/uboot-script.cmd @@ -0,0 +1,14 @@ +led tolinoshine2hd:white:on on +setenv bootargs console=ttymxc0,115200 + +echo Loading kernel +load mmc 0:1 0x80800000 vmlinuz + +echo Loading DTB +load mmc 0:1 0x83000000 imx6sl-tolino-shine2hd.dtb + +echo Loading initrd +load mmc 0:1 0x85000000 uInitrd + +echo Booting kernel +bootz 0x80800000 0x85000000 0x83000000 diff --git a/device/testing/u-boot-tolino-shine2hd/APKBUILD b/device/testing/u-boot-tolino-shine2hd/APKBUILD new file mode 100644 index 000000000..04cf3cada --- /dev/null +++ b/device/testing/u-boot-tolino-shine2hd/APKBUILD @@ -0,0 +1,37 @@ +# Reference: +pkgname=u-boot-tolino-shine2hd +pkgver=2020.10 +pkgrel=0 +pkgdesc="U-Boot for Tolino Shine 2 HD, based on freescale fork" +arch="armv7" +_carch="arm" +license="GPL-2.0" +url="https://github.com/akemnade/u-boot-fslc" +makedepends="$depends_dev bc dtc bison flex" +options="!check" + +_repository="u-boot-fslc" +_commit="fcf25705fc8b57cb22c81b2d352e9a06269911be" +source=" + $pkgname-$_commit.tar.gz::https://github.com/akemnade/$_repository/archive/$_commit.tar.gz + u-boot-env.txt +" + +builddir="$srcdir/$_repository-$_commit" + +build() { + make ARCH="$_carch" mx6sltolinoshine3_defconfig + make ARCH="$_carch" DEVICE_TREE=imx6sl-tolino-shine2hd + tools/mkenvimage -p 0 -s 8192 -o u-boot-env.bin "$srcdir/u-boot-env.txt" +} + +package() { + install -D -m644 "$builddir/u-boot-dtb.bin" "$pkgdir/usr/share/u-boot/tolino-shine2hd/u-boot.bin" + install -D -m644 "$builddir/u-boot-dtb.imx" "$pkgdir/usr/share/u-boot/tolino-shine2hd/u-boot.imx" + install -D -m644 "$builddir/u-boot-env.bin" "$pkgdir/usr/share/u-boot/tolino-shine2hd/u-boot-env.bin" +} + +sha512sums=" +6a9c3f5d2ad806ab9529f0c8fc19213098aae620c5bf34e5cc273453bf007266a674489deff18ffa82e8826280192dbc443b024a3f878836021ae6c062be4189 u-boot-tolino-shine2hd-fcf25705fc8b57cb22c81b2d352e9a06269911be.tar.gz +ca8237a86da93dfea62355cfbb8dbe4104c2f3aea71b4c36d5418e6aef6ead32e9d23e4731b8ff64b4a73ca563b0323087384de10d4946afd657dce4cc7c6fee u-boot-env.txt +" diff --git a/device/testing/u-boot-tolino-shine2hd/u-boot-env.txt b/device/testing/u-boot-tolino-shine2hd/u-boot-env.txt new file mode 100644 index 000000000..acd851bfc --- /dev/null +++ b/device/testing/u-boot-tolino-shine2hd/u-boot-env.txt @@ -0,0 +1,2 @@ +# Load actual boot script from the boot partition +bootcmd=load mmc 0:1 0x80800000 boot.scr ; source 0x80800000