From b4b4dff0b58f384f94021229bba6465cff935c73 Mon Sep 17 00:00:00 2001 From: Yannick Heneault Date: Sat, 10 Feb 2018 11:31:37 -0500 Subject: [PATCH] added files --- .gitignore | 9 ++++ .gitmodules | 12 ++++++ README.md | 2 + build/conf/bblayers.conf | 16 +++++++ build/conf/local.conf | 33 +++++++++++++++ meta-openembedded | 1 + meta-pitrezor/conf/layer.conf | 10 +++++ .../bootfiles/bcm2835-bootfiles.bbappend | 14 +++++++ .../bootfiles/rpi-config_%.bbappend | 8 ++++ .../images/pitrezor-image-debug.bb | 8 ++++ .../recipes-core/images/pitrezor-image.bb | 33 +++++++++++++++ .../pitrezor/files/pitrezor.config | 9 ++++ .../pitrezor/files/start_pitrezor | 6 +++ .../recipes-core/pitrezor/pitrezor_git.bb | 42 +++++++++++++++++++ .../bcm2835/bcm2835_%.bbappend | 2 + .../bcm2835/files/fix_i2c_core_clock.patch | 12 ++++++ .../recipes-graphics/libsdl/libsdl_%.bbappend | 2 + .../recipes-support/libusbgx/libusbgx_git.bb | 18 ++++++++ meta-raspberrypi | 1 + poky | 1 + 20 files changed, 239 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 build/conf/bblayers.conf create mode 100644 build/conf/local.conf create mode 160000 meta-openembedded create mode 100644 meta-pitrezor/conf/layer.conf create mode 100644 meta-pitrezor/recipes-bsp/bootfiles/bcm2835-bootfiles.bbappend create mode 100644 meta-pitrezor/recipes-bsp/bootfiles/rpi-config_%.bbappend create mode 100644 meta-pitrezor/recipes-core/images/pitrezor-image-debug.bb create mode 100644 meta-pitrezor/recipes-core/images/pitrezor-image.bb create mode 100644 meta-pitrezor/recipes-core/pitrezor/files/pitrezor.config create mode 100755 meta-pitrezor/recipes-core/pitrezor/files/start_pitrezor create mode 100644 meta-pitrezor/recipes-core/pitrezor/pitrezor_git.bb create mode 100644 meta-pitrezor/recipes-devtools/bcm2835/bcm2835_%.bbappend create mode 100644 meta-pitrezor/recipes-devtools/bcm2835/files/fix_i2c_core_clock.patch create mode 100644 meta-pitrezor/recipes-graphics/libsdl/libsdl_%.bbappend create mode 100644 meta-pitrezor/recipes-support/libusbgx/libusbgx_git.bb create mode 160000 meta-raspberrypi create mode 160000 poky diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..44bd340 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +build/bitbake.lock +build/cache/ +build/conf/sanity_info +build/conf/templateconf.cfg +build/downloads/ +build/sstate-cache/ +build/tmp/ +build/bitbake-cookerdaemon.log + diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5d3008e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,12 @@ +[submodule "poky"] + path = poky + url = git://git.yoctoproject.org/poky.git + branch = rocko +[submodule "meta-openembedded"] + path = meta-openembedded + url = git://git.openembedded.org/meta-openembedded + branch = rocko +[submodule "meta-raspberrypi"] + path = meta-raspberrypi + url = git://git.yoctoproject.org/meta-raspberrypi + branch = rocko diff --git a/README.md b/README.md index e9c39c2..bbd376c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # yocto-pitrezor OS linux platform for the pitrezor project (usign yocto) + +This code is used to build the linux platform for the pi zero to be able to run the pitrezor software at boot. diff --git a/build/conf/bblayers.conf b/build/conf/bblayers.conf new file mode 100644 index 0000000..fc732e8 --- /dev/null +++ b/build/conf/bblayers.conf @@ -0,0 +1,16 @@ +POKY_BBLAYERS_CONF_VERSION = "2" + +BBPATH = "${TOPDIR}" +BBFILES ?= "" + +BBLAYERS ?= " \ + ${TOPDIR}/../poky/meta \ + ${TOPDIR}/../poky/meta-poky \ + ${TOPDIR}/../poky/meta-yocto-bsp \ + ${TOPDIR}/../meta-openembedded/meta-oe \ + ${TOPDIR}/../meta-openembedded/meta-multimedia \ + ${TOPDIR}/../meta-openembedded/meta-networking \ + ${TOPDIR}/../meta-openembedded/meta-python \ + ${TOPDIR}/../meta-raspberrypi \ + ${TOPDIR}/../meta-pitrezor \ + " diff --git a/build/conf/local.conf b/build/conf/local.conf new file mode 100644 index 0000000..1514881 --- /dev/null +++ b/build/conf/local.conf @@ -0,0 +1,33 @@ +MACHINE ??= "raspberrypi0-wifi" +DISTRO ?= "poky" +PACKAGE_CLASSES ?= "package_rpm" +EXTRA_IMAGE_FEATURES += "debug-tweaks read-only-rootfs" +USER_CLASSES ?= "buildstats image-mklibs image-prelink" +PATCHRESOLVE = "noop" + +DISTRO_FEATURES_remove = " acl alsa argp bluetooth irda largefile pcmcia usbgadget usbhost xattr nfs zeroconf pci 3g nfc x11 wayland pulseaudio " +VIRTUAL-RUNTIME_init_manager = "sysvinit" +VIRTUAL-RUNTIME_dev_manager = "" +BOOTDD_VOLUME_ID = "boot" +SERIAL_CONSOLE = "" +SYSVINIT_ENABLED_GETTYS = "" +KERNEL_DEVICETREE_append = " overlays/dwc2.dtbo " +GPU_MEM = "16" +CMDLINE = "dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait consoleblank=0 ro quiet " +KERNEL_MODULE_AUTOLOAD += " usb_f_hid dwc2 " +EXTRA_IMAGECMD_ext3 = "-i 4096 -L fs" +FATPAYLOAD += " ${datadir}/pitrezor/pitrezor.config" +TOOLCHAIN_TARGET_TASK += "bcm2835-staticdev" + +BB_DISKMON_DIRS = "\ + STOPTASKS,${TMPDIR},1G,100K \ + STOPTASKS,${DL_DIR},1G,100K \ + STOPTASKS,${SSTATE_DIR},1G,100K \ + STOPTASKS,/tmp,100M,100K \ + ABORT,${TMPDIR},100M,1K \ + ABORT,${DL_DIR},100M,1K \ + ABORT,${SSTATE_DIR},100M,1K \ + ABORT,/tmp,10M,1K" + +CONF_VERSION = "1" + diff --git a/meta-openembedded b/meta-openembedded new file mode 160000 index 0000000..6e3fc5b --- /dev/null +++ b/meta-openembedded @@ -0,0 +1 @@ +Subproject commit 6e3fc5b8d904d06e3aa77e9ec9968ab37a798188 diff --git a/meta-pitrezor/conf/layer.conf b/meta-pitrezor/conf/layer.conf new file mode 100644 index 0000000..eab68f3 --- /dev/null +++ b/meta-pitrezor/conf/layer.conf @@ -0,0 +1,10 @@ +# We have a conf and classes directory, add to BBPATH +BBPATH .= ":${LAYERDIR}" + +# We have recipes-* directories, add to BBFILES +BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ + ${LAYERDIR}/recipes-*/*/*.bbappend" + +BBFILE_COLLECTIONS += "meta-pitrezor" +BBFILE_PATTERN_meta-pitrezor = "^${LAYERDIR}/" +BBFILE_PRIORITY_meta-pitrezor = "10" diff --git a/meta-pitrezor/recipes-bsp/bootfiles/bcm2835-bootfiles.bbappend b/meta-pitrezor/recipes-bsp/bootfiles/bcm2835-bootfiles.bbappend new file mode 100644 index 0000000..36d19e1 --- /dev/null +++ b/meta-pitrezor/recipes-bsp/bootfiles/bcm2835-bootfiles.bbappend @@ -0,0 +1,14 @@ +do_deploy() { + install -d ${DEPLOYDIR}/${PN} + + for i in ${S}/*.bin ; do + cp $i ${DEPLOYDIR}/${PN} + done + + cp ${S}/start_cd.elf ${DEPLOYDIR}/${PN} + cp ${S}/fixup_cd.dat ${DEPLOYDIR}/${PN} + + # Add stamp in deploy directory + touch ${DEPLOYDIR}/${PN}/${PN}-${PV}.stamp +} + diff --git a/meta-pitrezor/recipes-bsp/bootfiles/rpi-config_%.bbappend b/meta-pitrezor/recipes-bsp/bootfiles/rpi-config_%.bbappend new file mode 100644 index 0000000..bcf2643 --- /dev/null +++ b/meta-pitrezor/recipes-bsp/bootfiles/rpi-config_%.bbappend @@ -0,0 +1,8 @@ +do_deploy_append() { +cat <> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt +dtoverlay=dwc2 +hdmi_group=2 +hdmi_mode=4 +EOL +} + diff --git a/meta-pitrezor/recipes-core/images/pitrezor-image-debug.bb b/meta-pitrezor/recipes-core/images/pitrezor-image-debug.bb new file mode 100644 index 0000000..8e517fc --- /dev/null +++ b/meta-pitrezor/recipes-core/images/pitrezor-image-debug.bb @@ -0,0 +1,8 @@ +include pitrezor-image.bb + +IMAGE_INSTALL += " \ + kernel-module-brcmfmac \ + " + +IMAGE_INSTALL += " linux-firmware-bcm43430 wireless-tools wpa-supplicant dropbear gdbserver " + diff --git a/meta-pitrezor/recipes-core/images/pitrezor-image.bb b/meta-pitrezor/recipes-core/images/pitrezor-image.bb new file mode 100644 index 0000000..8fad793 --- /dev/null +++ b/meta-pitrezor/recipes-core/images/pitrezor-image.bb @@ -0,0 +1,33 @@ +# Base this image on core-image-minimal +include recipes-core/images/core-image-minimal.bb + +# Include modules in rootfs +IMAGE_INSTALL += " \ + kernel-module-usb-f-hid \ + kernel-module-dwc2 \ + " +IMAGE_INSTALL += " pitrezor " + +customize_image() { + rm -f ${IMAGE_ROOTFS}/etc/rcS.d/*keymap.sh + rm -f ${IMAGE_ROOTFS}/etc/rcS.d/*bootlogd + rm -f ${IMAGE_ROOTFS}/etc/rcS.d/*urandom + rm -f ${IMAGE_ROOTFS}/etc/rcS.d/*banner.sh + rm -f ${IMAGE_ROOTFS}/etc/rcS.d/*populate-volatile.sh + rm -f ${IMAGE_ROOTFS}/etc/rcS.d/*dmesg.sh + rm -f ${IMAGE_ROOTFS}/etc/rcS.d/*bootmisc.sh + + rm -f ${IMAGE_ROOTFS}/etc/rc5.d/*syslog + rm -f ${IMAGE_ROOTFS}/etc/rc5.d/*rmnologin.sh + rm -f ${IMAGE_ROOTFS}/etc/rc5.d/*mountnfs.sh + rm -f ${IMAGE_ROOTFS}/etc/rc5.d/*stop-bootlogd + rm -f ${IMAGE_ROOTFS}/etc/rc5.d/*networking + + echo "pitrezor" > ${IMAGE_ROOTFS}/etc/hostname + + echo "tz:5:respawn:/usr/bin/start_pitrezor" >> ${IMAGE_ROOTFS}/etc/inittab + + echo "LABEL=boot /boot vfat defaults 0 0" >> ${IMAGE_ROOTFS}/etc/fstab +} + +ROOTFS_POSTPROCESS_COMMAND_append = " customize_image; " diff --git a/meta-pitrezor/recipes-core/pitrezor/files/pitrezor.config b/meta-pitrezor/recipes-core/pitrezor/files/pitrezor.config new file mode 100644 index 0000000..c2c6fb8 --- /dev/null +++ b/meta-pitrezor/recipes-core/pitrezor/files/pitrezor.config @@ -0,0 +1,9 @@ +#scale factor of display when using hdmi +export TREZOR_SDL_SCALE=2 + +#type of oled to use +# NO OLED = 0 +# OLED_ADAFRUIT_I2C_128x64 = 1 +# OLED_SEEED_I2C_128x64 = 2 +# OLED_SH1106_I2C_128x64 = 3 +export TREZOR_OLED_TYPE=3 diff --git a/meta-pitrezor/recipes-core/pitrezor/files/start_pitrezor b/meta-pitrezor/recipes-core/pitrezor/files/start_pitrezor new file mode 100755 index 0000000..08e2ef5 --- /dev/null +++ b/meta-pitrezor/recipes-core/pitrezor/files/start_pitrezor @@ -0,0 +1,6 @@ +#!/bin/sh + +source /boot/pitrezor.config + +cd /boot +/usr/bin/pitrezor diff --git a/meta-pitrezor/recipes-core/pitrezor/pitrezor_git.bb b/meta-pitrezor/recipes-core/pitrezor/pitrezor_git.bb new file mode 100644 index 0000000..a0fed23 --- /dev/null +++ b/meta-pitrezor/recipes-core/pitrezor/pitrezor_git.bb @@ -0,0 +1,42 @@ +SUMMARY = "Pitrezor application" + +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=e6a600fd5e1d9cbde2d983680233ad02" + +DEPENDS = "libsdl libusbgx bcm2835 protobuf-native python3-protobuf-native python3-six-native" +RDEPENDS_${PN} = "rng-tools" + +inherit pkgconfig python3native + +SRC_URI = "gitsm:///github.com/heneault/trezor-mcu.git;branch=pizero \ + file://start_pitrezor \ + file://pitrezor.config \ + " + +SRCREV = "5974180199dfa3b687faed96a5e34f065098da22" + +S = "${WORKDIR}/git" + +do_compile() { + export EMULATOR=1 + export TRANSPORT=USBG + export PIZERO=1 + export CPUFLAGS="" + export USE_RANDOM=1 + make -C emulator + make -C vendor/nanopb/generator/proto + make -C firmware/protob + make + make -C firmware trezor.elf +} + +do_install() { + install -d ${D}${bindir} + install -d ${D}${datadir}/pitrezor + install -m 0755 ${WORKDIR}/start_pitrezor ${D}${bindir} + install -m 0766 ${B}/firmware/trezor.elf ${D}${bindir}/pitrezor + install -m 0444 ${WORKDIR}/pitrezor.config ${D}${datadir}/pitrezor +} + +FILES_${PN} = "${bindir} ${datadir}/pitrezor" + diff --git a/meta-pitrezor/recipes-devtools/bcm2835/bcm2835_%.bbappend b/meta-pitrezor/recipes-devtools/bcm2835/bcm2835_%.bbappend new file mode 100644 index 0000000..6f6bc4d --- /dev/null +++ b/meta-pitrezor/recipes-devtools/bcm2835/bcm2835_%.bbappend @@ -0,0 +1,2 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" +SRC_URI += "file://fix_i2c_core_clock.patch" diff --git a/meta-pitrezor/recipes-devtools/bcm2835/files/fix_i2c_core_clock.patch b/meta-pitrezor/recipes-devtools/bcm2835/files/fix_i2c_core_clock.patch new file mode 100644 index 0000000..8cd2907 --- /dev/null +++ b/meta-pitrezor/recipes-devtools/bcm2835/files/fix_i2c_core_clock.patch @@ -0,0 +1,12 @@ +diff -Nur bcm2835-1.52.orig/src/bcm2835.h bcm2835-1.52/src/bcm2835.h +--- bcm2835-1.52.orig/src/bcm2835.h 2017-03-01 20:17:16.000000000 -0500 ++++ bcm2835-1.52/src/bcm2835.h 2018-01-24 14:15:00.055739461 -0500 +@@ -503,7 +503,7 @@ + #define LOW 0x0 + + /*! Speed of the core clock core_clk */ +-#define BCM2835_CORE_CLK_HZ 250000000 /*!< 250 MHz */ ++#define BCM2835_CORE_CLK_HZ 150000000 /*!< 150 MHz */ + + /*! On RPi2 with BCM2836, and all recent OSs, the base of the peripherals is read from a /proc file */ + #define BMC2835_RPI2_DT_FILENAME "/proc/device-tree/soc/ranges" diff --git a/meta-pitrezor/recipes-graphics/libsdl/libsdl_%.bbappend b/meta-pitrezor/recipes-graphics/libsdl/libsdl_%.bbappend new file mode 100644 index 0000000..d5f5476 --- /dev/null +++ b/meta-pitrezor/recipes-graphics/libsdl/libsdl_%.bbappend @@ -0,0 +1,2 @@ +EXTRA_OECONF += " --enable-video-fbcon " + diff --git a/meta-pitrezor/recipes-support/libusbgx/libusbgx_git.bb b/meta-pitrezor/recipes-support/libusbgx/libusbgx_git.bb new file mode 100644 index 0000000..24d9085 --- /dev/null +++ b/meta-pitrezor/recipes-support/libusbgx/libusbgx_git.bb @@ -0,0 +1,18 @@ +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}/*" diff --git a/meta-raspberrypi b/meta-raspberrypi new file mode 160000 index 0000000..510009f --- /dev/null +++ b/meta-raspberrypi @@ -0,0 +1 @@ +Subproject commit 510009f0c825cd7992d2d37e9ed0007f6c3be723 diff --git a/poky b/poky new file mode 160000 index 0000000..16e22f3 --- /dev/null +++ b/poky @@ -0,0 +1 @@ +Subproject commit 16e22f3e37788afb83044f5089d24187d70094bd