From 0f10a16a23a21887b2d1519534bf8e467841c273 Mon Sep 17 00:00:00 2001 From: Yannick Heneault Date: Sun, 18 Nov 2018 16:38:20 -0500 Subject: [PATCH] Adapted platform for trezor 1.7.1 (webusb) --- build/conf/local.conf | 5 +-- .../recipes-core/images/pitrezor-image.bb | 5 ++- .../pitrezor/files/start_pitrezor | 4 +-- .../recipes-core/pitrezor/pitrezor_git.bb | 6 ++-- .../python/python3-munch_2.3.2.bb | 13 ++++++++ .../python/python3-protobuf_3.4.0.bbappend | 1 + .../python/python3-trezor_git.bb | 18 +++++++++++ .../linux/linux-raspberrypi/usb_inode.patch | 32 +++++++++++++++++++ .../linux/linux-raspberrypi_4.9.bbappend | 2 ++ .../recipes-support/libusbgx/libusbgx_git.bb | 18 ----------- 10 files changed, 78 insertions(+), 26 deletions(-) create mode 100644 meta-pitrezor/recipes-devtools/python/python3-munch_2.3.2.bb create mode 100644 meta-pitrezor/recipes-devtools/python/python3-protobuf_3.4.0.bbappend create mode 100644 meta-pitrezor/recipes-devtools/python/python3-trezor_git.bb create mode 100644 meta-pitrezor/recipes-kernel/linux/linux-raspberrypi/usb_inode.patch create mode 100644 meta-pitrezor/recipes-kernel/linux/linux-raspberrypi_4.9.bbappend delete mode 100644 meta-pitrezor/recipes-support/libusbgx/libusbgx_git.bb diff --git a/build/conf/local.conf b/build/conf/local.conf index c767d83..cc9183a 100644 --- a/build/conf/local.conf +++ b/build/conf/local.conf @@ -14,10 +14,11 @@ SYSVINIT_ENABLED_GETTYS = "" KERNEL_DEVICETREE_append = " overlays/dwc2.dtbo " GPU_MEM = "64" CMDLINE = "dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait consoleblank=0 ro quiet " -KERNEL_MODULE_AUTOLOAD += " usb_f_hid dwc2 " +KERNEL_MODULE_AUTOLOAD += " gadgetfs dwc2 " EXTRA_IMAGECMD_ext3 = "-i 4096 -L fs" FATPAYLOAD += " ${datadir}/pitrezor/pitrezor.config" -TOOLCHAIN_TARGET_TASK += "bcm2835-staticdev" +TOOLCHAIN_TARGET_TASK += " bcm2835-staticdev " +TOOLCHAIN_HOST_TASK_append += " nativesdk-protobuf-compiler nativesdk-python3-protobuf nativesdk-python3-setuptools nativesdk-python3 nativesdk-python3-click nativesdk-python3-trezor nativesdk-python3-mako nativesdk-python3-munch " BB_DISKMON_DIRS = "\ STOPTASKS,${TMPDIR},1G,100K \ diff --git a/meta-pitrezor/recipes-core/images/pitrezor-image.bb b/meta-pitrezor/recipes-core/images/pitrezor-image.bb index 8fad793..b4d132a 100644 --- a/meta-pitrezor/recipes-core/images/pitrezor-image.bb +++ b/meta-pitrezor/recipes-core/images/pitrezor-image.bb @@ -3,7 +3,7 @@ include recipes-core/images/core-image-minimal.bb # Include modules in rootfs IMAGE_INSTALL += " \ - kernel-module-usb-f-hid \ + kernel-module-gadgetfs \ kernel-module-dwc2 \ " IMAGE_INSTALL += " pitrezor " @@ -28,6 +28,9 @@ customize_image() { echo "tz:5:respawn:/usr/bin/start_pitrezor" >> ${IMAGE_ROOTFS}/etc/inittab echo "LABEL=boot /boot vfat defaults 0 0" >> ${IMAGE_ROOTFS}/etc/fstab + + echo "mkdir /dev/gadget && mount -t gadgetfs none /dev/gadget" >> ${IMAGE_ROOTFS}/etc/rcS.d/S10mountgadget + chmod a+x ${IMAGE_ROOTFS}/etc/rcS.d/S10mountgadget } ROOTFS_POSTPROCESS_COMMAND_append = " customize_image; " diff --git a/meta-pitrezor/recipes-core/pitrezor/files/start_pitrezor b/meta-pitrezor/recipes-core/pitrezor/files/start_pitrezor index 3594fd1..59def78 100755 --- a/meta-pitrezor/recipes-core/pitrezor/files/start_pitrezor +++ b/meta-pitrezor/recipes-core/pitrezor/files/start_pitrezor @@ -1,6 +1,6 @@ #!/bin/sh -source /boot/pitrezor.config - cd /boot +dos2unix -n pitrezor.config /var/volatile/pitrezor.config +source /var/volatile/pitrezor.config TREZOR_OLED_FULLSCREEN=1 /usr/bin/pitrezor diff --git a/meta-pitrezor/recipes-core/pitrezor/pitrezor_git.bb b/meta-pitrezor/recipes-core/pitrezor/pitrezor_git.bb index da78e13..f51c82d 100644 --- a/meta-pitrezor/recipes-core/pitrezor/pitrezor_git.bb +++ b/meta-pitrezor/recipes-core/pitrezor/pitrezor_git.bb @@ -3,8 +3,8 @@ SUMMARY = "Pitrezor application" LICENSE = "GPLv2" LIC_FILES_CHKSUM = "file://COPYING;md5=e6a600fd5e1d9cbde2d983680233ad02" -DEPENDS = "libsdl2 libusbgx bcm2835 protobuf-native python3-protobuf-native python3-six-native dos2unix-native" -RDEPENDS_${PN} = "rng-tools" +DEPENDS = "libsdl2 bcm2835 protobuf-native python3-protobuf-native python3-six-native python3-click-native python3-trezor-native dos2unix-native python3-mako-native python3-munch-native libconfig" +RDEPENDS_${PN} = "rng-tools dos2unix" inherit pkgconfig python3native @@ -13,7 +13,7 @@ SRC_URI = "gitsm://github.com/heneault/trezor-mcu.git;branch=pitrezor \ file://pitrezor.config \ " -SRCREV = "fca6824df2faf004f168c7db5b1b7c2ed95a244f" +SRCREV = "58035f00a81b4b1388c2c9f69acdccedd362d413" S = "${WORKDIR}/git" diff --git a/meta-pitrezor/recipes-devtools/python/python3-munch_2.3.2.bb b/meta-pitrezor/recipes-devtools/python/python3-munch_2.3.2.bb new file mode 100644 index 0000000..61cdab8 --- /dev/null +++ b/meta-pitrezor/recipes-devtools/python/python3-munch_2.3.2.bb @@ -0,0 +1,13 @@ +SUMMARY = "A dot-accessible dictionary (a la JavaScript objects)." + +HOMEPAGE = "https://github.com/Infinidat/munch" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=f0291cd32b2d6a91d9b19970c94d0a46" + +SRC_URI[md5sum] = "539311fdfc6419381b6f38d0695f01ee" +SRC_URI[sha256sum] = "6ae3d26b837feacf732fb8aa5b842130da1daf221f5af9f9d4b2a0a6414b0d51" + +BBCLASSEXTEND = "native nativesdk" + +inherit pypi setuptools3 + diff --git a/meta-pitrezor/recipes-devtools/python/python3-protobuf_3.4.0.bbappend b/meta-pitrezor/recipes-devtools/python/python3-protobuf_3.4.0.bbappend new file mode 100644 index 0000000..608377e --- /dev/null +++ b/meta-pitrezor/recipes-devtools/python/python3-protobuf_3.4.0.bbappend @@ -0,0 +1 @@ +BBCLASSEXTEND = "native nativesdk" diff --git a/meta-pitrezor/recipes-devtools/python/python3-trezor_git.bb b/meta-pitrezor/recipes-devtools/python/python3-trezor_git.bb new file mode 100644 index 0000000..1f8d469 --- /dev/null +++ b/meta-pitrezor/recipes-devtools/python/python3-trezor_git.bb @@ -0,0 +1,18 @@ +SUMMARY = "Client side implementation for TREZOR-compatible Bitcoin hardware wallets." + +HOMEPAGE = "https://github.com/trezor/python-trezor" +LICENSE = "LGPLv3" +LIC_FILES_CHKSUM = "file://COPYING;md5=e6a600fd5e1d9cbde2d983680233ad02" + +SRC_URI = "gitsm://github.com/trezor/python-trezor.git" +SRCREV = "252f946f409fc87d6b9f462682ef36219b96ece3" +S="${WORKDIR}/git" + +SRC_URI[md5sum] = "" +SRC_URI[sha256sum] = "" + +BBCLASSEXTEND = "native nativesdk" + +inherit setuptools3 + +DEPENDS += " protobuf-native python3-protobuf-native python3-six-native " diff --git a/meta-pitrezor/recipes-kernel/linux/linux-raspberrypi/usb_inode.patch b/meta-pitrezor/recipes-kernel/linux/linux-raspberrypi/usb_inode.patch new file mode 100644 index 0000000..fc796f8 --- /dev/null +++ b/meta-pitrezor/recipes-kernel/linux/linux-raspberrypi/usb_inode.patch @@ -0,0 +1,32 @@ +--- git/drivers/usb/gadget/legacy/inode.c 2018-11-10 17:41:56.027719759 -0500 ++++ git.new/drivers/usb/gadget/legacy/inode.c 2018-11-10 18:00:17.401165612 -0500 +@@ -1284,7 +1284,7 @@ + + qual.bLength = sizeof qual; + qual.bDescriptorType = USB_DT_DEVICE_QUALIFIER; +- qual.bcdUSB = cpu_to_le16 (0x0200); ++ qual.bcdUSB = desc->bcdUSB; + + desc = dev->dev; + qual.bDeviceClass = desc->bDeviceClass; +@@ -1393,11 +1393,8 @@ + if (value >= 0) + value = min (w_length, (u16) value); + break; +- case USB_DT_STRING: ++ default: + goto unrecognized; +- +- default: // all others are errors +- break; + } + break; + +@@ -1856,7 +1853,6 @@ + || dev->dev->bNumConfigurations != 1) + goto fail; + dev->dev->bNumConfigurations = 1; +- dev->dev->bcdUSB = cpu_to_le16 (0x0200); + + /* triggers gadgetfs_bind(); then we can enumerate. */ + spin_unlock_irq (&dev->lock); diff --git a/meta-pitrezor/recipes-kernel/linux/linux-raspberrypi_4.9.bbappend b/meta-pitrezor/recipes-kernel/linux/linux-raspberrypi_4.9.bbappend new file mode 100644 index 0000000..1e83748 --- /dev/null +++ b/meta-pitrezor/recipes-kernel/linux/linux-raspberrypi_4.9.bbappend @@ -0,0 +1,2 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +SRC_URI += "file://usb_inode.patch" diff --git a/meta-pitrezor/recipes-support/libusbgx/libusbgx_git.bb b/meta-pitrezor/recipes-support/libusbgx/libusbgx_git.bb deleted file mode 100644 index 24d9085..0000000 --- a/meta-pitrezor/recipes-support/libusbgx/libusbgx_git.bb +++ /dev/null @@ -1,18 +0,0 @@ -SUMMARY = "USB Gadget Configfs Library (next)" - -LICENSE = "GPLv2 & LGPLv2.1" -LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ - file://COPYING.LGPL;md5=4fbd65380cdd255951079008b364516c" - -DEPENDS = "libconfig" - -inherit autotools pkgconfig - -SRCREV = "904b04c4b46ec673197ad1d8291a0aabe6a34f52" -SRC_URI = "git://github.com/libusbgx/libusbgx.git \ - " -S = "${WORKDIR}/git" - -PACKAGES = "${PN}-example ${PN} ${PN}-dev ${PN}-dbg" - -FILES_${PN}-example = "${bindir}/*"