linux 在Yocto OS上运行Java 17

pzfprimi  于 2023-08-03  发布在  Linux
关注(0)|答案(1)|浏览(147)

我和我的同事正在尝试建立一个Yocto OS映像。我们的应用程序由几个用Java 17编写的微服务组成,它们需要在嵌入式设备(phyCORE i.MX 8M Plus Setup Guide)上运行。在另一个系统上,我们会在Docker容器中运行它们并以这种方式部署它们,但由于我们之前没有人在Yocto构建上工作过,我们有点陷入了让事情工作并找到我们必须添加到Yocto构建的层。
我们确实安装了meta-java layer,但它只基于openjdk-8。
以下文件是当前的生成配置

local.conf

MACHINE ?= "phyboard-pollux-imx8mp-3"

DISTRO ?= "ampliphy-vendor"

########################
# global configuration #
########################

# That are the default values of bitbake.  Adapt these to your workspace and
# host preferences.
#DL_DIR = "${TOPDIR}/downloads"
#SSTATE_DIR = "${TOPDIR}/sstate-cache"

# License Handling
#  - Uncomment for i.MX6 proprietary GPU libraries
#LICENSE_FLAGS_WHITELIST += "license-nxp_v14-june-2016_imx-gpu-viv"
#  - Uncomment for Freescale i.MX6 VPU firmware blobs
#LICENSE_FLAGS_WHITELIST += "license-freescale_v12-march-2016_firmware-imx"

# build artifacts are deployed here
DEPLOY_DIR = "${TOPDIR}/deploy"

# enable bitbakes git shallow functionality: this reduces download volume
# from 7.3G to 1.6 G as of sumo. If you need the git history of a project,
# you can run a "git remote update" in the tmp dir, as the remotes are
# correctly specified
BB_GIT_SHALLOW = "1"

# Select configuration UI for linux and barebox recipe. The openembedded
# default is 'menuconfig', 'nconfig' has more features.
# busybox only supports menuconfig
#KCONFIG_CONFIG_COMMAND = "menuconfig"
KCONFIG_CONFIG_COMMAND = "nconfig"
KCONFIG_CONFIG_COMMAND_pn-busybox = "menuconfig"

# SDK will be build for that cpu
#SDKMACHINE ?= "x86_64"

# bitbake disk monitor setup
BB_DISKMON_DIRS ??= "\
    STOPTASKS,${TMPDIR},1G,100K \
    STOPTASKS,${DL_DIR},1G,100K \
    STOPTASKS,${SSTATE_DIR},1G,100K \
    STOPTASKS,/tmp,100M,100K \
    ABORT,${TMPDIR},100M,1K \
    ABORT,${DL_DIR},100M,1K \
    ABORT,${SSTATE_DIR},100M,1K \
    ABORT,/tmp,10M,1K"

#######################
# Image configuration #
#######################

# The following line disables the autostart of the phytec-qtdemo by
# default, but you can start the demo anytime using
#  $ systemctl start phytec-qtdemo.service
#SYSTEMD_AUTO_ENABLE_pn-phytec-qtdemo = "disable"

# You can disable and enable FSTYPES as you wish. e.g. 'ext4'.
# This variable is ordering dependend.
#IMAGE_FSTYPES = "tar.gz wic ubifs emmc"

# To change the variable for any imx8 machine:
#IMAGE_FSTYPES_mx8 = "tar.gz wic ubifs emmc"

# Turn on debugging options of the kernel
#DEBUG_BUILD_pn-linux-mainline = "1"
# Turn on debugging options of the imx kernel
#DEBUG_BUILD_pn-linux-imx = "1"
# Turn on debugging options of the barebox
#DEBUG_BUILD_pn-barebox = "1"

# Include kernel sources in SDK
TOOLCHAIN_TARGET_TASK_append = " kernel-devsrc"

# The default package class of the distro ampliphy is 'package_ipk'. The first
# value is used as the package manager to build the image and sdk. To build
# also tar packages use
#PACKAGE_CLASSES = "package_ipk package_tar"

# Variable IMAGE_ROOTFS_EXTRA_SPACE from poky/meta/conf/documentation.conf:
#   Defines additional free disk space created in the image in Kbytes. By
#   default, this variable is set to '0'.
# This example line adds an additional 512 MiB of free space to the root
# filesystem:
#IMAGE_ROOTFS_EXTRA_SPACE = "524288"

# See http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#ref-features-image
#    Through these variables, you can add several different predefined
#    packages such as development utilities or packages with debug information
#    needed to investigate application problems or profile applications
EXTRA_IMAGE_FEATURES = ""
# - "Makes an image suitable for development (e.g. allows root logins without
#    passwords and enables post-installation logging)"
EXTRA_IMAGE_FEATURES += "debug-tweaks"
# - "Installs debug symbol packages for all packages installed in a given
#    image."
#EXTRA_IMAGE_FEATURES += "dbg-pkgs"
# - "Installs debugging tools such as strace and gdb."
#EXTRA_IMAGE_FEATURES += "tools-debug"

