Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mont3z committed Sep 15, 2016
0 parents commit f2158b1
Show file tree
Hide file tree
Showing 24 changed files with 16,549 additions and 0 deletions.
Empty file added .gitignore
Empty file.
17 changes: 17 additions & 0 deletions COPYING.MIT
@@ -0,0 +1,17 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
145 changes: 145 additions & 0 deletions README.md
@@ -0,0 +1,145 @@
## DEPENDENCIES ##

This layer depends on:

**poky**
URI: git://git.yoctoproject.org/poky.git
branch: krogoth
revision: HEAD

**meta-openembedded (meta-oe)**
URI: git://git.openembedded.org/meta-openembedded
subdirectory: meta-oe
branch: krogoth
revision: HEAD

**meta-linaro**
URI: https://git.linaro.org/openembedded/meta-linaro.git
subdirectory: meta-linaro
branch: krogoth
revision: HEAD


## INSTALLATION ##

For the following instructions we assume you are on a Linux Ubuntu or Debian distribution compatible with Yocto Krogoth.
However, most of the instructions should also be valid for other Linux systems.

Install required packages for Yocto:

```shell
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm
```

Download the required sources to some folder in your home directory.
For these instructions, we use the folder ~/yocto:

```shell
mkdir ~/yocto && cd ~/yocto
git clone -b krogoth git://git.yoctoproject.org/poky.git
git clone -b krogoth git://git.openembedded.org/meta-openembedded
git clone https://git.linaro.org/openembedded/meta-linaro.git
git clone https://github.com/mont3z/meta-pine64.git

```

Download and untar linaro gnueabihf toolchain which will be used for compiling u-boot:
(Note: this toolchain is for 64-bits host machines, if your PC is not 64 bits you need to compile a 32 bits linaro toolchain.)

```shell
mkdir ~/linaro-gnueabihf && cd ~/linaro-gnueabihf
wget https://releases.linaro.org/components/toolchain/binaries/latest-5/arm-linux-gnueabihf/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf.tar.xz
tar xvf gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf.tar.xz --strip 1
```

To initialize the build environment of Yocto, execute:

```shell
cd ~/yocto/poky
. oe-init-build-env
```

The script oe-init-build-env creates an initial build folder at ~/yocto/poky/build and corresponding build configuration files at ~/yocto/poky/build/conf.

The file ~/yocto/poky/build/conf/bblayers.conf defines the location of Yocto meta layers.
Edit this file and add the absolute paths to the layers needed by meta-pine64 to the variable BBLAYERS. For example, for a user "ME" the
absolute paths to these meta layers would be:

```shell
BBLAYERS ?= " \
/home/ME/yocto/poky/meta \
/home/ME/yocto/poky/meta-poky \
/home/ME/yocto/poky/meta-yocto-bsp \
/home/ME/yocto/meta-openembedded/meta-networking \
/home/ME/yocto/meta-openembedded/meta-oe \
/home/ME/yocto/meta-openembedded/meta-python \
/home/ME/yocto/meta-linaro/meta-linaro \
/home/ME/yocto/meta-linaro/meta-linaro-toolchain \
/home/ME/yocto/meta-linaro/meta-ilp32 \
/home/ME/yocto/meta-pine64 \
"
```

The variable MACHINE of local.conf defines the target hardware for which we will cross-compile.
Make sure it is set to

```shell
MACHINE ?= "pine64"
```

Additionally, add the following line to your local.conf to opt for linaro toolchain:

```shell
GCCVERSION = "linaro-5.3"
SDKGCCVERSION = "linaro-5.3"
# Substitute ME by your username or whatever path you unpacked linaro gnu eabihf
LINARO_EABIHF_PATH = "/home/ME/linaro-gnueabihf"
```

## USAGE ##

To initialize the build environment, execute:

```shell
cd ~/yocto/poky
. oe-init-build-env
```

Your configuration setup at ~/yocto/poky/build/conf will be preserved.

To create a minimal system, in your build folder ~/yocto/poky/build execute the following command. This image only has a
login interface in UART. You'll need a RS-232 to USB converter to see it. Login with the user "root" (no password).

```shell
bitbake core-image-minimal
```

To create a yocto sato image, in your build folder ~/yocto/poky/build execute the following command. Image with Sato, a mobile
environment and visual style for mobile devices. It uses pine64 HDMI output and supports X11 with a Sato theme, Pimlico applications,
and contains terminal, editor, and file manager.

```shell
bitbake core-image-sato
```

## BURNING IMAGE TO SDCARD ##

Under Linux, insert a USB flash drive. Assuming the USB flash drive takes device /dev/sdf, use dd to copy the live image to it.
For example:

WARNING: dd can destroy your HDD data if not used with the proper device path.

