Skip to content

Commit

Permalink
Yocto: Add initial Dunfell implementation [1/1]
Browse files Browse the repository at this point in the history
Signed-off-by: Blance Tang <[email protected]>
Change-Id: Ie99e7a6187812702741d509409b2e0f9f9919164
  • Loading branch information
Blance Tang committed Jan 4, 2021
1 parent 28129ac commit 95c76ee
Show file tree
Hide file tree
Showing 48 changed files with 14,364 additions and 0 deletions.
162 changes: 162 additions & 0 deletions aml-setenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#!/bin/bash

if [ -n "$BASH_SOURCE" ]; then
THIS_SCRIPT=$BASH_SOURCE
elif [ -n "$ZSH_NAME" ]; then
THIS_SCRIPT=$0
else
THIS_SCRIPT="$(pwd)/oe-init-build-env"
fi
MESON_PATH=$(cd `dirname $(realpath -P $THIS_SCRIPT)`; pwd)

LOCAL_DIR=$(pwd)
if [ -z $BUILD_DIR ]; then
BUILD_DIR="build"
fi
if [ -z $LOCAL_BUILD ]; then
LOCAL_BUILD=0
else
LOCAL_BUILD=1
fi

DEFCONFIG_ARRAY=($(pushd $MESON_PATH/conf/machine 2>&1 >> /dev/null; find -name '*\.conf' | sed 's@./@@' | sed 's@\.conf@@' | sort))