######################
# rauc configuration #
######################

# certificate location for signing bundles
#CERT_PATH = "${TOPDIR}/../sources/meta-ampliphy/openssl-ca"

####################
# QT configuration #
####################

# We disable qt widgets per default to save about 10 MB of storage. If
# you need qt widget support, you can enable it with this line
#DISTRO_FEATURES_append = " qtwidgets"

CONF_VERSION = "1"

# Uncomment to accept NXP EULA (needed, if any NXP / freescale layer is used)
# EULA can then be found under ../sources/meta-freescale/EULA
ACCEPT_FSL_EULA = "1"

# A TISDK BSP requires per default an external toolchain
# Provide a default path that is compatible to our TISDK docker image
TOOLCHAIN_BASE ?= "/opt/PHYTEC_BSPs"

############################################
# Addition of openjdk-8 and minicom to the default build
PREFERRED_PROVIDER_virtual/java-initial-native = "cacao-initial-native"
PREFERRED_PROVIDER_virtual/java-native = "jamvm-native"
PREFERRED_PROVIDER_virtual/javac-native = "ecj-bootstrap-native"

IMAGE_INSTALL_append = " minicom openjdk-8"
############################################

字符串

bbllayers.conf

# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""

OEROOT := "/home/ubuntu/yocto/sources/poky"
# add BSPDIR variable, as it is needed by recipes of NXP
BSPDIR := "${OEROOT}/../.."

#######################################
# IMPORTANT NOTE: change to correct location and username on your build!
MYBSPDIR := "/home/ubuntu/yocto/sources"
########################################

# In our BSPs active layers are defined by the manifest.xml for all BSPs. The
# bblayers.conf gets created by the init_bblayers.py script.
BBLAYERS ?= ""
BBLAYERS += "\
  ${OEROOT}/../poky/meta \
  ${OEROOT}/../poky/meta-poky \
  ${OEROOT}/../meta-openembedded/meta-oe \
  ${OEROOT}/../meta-openembedded/meta-networking \
  ${OEROOT}/../meta-openembedded/meta-python \
  ${OEROOT}/../meta-openembedded/meta-multimedia \
  ${OEROOT}/../meta-openembedded/meta-filesystems \
  ${OEROOT}/../meta-openembedded/meta-perl \
  ${OEROOT}/../meta-openembedded/meta-gnome \
  ${OEROOT}/../meta-imx/meta-bsp \
  ${OEROOT}/../meta-imx/meta-sdk \
  ${OEROOT}/../meta-imx/meta-ml \
  ${OEROOT}/../meta-browser/meta-chromium \
  ${OEROOT}/../meta-clang \
  ${OEROOT}/../meta-freescale \
  ${OEROOT}/../meta-freescale-3rdparty \
  ${OEROOT}/../meta-freescale-distro \
  ${OEROOT}/../meta-nxp-demo-experience \
  ${OEROOT}/../meta-python2 \
  ${OEROOT}/../meta-qt5 \
  ${OEROOT}/../meta-virtualization \
  ${OEROOT}/../meta-rauc \
  ${OEROOT}/../meta-phytec \
  ${OEROOT}/../meta-ampliphy \
  ${OEROOT}/../meta-security \
  ${OEROOT}/../meta-security/meta-tpm \
  "
###################################
# Addition of the meta-java layer
BBLAYERS += "${MYBSPDIR}/meta-java"
###################################


我们还尝试创建和添加一个包含openjdk-17的自定义层,但在do_configure()部分中通过bitbake <recipe-name>启动的交叉编译过程中失败。
是否有任何现有的层,我们可以添加使用一个新的Java版本比版本8或有任何提示,如何获得一个自定义层运行?

2izufjch

2izufjch1#

我也遇到过同样的问题,但我通过创建my own layer解决了这个问题,它利用了AdoptiumEclipse Temurin项目。它需要一个预构建的JRE,并将其包含在您的OE/Yocto构建中。顺便说一句,这比你自己构建整个JRE要快得多。
您可以使用我的层,将其添加到您的bblayers.conf,然后将openjdk-17-jre附加到您的local.conf文件中的IMAGE_INSTALL。我的层目前支持ARM、ARM 64和x86_64架构的JRE。
请确保您的安装程序至少使用OE/Yocto的dunfell代号/分支。您可以查看Yocto project on how to migrate的文档。
对于想知道为什么官方java层meta-java似乎停留在OpenJDK版本8上的人:构建和维护一个JVM需要做很多工作。此外,为了编译所需版本的JVM,您需要一个前一版本的引导JVM。例如,通过构建OpenJDK 11 JRE,您需要OpenJDK 10 JDK。就像我说的,这是一个很大的工作。

相关问题