```shell
cd ~/yocto/poky/build/tmp/deploy/images/pine64/
# for image minimal
sudo dd if=core-image-minimal-pine64.pine64-sdimg of=/dev/sdf
# for image sato
sudo dd if=core-image-sato-pine64.pine64-sdimg of=/dev/sdf
sync
```

### Notes ###
This README file was adapted from:
* https://github.com/bmwcarit/dpc/blob/master/README.md
* https://wiki.yoctoproject.org/wiki/Web_Application_for_Interactive_Kiosk_Devices

5 changes: 5 additions & 0 deletions README.sources
@@ -0,0 +1,5 @@
The metadata used to generate the images shipped with this BSP, in
addition to the code contained in this BSP, can be found at the
following locations:

https://github.com/mont3z/meta-pine64.git
104 changes: 104 additions & 0 deletions classes/sdcard_image-pine64.bbclass
@@ -0,0 +1,104 @@
inherit image_types

# Add the fstypes we need
IMAGE_FSTYPES_append = " pine64-sdimg"

#
# Create an image that can by written onto a SD card using dd.
# Based on rasberrypi sdimg and adapt for pine64 needs
#
# The disk layout used is:
#
# 0 -> reserverd
# 8 KiB -> boot0
# 19096 KiB -> u-boot
# 20480 KiB -> BOOT_SPACE - kernel
# 20480 KiB + 50 MiB (rounded by 4096) -> rootfs
#

# This image depends on the rootfs image
IMAGE_TYPEDEP_pine64-sdimg = "${SDIMG_ROOTFS_TYPE}"

# Boot partition volume id
BOOTDD_VOLUME_ID = "${MACHINE}"

# Positions in KiB
BOOT0_POSITION = "8"
UBOOT_POSITION = "19096"
BOOT_POSITION = "20480"

# Size in MiB
BOOT_SIZE = "50"

# Use an uncompressed ext3 by default as rootfs
SDIMG_ROOTFS_TYPE = "ext3"
SDIMG_ROOTFS = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.${SDIMG_ROOTFS_TYPE}"
#SDIMG_ROOTFS = "${DEPLOY_DIR_IMAGE}/${LOCALEBASEPN}-${MACHINE}.${SDIMG_ROOTFS_TYPE}"

IMAGE_DEPENDS_pine64-sdimg += " \
parted-native \
mtools-native \
dosfstools-native \
virtual/kernel \
virtual/bootloader \
boot0 \
"

rootfs[depends] += "virtual/kernel:do_deploy"

# SD card image name
SDIMG = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.pine64-sdimg"

IMAGE_CMD_pine64-sdimg () {
# Align partitions
ROOTFS_ALIGNMENT=4096
ROOTFS_POSITION=$(expr ${BOOT_POSITION} \+ ${BOOT_SIZE} \* 1024)
ROOTFS_DELTA=$(expr ${ROOTFS_ALIGNMENT} - ${ROOTFS_POSITION} % ${ROOTFS_ALIGNMENT})
ROOTFS_POSITION=$(expr ${ROOTFS_POSITION} \+ ${ROOTFS_DELTA})

SDIMG_SIZE=$(expr ${ROOTFS_POSITION} \+ $ROOTFS_SIZE \+ ${ROOTFS_ALIGNMENT})

# Initialize sdcard image file
dd if=/dev/zero of=${SDIMG} bs=1 count=0 seek=$(expr 1024 \* ${SDIMG_SIZE})

# Create partition table
parted -s ${SDIMG} mklabel msdos
# Create boot partition and mark it as bootable
parted -s ${SDIMG} unit KiB mkpart primary fat32 ${BOOT_POSITION} ${ROOTFS_POSITION}
parted -s ${SDIMG} set 1 boot on
# Create rootfs partition
parted -s ${SDIMG} unit KiB mkpart primary ext3 ${ROOTFS_POSITION} $(expr ${ROOTFS_POSITION} \+ $ROOTFS_SIZE)
parted ${SDIMG} print

# Create a vfat image with boot files
BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }')
rm -f ${WORKDIR}/boot.img
mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS

mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::Image

# Copy device tree files
if test -n "${KERNEL_DEVICETREE}"; then
for DTB_FILE in ${KERNEL_DEVICETREE}; do
if [ -e "${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_FILE}" ]; then
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_FILE} ::${DTB_FILE}
fi
done
fi

if [ -e "${DEPLOY_DIR_IMAGE}/boot-${MACHINE}.scr" ]
then
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/boot-${MACHINE}.scr ::boot.scr
fi