DEFCONFIG_ARRAY_LEN=${#DEFCONFIG_ARRAY[@]}

i=0
while [[ $i -lt $DEFCONFIG_ARRAY_LEN ]]
do
let i++
done

function choose_info()
{
echo
echo "You're building on Linux"
echo "Lunch menu...pick a combo:"
i=0
while [[ $i -lt $DEFCONFIG_ARRAY_LEN ]]
do
echo -e "$((${i}+1)).\t${DEFCONFIG_ARRAY[$i]}"
let i++
done
echo
}

function get_index() {
if [ $# -eq 0 ]; then
return 0
fi

i=0
while [[ $i -lt $DEFCONFIG_ARRAY_LEN ]]
do
if [ $1 = "${DEFCONFIG_ARRAY[$i]}" ]; then
let i++
return ${i}
fi
let i++
done
return 0
}

function choose_type()
{
choose_info
local DEFAULT_NUM DEFAULT_VALUE
DEFAULT_NUM=2
DEFAULT_VALUE="mesong12a_u212.conf"

export TARGET_MACHINE=
local ANSWER
while [ -z $TARGET_MACHINE ]
do
echo -n "Which would you like? ["$DEFAULT_NUM"] "
if [ -z "$1" ]; then
read ANSWER
else
echo $1
ANSWER=$1
fi

if [ -z "$ANSWER" ]; then
ANSWER="$DEFAULT_NUM"
fi

if [ -n "`echo $ANSWER | sed -n '/^[0-9][0-9]*$/p'`" ]; then
if [ $ANSWER -le $DEFCONFIG_ARRAY_LEN ] && [ $ANSWER -gt 0 ]; then
index=$((${ANSWER}-1))
TARGET_MACHINE=${DEFCONFIG_ARRAY[$index]}
else
echo
echo "number not in range. Please try again."
echo
fi
else
get_index $ANSWER
ANSWER=$?
if [ $ANSWER -gt 0 ]; then
index=$((${ANSWER}-1))
TARGET_MACHINE=${DEFCONFIG_ARRAY[$index]}
else
echo
echo "I didn't understand your response. Please try again."
echo
fi
fi
if [ -n "$1" ]; then
break
fi
done
}

function lunch()
{
if [ -n "$TARGET_MACHINE" ]; then
MACHINE=$TARGET_MACHINE source $MESON_PATH/oe-init-build-env-meson $BUILD_DIR
if [ $LOCAL_BUILD == "1" ];then
cat >> conf/local.conf <<EOF
AML_GIT_ROOT = "git.myamlogic.com"
AML_GIT_PROTOCOL = "git"
AML_GIT_ROOT_YOCTO_SUFFIX = "/yocto"
EOF
fi
export MACHINE=$TARGET_MACHINE
export AML_PATCH_PATH=${MESON_ROOT_PATH}/aml-patches
export BB_ENV_EXTRAWHITE="${BB_ENV_EXTRAWHITE} AML_PATCH_PATH"
echo "==========================================="
echo
echo "MACHINE=${TARGET_MACHINE}"
echo "OUTPUT_DIR=${BUILD_DIR}"
echo "LOCAL_BUILD=${LOCAL_BUILD}"
echo "AML_PATCH_PATH=${AML_PATCH_PATH}"
echo
echo "==========================================="

echo "Common targets are:"
for file in `ls ${MESON_PATH}/recipes-core/images`
do
if [ "bb" = "${file#*.}" ]; then
echo "${file%%.*}"
fi
done
fi
# # Copy <manifest>.conf file to auto.conf for revision lock
# if [ -L ./../.repo/manifest.xml ] ; then
# MANIFEST="$(basename `readlink -f ./../.repo/manifest.xml ` | cut -d '.' -f 1)"
# else
# MANIFEST=$(grep include ./../.repo/manifest.xml | cut -d '"' -f 2 | cut -d '.' -f 1)
# fi
# echo " Manifest Name = ${MANIFEST}"
# if [ -f "./../.repo/manifests/${MANIFEST}.conf" ]; then
# cp ./../.repo/manifests/${MANIFEST}.conf ./conf/auto.conf
# fi
}

function function_stuff()
{
choose_type $@
lunch
}
function_stuff $@
22 changes: 22 additions & 0 deletions classes/image_meson.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
inherit image

IMAGE_CMD_cpio () {
echo "inside image_meson"
(cd ${IMAGE_ROOTFS} && cat ${WORKDIR}/${INITRAMFS_FILES} | cpio -o -H newc >${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.cpio)
# We only need the /init symlink if we're building the real
# image. The -dbg image doesn't need it! By being clever
# about this we also avoid 'touch' below failing, as it
# might be trying to touch /sbin/init on the host since both
# the normal and the -dbg image share the same WORKDIR
if [ "${IMAGE_BUILDING_DEBUGFS}" != "true" ]; then
if [ ! -L ${IMAGE_ROOTFS}/init ] && [ ! -e ${IMAGE_ROOTFS}/init ]; then
if [ -L ${IMAGE_ROOTFS}/sbin/init ] || [ -e ${IMAGE_ROOTFS}/sbin/init ]; then
ln -sf /sbin/init ${WORKDIR}/cpio_append/init
else
touch ${WORKDIR}/cpio_append/init
fi
(cd ${WORKDIR}/cpio_append && echo ./init | cpio -oA -H newc -F ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.cpio)
fi
fi
}

39 changes: 39 additions & 0 deletions classes/image_types_meson.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
inherit image_types

WIC_COMMAND_meson-gxl = "wic_command_meson_gxl"
WIC_COMMAND_meson-gxm = "wic_command_meson_gxl"
WIC_COMMAND_meson-g12a = "wic_command_meson_gxl"
WIC_COMMAND_meson-g12b = "wic_command_meson_gxl"
WIC_COMMAND_meson-sm1 = "wic_command_meson_gxl"
WIC_COMMAND_meson-gxbb = "wic_command_meson_gxbb"
WIC_COMMAND_hardkernel-odroidc2 = "wic_command_odroidc2"
WIC_COMMAND_friendlyelec-nanopik2 = "wic_command_nanopik2"
WIC_COMMAND_amlogic-s400 = "wic_command_s400"

wic_command_odroidc2 () {
dd if=${DEPLOY_DIR_IMAGE}/bl1.bin.hardkernel of=$out${IMAGE_NAME_SUFFIX}.wic conv=notrunc bs=1 count=442
dd if=${DEPLOY_DIR_IMAGE}/bl1.bin.hardkernel of=$out${IMAGE_NAME_SUFFIX}.wic conv=notrunc bs=512 skip=1 seek=1
dd if=${DEPLOY_DIR_IMAGE}/u-boot.img of=$out${IMAGE_NAME_SUFFIX}.wic conv=notrunc bs=512 skip=96 seek=97
}

wic_command_nanopik2 () {
dd if=${DEPLOY_DIR_IMAGE}/u-boot.bin of=$out${IMAGE_NAME_SUFFIX}.wic conv=notrunc bs=512 seek=1
}

wic_command_meson_gxl () {
dd if=${DEPLOY_DIR_IMAGE}/u-boot.bin.sd.bin of=$out${IMAGE_NAME_SUFFIX}.wic conv=notrunc bs=1 count=444
dd if=${DEPLOY_DIR_IMAGE}/u-boot.bin.sd.bin of=$out${IMAGE_NAME_SUFFIX}.wic conv=notrunc bs=512 skip=1 seek=1
}

wic_command_meson_gxbb() {
dd if=${DEPLOY_DIR_IMAGE}/u-boot.bin.sd.bin of=$out${IMAGE_NAME_SUFFIX}.wic conv=notrunc bs=1 count=442
dd if=${DEPLOY_DIR_IMAGE}/u-boot.bin.sd.bin of=$out${IMAGE_NAME_SUFFIX}.wic conv=notrunc bs=512 skip=1 seek=1
}

wic_command_s400 () {
dd if=${DEPLOY_DIR_IMAGE}/u-boot.bin of=$out${IMAGE_NAME_SUFFIX}.wic conv=notrunc bs=512 seek=1
}

IMAGE_CMD_wic_append () {
${WIC_COMMAND}
}
18 changes: 18 additions & 0 deletions classes/kernel-uimage-meson.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
inherit kernel-uboot

python __anonymous () {
kerneltype = d.getVar('KERNEL_IMAGETYPE', True)
if kerneltype == 'uImage':
depends = d.getVar("DEPENDS", True)
depends = "%s u-boot-mkimage-native" % depends
d.setVar("DEPENDS", depends)
d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", "Image")
}

do_uboot_mkimage() {
if test "x${KERNEL_IMAGETYPE}" = "xuImage" ; then
uboot-mkimage -A ${UBOOT_ARCH} -O linux -T kernel -C none -a ${UBOOT_LOADADDRESS} -e ${UBOOT_ENTRYPOINT} -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d ${B}/arch/${ARCH}/boot/Image ${B}/arch/${ARCH}/boot/uImage
fi
}

addtask uboot_mkimage before do_install after do_compile
33 changes: 33 additions & 0 deletions classes/kernel_meson.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
inherit kernel
#inherit more-new

kernel_do_compile() {
echo "inside kernel_meson"
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
# The $use_alternate_initrd is only set from
# do_bundle_initramfs() This variable is specifically for the
# case where we are making a second pass at the kernel
# compilation and we want to force the kernel build to use a
# different initramfs image. The way to do that in the kernel
# is to specify:
# make ...args... CONFIG_INITRAMFS_SOURCE=some_other_initramfs.cpio
if [ "$use_alternate_initrd" = "" ] && [ "${INITRAMFS_TASK}" != "" ] ; then
# The old style way of copying an prebuilt image and building it
# is turned on via INTIRAMFS_TASK != ""
copy_initramfs
use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio
fi
for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
oe_runmake ${typeformake} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
for type in ${KERNEL_IMAGETYPES} ; do
if test "${typeformake}.gz" = "${type}"; then
cp "${KERNEL_OUTPUT_DIR}/${typeformake}" .
gzip -9c < "${typeformake}" > "${KERNEL_OUTPUT_DIR}/${type}"
break;
fi
done
done
cd ${KERNEL_OUTPUT_DIR}
gzip -9c Image> Image.gz
cd -
}
44 changes: 44 additions & 0 deletions classes/manpages.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Inherit this class to enable or disable building and installation of manpages
# depending on whether 'api-documentation' is in DISTRO_FEATURES. Such building
# tends to pull in the entire XML stack and other tools, so it's not enabled
# by default.
PACKAGECONFIG_append_class-target = " ${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', 'manpages', '', d)}"

inherit qemu

# usually manual files are packaged to ${PN}-doc except man-pages
MAN_PKG ?= "${PN}-doc"

# only add man-db to RDEPENDS when manual files are built and installed
RDEPENDS_${MAN_PKG} += "${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'man-db', '', d)}"

pkg_postinst_append_${MAN_PKG} () {
# only update manual page index caches when manual files are built and installed
if ${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'true', 'false', d)}; then
if test -n "$D"; then
if ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'true','false', d)}; then
sed "s:\(\s\)/:\1$D/:g" $D${sysconfdir}/man_db.conf | ${@qemu_run_binary(d, '$D', '${bindir}/mandb')} -C - -u -q $D${mandir}
chown -R root:root $D${mandir}
mkdir -p $D${localstatedir}/cache/man
cd $D${mandir}
find . -name index.db | while read index; do
mkdir -p $D${localstatedir}/cache/man/$(dirname ${index})
mv ${index} $D${localstatedir}/cache/man/${index}
chown man:man $D${localstatedir}/cache/man/${index}
done
cd -
else
$INTERCEPT_DIR/postinst_intercept delay_to_first_boot ${PKG} mlprefix=${MLPREFIX}
fi
else
mandb -q
fi
fi
}

pkg_postrm_append_${MAN_PKG} () {
# only update manual page index caches when manual files are built and installed
if ${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'true', 'false', d)}; then
mandb -q
fi
}
Loading

0 comments on commit 95c76ee

Please sign in to comment.