This series of patches forms the initial support for the Morello hardware in Yocto. For limitations and instructions to build refer to the README.md
To-do list: - create clang-morello toolchain, follow the guide here [1] and move llvm-morello to its own layer * can try append meta-clang instead * can try to use precompiled external toolchain like here [2] instead * thus there are 3 paths to explore forward for the toolchain, Yocto expects target_prefixed toolchain binaries - be considerate of incoming purecap GNU toolchain [3] (related to the above toolchain problem) - decide what combinations of musl/glibc env the user might want and stick that in grub cfg, the current division between glibc/musl machines is a ripple from the past
Changes in V4: - removed AUTOREV from all recipes - removed dual code when not necessary in the bbappends - fixed submodule paths and copy paste bugs in the uefi bbappend - added native fiptool recipe - added gdb - added llvm that can run on the target
[1] http://www.openembedded.org/wiki/Adding_a_secondary_toolchain [2] https://github.com/MentorEmbedded/meta-sourcery/ [3] https://developer.arm.com/downloads/-/arm-gnu-toolchain-for-morello-download...
Pawel Zalewski (18): Add LLVM Morello compiler support Add initial Morello machines and layer config Add scp firmware Add trusted-firmware-a Add UEFI Add grub Add fiptool Add board firmware image Add Morello Linux kernel Add musl libc Add busybox Add simple purecap application Add gen-init-cpio Add llvm-morelllo for aarch64. Add gdb Add Linux image Add kas scripts Add README.md
Add a native LLVM Morello cross compiler and a native LLVM that will build it. Add class to be inherited by users of LLVM Morello compiler, this class is required as the inital commit does not provide a proper Yocto Morello toolchain.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- COPYING.MIT | 17 +++ classes/llvm-morello-native.bbclass | 47 +++++++ recipes-devtools/llvm/llvm-13.0.1-native.bb | 31 ++++ .../llvm/llvm-morello-native_13.0.bb | 16 +++ recipes-devtools/llvm/llvm-morello.inc | 133 ++++++++++++++++++ 5 files changed, 244 insertions(+) create mode 100644 COPYING.MIT create mode 100644 classes/llvm-morello-native.bbclass create mode 100644 recipes-devtools/llvm/llvm-13.0.1-native.bb create mode 100644 recipes-devtools/llvm/llvm-morello-native_13.0.bb create mode 100644 recipes-devtools/llvm/llvm-morello.inc
diff --git a/COPYING.MIT b/COPYING.MIT new file mode 100644 index 0000000..e14c371 --- /dev/null +++ b/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. \ No newline at end of file diff --git a/classes/llvm-morello-native.bbclass b/classes/llvm-morello-native.bbclass new file mode 100644 index 0000000..d1e2397 --- /dev/null +++ b/classes/llvm-morello-native.bbclass @@ -0,0 +1,47 @@ +MORELLO_COMPILER = "llvm-morello-native" + +LLVM_VERSION = "13.0.0" + +LLVM_PATH = "${STAGING_DIR_NATIVE}/usr/bin" + +INHIBIT_DEFAULT_DEPS = "1" + +DEPENDS += "virtual/llvm-morello-native" +DEPENDS:append:morello-linux-glibc:class-target = " virtual/musl-morello-libs-native" +DEPENDS:append:morello-linux-musl:class-target = " virtual/musl-morello-libs-native" + +# rough hack to deal with llvm-morello not being a proper toolchain in its own meta yet +DEPENDS:remove = "libgcc" + +do_configure[depends] += " ${@get_depends(d)}" + +LIBCPLUSPLUS = "-stdlib-libc++" + +export CC = "${LLVM_PATH}/clang" +export CXX = "${LLVM_PATH}/clang++" +export CPP = "${LLVM_PATH}/clang -E" +export CCLD = "${LLVM_PATH}/clang" +export RANLIB = "${LLVM_PATH}/llvm-ranlib" +export AR = "${LLVM_PATH}/llvm-ar" +export AS = "${LLVM_PATH}/llvm-as" +export NM = "${LLVM_PATH}/llvm-nm" +export OBJDUMP = "${LLVM_PATH}/llvm-objdump" +export OBJCOPY = "${LLVM_PATH}/llvm-objcopy" +export STRIP = "${LLVM_PATH}/llvm-strip" +export STRINGS = "${LLVM_PATH}/llvm-strings" +export READELF = "${LLVM_PATH}/llvm-readelf" +export LD = "${LLVM_PATH}/ld.lld" +export LTO = "-fuse-ld=lld" +export HOSTCC = "${LLVM_PATH}/clang" +export LLVM_CONFIG = "${LLVM_PATH}/llvm-config" + +def get_depends(d): + if d.getVar('DEPENDENCIES'): + return "llvm-morello-native:do_populate_sysroot" + else: + return "llvm-morello-native:do_populate_sysroot virtual/musl-morello:do_populate_sysroot" + +DEPENDENCIES:kernel = "1" +DEPENDENCIES:musl = "1" +DEPENDENCIES:musl-morello-native = "1" +DEPENDENCIES ?= "0" \ No newline at end of file diff --git a/recipes-devtools/llvm/llvm-13.0.1-native.bb b/recipes-devtools/llvm/llvm-13.0.1-native.bb new file mode 100644 index 0000000..37140ce --- /dev/null +++ b/recipes-devtools/llvm/llvm-13.0.1-native.bb @@ -0,0 +1,31 @@ +inherit native nopackages + +SUMMARY = "LLVM 13.01" +DESCRIPTION = "LLVM used purely for compiling llvm-morello" +HOMEPAGE = "http://llvm.org" +LICENSE = "Apache-2.0-with-LLVM-exception" +OUTPUTS_NAME = "llvm-13.0.1" + +PROVIDES = "virtual/${OUTPUTS_NAME}-native ${OUTPUTS_NAME}-native" + +SRC_URI = "https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/clang+..." + +SRC_URI[md5sum] = "041e3a5c735d5f956668254b1ffd35d1" +LIC_FILES_CHKSUM = "file://include/llvm/Support/LICENSE.TXT;md5=986c03435151a0086b8aaac964939cdd" + +S = "${WORKDIR}/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04" +FILES:${PN} = "/${OUTPUTS_NAME}" + +SYSROOT_DIRS_NATIVE += "/${OUTPUTS_NAME}" + +do_install() { + install -d ${D}${libdir}/${OUTPUTS_NAME} + cp -rf ${S}/* ${D}${libdir}/${OUTPUTS_NAME} +} + +INSANE_SKIP_${PN} = "already-stripped libdir staticdev file-rdeps arch dev-so rpaths useless-rpaths" +INHIBIT_SYSROOT_STRIP = "1" +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_DEFAULT_DEPS = "1" +EXCLUDE_FROM_SHLIBS = "1" \ No newline at end of file diff --git a/recipes-devtools/llvm/llvm-morello-native_13.0.bb b/recipes-devtools/llvm/llvm-morello-native_13.0.bb new file mode 100644 index 0000000..d9dcc97 --- /dev/null +++ b/recipes-devtools/llvm/llvm-morello-native_13.0.bb @@ -0,0 +1,16 @@ +inherit cmake pkgconfig python3native native +require llvm-morello.inc +DESCRIPTION = "The Morello LLVM Compiler Infrastructure native" + +PROVIDES = "virtual/${OUTPUTS_NAME}-native" +PN = "${OUTPUTS_NAME}-native" + +FILES:${PN} += "${prefix}" + +LLVM_TARGETS_TO_BUILD = "X86;AArch64" +LLVM_INSTALL_DIR = "${D}/${OUTPUTS_NAME}" + +do_install:append() { + install -d ${D}${prefix} + cp -rvf ${LLVM_INSTALL_DIR}/* ${D}${prefix} +} \ No newline at end of file diff --git a/recipes-devtools/llvm/llvm-morello.inc b/recipes-devtools/llvm/llvm-morello.inc new file mode 100644 index 0000000..580427e --- /dev/null +++ b/recipes-devtools/llvm/llvm-morello.inc @@ -0,0 +1,133 @@ + + +SUMMARY = "LLVM Morello" +HOMEPAGE = "http://llvm.org" +LICENSE = "Apache-2.0-with-LLVM-exception" +OUTPUTS_NAME = "llvm-morello" + +DEPENDS = "zlib-native ninja-native ${COMPILER}-native" + +SRC_URI = "git://git.morello-project.org/morello/llvm-project;protocol=https;branch=${SRCBRANCH}" +SRCREV = "cac045cbb70a9c8161f2f32fa5ef056242eb28f3" + +SRCBRANCH = "morello/release-1.5" +LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=8a15a0759ef07f2682d2ba4b893c9afe" + +S = "${WORKDIR}/git/llvm" +S_git = "${WORKDIR}/git" + +FILES:${PN} = "/${OUTPUTS_NAME}" +SYSROOT_DIRS_NATIVE += "/${OUTPUTS_NAME}" + +COMPILER = "llvm-13.0.1" + +LLVM_PROJECTS = "libcxx;libcxxabi;compiler-rt;libunwind;llvm;clang;lld;lldb" +LLVM_BUILD_DIR = "${WORKDIR}/${OUTPUTS_NAME}-build" + +NATIVE_LLVM_PATH = "${STAGING_LIBDIR_NATIVE}/${COMPILER}/bin" +LIB_PATH = "${STAGING_LIBDIR_NATIVE}/${COMPILER}/lib" + +EXTRA_OECMAKE += "-Wno-dev -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=${LLVM_INSTALL_DIR} \ + -DCMAKE_C_COMPILER='${NATIVE_LLVM_PATH}/clang' \ + -DCMAKE_CXX_COMPILER='${NATIVE_LLVM_PATH}/clang++' \ + -DCMAKE_ASM_COMPILER='${NATIVE_LLVM_PATH}/clang' \ + -DCMAKE_AR='${NATIVE_LLVM_PATH}/llvm-ar' \ + -DCMAKE_RANLIB='${NATIVE_LLVM_PATH}/llvm-ranlib' \ + -DCMAKE_NM='${NATIVE_LLVM_PATH}/llvm-nm' \ + -DCMAKE_OBJDUMP='${NATIVE_LLVM_PATH}/llvm-objdump' \ + -DCMAKE_OBJCOPY='${NATIVE_LLVM_PATH}/llvm-objcopy' \ + -DCMAKE_LINKER='${NATIVE_LLVM_PATH}/ld.lld' \ + -DCMAKE_C_FLAGS_RELEASE='${CFLAGS}' \ + -DCLANG_DEFAULT_LINKER='lld' \ + -DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=lld' \ + -DCMAKE_SHARED_LINKER_FLAGS='-fuse-ld=lld' \ + -DCMAKE_SKIP_BUILD_RPATH=OFF \ + -DCMAKE_INSTALL_RPATH='$ORIGIN/../lib:${LIB_PATH}' \ + -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DLLVM_CCACHE_BUILD=FALSE \ + -DLLVM_ENABLE_ASSERTIONS=OFF \ + -DLLVM_ENABLE_EH=ON \ + -DLLVM_ENABLE_RTTI=ON \ + -DLLVM_ENABLE_LLD=ON \ + -DLLVM_ENABLE_LIBCXX=ON \ + -DBUILD_SHARED_LIBS=ON \ + -DCOMPILER_RT_BUILD_BUILTINS=ON \ + -DCOMPILER_RT_BUILD_XRAY=OFF \ + -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \ + -DCOMPILER_RT_BUILD_PROFILE=OFF \ + -DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS_TO_BUILD}' \ + -DLLVM_ENABLE_PROJECTS='${LLVM_PROJECTS}' \ + -DLIBCXX_CXX_ABI='libcxxabi' \ + -DLIBCXX_CXX_ABI_INCLUDE_PATHS='${WORKDIR}/git/libcxxabi/include' \ + -DLIBCXXABI_USE_LLVM_UNWINDER=ON \ + -DLIBCXXABI_USE_COMPILER_RT=ON \ + -DLIBUNWIND_ENABLE_THREADS=ON \ + -DCLANG_DEFAULT_RTLIB='compiler-rt' \ + -DCLANG_DEFAULT_CXX_STDLIB='libc++' \ + -DCLANG_DEFAULT_OBJCOPY='llvm-objcopy'\ + '-DLLVM_LIT_ARGS=--max-time 3600 --timeout 300 -s -vv' \ + -DLLVM_USE_SPLIT_DWARF=TRUE \ + -DLLVM_ENABLE_OCAMLDOC=FALSE \ + -DLLVM_ENABLE_BINDINGS=FALSE \ + -DLLVM_INCLUDE_EXAMPLES=FALSE \ + -DLLVM_INCLUDE_DOCS=FALSE \ + -DLLVM_INCLUDE_BENCHMARKS=FALSE \ + -DCLANG_ENABLE_STATIC_ANALYZER=FALSE \ + -DCLANG_ENABLE_ARCMT=FALSE \ + -DLLVM_ENABLE_Z3_SOLVER=FALSE \ + -DLLVM_TOOL_LLVM_MCA_BUILD=FALSE \ + -DLLVM_TOOL_LLVM_EXEGESIS_BUILD=FALSE \ + -DLLVM_TOOL_LLVM_RC_BUILD=FALSE \ + -DLLVM_OPTIMIZED_TABLEGEN=FALSE \ + -DLLVM_ENABLE_ZLIB=FORCE_ON \ + -DLLVM_ENABLE_LIBXML2=FALSE \ +" + +INSANE_SKIP_${PN} = "already-stripped" +INHIBIT_SYSROOT_STRIP = "1" +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_DEFAULT_DEPS = "1" + +do_unpack[depends] += "${COMPILER}-native:do_populate_sysroot" + +do_configure() { + mkdir -p ${LLVM_BUILD_DIR} + cd ${LLVM_BUILD_DIR} + cmake -S ${S} -B ${LLVM_BUILD_DIR} ${EXTRA_OECMAKE} +} + +do_compile() { + export CC="${NATIVE_LLVM_PATH}/clang" + export NM="${NATIVE_LLVM_PATH}/llvm-nm" + export CXX="${NATIVE_LLVM_PATH}/clang++" + export LD="${NATIVE_LLVM_PATH}/ld.lld" + cd ${LLVM_BUILD_DIR} + cmake --build . --target all -- -j20 +} + +do_install() { + cd ${LLVM_BUILD_DIR} + cmake --build . --target install + install -d ${LLVM_SHARED_SOURCE} +} + +python do_symlink() { + s = d.getVar("S_git") + if s[-1] == '/': + # drop trailing slash, so that os.symlink(src, s) doesn't use s as directory name and fail + s=s[:-1] + src = d.getVar("LLVM_SHARED_SOURCE") + if s != src: + bb.utils.mkdirhier(src) + bb.utils.remove(src, recurse=True) + os.symlink(s, src) + else: + import shutil + shutil.move(s, src) + os.symlink(src, s) +} +addtask do_symlink after do_install before do_build \ No newline at end of file
The machines are split between bsp/linux musl-only/linux with glibc. This way the users will be able to build a purecap-musl-only environment in the future or a glibc environment with purecap being statically linked. The bsp is its own separate machine to deal with the fact that LLVM Morello is not a fully implemented toolchain (we might get build errors relating to gcc lib which needs libc, but libc is purecap only).
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- conf/bblayers.conf.sample | 16 ++ conf/layer.conf | 15 ++ conf/local.conf.sample | 177 ++++++++++++++++++++++ conf/machine/include/morello-1.5.inc | 1 + conf/machine/include/morello-common.inc | 27 ++++ conf/machine/morello-bsp.conf | 1 + conf/machine/morello-linux-glibc.conf | 3 + conf/machine/morello-linux-musl.conf | 3 + conf/multiconfig/morello-firmware.conf | 1 + conf/multiconfig/morello-linux-glibc.conf | 1 + conf/multiconfig/morello-linux-musl.conf | 1 + 11 files changed, 246 insertions(+) create mode 100644 conf/bblayers.conf.sample create mode 100644 conf/layer.conf create mode 100644 conf/local.conf.sample create mode 100644 conf/machine/include/morello-1.5.inc create mode 100644 conf/machine/include/morello-common.inc create mode 100644 conf/machine/morello-bsp.conf create mode 100644 conf/machine/morello-linux-glibc.conf create mode 100644 conf/machine/morello-linux-musl.conf create mode 100644 conf/multiconfig/morello-firmware.conf create mode 100644 conf/multiconfig/morello-linux-glibc.conf create mode 100644 conf/multiconfig/morello-linux-musl.conf
diff --git a/conf/bblayers.conf.sample b/conf/bblayers.conf.sample new file mode 100644 index 0000000..d86dbed --- /dev/null +++ b/conf/bblayers.conf.sample @@ -0,0 +1,16 @@ +# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf +# changes incompatibly +LCONF_VERSION = "7" + +BBPATH = "${TOPDIR}" + +BBFILES ?= "" + +BBLAYERS = " \ + ##OEROOT##/meta \ + ##OEROOT##/meta-poky \ + ##OEROOT##/meta-arm/meta-arm \ + ##OEROOT##/meta-arm/meta-arm-bsp \ + ##OEROOT##/meta-arm/meta-arm-toolchain \ + ##OEROOT##/meta-morello \ + " \ No newline at end of file diff --git a/conf/layer.conf b/conf/layer.conf new file mode 100644 index 0000000..5cd622e --- /dev/null +++ b/conf/layer.conf @@ -0,0 +1,15 @@ +BBPATH := "${BBPATH}:${LAYERDIR}" + +BBFILES := "${BBFILES} \ + ${LAYERDIR}/recipes-*/*/*.bb \ + ${LAYERDIR}/recipes-*/*/*.bbappend" + +BBFILE_COLLECTIONS += "meta-morello" +BBFILE_PATTERN_meta-morello := "^${LAYERDIR}/" +BBFILE_PRIORITY_meta-morello = "5" + +LAYERDEPENDS_meta-morello = " \ + core \ + meta-arm \ +" +LAYERSERIES_COMPAT_meta-morello = "kirkstone" diff --git a/conf/local.conf.sample b/conf/local.conf.sample new file mode 100644 index 0000000..ef7bc7d --- /dev/null +++ b/conf/local.conf.sample @@ -0,0 +1,177 @@ +MACHINE ?= "morello-linux-glibc" +BBMULTICONFIG = "morello-firmware morello-linux-glibc" + +BB_NUMBER_THREADS ?= "${@oe.utils.cpu_count()}" +PARALLEL_MAKE ?= "-j ${@oe.utils.cpu_count()}" + +PACKAGE_CLASSES ?= "package_rpm" + +# DISTRO ?= "poky-bleeding" + +# +# SDK target architecture +# +# This variable specifies the architecture to build SDK items for and means +# you can build the SDK packages for architectures other than the machine you are +# running the build on (i.e. building i686 packages on an x86_64 host). +# Supported values are i686, x86_64, aarch64 +#SDKMACHINE ?= "i686" + +# +# Extra image configuration defaults +# +# The EXTRA_IMAGE_FEATURES variable allows extra packages to be added to the generated +# images. Some of these options are added to certain image types automatically. The +# variable can contain the following options: +# "dbg-pkgs" - add -dbg packages for all installed packages +# (adds symbol information for debugging/profiling) +# "src-pkgs" - add -src packages for all installed packages +# (adds source code for debugging) +# "dev-pkgs" - add -dev packages for all installed packages +# (useful if you want to develop against libs in the image) +# "ptest-pkgs" - add -ptest packages for all ptest-enabled packages +# (useful if you want to run the package test suites) +# "tools-sdk" - add development tools (gcc, make, pkgconfig etc.) +# "tools-debug" - add debugging tools (gdb, strace) +# "eclipse-debug" - add Eclipse remote debugging support +# "tools-profile" - add profiling tools (oprofile, lttng, valgrind) +# "tools-testapps" - add useful testing tools (ts_print, aplay, arecord etc.) +# "debug-tweaks" - make an image suitable for development +# e.g. ssh root access has a blank password +# There are other application targets that can be used here too, see +# meta/classes/image.bbclass and meta/classes/core-image.bbclass for more details. +# We default to enabling the debugging tweaks. +EXTRA_IMAGE_FEATURES ?= "debug-tweaks" + +# +# Additional image features +# +# The following is a list of additional classes to use when building images which +# enable extra features. Some available options which can be included in this variable +# are: +# - 'buildstats' collect build statistics +USER_CLASSES ?= "buildstats" + +# +# Runtime testing of images +# +# The build system can test booting virtual machine images under qemu (an emulator) +# after any root filesystems are created and run tests against those images. It can also +# run tests against any SDK that are built. To enable this uncomment these lines. +# See classes/test{image,sdk}.bbclass for further details. +#IMAGE_CLASSES += "testimage testsdk" +#TESTIMAGE_AUTO:qemuall = "1" + +# +# Interactive shell configuration +# +# Under certain circumstances the system may need input from you and to do this it +# can launch an interactive shell. It needs to do this since the build is +# multithreaded and needs to be able to handle the case where more than one parallel +# process may require the user's attention. The default is iterate over the available +# terminal types to find one that works. +# +# Examples of the occasions this may happen are when resolving patches which cannot +# be applied, to use the devshell or the kernel menuconfig +# +# Supported values are auto, gnome, xfce, rxvt, screen, konsole (KDE 3.x only), none +# Note: currently, Konsole support only works for KDE 3.x due to the way +# newer Konsole versions behave +#OE_TERMINAL = "auto" +# By default disable interactive patch resolution (tasks will just fail instead): +PATCHRESOLVE = "noop" + +# +# Disk Space Monitoring during the build +# +# Monitor the disk space during the build. If there is less that 1GB of space or less +# than 100K inodes in any key build location (TMPDIR, DL_DIR, SSTATE_DIR), gracefully +# shutdown the build. If there is less than 100MB or 1K inodes, perform a hard halt +# of the build. The reason for this is that running completely out of space can corrupt +# files and damages the build in ways which may not be easily recoverable. +# It's necessary to monitor /tmp, if there is no space left the build will fail +# with very exotic errors. +BB_DISKMON_DIRS ??= "\ + STOPTASKS,${TMPDIR},1G,100K \ + STOPTASKS,${DL_DIR},1G,100K \ + STOPTASKS,${SSTATE_DIR},1G,100K \ + STOPTASKS,/tmp,100M,100K \ + HALT,${TMPDIR},100M,1K \ + HALT,${DL_DIR},100M,1K \ + HALT,${SSTATE_DIR},100M,1K \ + HALT,/tmp,10M,1K" + +# +# Shared-state files from other locations +# +# As mentioned above, shared state files are prebuilt cache data objects which can be +# used to accelerate build time. This variable can be used to configure the system +# to search other mirror locations for these objects before it builds the data itself. +# +# This can be a filesystem directory, or a remote url such as https or ftp. These +# would contain the sstate-cache results from previous builds (possibly from other +# machines). This variable works like fetcher MIRRORS/PREMIRRORS and points to the +# cache locations to check for the shared objects. +# NOTE: if the mirror uses the same structure as SSTATE_DIR, you need to add PATH +# at the end as shown in the examples below. This will be substituted with the +# correct path within the directory structure. +#SSTATE_MIRRORS ?= "\ +#file://.* https://someserver.tld/share/sstate/PATH%3Bdownloadfilename=PATH \ +#file://.* file:///some/local/dir/sstate/PATH" + +# +# Yocto Project SState Mirror +# +# The Yocto Project has prebuilt artefacts available for its releases, you can enable +# use of these by uncommenting the following lines. This will mean the build uses +# the network to check for artefacts at the start of builds, which does slow it down +# equally, it will also speed up the builds by not having to build things if they are +# present in the cache. It assumes you can download something faster than you can build it +# which will depend on your network. +# Note: For this to work you also need hash-equivalence passthrough to the matching server +# +#BB_HASHSERVE_UPSTREAM = "typhoon.yocto.io:8687" +#SSTATE_MIRRORS ?= "file://.* http://sstate.yoctoproject.org/all/PATH%3Bdownloadfilename=PATH" + +# +# Qemu configuration +# +# By default native qemu will build with a builtin VNC server where graphical output can be +# seen. The line below enables the SDL UI frontend too. +PACKAGECONFIG:append:pn-qemu-system-native = " sdl" +# By default libsdl2-native will be built, if you want to use your host's libSDL instead of +# the minimal libsdl built by libsdl2-native then uncomment the ASSUME_PROVIDED line below. +#ASSUME_PROVIDED += "libsdl2-native" + +# You can also enable the Gtk UI frontend, which takes somewhat longer to build, but adds +# a handy set of menus for controlling the emulator. +#PACKAGECONFIG:append:pn-qemu-system-native = " gtk+" + +# +# Hash Equivalence +# +# Enable support for automatically running a local hash equivalence server and +# instruct bitbake to use a hash equivalence aware signature generator. Hash +# equivalence improves reuse of sstate by detecting when a given sstate +# artifact can be reused as equivalent, even if the current task hash doesn't +# match the one that generated the artifact. +# +# A shared hash equivalent server can be set with "<HOSTNAME>:<PORT>" format +# +#BB_HASHSERVE = "auto" +#BB_SIGNATURE_HANDLER = "OEEquivHash" + +# +# Memory Resident Bitbake +# +# Bitbake's server component can stay in memory after the UI for the current command +# has completed. This means subsequent commands can run faster since there is no need +# for bitbake to reload cache files and so on. Number is in seconds, after which the +# server will shut down. +# +#BB_SERVER_TIMEOUT = "60" + +# CONF_VERSION is increased each time build/conf/ changes incompatibly and is used to +# track the version of this file when it was generated. This can safely be ignored if +# this doesn't mean anything to you. +CONF_VERSION = "2" diff --git a/conf/machine/include/morello-1.5.inc b/conf/machine/include/morello-1.5.inc new file mode 100644 index 0000000..ba38033 --- /dev/null +++ b/conf/machine/include/morello-1.5.inc @@ -0,0 +1 @@ +MORELLO_RELEASE_VERSION = "1.5" \ No newline at end of file diff --git a/conf/machine/include/morello-common.inc b/conf/machine/include/morello-common.inc new file mode 100644 index 0000000..31601a4 --- /dev/null +++ b/conf/machine/include/morello-common.inc @@ -0,0 +1,27 @@ +require ${COREBASE}/meta/conf/machine/include/arm/armv8-2a/tune-neoversen1.inc +require conf/machine/include/morello-1.5.inc + +MACHINEOVERRIDES =. "morello" + +LLVM_SHARED_SOURCE ?= "${TMPDIR}/work-shared/${MACHINE}/llvm-morello-source" + +MUSL_INSTALL_DIR ??="" + +C64_ARCH_TRIPLE = "aarch64-linux-musl_purecap" +A64_ARCH_TRIPLE = "aarch64-linux-gnu" + +A64_LIB_TRIPLE = "aarch64-unknown-linux-gnu" +C64_LIB_TRIPLE = "aarch64-unknown-linux-musl_purecap" + +A64_ARCH_FLAGS = "-march=armv8" +C64_ARCH_FLAGS = "-march=morello+c64 -mabi=purecap" + +MORELLO_ARCH ?= "c64" +GLOBAL_ARCH_TRIPLE ?= "${C64_ARCH_TRIPLE}" +GLOBAL_LIB_TRIPLE ?= "${C64_LIB_TRIPLE}" +GLOBAL_ARCH_FLAGS ?= "${C64_ARCH_FLAGS}" + +TMPDIR_BSP = "tmp-bsp" +TMPDIR_LINUX = "tmp-linux" + +APP_DIR ?= "pure-cap-apps" \ No newline at end of file diff --git a/conf/machine/morello-bsp.conf b/conf/machine/morello-bsp.conf new file mode 100644 index 0000000..e5c8799 --- /dev/null +++ b/conf/machine/morello-bsp.conf @@ -0,0 +1 @@ +require conf/machine/include/morello-common.inc diff --git a/conf/machine/morello-linux-glibc.conf b/conf/machine/morello-linux-glibc.conf new file mode 100644 index 0000000..6ed824d --- /dev/null +++ b/conf/machine/morello-linux-glibc.conf @@ -0,0 +1,3 @@ +require conf/machine/include/morello-common.inc + +MACHINEOVERRIDES =. "morello-linux-glibc:" diff --git a/conf/machine/morello-linux-musl.conf b/conf/machine/morello-linux-musl.conf new file mode 100644 index 0000000..e22493d --- /dev/null +++ b/conf/machine/morello-linux-musl.conf @@ -0,0 +1,3 @@ +require conf/machine/include/morello-common.inc + +MACHINEOVERRIDES =. "morello-linux-musl:" diff --git a/conf/multiconfig/morello-firmware.conf b/conf/multiconfig/morello-firmware.conf new file mode 100644 index 0000000..1473440 --- /dev/null +++ b/conf/multiconfig/morello-firmware.conf @@ -0,0 +1 @@ +MACHINE="morello-bsp" \ No newline at end of file diff --git a/conf/multiconfig/morello-linux-glibc.conf b/conf/multiconfig/morello-linux-glibc.conf new file mode 100644 index 0000000..9f9a8e8 --- /dev/null +++ b/conf/multiconfig/morello-linux-glibc.conf @@ -0,0 +1 @@ +MACHINE="morello-linux-glibc" \ No newline at end of file diff --git a/conf/multiconfig/morello-linux-musl.conf b/conf/multiconfig/morello-linux-musl.conf new file mode 100644 index 0000000..f8660f3 --- /dev/null +++ b/conf/multiconfig/morello-linux-musl.conf @@ -0,0 +1 @@ +MACHINE="morello-linux-musl" \ No newline at end of file
Append the scp firmware recipe.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- conf/machine/morello-bsp.conf | 5 ++ .../scp-firmware/scp-firmware_2.10.%.bbappend | 75 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 recipes-bsp/scp-firmware/scp-firmware_2.10.%.bbappend
diff --git a/conf/machine/morello-bsp.conf b/conf/machine/morello-bsp.conf index e5c8799..ee40190 100644 --- a/conf/machine/morello-bsp.conf +++ b/conf/machine/morello-bsp.conf @@ -1 +1,6 @@ require conf/machine/include/morello-common.inc + +PREFERRED_VERSION_scp-firmware ?= "2.10%" + + +TMPDIR = "${TOPDIR}/${TMPDIR_BSP}" \ No newline at end of file diff --git a/recipes-bsp/scp-firmware/scp-firmware_2.10.%.bbappend b/recipes-bsp/scp-firmware/scp-firmware_2.10.%.bbappend new file mode 100644 index 0000000..10fb915 --- /dev/null +++ b/recipes-bsp/scp-firmware/scp-firmware_2.10.%.bbappend @@ -0,0 +1,75 @@ +inherit cmake + +COMPATIBLE_MACHINE = "morello" +OUTPUTS_NAME = "scp-firmware" +SECTION = "firmware" + +DEPENDS += "virtual/board-firmware" + +PROVIDES += "virtual/${OUTPUTS_NAME}" + +SRC_URI = "gitsm://git.morello-project.org/morello/scp-firmware.git;protocol=https;branch=${SRCBRANCH}" +SRCREV = "758aad2f0c522d2dd7b8f84eca5d9d71fa2d9359" +PV = "2.10.0+git${SRCPV}" + +SRCBRANCH = "morello/master" + +SCP_PLATFORM = "morello" +SCP_LOG_LEVEL = "INFO" + +SENSOR = "${RECIPE_SYSROOT}/board-firmware/LIB/sensor.a" +B = "${WORKDIR}/build/morello" + +FW_TARGETS = "scp mcp" +FW_INSTALL = "ramfw_soc romfw" + +unset do_configure[noexec] +unset do_compile[cleandirs] +do_deploy[noexec] = "1" + +do_configure() { + + cd ${S} + + for FW in ${FW_TARGETS}; do + for TYPE in ${FW_INSTALL}; do + + local target="${FW}_${TYPE}" + + local extra_cmake="\ + -DSCP_ENABLE_DEBUGGER='0' \ + -DSCP_FIRMWARE_SOURCE_DIR:PATH='${SCP_PLATFORM}/${target}' \ + -DSCP_TOOLCHAIN:STRING='GNU' \ + -DDISABLE_CPPCHECK='1' \ + -DCMAKE_BUILD_TYPE=Release \ + " + + if [ "${target}" = "scp_ramfw_soc" ]; then + extra_cmake="${extra_cmake} -DSCP_MORELLO_SENSOR_LIB_PATH='${SENSOR}'" + fi + + local builddir="${B}/${target}" + cmake -S ${S} -B ${builddir} ${extra_cmake} + done + done +} + +do_compile() { + cd ${S} + for FW in ${FW_TARGETS}; do + for TYPE in ${FW_INSTALL}; do + local target="${FW}_${TYPE}" + cmake --build "${B}/${target}" + done + done +} + +do_install() { + install -d ${D}/firmware + for FW in ${FW_TARGETS}; do + for TYPE in ${FW_INSTALL}; do + local target="${FW}_${TYPE}" + cp -rf "${B}/${target}/bin/"*.bin "${D}/firmware/${target}.bin" + done + done +} \ No newline at end of file
Append trusted-firmware-a recipe.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- conf/machine/morello-bsp.conf | 2 +- .../trusted-firmware-a_2.%.bbappend | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.%.bbappend
diff --git a/conf/machine/morello-bsp.conf b/conf/machine/morello-bsp.conf index ee40190..9998fff 100644 --- a/conf/machine/morello-bsp.conf +++ b/conf/machine/morello-bsp.conf @@ -1,6 +1,6 @@ require conf/machine/include/morello-common.inc
PREFERRED_VERSION_scp-firmware ?= "2.10%" - +PREFERRED_VERSION_trusted-firmware-a ?= "2.7%"
TMPDIR = "${TOPDIR}/${TMPDIR_BSP}" \ No newline at end of file diff --git a/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.%.bbappend b/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.%.bbappend new file mode 100644 index 0000000..227dc57 --- /dev/null +++ b/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.%.bbappend @@ -0,0 +1,46 @@ +inherit llvm-morello-native + +COMPATIBLE_MACHINE = "morello" +SUMMARY = "TF-A to be compiled with LLVM Morello" +OUTPUTS_NAME = "trusted-firmware-a" +SECTION = "firmware" + +PROVIDES += "virtual/${OUTPUTS_NAME}" + +SRC_URI = "gitsm://git.morello-project.org/morello/trusted-firmware-a;protocol=https;name=tfa;branch=${SRCBRANCH}" +SRCREV_tfa = "3ce2815936774fe924ec7538151b71085c2f18d9" +PV = "2.7+git${SRCPV}" + +SRCBRANCH = "morello/master" +LIC_FILES_CHKSUM = "file://docs/license.rst;md5=b2c740efedc159745b9b31f88ff03dde" + +TFA_MBEDTLS = "1" +TFA_MBEDTLS_DIR = "mbedtls" +TFA_MBEDTLS_BRANCH = "mbedtls-2.28" +SRC_URI_MBEDTLS = "git://github.com/ARMmbed/mbedtls;protocol=https;destsuffix=git/mbedtls;name=mbedtls;branch=${TFA_MBEDTLS_BRANCH}" +SRCREV_mbedtls = "8b3f26a5ac38d4fdccbc5c5366229f3e01dafcc0" +LIC_FILES_CHKSUM_MBEDTLS = "file://mbedtls/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" + +TFA_PLATFORM = "morello" +TFA_UBOOT = "0" +TFA_BUILD_TARGET = "bl1 bl2 bl31 dtbs" +TFA_DEBUG = "0" + +TFA_INSTALL_TARGET = "bl1 bl2 bl31 dtbs morello-soc morello_fw_config morello_tb_fw_config morello_nt_fw_config " + +ARM_TF_ARCH = "aarch64" + +EXTRA_OEMAKE += "\ + CREATE_KEYS=1 \ + GENERATE_COT=1 \ + ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem \ + TRUSTED_BOARD_BOOT=1 \ + ARM_ROTPK_LOCATION=devel_rsa \ + TARGET_PLATFORM=soc \ + ENABLE_MORELLO_CAP=1 \ + ARCH='${ARM_TF_ARCH}' \ + " + +do_install:append() { + install -m 0644 ${S}/plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem "${D}/firmware/"arm_rotprivk_rsa.pem +} \ No newline at end of file
Append the UEFI recipe. Patch was necessary for brotli, taken from [1]
[1] https://github.com/google/brotli/commit/0a3944c8c99b8d10cc4325f721b7c273d2b4...
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- recipes-bsp/uefi/edk2-firmware_%.bbappend | 48 +++++++++++++++++++ ...Basetools-remove-brotli-build-errors.patch | 45 +++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 recipes-bsp/uefi/edk2-firmware_%.bbappend create mode 100644 recipes-bsp/uefi/files/0001-Basetools-remove-brotli-build-errors.patch
diff --git a/recipes-bsp/uefi/edk2-firmware_%.bbappend b/recipes-bsp/uefi/edk2-firmware_%.bbappend new file mode 100644 index 0000000..146c962 --- /dev/null +++ b/recipes-bsp/uefi/edk2-firmware_%.bbappend @@ -0,0 +1,48 @@ +inherit python3native llvm-morello-native + +COMPATIBLE_MACHINE = "morello" +SUMMARY = "EDK2 to be compiled with LLVM Morello" +OUTPUTS_NAME = "uefi" +SECTION = "firmware" + +PROVIDES += "virtual/${OUTPUTS_NAME}" +DEPENDS += "acpica-native python3-native" + +FILESEXTRAPATHS:prepend := "${THISDIR}:" + +SRC_URI = "\ + ${EDK2_SRC_URI};name=edk2;destsuffix=edk2 \ + ${EDK2_PLATFORMS_SRC_URI};name=edk2-platforms;destsuffix=edk2/edk2-platforms \ + ${EDK2_NON_OSI_SRC_URI};name=edk2-non-osi;destsuffix=edk2-non-osi \ + file://files/0001-Basetools-remove-brotli-build-errors.patch \ + " + +EDK2_SRC_URI = "gitsm://git.morello-project.org/morello/edk2;branch=morello/master;protocol=https" +EDK2_PLATFORMS_SRC_URI = "gitsm://git.morello-project.org/morello/edk2-platforms;branch=morello/master;protocol=https" +EDK2_NON_OSI_SRC_URI = "git://github.com/tianocore/edk2-non-osi;branch=master;protocol=https" +SRCREV_edk2-non-osi = "0320db977fb27e63424b0953a3020bb81c89e8f0" +SRCREV_edk2 = "ce510c33dfc354e262ccd71619add069876d6a08" +SRCREV_edk2-platforms = "6bae2381d664e668875720e7eb86f751cb1de373" +PV = "git${SRCPV}" + +EDK2_BUILD_RELEASE = "0" +EDK2_PLATFORM = "morellosoc" +EDK2_PLATFORM_DSC = "edk2-platforms/Platform/ARM/Morello/MorelloPlatformSoc.dsc" +EDK2_BIN_NAME = "BL33_AP_UEFI.fd" +EDK2_ARCH = "AARCH64" +EDK2_BUILD_FLAGS += "-D ENABLE_MORELLO_CAP=1" +EDK_COMPILER = "CLANG35" + +export CLANG35_AARCH64_PREFIX = "${TARGET_PREFIX}" +export CLANG35_BIN = "${LLVM_PATH}/" +export CLANG35_AARCH64_PREFIX = "${LLVM_PATH}/llvm-" +export PACKAGES_PATH = "${S}:${S}/edk2-platforms:${WORKDIR}/edk2-non-osi" +export CC_PATH = "${LLVM_PATH}/clang" +export LLVM_PATH_35 = "${LLVM_PATH}" + +do_deploy[noexec] = "1" + +do_install() { + install -d ${D}/firmware + install ${B}/Build/${EDK2_PLATFORM}/${EDK2_BUILD_MODE}_${EDK_COMPILER}/FV/${EDK2_BIN_NAME} ${D}/firmware/uefi.bin +} \ No newline at end of file diff --git a/recipes-bsp/uefi/files/0001-Basetools-remove-brotli-build-errors.patch b/recipes-bsp/uefi/files/0001-Basetools-remove-brotli-build-errors.patch new file mode 100644 index 0000000..53d16ad --- /dev/null +++ b/recipes-bsp/uefi/files/0001-Basetools-remove-brotli-build-errors.patch @@ -0,0 +1,45 @@ +From 27dd7265403d8e8fed99a854b9c3e1db7d79525f Mon Sep 17 00:00:00 2001 +From: Jeremy Maitin-Shepard jbms@google.com +Date: Tue, 14 Sep 2021 12:27:45 -0700 +Subject: [PATCH 09/22] Fix -Werror=vla-parameter errors with GCC 11.2.0 + +--- + BaseTools/Source/C/BrotliCompress/brotli/c/dec/decode.c | 6 ++++-- + BaseTools/Source/C/BrotliCompress/brotli/c/enc/encode.c | 5 +++-- + 2 files changed, 7 insertions(+), 4 deletions(-) + +diff --git a/BaseTools/Source/C/BrotliCompress/brotli/c/dec/decode.c b/c/dec/decode.c +index 114c505..4c89a73 100644 +--- a/BaseTools/Source/C/BrotliCompress/brotli/c/dec/decode.c ++++ b/BaseTools/Source/C/BrotliCompress/brotli/c/dec/decode.c +@@ -2030,8 +2030,10 @@ static BROTLI_NOINLINE BrotliDecoderErrorCode SafeProcessCommands( + } + + BrotliDecoderResult BrotliDecoderDecompress( +- size_t encoded_size, const uint8_t* encoded_buffer, size_t* decoded_size, +- uint8_t* decoded_buffer) { ++ size_t encoded_size, ++ const uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(encoded_size)], ++ size_t* decoded_size, ++ uint8_t decoded_buffer[BROTLI_ARRAY_PARAM(*decoded_size)]) { + BrotliDecoderState s; + BrotliDecoderResult result; + size_t total_out = 0; +diff --git a/BaseTools/Source/C/BrotliCompress/brotli/c/enc/encode.c b/c/enc/encode.c +index 68548ef..dc3704e 100644 +--- a/BaseTools/Source/C/BrotliCompress/brotli/c/enc/encode.c ++++ b/BaseTools/Source/C/BrotliCompress/brotli/c/enc/encode.c +@@ -1470,8 +1470,9 @@ static size_t MakeUncompressedStream( + + BROTLI_BOOL BrotliEncoderCompress( + int quality, int lgwin, BrotliEncoderMode mode, size_t input_size, +- const uint8_t* input_buffer, size_t* encoded_size, +- uint8_t* encoded_buffer) { ++ const uint8_t input_buffer[BROTLI_ARRAY_PARAM(input_size)], ++ size_t* encoded_size, ++ uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(*encoded_size)]) { + BrotliEncoderState* s; + size_t out_size = *encoded_size; + const uint8_t* input_start = input_buffer; +-- +2.34.1 \ No newline at end of file
Append the grub recipes. Note that due to the fact that grub requires lib gcc it should be built using the bsp machine, otherwise we will get build errors. The actual outputs are part of the Linux image that is built using the glibc/musl machines. For now this is resolved using well defined tmp dirs in the machine configs.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- recipes-bsp/grub/files/grub-config.cfg | 37 ++++++++++++++++++++++++++ recipes-bsp/grub/grub-efi_2.%.bbappend | 22 +++++++++++++++ recipes-bsp/grub/grub_2.%.bbappend | 10 +++++++ 3 files changed, 69 insertions(+) create mode 100644 recipes-bsp/grub/files/grub-config.cfg create mode 100644 recipes-bsp/grub/grub-efi_2.%.bbappend create mode 100644 recipes-bsp/grub/grub_2.%.bbappend
diff --git a/recipes-bsp/grub/files/grub-config.cfg b/recipes-bsp/grub/files/grub-config.cfg new file mode 100644 index 0000000..2273be7 --- /dev/null +++ b/recipes-bsp/grub/files/grub-config.cfg @@ -0,0 +1,37 @@ +set debug="loader,mm" +set term="vt100" +set default="1" +set timeout="5" + +menuentry 'BusyBox Morello Platform (Device Tree)' { + devicetree /morello.dtb + linux /Image \ + acpi=off \ + console=ttyAMA0,115200 \ + debug \ + earlycon=pl011,0x2A400000 \ + ip=dhcp \ + + initrd /initramfs +} + +menuentry 'BusyBox Morello Platform (ACPI)' { + linux /Image \ + acpi=force \ + debug \ + earlycon=pl011,0x2A400000 \ + ip=dhcp \ + root=PARTUUID=%UUID% \ + + initrd /initramfs +} + +menuentry 'BusyBox Morello Platform (ACPI) - no initramfs' { + linux /Image \ + acpi=force \ + console=ttyAMA0,115200 \ + debug \ + earlycon=pl011,0x2A400000 \ + ip=dhcp \ + root=PARTUUID=%UUID% \ +} \ No newline at end of file diff --git a/recipes-bsp/grub/grub-efi_2.%.bbappend b/recipes-bsp/grub/grub-efi_2.%.bbappend new file mode 100644 index 0000000..c03b87c --- /dev/null +++ b/recipes-bsp/grub/grub-efi_2.%.bbappend @@ -0,0 +1,22 @@ +inherit deploy nopackages + +COMPATIBLE_MACHINE = "morello" +OUTPUTS_NAME = "grub-efi" + +PROVIDES += "virtual/${OUTPUTS_NAME}" + +FILESEXTRAPATHS:prepend := "${THISDIR}:" + +GRUB_BUILDIN = " boot chain configfile ext2 fat gzio help linux loadenv \ + lsefi normal ntfs ntfscomp part_gpt part_msdos progress read search \ + search_fs_file search_fs_uuid search_label terminal terminfo \ + " + +SRC_URI += "file://files/grub-config.cfg" + +do_deploy() { + install -d ${DEPLOYDIR}/${OUTPUTS_NAME} + install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} "${DEPLOYDIR}/${OUTPUTS_NAME}/" + install -m 644 ${WORKDIR}/files/grub-config.cfg "${DEPLOYDIR}/${OUTPUTS_NAME}/grub-config.cfg" +} +addtask deploy after do_install before do_build \ No newline at end of file diff --git a/recipes-bsp/grub/grub_2.%.bbappend b/recipes-bsp/grub/grub_2.%.bbappend new file mode 100644 index 0000000..a2f232d --- /dev/null +++ b/recipes-bsp/grub/grub_2.%.bbappend @@ -0,0 +1,10 @@ + + +EXTRA_OECONF+="\ + --disable-efiemu \ + --disable-werror \ + --enable-dependency-tracking \ + --disable-grub-mkfont \ + --disable-grub-themes \ + --disable-grub-mount \ + " \ No newline at end of file
Add native fiptool and cert_create used to create the fip.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- .../fiptool/fiptool-native_2.7.bb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 recipes-devtools/fiptool/fiptool-native_2.7.bb
diff --git a/recipes-devtools/fiptool/fiptool-native_2.7.bb b/recipes-devtools/fiptool/fiptool-native_2.7.bb new file mode 100644 index 0000000..9c21c7a --- /dev/null +++ b/recipes-devtools/fiptool/fiptool-native_2.7.bb @@ -0,0 +1,31 @@ +inherit native + +DESCRIPTION = "fiptool - Trusted Firmware tool for packaging" +LICENSE = "BSD-3-Clause" + +DEPENDS += "openssl-native" +PROVIDES = "virtual/fiptool-native" + +SRC_URI = "gitsm://git.morello-project.org/morello/trusted-firmware-a;protocol=https;branch=${SRCBRANCH}" +SRCBRANCH = "morello/master" +SRCREV = "3ce2815936774fe924ec7538151b71085c2f18d9" + +LIC_FILES_CHKSUM = "file://docs/license.rst;md5=b2c740efedc159745b9b31f88ff03dde" + +EXTRA_OEMAKE = "HOSTCC='${BUILD_CC}' OPENSSL_DIR=${STAGING_DIR_NATIVE}${prefix_native}" + +S = "${WORKDIR}/git" + +do_compile() { + sed -i '/^LDLIBS/ s,$, ${BUILD_LDFLAGS},' ${S}/tools/fiptool/Makefile + sed -i '/^INCLUDE_PATHS/ s,$, ${BUILD_CFLAGS},' ${S}/tools/fiptool/Makefile + oe_runmake fiptool + + sed -i '/^LIB/ s,$, ${BUILD_LDFLAGS},' ${S}/tools/cert_create/Makefile + oe_runmake certtool +} + +do_install() { + install -D -p -m 0755 tools/fiptool/fiptool ${D}${bindir}/fiptool + install -D -p -m 0755 tools/cert_create/cert_create ${D}${bindir}/cert_create +} \ No newline at end of file
This recipe is already in meta-arm. Does it need to be overridden?
Ross
On 27 Jan 2023, at 15:28, Pawel Zalewski pzalewski@thegoodpenguin.co.uk wrote:
Add native fiptool and cert_create used to create the fip.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk
.../fiptool/fiptool-native_2.7.bb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 recipes-devtools/fiptool/fiptool-native_2.7.bb
diff --git a/recipes-devtools/fiptool/fiptool-native_2.7.bb b/recipes-devtools/fiptool/fiptool-native_2.7.bb new file mode 100644 index 0000000..9c21c7a --- /dev/null +++ b/recipes-devtools/fiptool/fiptool-native_2.7.bb @@ -0,0 +1,31 @@ +inherit native
+DESCRIPTION = "fiptool - Trusted Firmware tool for packaging" +LICENSE = "BSD-3-Clause"
+DEPENDS += "openssl-native" +PROVIDES = "virtual/fiptool-native"
+SRC_URI = "gitsm://git.morello-project.org/morello/trusted-firmware-a;protocol=https;branch=${SRCBRANCH}" +SRCBRANCH = "morello/master" +SRCREV = "3ce2815936774fe924ec7538151b71085c2f18d9"
+LIC_FILES_CHKSUM = "file://docs/license.rst;md5=b2c740efedc159745b9b31f88ff03dde"
+EXTRA_OEMAKE = "HOSTCC='${BUILD_CC}' OPENSSL_DIR=${STAGING_DIR_NATIVE}${prefix_native}"
+S = "${WORKDIR}/git"
+do_compile() {
- sed -i '/^LDLIBS/ s,$, ${BUILD_LDFLAGS},' ${S}/tools/fiptool/Makefile
- sed -i '/^INCLUDE_PATHS/ s,$, ${BUILD_CFLAGS},' ${S}/tools/fiptool/Makefile
- oe_runmake fiptool
- sed -i '/^LIB/ s,$, ${BUILD_LDFLAGS},' ${S}/tools/cert_create/Makefile
- oe_runmake certtool
+}
+do_install() {
- install -D -p -m 0755 tools/fiptool/fiptool ${D}${bindir}/fiptool
- install -D -p -m 0755 tools/cert_create/cert_create ${D}${bindir}/cert_create
+} \ No newline at end of file -- 2.34.1
linux-morello-distros mailing list -- linux-morello-distros@op-lists.linaro.org To unsubscribe send an email to linux-morello-distros-leave@op-lists.linaro.org
It is at version 2.5 in the commit hash of meta-arm that I use, this is 2.7, hence a new recipe.
The original fiptool recipe in meta-arm has a typo @ ${STAGING_DIR_NATIVE}${prefix_native}" where it is : ${STAGING_DIR_NATIVE}/${prefix_native}" - there is an unnecessary forward slash, which is already contained in the variable.
I have not submitted a patch for this yet, but thought you would want to know.
Pawel
On Mon, 30 Jan 2023 at 11:30, Ross Burton Ross.Burton@arm.com wrote:
This recipe is already in meta-arm. Does it need to be overridden?
Ross
On 27 Jan 2023, at 15:28, Pawel Zalewski pzalewski@thegoodpenguin.co.uk
wrote:
Add native fiptool and cert_create used to create the fip.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk
.../fiptool/fiptool-native_2.7.bb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 recipes-devtools/fiptool/fiptool-native_2.7.bb
diff --git a/recipes-devtools/fiptool/fiptool-native_2.7.bb
b/recipes-devtools/fiptool/fiptool-native_2.7.bb
new file mode 100644 index 0000000..9c21c7a --- /dev/null +++ b/recipes-devtools/fiptool/fiptool-native_2.7.bb @@ -0,0 +1,31 @@ +inherit native
+DESCRIPTION = "fiptool - Trusted Firmware tool for packaging" +LICENSE = "BSD-3-Clause"
+DEPENDS += "openssl-native" +PROVIDES = "virtual/fiptool-native"
+SRC_URI = "gitsm://
git.morello-project.org/morello/trusted-firmware-a;protocol=https;branch=${SRCBRANCH} http://git.morello-project.org/morello/trusted-firmware-a;protocol=https;branch=$%7BSRCBRANCH%7D "
+SRCBRANCH = "morello/master" +SRCREV = "3ce2815936774fe924ec7538151b71085c2f18d9"
+LIC_FILES_CHKSUM =
"file://docs/license.rst;md5=b2c740efedc159745b9b31f88ff03dde"
+EXTRA_OEMAKE = "HOSTCC='${BUILD_CC}'
OPENSSL_DIR=${STAGING_DIR_NATIVE}${prefix_native}"
+S = "${WORKDIR}/git"
+do_compile() {
- sed -i '/^LDLIBS/ s,$, ${BUILD_LDFLAGS},'
${S}/tools/fiptool/Makefile
- sed -i '/^INCLUDE_PATHS/ s,$, ${BUILD_CFLAGS},'
${S}/tools/fiptool/Makefile
- oe_runmake fiptool
- sed -i '/^LIB/ s,$, ${BUILD_LDFLAGS},'
${S}/tools/cert_create/Makefile
- oe_runmake certtool
+}
+do_install() {
- install -D -p -m 0755 tools/fiptool/fiptool ${D}${bindir}/fiptool
- install -D -p -m 0755 tools/cert_create/cert_create
${D}${bindir}/cert_create
+} \ No newline at end of file -- 2.34.1
linux-morello-distros mailing list --
linux-morello-distros@op-lists.linaro.org
To unsubscribe send an email to
linux-morello-distros-leave@op-lists.linaro.org
This two-step recipe takes the board firmware repo and overwrites its contents with the outputs obtained from the firmware recipes. SD card image is then created using mtools.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- conf/machine/morello-bsp.conf | 9 +- .../board-firmware/board-firmware-image.bb | 82 +++++++++++++++++++ .../board-firmware/board-firmware_1.4.bb | 29 +++++++ 3 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 recipes-bsp/board-firmware/board-firmware-image.bb create mode 100644 recipes-bsp/board-firmware/board-firmware_1.4.bb
diff --git a/conf/machine/morello-bsp.conf b/conf/machine/morello-bsp.conf index 9998fff..45b12fb 100644 --- a/conf/machine/morello-bsp.conf +++ b/conf/machine/morello-bsp.conf @@ -1,6 +1,9 @@ require conf/machine/include/morello-common.inc
-PREFERRED_VERSION_scp-firmware ?= "2.10%" -PREFERRED_VERSION_trusted-firmware-a ?= "2.7%" +PREFERRED_VERSION_scp-firmware = "2.10%" +PREFERRED_VERSION_trusted-firmware-a = "2.7%" +PREFERRED_VERSION_board-firmware = "1.4"
-TMPDIR = "${TOPDIR}/${TMPDIR_BSP}" \ No newline at end of file +TMPDIR = "${TOPDIR}/${TMPDIR_BSP}" + +TCLIBCAPPEND = "" \ No newline at end of file diff --git a/recipes-bsp/board-firmware/board-firmware-image.bb b/recipes-bsp/board-firmware/board-firmware-image.bb new file mode 100644 index 0000000..b872a3a --- /dev/null +++ b/recipes-bsp/board-firmware/board-firmware-image.bb @@ -0,0 +1,82 @@ +inherit deploy nopackages + +COMPATIBLE_MACHINE = "morello" +SUMMARY = "SDK Card Firmware Image " +DESCRIPTION = "Image containing all the firmwares and motherboard configuration files" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +OUTPUTS_NAME = "board-firmware-sd-image" +SECTION = "firmware" + +BB_DONT_CACHE = "1" + +DEPENDS += "virtual/board-firmware virtual/scp-firmware virtual/trusted-firmware-a virtual/uefi virtual/grub-efi mtools-native fiptool-native" +PROVIDES = "virtual/board-firmware-image" + +MCP_BLOB_ID = "54464222-a4cf-4bf8-b1b6-cee7dade539e" + +FIP_OPTIONS = "\ + --tb-fw '${FIRMWARE_PATH}/bl2.bin' \ + --soc-fw '${FIRMWARE_PATH}/bl31.bin' \ + --nt-fw '${FIRMWARE_PATH}/uefi.bin' \ + --fw-config '${FIRMWARE_PATH}/morello_fw_config.dtb' \ + --tb-fw-config '${FIRMWARE_PATH}/morello_tb_fw_config.dtb' \ + --nt-fw-config '${FIRMWARE_PATH}/morello_nt_fw_config.dtb' \ + --trusted-key-cert '${FIRMWARE_PATH}/tfa_certs/trusted_key.crt' \ + --soc-fw-key-cert '${FIRMWARE_PATH}/tfa_certs/bl31_key.crt' \ + --nt-fw-key-cert '${FIRMWARE_PATH}/tfa_certs/bl33_key.crt' \ + --soc-fw-cert '${FIRMWARE_PATH}/tfa_certs/bl31.crt' \ + --nt-fw-cert '${FIRMWARE_PATH}/tfa_certs/bl33.crt' \ + --tb-fw-cert '${FIRMWARE_PATH}/tfa_certs/bl2.crt' \ + " + +FIRMWARE_PATH = "${RECIPE_SYSROOT}/firmware" +SYSROOT_SOFTWARE_PATH = "${RECIPE_SYSROOT}/board-firmware/SOFTWARE" + +do_configure[noexec] = "1" +do_compile[noexec] = "1" +do_install[depends] += "virtual/board-firmware:do_populate_sysroot" +do_install[depends] += "virtual/scp-firmware:do_populate_sysroot" +do_install[depends] += "virtual/uefi:do_populate_sysroot" +do_install[depends] += "virtual/trusted-firmware-a:do_populate_sysroot" + +do_install:prepend() { + + fiptool create \ + --scp-fw "${FIRMWARE_PATH}/scp_ramfw_soc.bin" \ + "${FIRMWARE_PATH}/scp_fw.bin" + + fiptool create \ + --blob uuid="${MCP_BLOB_ID}",file="${FIRMWARE_PATH}/mcp_ramfw_soc.bin" \ + "${FIRMWARE_PATH}/mcp_fw.bin" + + install -d "${FIRMWARE_PATH}/tfa_certs" + cert_create ${FIP_OPTIONS} -n --tfw-nvctr 0 --ntfw-nvctr 0 \ + --rot-key ${FIRMWARE_PATH}/arm_rotprivk_rsa.pem + + fiptool update ${FIP_OPTIONS} "${FIRMWARE_PATH}/fip.bin" +} + +do_install() { + + cp -rf ${FIRMWARE_PATH}/fip.bin ${SYSROOT_SOFTWARE_PATH}/fip.bin + cp -rf ${FIRMWARE_PATH}/scp_fw.bin ${SYSROOT_SOFTWARE_PATH}/scp_fw.bin + cp -rf ${FIRMWARE_PATH}/mcp_fw.bin ${SYSROOT_SOFTWARE_PATH}/mcp_fw.bin + + install -d ${D}/board-firmware/SOFTWARE + install -m 644 ${SYSROOT_SOFTWARE_PATH}/fip.bin ${D}/board-firmware/SOFTWARE/fip.bin + install -m 644 ${SYSROOT_SOFTWARE_PATH}/scp_fw.bin ${D}/board-firmware/SOFTWARE/scp_fw.bin + install -m 644 ${SYSROOT_SOFTWARE_PATH}/mcp_fw.bin ${D}/board-firmware/SOFTWARE/mcp_fw.bin + + dd if=/dev/zero of=${OUTPUTS_NAME}.img bs=512K count=100 + mformat -i ${OUTPUTS_NAME}.img :: + mcopy -i ${OUTPUTS_NAME}.img -s -Q -p -m ${RECIPE_SYSROOT}/board-firmware/* :: + + install -d ${D}/firmware/board-firmware-image + install -m 644 ${OUTPUTS_NAME}.img ${D}/firmware/board-firmware-image/${OUTPUTS_NAME}.img +} + +do_deploy() { + cp -rf ${D}/firmware/board-firmware-image/${OUTPUTS_NAME}.img ${DEPLOYDIR}/${OUTPUTS_NAME}.img +} +addtask deploy after do_install \ No newline at end of file diff --git a/recipes-bsp/board-firmware/board-firmware_1.4.bb b/recipes-bsp/board-firmware/board-firmware_1.4.bb new file mode 100644 index 0000000..502e643 --- /dev/null +++ b/recipes-bsp/board-firmware/board-firmware_1.4.bb @@ -0,0 +1,29 @@ + + +COMPATIBLE_MACHINE = "morello" +SUMMARY = "Board firmware for Morello" +DESCRIPTION = "The SD card image from ARM that contains non compile-able binaries." +HOMEPAGE = "https://git.morello-project.org/morello/board-firmware" +LICENSE = "STMicroelectronics&BSD-3 & BDS-2" +OUTPUTS_NAME = "board-firmware" +SECTION = "firmware" + +PROVIDES += "virtual/${OUTPUTS_NAME}" + +SRC_URI = "git://git.morello-project.org/morello/board-firmware;protocol=https;branch=${SRCBRANCH}" +SRCREV = "20e3e673f13e854109a069dd719f49e06336142d" + +SRCBRANCH = "morello/release-1.4" +LIC_FILES_CHKSUM = "file://LICENSES/MB/STM.TXT;md5=15054b089e974faf5fb98db442a7415a \ + file://LICENSES/LIB/sensor.txt;md5=7ba201f1f1e4959d3505d9c59c6cfdfa \ + " + +S = "${WORKDIR}/git" +FILES:${PN} += "/${OUTPUTS_NAME}" +FILES:${PN}-staticdev += "/${OUTPUTS_NAME}/LIB/sensor.a" +SYSROOT_DIRS += "/${OUTPUTS_NAME}" + +do_install() { + install -d "${D}/${OUTPUTS_NAME}" + cp -rf ${S}/* "${D}/${OUTPUTS_NAME}/" +} \ No newline at end of file
Add recipes for the Linux kernel. The recipe has a common include so that future versions can re-use the code (the recipe is not versioned itself).
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- recipes-kernel/linux/linux-morello-1.5.bb | 9 +++++ recipes-kernel/linux/linux-morello.inc | 47 +++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 recipes-kernel/linux/linux-morello-1.5.bb create mode 100644 recipes-kernel/linux/linux-morello.inc
diff --git a/recipes-kernel/linux/linux-morello-1.5.bb b/recipes-kernel/linux/linux-morello-1.5.bb new file mode 100644 index 0000000..ea3e0ca --- /dev/null +++ b/recipes-kernel/linux/linux-morello-1.5.bb @@ -0,0 +1,9 @@ +require linux-morello.inc + +LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" + +SRCBRANCH = "morello/master" +SRCTAG = "morello-release-1.5.0" + +LINUX_VERSION = "5.18" +LINUX_VERSION_EXTENSION= "-yocto-purecap" \ No newline at end of file diff --git a/recipes-kernel/linux/linux-morello.inc b/recipes-kernel/linux/linux-morello.inc new file mode 100644 index 0000000..a5effbb --- /dev/null +++ b/recipes-kernel/linux/linux-morello.inc @@ -0,0 +1,47 @@ +inherit llvm-morello-native +require recipes-kernel/linux/linux-yocto.inc +COMPATIBLE_MACHINE = "morello-linux" +SUMMARY = "Morello Linux kernel fork" +DESCRIPTION = "CHERI aware Linux kernel" +OUTPUTS_NAME = "morello-linux" +SECTION = "kernel" + +FILESEXTRAPATHS:prepend := "${THISDIR}:${THISDIR}/${PN}:" + +DEPENDS += "rsync-native" +PROVIDES += "virtual/${OUTPUTS_NAME}" + +SRC_URI = " \ + git://git.morello-project.org/morello/kernel/linux;protocol=https;tag=${SRCTAG};branch=${SRCBRANCH} \ + " + +PV = "${LINUX_VERSION}+git${SRCPV}" +S = "${WORKDIR}/git" + +BUILD_CC = "${LLVM_PATH}/clang" +BUILD_CPP = "${LLVM_PATH}/clang" +BUILD_CXX = "${LLVM_PATH}/clang++" +BUILD_LD = "${LLVM_PATH}/ld.lld" + +KERNEL_CC = "${LLVM_PATH}/clang" +KERNEL_LD = "${LLVM_PATH}/ld.lld" + +ARCH = "arm64" + +LINUX_KERNEL_TYPE ?= "standard" + +KERNEL_FEATURES:append = " ${KERNEL_EXTRA_FEATURES}" +KERNEL_IMAGETYPE = "Image" + +KBUILD_DEFCONFIG = "morello_transitional_pcuabi_defconfig" + +do_kernel_configcheck[noexec] = "1" +do_kernel_configme[depends] += "llvm-morello-native:do_populate_sysroot" + +do_configure:prepend(){ + rm -f ${B}/.config +} + +do_install:append() { + oe_runmake headers_install ARCH=arm64 INSTALL_HDR_PATH=${STAGING_KERNEL_BUILDDIR}/kernel-headers +} \ No newline at end of file
The morello musl libc appends the musl_git.bb recipe. The installation path and PROVIDES depend on the machine. The native libraries that go into clang resource folder are also covered. The build order is: musl-morello-native, musl-morello-libs-native, and musl-morello-target.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- recipes-core/musl/files/compiler_rt.cmake | 5 ++ recipes-core/musl/musl-morello-1.5.inc | 4 + recipes-core/musl/musl-morello-a64-so.inc | 7 ++ recipes-core/musl/musl-morello-a64.inc | 7 ++ recipes-core/musl/musl-morello-c64-so.inc | 7 ++ recipes-core/musl/musl-morello-c64.inc | 7 ++ recipes-core/musl/musl-morello-common.inc | 65 ++++++++++++++++ recipes-core/musl/musl-morello-libs-native.bb | 74 +++++++++++++++++++ recipes-core/musl/musl-morello-native.bb | 36 +++++++++ recipes-core/musl/musl-morello-target.inc | 52 +++++++++++++ recipes-core/musl/musl_%.bbappend | 17 +++++ recipes-core/musl/override-glibc.inc | 4 + recipes-core/musl/override-musl.inc | 2 + 13 files changed, 287 insertions(+) create mode 100644 recipes-core/musl/files/compiler_rt.cmake create mode 100644 recipes-core/musl/musl-morello-1.5.inc create mode 100644 recipes-core/musl/musl-morello-a64-so.inc create mode 100644 recipes-core/musl/musl-morello-a64.inc create mode 100644 recipes-core/musl/musl-morello-c64-so.inc create mode 100644 recipes-core/musl/musl-morello-c64.inc create mode 100644 recipes-core/musl/musl-morello-common.inc create mode 100644 recipes-core/musl/musl-morello-libs-native.bb create mode 100644 recipes-core/musl/musl-morello-native.bb create mode 100644 recipes-core/musl/musl-morello-target.inc create mode 100644 recipes-core/musl/musl_%.bbappend create mode 100644 recipes-core/musl/override-glibc.inc create mode 100644 recipes-core/musl/override-musl.inc
diff --git a/recipes-core/musl/files/compiler_rt.cmake b/recipes-core/musl/files/compiler_rt.cmake new file mode 100644 index 0000000..24ea9e7 --- /dev/null +++ b/recipes-core/musl/files/compiler_rt.cmake @@ -0,0 +1,5 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") +set(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-1.5.inc b/recipes-core/musl/musl-morello-1.5.inc new file mode 100644 index 0000000..750120d --- /dev/null +++ b/recipes-core/musl/musl-morello-1.5.inc @@ -0,0 +1,4 @@ +LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=b03f1cc25363d094011f8f4fd8bcfb68" + +SRCBRANCH = "morello/master" +SRCTAG = "morello-release-1.5.0" \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-a64-so.inc b/recipes-core/musl/musl-morello-a64-so.inc new file mode 100644 index 0000000..1a294dd --- /dev/null +++ b/recipes-core/musl/musl-morello-a64-so.inc @@ -0,0 +1,7 @@ +PROVIDES += "virtual/${OUTPUTS_NAME}-a64 virtual/crypt-a64" + +do_install:append() { + install -d ${D}${nonarch_base_libdir} + ln -rs ${TARGET_INSTALL_DIR}${libdir}/libc.so ${D}${nonarch_base_libdir}/ld-musl-${MUSL_LDSO_ARCH}.so.1 + rm -f ${TARGET_INSTALL_DIR}${nonarch_base_libdir}/ld-musl-morello.so.1 +} \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-a64.inc b/recipes-core/musl/musl-morello-a64.inc new file mode 100644 index 0000000..7aa18a3 --- /dev/null +++ b/recipes-core/musl/musl-morello-a64.inc @@ -0,0 +1,7 @@ +require musl-morello-common.inc + +EXTRA_CONFIGUREOPTS = "--disable-morello" + +ARCH_TRIPLE = "${A64_ARCH_TRIPLE}" +LIB_TRIPLE = "${A64_LIB_TRIPLE}" +ARCH_FLAGS = "-march=armv8" \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-c64-so.inc b/recipes-core/musl/musl-morello-c64-so.inc new file mode 100644 index 0000000..b6c8c75 --- /dev/null +++ b/recipes-core/musl/musl-morello-c64-so.inc @@ -0,0 +1,7 @@ +PROVIDES += "virtual/${OUTPUTS_NAME}-c64 virtual/crypt-c64" + +do_install:append() { + install -d ${D}${nonarch_base_libdir} + ln -rs ${TARGET_INSTALL_DIR}${libdir}/libc.so ${D}${nonarch_base_libdir}/ld-musl-${MUSL_LDSO_ARCH}.so.1 + rm -f ${TARGET_INSTALL_DIR}${nonarch_base_libdir}/ld-musl-morello.so.1 +} \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-c64.inc b/recipes-core/musl/musl-morello-c64.inc new file mode 100644 index 0000000..761b9d2 --- /dev/null +++ b/recipes-core/musl/musl-morello-c64.inc @@ -0,0 +1,7 @@ +require musl-morello-common.inc + +EXTRA_CONFIGUREOPTS = "--enable-morello" + +ARCH_TRIPLE = "${C64_ARCH_TRIPLE}" +LIB_TRIPLE = "${C64_LIB_TRIPLE}" +ARCH_FLAGS = "-march=morello+c64 -mabi=purecap" \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-common.inc b/recipes-core/musl/musl-morello-common.inc new file mode 100644 index 0000000..f296e08 --- /dev/null +++ b/recipes-core/musl/musl-morello-common.inc @@ -0,0 +1,65 @@ +require musl-morello-${MORELLO_RELEASE_VERSION}.inc + +DESCRIPTION = "CHERI enabled musl libc" +OUTPUTS_NAME = "libc" +LICENSE = "MIT" + +FILESEXTRAPATHS:prepend := "${THISDIR}:" + +SUMMARY = "CHERI enabled musl libc" +SRC_URI = " \ + git://git.morello-project.org/morello/musl-libc;protocol=https;tag=${SRCTAG};branch=${SRCBRANCH} \ + file://files/compiler_rt.cmake \ +" + +SRCREV ="" + +PV = "git${SRCPV}" +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +TARGET_INSTALL_DIR = "${D}${MUSL_INSTALL_DIR}" + +INHIBIT_SYSROOT_STRIP = "1" +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" + +CONFIGUREOPTS = " \ + --prefix=${prefix} \ + --exec-prefix=${exec_prefix} \ + --bindir=${bindir} \ + --libdir=${libdir} \ + --includedir=${includedir} \ + --syslibdir=${nonarch_base_libdir} \ + --target=${ARCH_TRIPLE} \ + --disable-libshim \ +" + +COMPILERRT_CMAKE = "-Wno-dev \ + -DCMAKE_TOOLCHAIN_FILE=compiler_rt.cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_CONFIG_PATH='${LLVM_CONFIG}' \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_SKIP_BUILD_RPATH=OFF \ + -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \ + -DLLVM_TARGETS_TO_BUILD='AArch64' \ + -DLLVM_ENABLE_ASSERTIONS=OFF \ + -DBUILD_SHARED_LIBS=ON \ + -DCOMPILER_RT_BUILD_BUILTINS=ON \ + -DCOMPILER_RT_BUILD_SANITIZERS=OFF \ + -DCOMPILER_RT_BUILD_XRAY=OFF \ + -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \ + -DCOMPILER_RT_BUILD_PROFILE=OFF \ +" +do_configure() { + export CFLAGS="" + local config="${CONFIGUREOPTS}" + echo "Install dir ${TARGET_INSTALL_DIR} with ${TCLIBC} MACHINE_INC ${MACHINE_INC}" + config="${config} --target=${ARCH_TRIPLE} ${EXTRA_CONFIGUREOPTS} --disable-shared" + ${S}/configure ${config} +} + +do_compile() { + export CFLAGS="" + oe_runmake +} \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-libs-native.bb b/recipes-core/musl/musl-morello-libs-native.bb new file mode 100644 index 0000000..6318aa9 --- /dev/null +++ b/recipes-core/musl/musl-morello-libs-native.bb @@ -0,0 +1,74 @@ +inherit cmake llvm-morello-native native +require musl-morello-${MORELLO_ARCH}.inc + +DESCRIPTION = "Libraries that go into the clang resource folder, \ + search path for that folder is relative to clang directory itself." + +DEPENDS += "musl-morello-native" +PROVIDES = "virtual/musl-morello-libs-native" + +B_COMPILERRT = "${WORKDIR}/build_compiler_rt" +S_CRT = "${LLVM_SHARED_SOURCE}/compiler-rt/lib/crt" +S_COMPILER_RT = "${LLVM_SHARED_SOURCE}/compiler-rt" + +do_install[depends] += "llvm-morello-native:do_symlink" + +FILES:${PN} += "$(${CC} -print-resource-dir)/lib/${LIB_TRIPLE}" +INSANE_SKIP:${PN} += "$(${CC} -print-resource-dir)/lib/${LIB_TRIPLE}" + +BUILD_CC = "${LLVM_PATH}/clang" +BUILD_CXX = "${LLVM_PATH}/clang++" +BUILD_CPP = "${LLVM_PATH}/clang" +BUILD_CCLD = "${LLVM_PATH}/clang" +BUILD_RANLIB = "${LLVM_PATH}/llvm-ranlib" +BUILD_AR = "${LLVM_PATH}/llvm-ar" +BUILD_AS = "${LLVM_PATH}/llvm-as" +BUILD_NM = "${LLVM_PATH}/llvm-nm" +BUILD_OBJDUMP = "${LLVM_PATH}/llvm-objdump" +BUILD_OBJCOPY = "${LLVM_PATH}/llvm-objcopy" +BUILD_STRIP = "${LLVM_PATH}/llvm-strip" +BUILD_STRINGS = "${LLVM_PATH}/llvm-strings" +BUILD_READELF = "${LLVM_PATH}/llvm-readelf" +BUILD_LD = "${LLVM_PATH}/ld.lld" +BUILD_LTO = "-fuse-ld=lld" +BUILD_HOSTCC = "${LLVM_PATH}/clang" + + +do_install() { + + export CFLAGS="" + + local resourcedir=$(${CC} -print-resource-dir) + local destdir="${resourcedir}/lib/${LIB_TRIPLE}" + local builddir="${B_COMPILERRT}/${ARCH_TRIPLE}" + local sysroot="${STAGING_LIBDIR_NATIVE}/musl-morello-native/${ARCH_TRIPLE}" + local target="${LIB_TRIPLE}" + + install -d ${destdir} + mkdir -p ${builddir} + + local ccflags="--target=${target} ${ARCH_FLAGS} -nostdinc -isystem ${sysroot}/include" + ${CC} ${ccflags} -c ${S_CRT}/crtbegin.c -o ${destdir}/clang_rt.crtbegin.o + ${CC} ${ccflags} -c ${S_CRT}/crtend.c -o ${destdir}/clang_rt.crtend.o + + cp -f ${WORKDIR}/files/compiler_rt.cmake ${builddir}/compiler_rt.cmake + + local config="${COMPILERRT_CMAKE}" + config="${config} -DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=${LIB_TRIPLE} \ + -DCMAKE_INSTALL_RPATH=$ORIGIN/../lib \ + -DCMAKE_TOOLCHAIN_FILE='${builddir}/compiler_rt.cmake' \ + " + cmake -S ${S_COMPILER_RT} -B ${builddir} ${config} -DCMAKE_C_FLAGS="-nostdinc -isystem ${sysroot}/include" -DCMAKE_C_COMPILER_TARGET="${LIB_TRIPLE} ${ARCH_FLAGS}" + + cd ${builddir} + make ${PARALLEL_MAKE} clang_rt.builtins-aarch64 + + install ${builddir}/lib/linux/libclang_rt.builtins-aarch64.a ${destdir}/libclang_rt.builtins.a + + install -d ${D}${libdir}/clang/${LLVM_VERSION}/lib/${LIB_TRIPLE} + local install_dir=${D}${libdir}/clang/${LLVM_VERSION}/lib/${LIB_TRIPLE} + + install ${destdir}/clang_rt.crtbegin.o ${install_dir}/clang_rt.crtbegin.o + install ${destdir}/clang_rt.crtend.o ${install_dir}/clang_rt.crtend.o + install ${destdir}/libclang_rt.builtins.a ${install_dir}/libclang_rt.builtins.a +} \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-native.bb b/recipes-core/musl/musl-morello-native.bb new file mode 100644 index 0000000..e7e6792 --- /dev/null +++ b/recipes-core/musl/musl-morello-native.bb @@ -0,0 +1,36 @@ +inherit llvm-morello-native native +require musl-morello-${MORELLO_ARCH}.inc + +DESCRIPTION = " That is right, we have a native libc sysroot that is needed as an intermediate step \ +to provide crt and compiler-rt that will be used by the cross compiler, this recipe exist to avoid having \ +a native recipe dependant on a target recipe... which is actually the case, but there you go. Note that the \ +libc sysroot is NOT actually native, it is just a trick." + +PROVIDES = "virtual/musl-morello-native" + +BUILD_CC = "${LLVM_PATH}/clang" +BUILD_CXX = "${LLVM_PATH}/clang++" +BUILD_CPP = "${LLVM_PATH}/clang" +BUILD_CCLD = "${LLVM_PATH}/clang" +BUILD_RANLIB = "${LLVM_PATH}/llvm-ranlib" +BUILD_AR = "${LLVM_PATH}/llvm-ar" +BUILD_AS = "${LLVM_PATH}/llvm-as" +BUILD_NM = "${LLVM_PATH}/llvm-nm" +BUILD_OBJDUMP = "${LLVM_PATH}/llvm-objdump" +BUILD_OBJCOPY = "${LLVM_PATH}/llvm-objcopy" +BUILD_STRIP = "${LLVM_PATH}/llvm-strip" +BUILD_STRINGS = "${LLVM_PATH}/llvm-strings" +BUILD_READELF = "${LLVM_PATH}/llvm-readelf" +BUILD_LD = "${LLVM_PATH}/ld.lld" +BUILD_LTO = "-fuse-ld=lld" +BUILD_HOSTCC = "${LLVM_PATH}/clang" + +FILES:${PN} += "${libdir}/${PN}/${ARCH_TRIPLE}" +INSTALL_DIR = "${D}/${ARCH_TRIPLE}" + +do_install() { + export CFLAGS="" + make install DESTDIR="${INSTALL_DIR}" + install -d ${D}${libdir}/${PN}/${ARCH_TRIPLE} + cp -rf ${INSTALL_DIR}${prefix}/* ${D}${libdir}/${PN}/${ARCH_TRIPLE} +} \ No newline at end of file diff --git a/recipes-core/musl/musl-morello-target.inc b/recipes-core/musl/musl-morello-target.inc new file mode 100644 index 0000000..0b804fc --- /dev/null +++ b/recipes-core/musl/musl-morello-target.inc @@ -0,0 +1,52 @@ +inherit llvm-morello-native + +COMPATIBLE_MACHINE = "morello" +SECTION = "libs" + +DEPENDS:append = " virtual/musl-morello-libs-native" + +MUSL_LDSO_ARCH = "aarch64_purecap" + +FILES:${PN} = "${MUSL_INSTALL_DIR}" +FILES:${PN} += "${MUSL_INSTALL_DIR}${datadir} ${MUSL_INSTALL_DIR}${bindir} ${MUSL_INSTALL_DIR}${libdir}" +FILES:${PN} += "${MUSL_INSTALL_DIR}${includedir} ${MUSL_INSTALL_DIR}${includedir}/sys \ + ${MUSL_INSTALL_DIR}${includedir}/arpa ${MUSL_INSTALL_DIR}${includedir}/bits \ + ${MUSL_INSTALL_DIR}${includedir}/net ${MUSL_INSTALL_DIR}${includedir}/netinet \ + ${MUSL_INSTALL_DIR}${includedir}/netpacket ${MUSL_INSTALL_DIR}${includedir}/arpa \ + ${MUSL_INSTALL_DIR}${includedir}/scsi ${MUSL_INSTALL_DIR}${includedir}/sys" + +FILES:${PN} += "${nonarch_base_libdir}/ld-musl-${MUSL_LDSO_ARCH}.so.1 ${sysconfdir}/ld-musl-${MUSL_LDSO_ARCH}.path" + +FILES:${PN}-staticdev = "${MUSL_INSTALL_DIR}${libdir}/libc.a" +FILES:${PN}-dev =+ "${MUSL_INSTALL_DIR}${libdir}/libcrypt.a ${MUSL_INSTALL_DIR}${libdir}/libdl.a ${MUSL_INSTALL_DIR}${libdir}/libm.a \ + ${MUSL_INSTALL_DIR}${libdir}/libpthread.a ${MUSL_INSTALL_DIR}${libdir}/libresolv.a \ + ${MUSL_INSTALL_DIR}${libdir}/librt.a ${MUSL_INSTALL_DIR}${libdir}/libutil.a ${MUSL_INSTALL_DIR}${libdir}/libxnet.a \ + " + +SYSROOT_DIRS += "${sysconfdir} ${MUSL_INSTALL_DIR}${includedir}" + +do_install() { + + echo "Installing into ${TARGET_INSTALL_DIR}" + + export CFLAGS="" + + install -d ${TARGET_INSTALL_DIR}${includedir} ${TARGET_INSTALL_DIR}${includedir}/sys ${TARGET_INSTALL_DIR}${includedir}/arpa \ + ${TARGET_INSTALL_DIR}${includedir}/bits ${TARGET_INSTALL_DIR}${includedir}/net ${TARGET_INSTALL_DIR}${includedir}/netinet \ + ${TARGET_INSTALL_DIR}${includedir}/netpacket ${TARGET_INSTALL_DIR}${includedir}/arpa ${TARGET_INSTALL_DIR}${includedir}/scsi \ + ${TARGET_INSTALL_DIR}${includedir}/sys + + local destdir="${TARGET_INSTALL_DIR}" + + local config="${CONFIGUREOPTS}" + config="${config} --target=${ARCH_TRIPLE} ${EXTRA_CONFIGUREOPTS}" + + ${S}/configure ${CONFIGUREOPTS} + oe_runmake + oe_runmake install DESTDIR="${destdir}" + + install -d ${TARGET_INSTALL_DIR}${sysconfdir} + + echo "${TARGET_INSTALL_DIR}${base_libdir}" > ${TARGET_INSTALL_DIR}${sysconfdir}/ld-musl-${MUSL_LDSO_ARCH}.path + echo "${TARGET_INSTALL_DIR}${libdir}" >> ${TARGET_INSTALL_DIR}${sysconfdir}/ld-musl-${MUSL_LDSO_ARCH}.path +} \ No newline at end of file diff --git a/recipes-core/musl/musl_%.bbappend b/recipes-core/musl/musl_%.bbappend new file mode 100644 index 0000000..cfe23e8 --- /dev/null +++ b/recipes-core/musl/musl_%.bbappend @@ -0,0 +1,17 @@ +require musl-morello-${MORELLO_ARCH}.inc musl-morello-${MORELLO_ARCH}-so.inc musl-morello-target.inc + +MACHINE_INC ?= "" +MACHINE_INC:morello-linux-glibc = "override-glibc.inc" +MACHINE_INC:morello-linux-musl = "override-musl.inc" + +require ${MACHINE_INC} + +DEPENDS:remove = "virtual/${TARGET_PREFIX}binutils \ + virtual/${TARGET_PREFIX}gcc \ + libgcc-initial \ + linux-libc-headers \ + bsd-headers \ + libssp-nonshared \ + " + +RDEPENDS:${PN}-dev:remove = "linux-libc-headers-dev bsd-headers-dev libssp-nonshared-staticdev" \ No newline at end of file diff --git a/recipes-core/musl/override-glibc.inc b/recipes-core/musl/override-glibc.inc new file mode 100644 index 0000000..9ccf9c2 --- /dev/null +++ b/recipes-core/musl/override-glibc.inc @@ -0,0 +1,4 @@ +PROVIDES:append = " virtual/musl-morello" +PROVIDES:remove = "virtual/libc virtual/libiconv virtual/libintl virtual/crypt" +RPROVIDES:${PN}-dev:remove = "libc-dev virtual-libc-dev" +RPROVIDES:${PN}:append = " musl-libc" \ No newline at end of file diff --git a/recipes-core/musl/override-musl.inc b/recipes-core/musl/override-musl.inc new file mode 100644 index 0000000..1a810e6 --- /dev/null +++ b/recipes-core/musl/override-musl.inc @@ -0,0 +1,2 @@ +PROVIDES:append = " virtual/musl-morello" +RPROVIDES:${PN}:append = " musl-libc" \ No newline at end of file
Add recipe for the Morello busybox which is statically linked with musl libc.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- recipes-core/busybox/busybox-morello-1.5.bb | 7 ++ recipes-core/busybox/busybox-morello.inc | 52 ++++++++++++++ ...-append-toolchain-with-relative-path.patch | 72 +++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 recipes-core/busybox/busybox-morello-1.5.bb create mode 100644 recipes-core/busybox/busybox-morello.inc create mode 100644 recipes-core/busybox/files/0001-Remove-elf-patch-append-toolchain-with-relative-path.patch
diff --git a/recipes-core/busybox/busybox-morello-1.5.bb b/recipes-core/busybox/busybox-morello-1.5.bb new file mode 100644 index 0000000..46411b6 --- /dev/null +++ b/recipes-core/busybox/busybox-morello-1.5.bb @@ -0,0 +1,7 @@ +require busybox-morello.inc + +LIC_FILES_CHKSUM = "file://LICENSE;md5=de10de48642ab74318e893a61105afbb \ + file://archival/libarchive/bz/LICENSE;md5=28e3301eae987e8cfe19988e98383dae" + +SRCBRANCH = "morello/master" +SRCTAG = "morello-release-1.5.0" \ No newline at end of file diff --git a/recipes-core/busybox/busybox-morello.inc b/recipes-core/busybox/busybox-morello.inc new file mode 100644 index 0000000..6953213 --- /dev/null +++ b/recipes-core/busybox/busybox-morello.inc @@ -0,0 +1,52 @@ +inherit llvm-morello-native + +COMPATIBLE_MACHINE = "morello-linux" +SUMMARY = "CHERI enabled busybox" +LICENSE = "GPL-2.0-only" +SECTION = "base" + +FILESEXTRAPATHS:prepend := "${THISDIR}:${THISDIR}/${PN}:" + +DEPENDS += "virtual/kernel virtual/musl-morello" +PROVIDES += "virtual/morello-busybox" + +RPROVIDES:${PN} += "busybox-morello" + +SRC_URI = " \ + git://git.morello-project.org/morello/morello-busybox;protocol=https;tag=${SRCTAG};branch=${SRCBRANCH} \ + file://files/0001-Remove-elf-patch-append-toolchain-with-relative-path.patch \ + " + +PV = "git${SRCPV}" +S = "${WORKDIR}/git" + +do_compile[depends] = "virtual/kernel:do_install" + +EXTRA_OEMAKE = "\ + MUSL_HOME='${STAGING_DIR_TARGET}${MUSL_INSTALL_DIR}${prefix}' \ + KHEADERS='${STAGING_KERNEL_BUILDDIR}/kernel-headers/include/' \ + " + +FILES:${PN} += "/busybox/busybox" +SYSROOT_DIRS += "/busybox" + +INHIBIT_SYSROOT_STRIP = "1" +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" + +do_configure() { + export CFLAGS="" + oe_runmake ${EXTRA_OEMAKE} LLVM_PATH=${LLVM_PATH} morello_busybox_defconfig +} + +do_compile() { + export CFLAGS="" + local resourcedir=$(${CC} -print-resource-dir) + EXTRA_OEMAKE="${EXTRA_OEMAKE} CLANG_RESOURCE_DIR='${resourcedir}'" + oe_runmake ${EXTRA_OEMAKE} LLVM_PATH=${LLVM_PATH} +} + +do_install() { + install -d ${D}/busybox + install -m 0755 ${S}/busybox ${D}/busybox/busybox +} \ No newline at end of file diff --git a/recipes-core/busybox/files/0001-Remove-elf-patch-append-toolchain-with-relative-path.patch b/recipes-core/busybox/files/0001-Remove-elf-patch-append-toolchain-with-relative-path.patch new file mode 100644 index 0000000..ebac784 --- /dev/null +++ b/recipes-core/busybox/files/0001-Remove-elf-patch-append-toolchain-with-relative-path.patch @@ -0,0 +1,72 @@ +From 6040ff1d58789736b2c3547fa7803cb173981cb5 Mon Sep 17 00:00:00 2001 +From: Pawel Zalewski pzalewski@thegoodpenguin.co.uk +Date: Thu, 5 Jan 2023 10:27:45 +0000 +Subject: [PATCH] Remove elf patch, append toolchain with relative paths. + +Toolchain 1.5 does not require the elf patcher. +--- + Makefile | 22 +++++++++------------- + 1 file changed, 9 insertions(+), 13 deletions(-) + +diff --git a/Makefile b/Makefile +index f9d916f98..4c95c8d56 100644 +--- a/Makefile ++++ b/Makefile +@@ -142,10 +142,9 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) + # Morello Settings + MORELLO_TARGET := aarch64-linux-musl_purecap + MORELLO_FLAGS := -Wno-cheri-inefficient -march=morello+c64 +-ELF_PATCH := morello_elf + MUSL_HOME := ../../musl-bin + KHEADERS := ../morello-linux-headers/usr/include/ +-CLANG_RESOURCE_DIR := $(shell clang -print-resource-dir) ++CLANG_RESOURCE_DIR := $(shell ${LLVM_PATH}/clang -print-resource-dir) + + export srctree objtree VPATH TOPDIR + +@@ -296,16 +295,16 @@ MAKEFLAGS += -rR + + # Make variables (CC, etc...) + +-AS = llvm-as +-CC_ = clang ++AS = ${LLVM_PATH}/llvm-as ++CC_ = ${LLVM_PATH}/clang + CC = $(CC_) --target=${MORELLO_TARGET} --sysroot ${MUSL_HOME} ${MORELLO_FLAGS} + LD = $(CC) -fuse-ld=lld -rtlib=compiler-rt + CPP = $(CC) -E +-AR = llvm-ar +-NM = llvm-nm +-STRIP = llvm-strip +-OBJCOPY = llvm-objcopy +-OBJDUMP = llvm-objdump ++AR = ${LLVM_PATH}/llvm-ar ++NM = ${LLVM_PATH}/llvm-nm ++STRIP = ${LLVM_PATH}/llvm-strip ++OBJCOPY = ${LLVM_PATH}/llvm-objcopy ++OBJDUMP = ${LLVM_PATH}/llvm-objdump + PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config + AWK = awk + GENKSYMS = scripts/genksyms/genksyms +@@ -541,7 +540,7 @@ endif + # command line. + # This allow a user to issue only 'make' to build a kernel including modules + # Defaults busybox but it is usually overridden in the arch makefile +-all: busybox doc busybox_gen_elf ++all: busybox doc + + # arch Makefile may override CC so keep this after arch Makefile is included + #bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) +@@ -731,9 +730,6 @@ else + $(Q)chmod a+x $@ + endif + +-busybox_gen_elf: +- ${Q}${ELF_PATCH} busybox +- + # The actual objects are generated when descending, + # make sure no implicit rule kicks in + $(sort $(busybox-all)): $(busybox-dirs) ; +-- +2.34.1 +
Add recipe for a purecap application and a class it must inherit from.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- classes/pure-cap-application.bbclass | 35 ++ .../applications/files/Makefile | 30 ++ .../applications/files/pure-cap-app.c | 298 ++++++++++++++++++ .../applications/pure-cap-app.bb | 25 ++ 4 files changed, 388 insertions(+) create mode 100644 classes/pure-cap-application.bbclass create mode 100644 recipes-morello-apps/applications/files/Makefile create mode 100644 recipes-morello-apps/applications/files/pure-cap-app.c create mode 100644 recipes-morello-apps/applications/pure-cap-app.bb
diff --git a/classes/pure-cap-application.bbclass b/classes/pure-cap-application.bbclass new file mode 100644 index 0000000..78c01c9 --- /dev/null +++ b/classes/pure-cap-application.bbclass @@ -0,0 +1,35 @@ +OUTPUTS_NAME ?= "pure-cap-app-default-name" + +FILESEXTRAPATHS:prepend := "${THISDIR}:${THISDIR}/${PN}:" + +DEPENDS += "virtual/musl-morello" + +MUSL_HOME = "${STAGING_DIR_TARGET}${MUSL_INSTALL_DIR}" + +INHIBIT_SYSROOT_STRIP = "1" +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" + +S = "${WORKDIR}/src" + +EXTRA_OEMAKE = "\ + LLVM_PATH='${LLVM_PATH}' \ + NAME='${OUTPUTS_NAME}' \ + OUT='${S}' \ + SYSROOT_LIB='${MUSL_HOME}${libdir}' \ + SYSROOT_INC='${MUSL_HOME}${includedir}' \ + SYSROOT='${MUSL_HOME}' \ + " + +do_compile() { + cd ${S} + echo "Resource dir ${resourcedir}" + echo "Musl home ${MUSL_HOME}" + oe_runmake ${EXTRA_OEMAKE} +} + +do_install() { + install -d ${D}/${APP_DIR} ${D}${bindir} + install ${S}/${OUTPUTS_NAME} ${D}/${APP_DIR}/${OUTPUTS_NAME} + install ${S}/${OUTPUTS_NAME} ${D}${bindir} +} \ No newline at end of file diff --git a/recipes-morello-apps/applications/files/Makefile b/recipes-morello-apps/applications/files/Makefile new file mode 100644 index 0000000..a8464a3 --- /dev/null +++ b/recipes-morello-apps/applications/files/Makefile @@ -0,0 +1,30 @@ +NAME=$(OUTPUTS_NAME) +CC=$(LLVM_PATH)/clang + +TARGET=aarch64-linux-musl_purecap +ARCH=-march=morello+c64 -mabi=purecap +CLANG_RESOURCE_DIR=$(shell ${CC} -print-resource-dir) +CLANG_LIB=$(CLANG_RESOURCE_DIR)/lib/aarch64-unknown-linux-musl_purecap +COMPILER_INC=$(CLANG_RESOURCE_DIR)/include +OUT=$(S) + +CFLAGS=-Wno-gnu-alignof-expression \ + -Werror \ + -Wno-macro-redefined \ + -Werror=cheri \ + -Werror=cheri-inefficient \ + -Werror=cheri-pedantic \ + -Werror=cheri-pointer-conversion \ + -Werror=cheri-unimplemented-features + +all: + $(CC) -c -g -O0 -isystem $(SYSROOT_INC) -I$(COMPILER_INC) \ + $(ARCH) $(NAME).c -o $(OUT)/$(NAME).c.o \ + --target=$(TARGET) + $(CC) --target=$(TARGET) $(ARCH) -fuse-ld=lld -rtlib=compiler-rt --sysroot $(SYSROOT) \ + $(OUT)/$(NAME).c.o \ + -o $(OUT)/$(NAME) + +clean: + rm -f $(OUT)/$(NAME).c.o + rm -f $(OUT)/$(NAME) \ No newline at end of file diff --git a/recipes-morello-apps/applications/files/pure-cap-app.c b/recipes-morello-apps/applications/files/pure-cap-app.c new file mode 100644 index 0000000..0a9e62a --- /dev/null +++ b/recipes-morello-apps/applications/files/pure-cap-app.c @@ -0,0 +1,298 @@ +/** + * @author Pawel Zalewski Copyright (C) 2022 <The Good Penguin> + * @email pzalewski@thegoodpenguin.co.uk + * @create date 2022-07-11 16:13:49 + * @desc Simple Morello demonstration program aimed at Linux fs. + * + */ + +#include <stdio.h> +#include <stdbool.h> +#include <signal.h> +#include <string.h> +#include <stdlib.h> +#include <stdalign.h> +#include <stdint.h> + +#include <getopt.h> +#include <memory.h> + +#include <cheriintrin.h> + +static void usage(void); +static void subPointersToPointersTest(void); +static void subPointersToPointersTest2(void); +static void outOfBoundAccess(void); +static void functionPointersTest(void); +static void atomicAccess(void); + +static void sigactionSegfault(int signal, siginfo_t *si, void *args); +static void sigactionIllegal(int signal, siginfo_t *si, void *args); +static void sigactionAlingment(int signal, siginfo_t *si, void *args); + +static void printPointer(void *pointer); + +static void * cheri_perms_set(void * pointer, cheri_perms_t perm_new); + +typedef void (*functionPointer)(void); + +static const char shortOptions[] = "habcde"; + +static const struct option longOptions[] = { + {"help", 0, NULL, 'h'}, + {"subPointersToPointersTest", 0, NULL, 'a'}, + {"subPointersToPointersTest2", 0, NULL, 'b'}, + {"outOfBoundAccess", 0, NULL, 'c'}, + {"functionPointersTest", 0, NULL, 'd'}, + {"atomicAccess", 0, NULL, 'e'}, + {NULL, 0, NULL, 0}, +}; + +static void sigactionAlingment(int signal, siginfo_t *si, void *args) +{ + printf("Signal [%d] caught an alligment fault at address %p with code %d args: %p \n", signal, si->si_addr, si->si_code, args); + exit(0); +} + +static void sigactionSegfault(int signal, siginfo_t *si, void *args) +{ + printf("Signal [%d] caught a segfault at address %p with code %d args: %p \n", signal, si->si_addr, si->si_code, args); + exit(0); +} + +static void sigactionIllegal(int signal, siginfo_t *si, void *args) +{ + printf("Signal [%d] caught an illegal access at address %p with code %d args: %p \n", signal, si->si_addr, si->si_code, args); + exit(0); +} + +int main(int argc, char **argv) +{ + + struct sigaction sa; + + memset(&sa, 0, sizeof(struct sigaction)); + sigemptyset(&sa.sa_mask); + + sa.sa_sigaction = sigactionSegfault; + sa.sa_flags = SA_SIGINFO; + sigaction(SIGSEGV, &sa, NULL); + + memset(&sa, 0, sizeof(struct sigaction)); + sa.sa_sigaction = sigactionIllegal; + sa.sa_flags = SA_SIGINFO; + sigaction(SIGILL, &sa, NULL); + + memset(&sa, 0, sizeof(struct sigaction)); + sa.sa_sigaction = sigactionAlingment; + sa.sa_flags = SA_SIGINFO; + sigaction(SIGBUS, &sa, NULL); + + size_t sizeInt = sizeof(int64_t); + size_t sizePointer = sizeof(uint8_t *); + + printf("The size of int64 is %lu-byte/%lu-bit and pointers are %lu-byte/%lu-bit \r\n", sizeInt, sizeInt << 3, sizePointer, sizePointer << 3); + + int optionidx = 0; + int opt; + + while ((opt = getopt_long(argc, argv, shortOptions, longOptions, &optionidx)) != EOF) + { + switch (opt) + { + case 'h': + usage(); + return 0; + + case 'a': + subPointersToPointersTest(); + break; + + case 'b': + subPointersToPointersTest2(); + break; + + case 'c': + outOfBoundAccess(); + break; + + case 'd': + functionPointersTest(); + break; + + case 'e': + atomicAccess(); + break; + + default: + printf("Got: %c\r\n", opt); + usage(); + exit(1); + } + } + + return 0; +} + +/** + * @brief Prints the pointer meta-data + * + * @param pointer teh pointer + */ +static void printPointer(void *pointer) +{ + size_t addr = cheri_address_get(pointer); + size_t base = cheri_base_get(pointer); + size_t offset = cheri_offset_get(pointer); + size_t len = cheri_length_get(pointer); + size_t perm = cheri_perms_get(pointer); + bool tag = cheri_tag_get(pointer); + + printf("Capability size %lx align %lx addr %lX base %lX offset %lX length %lu permissions %lX tag %d \r\n", sizeof(pointer), alignof(pointer), addr, base, offset, len, perm, tag); + + cheri_perms_t permissions = cheri_perms_get(pointer); + + bool issealed = cheri_is_sealed(pointer); + bool hasload = (permissions & CHERI_PERM_LOAD ) == CHERI_PERM_LOAD; + bool hasstore = (permissions & CHERI_PERM_STORE ) == CHERI_PERM_STORE; + bool hasexec = (permissions & CHERI_PERM_EXECUTE ) == CHERI_PERM_EXECUTE; + bool hassys = (permissions & CHERI_PERM_SYSTEM_REGS ) == CHERI_PERM_SYSTEM_REGS; + bool hasseal = (permissions & CHERI_PERM_SEAL ) == CHERI_PERM_SEAL; + printf("Is sealed %d, load %d, store %d, execute %d, system %d, seal %d\r\n", issealed, hasload, hasstore, hasexec, hassys, hasseal); +} + +/** + * @brief This function tests how meta-data behaves in sub-sequent pointers. + * + */ + +static void subPointersToPointersTest(void) +{ + uint8_t array[21] = {42}; + + uint8_t *pArray10 = &array[10]; + uint8_t *pArray15 = pArray10 + 5; + + printPointer(array); + printPointer(pArray10); + printPointer(pArray15); +} + +/** + * @brief This function tests changing bounds of pointers. + * + */ +static void subPointersToPointersTest2(void) +{ + uint8_t array[21] = {42}; + + uint8_t *pArray10 = &array[10]; + uint8_t *pArray10Bounded = cheri_bounds_set(pArray10, 4); + + printPointer(array); + printPointer(pArray10); + printPointer(pArray10Bounded); + + uint8_t *pArray10UnBounded = cheri_bounds_set(pArray10Bounded, 5); + + printPointer(pArray10UnBounded); + + pArray10Bounded--; + + printf("Some value is %d \r\n", *pArray10Bounded); + printf("Some value is %d \r\n", *pArray10UnBounded); +} + +/** + * @brief This function checks if we can access OOB value. + * + */ + +int someValue = 0x8000; + +static void outOfBoundAccess(void) +{ + + int *pAddress = &someValue; + printPointer(pAddress); + + pAddress++; + printPointer(pAddress); + + printf("Some value is %d \r\n", *pAddress); +} + +/** + * @brief This function checks how function pointers behave. + * + */ + +static void functionPointersTest(void) +{ + + functionPointer fp = &outOfBoundAccess; + + printPointer(fp); + + int *pData = (int *)fp; + + printPointer(pData); + + cheri_perms_t perm = cheri_perms_get((void*)fp) | CHERI_PERM_STORE; + functionPointer fpE = cheri_perms_set(fp, perm); + + printPointer(fpE); + + fpE(); + + int *pAddress = &someValue; + functionPointer fpAddr = (functionPointer)pAddress; + + printPointer(pAddress); +} + +/** + * @brief This function checks if we can atomically apply capability to a data field. + * + */ +static void atomicAccess(void) +{ + uint8_t array[21] = {42}; + + uint8_t *pWriter = cheri_perms_set(&array[0], 0b010000000001000001); + uint8_t *pReader = cheri_perms_set(&array[0], 0b100000000001000001); + + printPointer(pWriter); + printPointer(pReader); + + pWriter[0] = 1; + + uint8_t value = pReader[0]; + + pReader[0] = 1; + + printf("Value is %u array is %u \r\n", value, array[0]); +} + +static void * cheri_perms_set(void * pointer, cheri_perms_t perm_new) { + + cheri_perms_t perm_old = cheri_perms_get(pointer); + return cheri_perms_clear(pointer, perm_old & ~perm_new); +} + +/** + * @brief Teh usage + * + */ +static void usage(void) +{ + printf( + "Usage: MorelloExample [OPTION]\n" + "\n" + "-h, --help help\n" + "-a subPointersToPointersTest\n" + "-b subPointersToPointersTest2\n" + "-c outOfBoundAccess \n" + "-d functionPointersTest \n" + "-e atomicAccess\n"); +} \ No newline at end of file diff --git a/recipes-morello-apps/applications/pure-cap-app.bb b/recipes-morello-apps/applications/pure-cap-app.bb new file mode 100644 index 0000000..a5b2e01 --- /dev/null +++ b/recipes-morello-apps/applications/pure-cap-app.bb @@ -0,0 +1,25 @@ +inherit pure-cap-application llvm-morello-native + +COMPATIBLE_MACHINE = "morello-linux" +SUMMARY = "Simple capability application" +DESCRIPTION = "Application used in the series of blogs found @ https://www.thegoodpenguin.co.uk/blog/tag/morello/" +OUTPUTS_NAME = "pure-cap-app" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +PROVIDES = "${OUTPUTS_NAME}" +RDEPENDS:${PN} = "musl-libc" +RPROVIDES:${PN} = "${OUTPUTS_NAME}" + +FILES:${PN} += "/${APP_DIR}" +SYSROOT_DIRS +="/${APP_DIR}" + +SRC_URI = " \ + file://files/pure-cap-app.c \ + file://files/Makefile \ + " + +do_configure () { + install -d ${S} + install ${WORKDIR}/files/* ${S} +} \ No newline at end of file
Add recipe for gen-init-cpio native.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- .../gen-init-cpio/gen-init-cpio-native.bb | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 recipes-devtools/gen-init-cpio/gen-init-cpio-native.bb
diff --git a/recipes-devtools/gen-init-cpio/gen-init-cpio-native.bb b/recipes-devtools/gen-init-cpio/gen-init-cpio-native.bb new file mode 100644 index 0000000..5041b9d --- /dev/null +++ b/recipes-devtools/gen-init-cpio/gen-init-cpio-native.bb @@ -0,0 +1,34 @@ +inherit llvm-morello-native native + +SUMMARY = "Gen init cpio" +DESCRIPTION = "Gen init cpio" +HOMEPAGE = "http://llvm.org" +LICENSE = "GPL-2.0-only" + +OUTPUTS_NAME = "gen-init-cpio" +PROVIDES = "${OUTPUTS_NAME}-native" + +LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" + +SRC_URI = " \ + git://git.morello-project.org/morello/kernel/linux;protocol=https;tag=${SRCTAG};branch=${SRCBRANCH} \ + " + +SRCBRANCH = "morello/master" +SRCTAG = "morello-release-1.5.0" + +S = "${WORKDIR}/git/usr" + +FILES:${PN} = "${bindir}/${OUTPUTS_NAME}" + +do_configure[noexec] = "1" + +do_compile(){ + mkdir -p ${B}/${OUTPUTS_NAME} + oe_runmake gen_init_cpio +} + +do_install(){ + install -d ${D}${bindir} + install -m 0744 ${S}/gen_init_cpio ${D}${bindir}/gen_init_cpio +} \ No newline at end of file
Add the llvm compiler that can run on the target.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- recipes-devtools/llvm/llvm-morello_13.0.bb | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 recipes-devtools/llvm/llvm-morello_13.0.bb
diff --git a/recipes-devtools/llvm/llvm-morello_13.0.bb b/recipes-devtools/llvm/llvm-morello_13.0.bb new file mode 100644 index 0000000..dc10f9d --- /dev/null +++ b/recipes-devtools/llvm/llvm-morello_13.0.bb @@ -0,0 +1,61 @@ + +COMPATIBLE_MACHINE = "morello-linux" +DESCRIPTION = "The Morello LLVM Compiler Infrastructure for A64" +SUMMARY = "LLVM Morello" +HOMEPAGE = "https://git.morello-project.org/morello/llvm-project-releases" +LICENSE = "Apache-2.0-with-LLVM-exception" + +RPROVIDES:${PN} = "llvm-morello" +RDEPENDS:${PN} = "zlib" +SRCBRANCH = "morello/linux-aarch64-release-1.5" + +SRC_URI = "https://git.morello-project.org/morello/llvm-project-releases/-/archive/%24%..." + +SRC_URI[md5sum] = "bc5ba415eccea9b2280586aa6f74519d" +LIC_FILES_CHKSUM = "file://include/llvm/Support/LICENSE.TXT;md5=986c03435151a0086b8aaac964939cdd" + +S = "${WORKDIR}/llvm-project-releases-morello-linux-aarch64-release-1.5" + +FILES:${PN} += "${bindir}" +FILES:${PN} += "${libdir} ${libdir}/clang" +FILES:${PN} += "${includedir}" + +FILES:${PN}-staticdev += "${libdir}/*.a ${libdir}/clang/13.0.0/lib/linux/*.a \ + ${libdir}/clang/13.0.0/lib/aarch64-unknown-linux-musl_purecap/*.a \ + ${libdir}/clang/13.0.0/lib/aarch64-unknown-linux-gnu/*.a \ + " +FILES:${PN}-dev += "\ + ${datadir} \ + ${libdir}/cmake \ +" + +FILES:libclang = "\ + ${libdir}/libclang.so.${PV} \ +" + +FILES:lldb = "\ + ${bindir}/lldb \ +" + +FILES:lldb-server = "\ + ${bindir}/lldb-server \ +" + +FILES:liblldb = "\ + ${libdir}/liblldbIntelFeatures.so* \ + ${libdir}/liblldb.so* \ +" + +INSANE_SKIP_${PN} = "staticdev" +INHIBIT_SYSROOT_STRIP = "1" +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" + +do_install() { + install -d ${D}${prefix} ${D}${libdir} ${D}${bindir} ${D}${includedir} ${D}${datadir} ${D}${libexecdir} + cp -rf ${S}/lib/* ${D}${libdir} + cp -rf ${S}/bin/* ${D}${bindir} + cp -rf ${S}/include/* ${D}${includedir} + cp -rf ${S}/share/* ${D}${datadir} + cp -rf ${S}/libexec/* ${D}${libexecdir} +} \ No newline at end of file
Append the gdb recipe.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- recipes-devtools/gdb/gdb_%.bbappend | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 recipes-devtools/gdb/gdb_%.bbappend
diff --git a/recipes-devtools/gdb/gdb_%.bbappend b/recipes-devtools/gdb/gdb_%.bbappend new file mode 100644 index 0000000..a73a113 --- /dev/null +++ b/recipes-devtools/gdb/gdb_%.bbappend @@ -0,0 +1,7 @@ +COMPATIBLE_MACHINE = "morello-linux" + +SRC_URI = "git://git.morello-project.org/morello/binutils-gdb.git;protocol=https;branch=${SRCBRANCH}" +SRCBRANCH = "users/ARM/morello-binutils-gdb-master" +SRCREV = "f6e8c7228463a552d175211f4fcea93cca889686" + +S = "${WORKDIR}/git" \ No newline at end of file
Add recipes that will output a Linux image and a initramfs that contains the Morello busybox and the purecap app. The glibc version can take an arbitrary Yocto image as the rootfs. The rootfs hosts two loaders: glibc and musl both can have their own shared objects.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- conf/machine/morello-linux-glibc.conf | 25 +++ conf/machine/morello-linux-musl.conf | 15 ++ .../images/morello-initramfs-glibc.bb | 50 ++++++ .../images/morello-initramfs-musl.bb | 53 +++++++ .../images/morello-linux-glibc/files/init.sh | 62 ++++++++ .../files/initramfs.list.template | 16 ++ .../images/morello-linux-image-glibc.bb | 145 ++++++++++++++++++ .../images/morello-linux-image-musl.bb | 96 ++++++++++++ .../images/morello-linux-musl/files/init.sh | 33 ++++ .../files/initramfs.list.template | 18 +++ 10 files changed, 513 insertions(+) create mode 100644 recipes-morello/images/morello-initramfs-glibc.bb create mode 100644 recipes-morello/images/morello-initramfs-musl.bb create mode 100644 recipes-morello/images/morello-linux-glibc/files/init.sh create mode 100644 recipes-morello/images/morello-linux-glibc/files/initramfs.list.template create mode 100644 recipes-morello/images/morello-linux-image-glibc.bb create mode 100644 recipes-morello/images/morello-linux-image-musl.bb create mode 100644 recipes-morello/images/morello-linux-musl/files/init.sh create mode 100644 recipes-morello/images/morello-linux-musl/files/initramfs.list.template
diff --git a/conf/machine/morello-linux-glibc.conf b/conf/machine/morello-linux-glibc.conf index 6ed824d..83e09ef 100644 --- a/conf/machine/morello-linux-glibc.conf +++ b/conf/machine/morello-linux-glibc.conf @@ -1,3 +1,28 @@ require conf/machine/include/morello-common.inc
MACHINEOVERRIDES =. "morello-linux-glibc:" + +PREFERRED_PROVIDER_virtual/kernel = "linux-morello-${MORELLO_RELEASE_VERSION}" +PREFFERED_PROVIDER_morello-linux-image = "morello-linux-image-glibc" +PREFFERED_PROVIDER_morello-initramfs = "morello-initramfs-glibc" + +BSP_GRUB_DIR ?= "${TOPDIR}/${TMPDIR_BSP}/deploy/images/morello-bsp/grub-efi" +BSP_DTB_DIR ?= "${TOPDIR}/${TMPDIR_BSP}/deploy/images/morello-bsp" + +TMPDIR = "${TOPDIR}/${TMPDIR_LINUX}" + +MUSL_INSTALL_DIR ?= "${libdir}/${GLOBAL_ARCH_TRIPLE}" + +IMAGE_BASENAME = "rootfs" +IMAGE_FSTYPES:append = " ext4" + +# The rootfs image that will go on a bootable drive +MORELLO_ROOTFS_IMAGE = "core-image-minimal" + +IMAGE_INSTALL:append = " linux-firmware-rtl8168" + +IMAGE_INSTALL:append = " musl-libc busybox-morello pure-cap-app llvm-morello gdbserver gdb llvm-morello-staticdev" + +DISTRO ?= "poky" + +SERIAL_CONSOLES = "115200;ttyAMA0" \ No newline at end of file diff --git a/conf/machine/morello-linux-musl.conf b/conf/machine/morello-linux-musl.conf index e22493d..c059775 100644 --- a/conf/machine/morello-linux-musl.conf +++ b/conf/machine/morello-linux-musl.conf @@ -1,3 +1,18 @@ require conf/machine/include/morello-common.inc
MACHINEOVERRIDES =. "morello-linux-musl:" + +TARGET_OS ?= "linux-musl" + +PREFERRED_PROVIDER_virtual/kernel = "linux-morello-${MORELLO_RELEASE_VERSION}" +PREFFERED_PROVIDER_morello-linux-image = "morello-linux-image-musl" +PREFFERED_PROVIDER_morello-initramfs = "morello-initramfs-musl" + +TCLIBC = "musl" + +BSP_GRUB_DIR ?= "${TOPDIR}/${TMPDIR_BSP}/deploy/images/morello-bsp/grub-efi" +BSP_DTB_DIR ?= "${TOPDIR}/${TMPDIR_BSP}/deploy/images/morello-bsp/trusted-firmware-a" + +TMPDIR = "${TOPDIR}/${TMPDIR_LINUX}" + +DISTRO = "" \ No newline at end of file diff --git a/recipes-morello/images/morello-initramfs-glibc.bb b/recipes-morello/images/morello-initramfs-glibc.bb new file mode 100644 index 0000000..707842e --- /dev/null +++ b/recipes-morello/images/morello-initramfs-glibc.bb @@ -0,0 +1,50 @@ +inherit deploy nopackages + +COMPATIBLE_MACHINE = "morello-linux-glibc" +SUMMARY = "Initramfs for busybox" +DESCRIPTION = "Initramfs for busybox, bypassing the Yocto way" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +OUTPUTS_NAME = "morello-initramfs" + +DEPENDS += "virtual/morello-busybox gen-init-cpio-native" +PROVIDES = "${OUTPUTS_NAME}" + +BB_DONT_CACHE = "1" +INHIBIT_DEFAULT_DEPS = "1" + +FILESEXTRAPATHS:prepend := "${THISDIR}:" + +SRC_URI = "file://files/init.sh \ + file://files/initramfs.list.template \ + " +do_configure[noexec] = "1" +do_compile[noexec] = "1" +do_deploy[depends] = "virtual/morello-busybox:do_populate_sysroot" + + +do_install() { + + local sysroot_prefix="recipe-sysroot" + + sed -e "s@%FILES%@/files@" \ + "${WORKDIR}/files/initramfs.list.template" > "${WORKDIR}/files/initramfs.list.tmp1" + + sed -e "s@%BUSYBOX%@/${sysroot_prefix}/busybox@" \ + "${WORKDIR}/files/initramfs.list.tmp1" > "${WORKDIR}/files/initramfs.list" + + install -d ${D}/${OUTPUTS_NAME} + + rm -f ${D}/${OUTPUTS_NAME}/initramfs + + { + env -C ${WORKDIR} ${STAGING_BINDIR_NATIVE}/gen_init_cpio "${WORKDIR}/files/initramfs.list" + } > ${D}/${OUTPUTS_NAME}/initramfs + +} + +do_deploy() { + install -d ${DEPLOYDIR}/${OUTPUTS_NAME} + install ${D}/${OUTPUTS_NAME}/initramfs ${DEPLOYDIR}/${OUTPUTS_NAME}/initramfs +} +addtask deploy after do_install \ No newline at end of file diff --git a/recipes-morello/images/morello-initramfs-musl.bb b/recipes-morello/images/morello-initramfs-musl.bb new file mode 100644 index 0000000..06cce37 --- /dev/null +++ b/recipes-morello/images/morello-initramfs-musl.bb @@ -0,0 +1,53 @@ +inherit deploy nopackages + +COMPATIBLE_MACHINE = "morello-linux-musl" +SUMMARY = "Initramfs for busybox" +DESCRIPTION = "Initramfs for busybox, bypassing the Yocto way" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +OUTPUTS_NAME = "morello-initramfs" + +DEPENDS += "virtual/morello-busybox gen-init-cpio-native pure-cap-app" +PROVIDES = "${OUTPUTS_NAME}" + +BB_DONT_CACHE = "1" +INHIBIT_DEFAULT_DEPS = "1" + +FILESEXTRAPATHS:prepend := "${THISDIR}:" + +SRC_URI = "file://files/init.sh \ + file://files/initramfs.list.template \ + " +do_configure[noexec] = "1" +do_compile[noexec] = "1" +do_deploy[depends] = "virtual/morello-busybox:do_populate_sysroot" + + +do_install() { + + local sysroot_prefix="recipe-sysroot" + + sed -e "s@%FILES%@/files@" \ + "${WORKDIR}/files/initramfs.list.template" > "${WORKDIR}/files/initramfs.list.tmp1" + + sed -e "s@%BUSYBOX%@/${sysroot_prefix}/busybox@" \ + "${WORKDIR}/files/initramfs.list.tmp1" > "${WORKDIR}/files/initramfs.list.tmp2" + + sed -e "s@%APP_DIR%@/${APP_DIR}@" \ + "${WORKDIR}/files/initramfs.list.tmp2" > "${WORKDIR}/files/initramfs.list" + + install -d ${D}/${OUTPUTS_NAME} + + rm -f ${D}/${OUTPUTS_NAME}/initramfs + + { + env -C ${WORKDIR} ${STAGING_BINDIR_NATIVE}/gen_init_cpio "${WORKDIR}/files/initramfs.list" + env -C "${STAGING_DIR_TARGET}/" find . -not -path "./sysroot-providers*" -print0 | env -C "${STAGING_DIR_TARGET}/" cpio --null --owner +0:+0 --create --format=newc + } > ${D}/${OUTPUTS_NAME}/initramfs +} + +do_deploy() { + install -d ${DEPLOYDIR}/${OUTPUTS_NAME} + install ${D}/${OUTPUTS_NAME}/initramfs ${DEPLOYDIR}/${OUTPUTS_NAME}/initramfs +} +addtask deploy after do_install \ No newline at end of file diff --git a/recipes-morello/images/morello-linux-glibc/files/init.sh b/recipes-morello/images/morello-linux-glibc/files/init.sh new file mode 100644 index 0000000..d98f607 --- /dev/null +++ b/recipes-morello/images/morello-linux-glibc/files/init.sh @@ -0,0 +1,62 @@ +#!/bin/busybox sh + +mount() { + /bin/busybox mount "$@" +} + +umount() { + /bin/busybox umount "$@" +} + +grep() { + /bin/busybox grep "$@" +} + +cp() { + /bin/busybox cp "$@" +} + +mkdir() { + /bin/busybox mkdir "$@" +} + +switch_root () { + /bin/busybox switch_root "$@" +} + +sed () { + /bin/busybox sed "$@" +} + +echo "Running init script" + +mount -t proc proc /proc +grep -qE $'\t'"devtmpfs$" /proc/filesystems && mount -t devtmpfs dev /dev +mount -t sysfs sysfs /sys + +echo "Installing busybox..." + +/bin/busybox --install -s + +! grep -qE $'\t'"devtmpfs$" /proc/filesystems && mdev -s + +ROOT="/newroot" + +PARTUUID=$(cat proc/cmdline | sed 's/ /\n/g' | sed -n 's/^root=PARTUUID=*//p') + +DEVID=$(blkid | sed -n "s/UUID="$PARTUUID" TYPE="ext4"*//p" | sed 's/://') + +echo "Mounting ${DEVID} rootfs with PARTUUID: ${PARTUUID}" + +mount ${DEVID} ${ROOT} + +ulimit -c unlimited + +cd ${ROOT} +exec switch_root . /sbin/init </dev/ttyAMA0 >dev/ttyAMA0 2>&1 + +echo "/bin/sh as PID 1!" +echo "init.sh" +exec setsid cttyhack sh +echo setsid ctty hack failed so "exec /bin/sh" fallback will be used +exec /bin/sh \ No newline at end of file diff --git a/recipes-morello/images/morello-linux-glibc/files/initramfs.list.template b/recipes-morello/images/morello-linux-glibc/files/initramfs.list.template new file mode 100644 index 0000000..da55738 --- /dev/null +++ b/recipes-morello/images/morello-linux-glibc/files/initramfs.list.template @@ -0,0 +1,16 @@ +dir /bin 755 0 0 +dir /include 755 0 0 +dir /lib 755 0 0 +dir /share 755 0 0 +dir /dev 755 0 0 +dir /proc 755 0 0 +dir /sbin 755 0 0 +dir /sys 755 0 0 +dir /newroot 755 0 0 +dir /usr 755 0 0 +dir /usr/lib 755 0 0 +dir /usr/bin 755 0 0 +dir /etc 755 0 0 + +file /bin/busybox .%BUSYBOX%/busybox 755 0 0 +file /init .%FILES%/init.sh 755 0 0 \ No newline at end of file diff --git a/recipes-morello/images/morello-linux-image-glibc.bb b/recipes-morello/images/morello-linux-image-glibc.bb new file mode 100644 index 0000000..135ce9a --- /dev/null +++ b/recipes-morello/images/morello-linux-image-glibc.bb @@ -0,0 +1,145 @@ +inherit deploy nopackages + +COMPATIBLE_MACHINE = "morello-linux-glibc" +SUMMARY = "Bootable Morello Linux Image" +DESCRIPTION = "Image that goes on a bootable device, can be DD'ed onto a USB stick" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +OUTPUTS_NAME = "morello-linux-image" + +INHIBIT_DEFAULT_DEPS = "1" + +DEPENDS += "virtual/kernel morello-initramfs mtools-native e2fsprogs-native coreutils-native bc-native util-linux-native" +PROVIDES = "${OUTPUTS_NAME}" + +ESP_SIZE = "100" +BOOT_SECTORS = "204800" + +LBA = "512" +PART_START_ALIGNMENT = "2048" + +ESP_IMAGE = "${OUTPUTS_NAME}-esp" + +ROOTFS = "${DEPLOY_DIR}/images/morello-linux-glibc/rootfs-morello-linux-glibc.ext4" + +do_compile[noexec] = "1" +do_configure[depends] += "${MORELLO_ROOTFS_IMAGE}:do_image_complete morello-initramfs:do_deploy" +do_configure[mcdepends] += "mc:${BB_CURRENT_MC}:morello-firmware:board-firmware-image:do_deploy" + +def get_next_part_start (d): + next_image_start = int(d.getVar('BOOT_SECTORS')) + int(d.getVar('PART_START_ALIGNMENT')) + int(d.getVar('PART_START_ALIGNMENT')) - 1 + next_image_start = next_image_start & ~(int(d.getVar('PART_START_ALIGNMENT')) -1) + return next_image_start + +mult() { + local ret=$(echo "${1} * ${2}" | bc) + echo ${ret} +} + +add() { + local ret=$(echo "${1} + ${2}" | bc) + echo ${ret} +} + +div() { + local ret=$(echo "${1} / ${2}" | bc) + echo ${ret} +} + +get_size() { + local link=$(readlink -f ${1}) + local size=$(stat --dereference --format="%s" ${link}) + local ret=${size% *} + echo ${ret} +} + +add_to_image() { + mcopy -i ${1} -m -D overwrite ${2} ::${3} +} + +get_uuid() { + local part="$(blkid ${1})" + local tmp=${part#*"} + local uuid=$(echo $tmp | head -c 36) + echo ${uuid} +} + +create_gpt() { + + local esp_type="C12A7328-F81F-11D2-BA4B-00A0C93EC93B" + local linux_type="0FC63DAF-8483-4772-8E79-3D69D8477DE4" + + local part_start_esp=${PART_START_ALIGNMENT} + local part_start_linux="${@get_next_part_start(d)}" + + local size=$(get_size ${ROOTFS}) + local tmp=$(add ${size} ${LBA}) + + local rootfs_sectors=$(div ${tmp} ${LBA}) + local rootfs_uuid=$(get_uuid ${ROOTFS}) + + echo "Sectors $rootfs_sectors ${BOOT_SECTORS}" + + { + echo "label: gpt" + echo "start=${part_start_esp}, size=${BOOT_SECTORS}, name=ESP, type=${esp_type}" + echo "start=${part_start_linux}, size=${rootfs_sectors}, name=root, type=${linux_type}, uuid=${rootfs_uuid}" + } | sfdisk -q "${1}" + + dd if="${2}" of="${1}" seek=$(mult ${part_start_esp} ${LBA}) bs=8M conv=notrunc,sparse oflag=seek_bytes status=progress + dd if="${3}" of="${1}" seek=$(mult ${part_start_linux} ${LBA}) bs=8M conv=notrunc,sparse oflag=seek_bytes status=progress +} + +do_configure() { + local grub="${BSP_GRUB_DIR}/grub-config.cfg" + local uuid=$(get_uuid ${ROOTFS}) + echo ${uuid} + rm -f ${BSP_GRUB_DIR}/grub-config.cfg.processed + sed -e "s@%UUID%@${uuid}@" \ + "${BSP_GRUB_DIR}/grub-config.cfg" > "${BSP_GRUB_DIR}/grub-config.cfg.processed" +} + +do_install() { + + local part0="${BSP_GRUB_DIR}/grub-efi-bootaa64.efi" + local part1="${BSP_GRUB_DIR}/grub-config.cfg.processed" + local part2="${BSP_DTB_DIR}/morello-soc.dtb" + local part3="${DEPLOY_DIR}/images/morello-linux-glibc/Image" + local part4="${DEPLOY_DIR}/images/morello-linux-glibc/morello-initramfs/initramfs" + + rm -f ${ESP_IMAGE}.img + + # create the ESP + dd if=/dev/zero of=${ESP_IMAGE}.img bs=1024K count=${ESP_SIZE} + mformat -i ${ESP_IMAGE}.img -v ESP :: + + mmd -i ${ESP_IMAGE}.img ::/EFI + mmd -i ${ESP_IMAGE}.img ::/EFI/BOOT + + add_to_image ${ESP_IMAGE}.img ${part0} /EFI/BOOT/BOOTAA64.EFI + add_to_image ${ESP_IMAGE}.img ${part1} /EFI/BOOT/grub.cfg + add_to_image ${ESP_IMAGE}.img ${part2} /morello.dtb + add_to_image ${ESP_IMAGE}.img ${part3} /Image + add_to_image ${ESP_IMAGE}.img ${part4} /initramfs + + local size=$(get_size ${ROOTFS}) + + local rootfs_size=$(div ${size} 1048576) + local total_size=$(add ${ESP_SIZE} ${rootfs_size}) + + : > ${OUTPUTS_NAME}.img + truncate --size="$(add ${total_size} 50)M" ${OUTPUTS_NAME}.img + + create_gpt ${OUTPUTS_NAME}.img ${ESP_IMAGE}.img ${ROOTFS} ${size} + + install ${OUTPUTS_NAME}.img ${D}/${OUTPUTS_NAME}.img + install ${ESP_IMAGE}.img ${D}/${ESP_IMAGE}.img +} + +do_deploy() { + install -d ${DEPLOYDIR}/ESP + install ${D}/${OUTPUTS_NAME}.img ${DEPLOYDIR}/${OUTPUTS_NAME}-${MORELLO_ARCH}-${TCLIBC}.img + install ${D}/${ESP_IMAGE}.img ${DEPLOYDIR}/ESP/${ESP_IMAGE}.img + +} +addtask deploy after do_install \ No newline at end of file diff --git a/recipes-morello/images/morello-linux-image-musl.bb b/recipes-morello/images/morello-linux-image-musl.bb new file mode 100644 index 0000000..7b5e6eb --- /dev/null +++ b/recipes-morello/images/morello-linux-image-musl.bb @@ -0,0 +1,96 @@ +inherit deploy nopackages + +COMPATIBLE_MACHINE = "morello-linux-musl" +SUMMARY = "Bootable Morello Linux Image" +DESCRIPTION = "Image that goes on a bootable device, can be DD'ed onto a USB stick" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +OUTPUTS_NAME = "morello-linux-image" + +INHIBIT_DEFAULT_DEPS = "1" + +DEPENDS += "virtual/kernel morello-initramfs mtools-native e2fsprogs-native coreutils-native bc-native util-linux-native" +PROVIDES = "${OUTPUTS_NAME}" + +IMAGE_SIZE = "100" + +IMAGE_SECTORS = "204800" + +LBA = "512" +PART_START_ALIGNMENT = "2048" + +ESP_IMAGE = "${OUTPUTS_NAME}-esp" + +do_configure[noexec] = "1" +do_compile[noexec] = "1" +do_install[mcdepends] = "mc:${BB_CURRENT_MC}:morello-firmware:board-firmware-image:do_deploy" + +def get_next_part_start (d): + next_image_start = int(d.getVar('IMAGE_SECTORS')) + int(d.getVar('PART_START_ALIGNMENT')) + int(d.getVar('PART_START_ALIGNMENT')) - 1 + next_image_start = next_image_start & ~(int(d.getVar('PART_START_ALIGNMENT')) -1) + return next_image_start + +add_to_image() { + mcopy -i ${1} -m -D overwrite ${2} ::${3} +} + +mult() { + local ret=$(echo "${1} * ${2}" | bc) + echo ${ret} +} + +create_gpt() { + + local esp_type="C12A7328-F81F-11D2-BA4B-00A0C93EC93B" + local linux_type="0FC63DAF-8483-4772-8E79-3D69D8477DE4" + + local part_start_esp=${PART_START_ALIGNMENT} + local part_start_linux="${@get_next_part_start(d)}" + + { + echo "label: gpt" + echo "start=${part_start_esp}, size=${IMAGE_SECTORS}, name=ESP, type=${esp_type}" + echo "start=${part_start_linux}, size=${IMAGE_SECTORS}, name=root, type=${linux_type}" + } | sfdisk -q "${1}" + + dd if="${2}" of="${1}" seek=$(mult ${part_start_esp} ${LBA}) bs=8M conv=notrunc,sparse oflag=seek_bytes status=progress + dd if="${3}" of="${1}" seek=$(mult ${part_start_linux} ${LBA}) bs=8M conv=notrunc,sparse oflag=seek_bytes status=progress +} + +do_install() { + + local part0="${BSP_GRUB_DIR}/grub-efi-bootaa64.efi" + local part1="${BSP_GRUB_DIR}/grub-config.cfg" + local part2="${BSP_DTB_DIR}/morello-soc.dtb" + local part3="${DEPLOY_DIR}/images/morello-linux-musl/Image" + local part4="${DEPLOY_DIR}/images/morello-linux-musl/morello-initramfs/initramfs" + + # create empty ext4 rootfs + : > ${D}/root.img + truncate --size="${IMAGE_SIZE}M" ${D}/root.img + mkfs.ext4 ${D}/root.img + + # create the ESP + dd if=/dev/zero of=${ESP_IMAGE}.img bs=1024K count=${IMAGE_SIZE} + mformat -i ${ESP_IMAGE}.img -v ESP :: + + mmd -i ${ESP_IMAGE}.img ::/EFI + mmd -i ${ESP_IMAGE}.img ::/EFI/BOOT + + add_to_image ${ESP_IMAGE}.img ${part0} /EFI/BOOT/BOOTAA64.EFI + add_to_image ${ESP_IMAGE}.img ${part1} /EFI/BOOT/grub.cfg + add_to_image ${ESP_IMAGE}.img ${part2} /morello.dtb + add_to_image ${ESP_IMAGE}.img ${part3} /Image + add_to_image ${ESP_IMAGE}.img ${part4} /initramfs + + : > ${OUTPUTS_NAME}.img + truncate --size="$(mult ${IMAGE_SIZE} 3)M" ${OUTPUTS_NAME}.img + + create_gpt ${OUTPUTS_NAME}.img ${ESP_IMAGE}.img /home/pawel/Code/ArmMorello/linux/output/root.img + install ${OUTPUTS_NAME}.img ${D}/${OUTPUTS_NAME}.img +} + +do_deploy() { + install ${D}/${OUTPUTS_NAME}.img ${DEPLOYDIR}/${OUTPUTS_NAME}-${MORELLO_ARCH}-${TCLIBC}.img +} +addtask deploy after do_install \ No newline at end of file diff --git a/recipes-morello/images/morello-linux-musl/files/init.sh b/recipes-morello/images/morello-linux-musl/files/init.sh new file mode 100644 index 0000000..7c1aa8d --- /dev/null +++ b/recipes-morello/images/morello-linux-musl/files/init.sh @@ -0,0 +1,33 @@ +#!/bin/busybox sh + +# Copyright (c) 2021 Arm Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause + +mount() { + /bin/busybox mount "$@" +} + +grep() { + /bin/busybox grep "$@" +} + +echo "Running init script" + +mount -t proc proc /proc +grep -qE $'\t'"devtmpfs$" /proc/filesystems && mount -t devtmpfs dev /dev +mount -t sysfs sysfs /sys + +echo "Installing busybox" + +/bin/busybox --install -s + +! grep -qE $'\t'"devtmpfs$" /proc/filesystems && mdev -s + +ulimit -c unlimited + +echo "/bin/sh as PID 1!" +echo "init.sh" +exec setsid cttyhack sh +echo setsid ctty hack failed so "exec /bin/sh" fallback will be used +exec /bin/sh diff --git a/recipes-morello/images/morello-linux-musl/files/initramfs.list.template b/recipes-morello/images/morello-linux-musl/files/initramfs.list.template new file mode 100644 index 0000000..3da25be --- /dev/null +++ b/recipes-morello/images/morello-linux-musl/files/initramfs.list.template @@ -0,0 +1,18 @@ +dir /bin 755 0 0 +dir /include 755 0 0 +dir /lib 755 0 0 +dir /share 755 0 0 +dir /dev 755 0 0 +dir /proc 755 0 0 +dir /sbin 755 0 0 +dir /sys 755 0 0 +dir /newroot 755 0 0 +dir /usr 755 0 0 +dir /usr/lib 755 0 0 +dir /usr/bin 755 0 0 +dir /etc 755 0 0 + +dir /%APP_DIR% 755 0 0 + +file /bin/busybox .%BUSYBOX%/busybox 755 0 0 +file /init .%FILES%/init.sh 755 0 0 \ No newline at end of file
Add scripts for all 3 machines and a common base.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- kas/base.yml | 33 +++++++++++++++++++++++++++++++++ kas/morello-bsp.yml | 7 +++++++ kas/morello-linux-glibc.yml | 8 ++++++++ kas/morello-linux-musl.yml | 8 ++++++++ 4 files changed, 56 insertions(+) create mode 100644 kas/base.yml create mode 100644 kas/morello-bsp.yml create mode 100644 kas/morello-linux-glibc.yml create mode 100644 kas/morello-linux-musl.yml
diff --git a/kas/base.yml b/kas/base.yml new file mode 100644 index 0000000..f955ead --- /dev/null +++ b/kas/base.yml @@ -0,0 +1,33 @@ +header: + version: 11 +distro: "" +repos: + poky: + path: poky + url: "https://git.yoctoproject.org/poky" + refspec: kirkstone + layers: + meta: + meta-poky: + meta-yocto-bsp: excluded + meta-arm: + path: poky/meta-arm + url: "https://git.yoctoproject.org/meta-arm" + refspec: kirkstone + layers: + meta-arm: + meta-arm-bsp: + meta-arm-toolchain: + meta-morello: + path: poky/meta-morello + url: "https://github.com/The-Good-Penguin/meta-morello" + refspec: kirkstone +bblayers_conf_header: + custom-local-conf: | + LCONF_VERSION = "7" + + YOCTOROOT := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}" +local_conf_header: + base: | + CONF_VERSION = "2" + EXTRA_IMAGE_FEATURES ?= "debug-tweaks" \ No newline at end of file diff --git a/kas/morello-bsp.yml b/kas/morello-bsp.yml new file mode 100644 index 0000000..da5a612 --- /dev/null +++ b/kas/morello-bsp.yml @@ -0,0 +1,7 @@ +header: + version: 11 + includes: + - base.yml +machine: morello-bsp +target: + - board-firmware-image \ No newline at end of file diff --git a/kas/morello-linux-glibc.yml b/kas/morello-linux-glibc.yml new file mode 100644 index 0000000..485d2f2 --- /dev/null +++ b/kas/morello-linux-glibc.yml @@ -0,0 +1,8 @@ +header: + version: 11 + includes: + - base.yml +machine: morello-linux-glibc +target: + - multiconfig:morello-firmware:board-firmware-image + - multiconfig:morello-linux-glibc:morello-linux-image \ No newline at end of file diff --git a/kas/morello-linux-musl.yml b/kas/morello-linux-musl.yml new file mode 100644 index 0000000..d4a31b4 --- /dev/null +++ b/kas/morello-linux-musl.yml @@ -0,0 +1,8 @@ +header: + version: 11 + includes: + - base.yml +machine: morello-linux-musl +target: + - multiconfig:morello-firmware:board-firmware-image + - multiconfig:morello-linux-musl:morello-linux-image \ No newline at end of file
Add README.md with references and instructions of usage.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk Reviewed-by: Andrew Murray amurray@thegoodpenguin.co.uk --- README.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 README.md
diff --git a/README.md b/README.md new file mode 100644 index 0000000..28f1ea2 --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +meta-morello +============== + +Meta-morello provides the layer required to build the firmware that lives on the SD card and a Morello enabled +Linux kernel for the Morello System Development Platform. + +-Use the provided kas scripts to get all of the dependencies. +-Read on how to get and use kas here [1] + +Booting the hardware +-------------------- + +For information on how to boot the hardware and how the hardware is booting see [2] and [3]. + +Machines +-------- + +The machines have been split into: +- morello-bsp for the SD card +- morello-linux-musl for the Linux image with musl being the only libc +- morello-linux-glibc for the Linux image with an arbitrary Yocto image as the rootfs, there are two system loaders: + musl for capability aware applications, glibc for all of the rest + +Building images +-------------------- + +kas build ./kas/morello-linux-glibc.yml + +or + +kas build ./kas/morello-linux-musl.yml + +Images +------ + +The outputs can be found under build/temp/deploy/images: +- board-firmware-sd-image.img goes on the SD card via DD +- morello-linux-image-...img goes on the USB via DD + +Linux and musl-libc +------------------- +The linux kernel and musl-libc are locked in sync so that the release tags from upstream always match. + + +Known limitations +----------------- + +- the current state of this layer is meant to be just a starting point and foundation for further development, the main aim was to have working Linux images ASAP for the community, do not expect elegant Yocto solutions yet +- the rtl_nic driver is missing from the musl image + +Adding new recipes +------------------ + +Follow the coding style found in other layers, the aim here is to keep them consistent where possible +and very easy to read. Follow the order found in the "headers" of each recipe and in general. + +.bb recipes that come from Morello gitlab and are Morello "edits"" of upstream inherit the name Morello in the recipe: package-name-morello +.bbappends do not need to do this even if they come from Morello gitlab as they would only change SRC_URI + +Whether to append or start a new recipe is up to the designer, whatever is the easiest. + + +Mailing list +------------ + +https://op-lists.linaro.org/mailman3/lists/linux-morello-distros.op-lists.li... + +References +---------- + +[1] https://kas.readthedocs.io/en/latest/ \ +[2] https://developer.arm.com/documentation/den0132/0100/Setting-up-the-Morello-... \ +[3] https://developer.arm.com/documentation/102278/0001/?lang=en
On 27 Jan 2023, at 15:28, Pawel Zalewski pzalewski@thegoodpenguin.co.uk wrote:
This series of patches forms the initial support for the Morello hardware in Yocto. For limitations and instructions to build refer to the README.md
To-do list:
- create clang-morello toolchain, follow the guide here [1] and move llvm-morello to its own layer
- can try append meta-clang instead
- can try to use precompiled external toolchain like here [2] instead
- thus there are 3 paths to explore forward for the toolchain, Yocto expects target_prefixed toolchain binaries
- be considerate of incoming purecap GNU toolchain [3] (related to the above toolchain problem)
- decide what combinations of musl/glibc env the user might want and stick that in grub cfg,
the current division between glibc/musl machines is a ripple from the past
Whilst the layer has some rough edges (it won’t get anywhere near passing yocto-check-layer, for example), the nature of the Morello development means this is IMHO acceptable for now and the edges can be smoothed over time.
Ross
Indeed, it has some rough edges :) Thanks for the feedback, I shall look into pasing yocto-check-layer.
Pawel
Pawel
On Mon, 30 Jan 2023 at 11:35, Ross Burton Ross.Burton@arm.com wrote:
On 27 Jan 2023, at 15:28, Pawel Zalewski pzalewski@thegoodpenguin.co.uk wrote:
This series of patches forms the initial support for the Morello hardware in Yocto. For limitations and instructions to build refer to the README.md
To-do list:
- create clang-morello toolchain, follow the guide here [1] and move llvm-morello to its own layer
- can try append meta-clang instead
- can try to use precompiled external toolchain like here [2] instead
- thus there are 3 paths to explore forward for the toolchain, Yocto expects target_prefixed toolchain binaries
- be considerate of incoming purecap GNU toolchain [3] (related to the above toolchain problem)
- decide what combinations of musl/glibc env the user might want and stick that in grub cfg,
the current division between glibc/musl machines is a ripple from the past
Whilst the layer has some rough edges (it won’t get anywhere near passing yocto-check-layer, for example), the nature of the Morello development means this is IMHO acceptable for now and the edges can be smoothed over time.
Ross
On 30 Jan 2023, at 12:33, Pawel Zalewski pzalewski@thegoodpenguin.co.uk wrote:
Indeed, it has some rough edges :) Thanks for the feedback, I shall look into pasing yocto-check-layer.
The catch with check-layer is that adding a BSP layer should do _nothing_ unless you switch MACHINE. Recipes that do bbappends and change SRC_URI definitely don’t pass!
Ross
If Morello goes into mass production I suppose the changes will be merged into meta-arm as the changes to the source code that now exist in Morello forks of tfa etc. will be merged as well. Then one can restructure the logic such that the appends just add another "require" statement to a morello-specific include file.
For the time being then these recipes should not really append anything and just be their own .bb files with meta-arm dependency dropped or just left alone as is until Morello leaves the research phase.
Pawel
On Mon, 30 Jan 2023 at 13:28, Ross Burton Ross.Burton@arm.com wrote:
On 30 Jan 2023, at 12:33, Pawel Zalewski pzalewski@thegoodpenguin.co.uk wrote:
Indeed, it has some rough edges :) Thanks for the feedback, I shall look into pasing yocto-check-layer.
The catch with check-layer is that adding a BSP layer should do _nothing_ unless you switch MACHINE. Recipes that do bbappends and change SRC_URI definitely don’t pass!
Ross
linux-morello-distros@op-lists.linaro.org