# Burn Partitions
dd if=${WORKDIR}/boot.img of=${SDIMG} conv=notrunc seek=1 bs=$(expr ${BOOT_POSITION} \* 1024) && sync && sync
# Write rootfs
dd if=${SDIMG_ROOTFS} of=${SDIMG} conv=notrunc seek=1 bs=$(expr ${ROOTFS_POSITION} \* 1024) && sync && sync

#write boot0 at the beginning of sdimage
dd if=${DEPLOY_DIR_IMAGE}/boot0.bin of=${SDIMG} conv=notrunc seek=1 bs=$(expr ${BOOT0_POSITION} \* 1024) && sync && sync

#write u-boot
dd if=${DEPLOY_DIR_IMAGE}/u-boot-with-dtb.bin of=${SDIMG} conv=notrunc seek=1 bs=$(expr ${UBOOT_POSITION} \* 1024) && sync && sync
}
14 changes: 14 additions & 0 deletions conf/layer.conf
@@ -0,0 +1,14 @@
#We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"

# We have a recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "pine64"
BBFILE_PATTERN_pine64 := "^${LAYERDIR}/"
BBFILE_PRIORITY_pine64 = "6"

LAYERDEPENDS_pine64 = "linaro linaro-toolchain"
LAYERVERSION_pine64 = "0.82"

37 changes: 37 additions & 0 deletions conf/machine/pine64.conf
@@ -0,0 +1,37 @@
#@TYPE: Machine
#@NAME: pine64

#@DESCRIPTION: Machine configuration for pine64 systems

require conf/machine/include/arm64/arch-armv8.inc

PREFERRED_PROVIDER_virtual/xserver = "xserver-xorg"
XSERVER = "xserver-xorg \
xf86-video-fbturbo \
xf86-input-evdev \
xf86-input-mouse \
xf86-input-keyboard"

MACHINE_EXTRA_RRECOMMENDS = "kernel-modules"

PREFERRED_PROVIDER_virtual/bootloader = "u-boot-pine64"
PREFERRED_PROVIDER_virtual/kernel = "linux-pine64"
KERNEL_IMAGETYPE ?= "Image"
OLDEST_KERNEL_pine64 = "3.10.0"

KERNEL_DEVICETREE = "pine64.dtb pine64noplus.dtb"
IMAGE_CLASSES += "sdcard_image-pine64"

SERIAL_CONSOLE ?= "115200 ttyS0"
MACHINE_FEATURES ?= "alsa apm keyboard rtc serial screen usbgadget usbhost vfat"

# Force auto-serial-console to be used by all image types
# Ideally this would be part of core oe or as a bbclassappend,
# but as we don't have an easy way to append a class, defining
# it here
#EXTRA_IMAGE_FEATURES += "autoserial"
#FEATURE_PACKAGES_autoserial = "auto-serial-console"

# we do not want to have getty running on tty1 as we run
# auto-serial-console there
#USE_VT = "0"
45 changes: 45 additions & 0 deletions recipes-bsp/arm-trusted-firmware/arm-trusted-firmware_1.0.bb
@@ -0,0 +1,45 @@
#
# arm-trusted-firmware.bb:
#
# This recipe compiles arm trusted from longsleep repository
# Based on layer meta-xilinx, recipe arm-trusted-firmware_git.bb
#
DESCRIPTION = "ARM Trusted Firmware"
LICENSE = "BSD"

inherit deploy

DEPENDS = ""
PARALLEL_MAKE=""

S = "${WORKDIR}/git"
LIC_FILES_CHKSUM = 'file://license.md;md5=829bdeb34c1d9044f393d5a16c068371'

BRANCH = "allwinner-a64-bsp"
SRC_URI = "git://github.com/longsleep/arm-trusted-firmware.git;protocol=git;branch=${BRANCH}"

SRCREV ?= "${AUTOREV}"

COMPATIBLE_MACHINE = "pine64"
PLATFORM_pine64 = "sun50iw1p1"

# Let the Makefile handle setting up the CFLAGS and LDFLAGS as it is a standalone application
CFLAGS[unexport] = "1"
LDFLAGS[unexport] = "1"
AS[unexport] = "1"
LD[unexport] = "1"

do_configure() {
:
}

do_compile() {
oe_runmake ARCH=arm CROSS_COMPILE="${TARGET_PREFIX}" PLAT="${PLATFORM}" bl31
}

do_deploy() {
install -d ${STAGING_LOADER_DIR}
install -m 0644 ${S}/build/${PLATFORM}/release/bl31/bl31.elf ${STAGING_LOADER_DIR}/bl31-${MACHINE}.elf
install -m 0644 ${S}/build/${PLATFORM}/release/bl31.bin ${STAGING_LOADER_DIR}/bl31-${MACHINE}.bin
}
addtask deploy before do_build after do_compile

0 comments on commit f2158b1

Please sign in to comment.