Skip to content

Commit

Permalink
added files
Browse files Browse the repository at this point in the history
  • Loading branch information
heneault committed Feb 10, 2018
1 parent f835148 commit b4b4dff
Show file tree
Hide file tree
Showing 20 changed files with 239 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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

12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
16 changes: 16 additions & 0 deletions build/conf/bblayers.conf
Original file line number Diff line number Diff line change
@@ -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 \
"
33 changes: 33 additions & 0 deletions build/conf/local.conf
Original file line number Diff line number Diff line change
@@ -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"

1 change: 1 addition & 0 deletions meta-openembedded
Submodule meta-openembedded added at 6e3fc5
10 changes: 10 additions & 0 deletions meta-pitrezor/conf/layer.conf
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 14 additions & 0 deletions meta-pitrezor/recipes-bsp/bootfiles/bcm2835-bootfiles.bbappend
Original file line number Diff line number Diff line change
@@ -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
}

8 changes: 8 additions & 0 deletions meta-pitrezor/recipes-bsp/bootfiles/rpi-config_%.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
do_deploy_append() {
cat <<EOL >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
dtoverlay=dwc2
hdmi_group=2
hdmi_mode=4
EOL
}

8 changes: 8 additions & 0 deletions meta-pitrezor/recipes-core/images/pitrezor-image-debug.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include pitrezor-image.bb

IMAGE_INSTALL += " \
kernel-module-brcmfmac \
"

IMAGE_INSTALL += " linux-firmware-bcm43430 wireless-tools wpa-supplicant dropbear gdbserver "

33 changes: 33 additions & 0 deletions meta-pitrezor/recipes-core/images/pitrezor-image.bb
Original file line number Diff line number Diff line change
@@ -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; "
9 changes: 9 additions & 0 deletions meta-pitrezor/recipes-core/pitrezor/files/pitrezor.config
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions meta-pitrezor/recipes-core/pitrezor/files/start_pitrezor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

source /boot/pitrezor.config

cd /boot
/usr/bin/pitrezor
42 changes: 42 additions & 0 deletions meta-pitrezor/recipes-core/pitrezor/pitrezor_git.bb
Original file line number Diff line number Diff line change
@@ -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"

2 changes: 2 additions & 0 deletions meta-pitrezor/recipes-devtools/bcm2835/bcm2835_%.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://fix_i2c_core_clock.patch"
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions meta-pitrezor/recipes-graphics/libsdl/libsdl_%.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
EXTRA_OECONF += " --enable-video-fbcon "

18 changes: 18 additions & 0 deletions meta-pitrezor/recipes-support/libusbgx/libusbgx_git.bb
Original file line number Diff line number Diff line change
@@ -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}/*"
1 change: 1 addition & 0 deletions meta-raspberrypi
Submodule meta-raspberrypi added at 510009
1 change: 1 addition & 0 deletions poky
Submodule poky added at 16e22f

0 comments on commit b4b4dff

Please sign in to comment.