How to add openjdk to Yocto Layers
This document will describe how to add open JDK to i.MX yocto BSP. It will take two versions of Linux BSP as an example, one is the lower version of L4.1.15-2.0.0, the other is the latest version of L4.19.35-1.1.0.
- Adding openjdk-8 to L4.1.15-2.0.0(Ubuntu 16.04 LTS platform)
Before adding an open JDK, you must download L4.1.15-2.0.0 BSP according to the
i.MX_Yocto_Project_User's_Guide.pdf, and ensure that it can pass the compilation normally, that is to say, there is no error in the compilation. In this example, BSP is compiled using the following command.
# DISTRO=fsl-imx-wayland MACHINE=imx6sxsabresd source fsl-setup-release.sh -b build-wayland
# bitbake fsl-image-qt5
Then follow the steps below to add openjdk to the yocto layer:
- Fetching openjdk-8 from Yocto website
# cd ~/imx-release-bsp
# cd sources
# git clone git://git.yoctoproject.org/meta-java
# cd meta-java
# git checkout -b krogoth origin/krogoth
[Comment]
Yocto’s version is described in i.MX_Yocto_Project_User's_Guide.pdf
2. Modifying related configurations
(1) build-wayland/conf/local.conf
Add following lines to the file:
# Possible provider: cacao-initial-native and jamvm-initial-native
PREFERRED_PROVIDER_virtual/java-initial-native = "cacao-initial-native"
# Possible provider: cacao-native and jamvm-native
PREFERRED_PROVIDER_virtual/java-native = "cacao-native"
# Optional since there is only one provider for now
PREFERRED_PROVIDER_virtual/javac-native = "ecj-bootstrap-native"
IMAGE_INSTALL_append = " openjdk-8"
Save it and exit
(2)build-wayland/conf/bblayers.conf
Add java layer to the file, like below:
BBLAYERS = " \
${BSPDIR}/sources/poky/meta \
${BSPDIR}/sources/poky/meta-poky \
\
${BSPDIR}/sources/meta-openembedded/meta-oe \
${BSPDIR}/sources/meta-openembedded/meta-multimedia \
\
${BSPDIR}/sources/meta-fsl-arm \
${BSPDIR}/sources/meta-fsl-arm-extra \
${BSPDIR}/sources/meta-fsl-demos \
${BSPDIR}/sources/meta-java \
"……
Save it and exit.
3. Build openjdk-8
# cd ~/imx-release-bsp
# source setup-environment build-wayland
#bitbake openjdk-8 -c fetchall
Fetch all packages related to openjdk-8.
[error handling]
During downloading packages, you may encounter errors like the following.
(1)Fetch fastjar-0.98.tar.gz errors
The error is caused by invalid web address, we can download it from another link, see below:
http://savannah.c3sl.ufpr.br/fastjar/fastjar-0.98.tar.gz
copy the link to firefox in Ubuntu platform, and it will be downloaded into ~/Downloads
# cd ~/imx-release-bsp/downloads
# cp ~/Downloads/ fastjar-0.98.tar.gz ./
# touch fastjar-0.98.tar.gz.done
(2)Fetch “classpath-0.93.tar.gz” error
Download it from : http://mirror.nbtelecom.com.br/gnu/classpath/classpath-0.93.tar.gz
And copy it to ~/imx-release-bsp/downloads, and create a file named classpath-0.93.tar.gz.done in the directory.
# cd ~/imx-release-bsp/downloads
# cp ~/Downloads/ classpath-0.93.tar.gz ./
# touch classpath-0.93.tar.gz.done
(3) 8 files with tar.bz2 (hotspot-Java jvm)
These similar errors are very likely to be encountered.
These errors are caused by the bad network environment. You can download these packages manually. These are Java virtual machine source packages, i.e. hotspot JVM
[Solution]
# mkdir ~/temp
# cd temp
# wget http://www.multitech.net/mlinux/sources/56b133772ec1.tar.bz2
# wget http://www.multitech.net/mlinux/sources/ac29c9c1193a.tar.bz2
# wget http://www.multitech.net/mlinux/sources/1f032000ff4b.tar.bz2
# wget http://www.multitech.net/mlinux/sources/81f2d81a48d7.tar.bz2
# wget http://www.multitech.net/mlinux/sources/0549bf2f507d.tar.bz2
# wget http://www.multitech.net/mlinux/sources/0948e61a3722.tar.bz2
# wget http://www.multitech.net/mlinux/sources/48c99b423839.tar.bz2
# wget http://www.multitech.net/mlinux/sources/bf0932d3e0f8.tar.bz2
Then create .tar.bz2.done files for each package via touch command
# touch 56b133772ec1.tar.bz2.done
# touch ac29c9c1193a.tar.bz2.done
# touch 1f032000ff4b.tar.bz2.done
# touch 81f2d81a48d7.tar.bz2.done
# touch 0549bf2f507d.tar.bz2.done
# touch 0948e61a3722.tar.bz2.done
# touch 48c99b423839.tar.bz2.done
# touch bf0932d3e0f8.tar.bz2.done
Like below:
Then copy these files to ~/ fsl-release-bsp/downloads/
# bitbake openjdk-8 -c compile
After openjdk compilation, you will be prompted as follows:
At last , install openjdk-8 to images
# bitbake fsl-image-qt5
Done:
[Additional description]
The above method of adding openjdk-8 is the steps after BSP compilation. Users can also add openjdk-8 before BSP compilation, and then compile it with BSP
According to steps in i.MX_Yocto_Project_User's_Guide.pdf, After running the following two commands, users can modify bblayers.conf and local.conf directly.
For example, steps below have been validated:
… …
# repo sync
# cd ~/fsl-release-bsp
# DISTRO=fsl-imx-x11 MACHINE=imx6qsabresd source fsl-setup-release.sh -b build-x11
# gedit ./conf/bblayers.conf
Add the same contents as above.
# gedit ./conf/local.conf
Add the same contents as above.
# bitbake fsl-image-gui
During compilation, users may encounter some errors, which can be handled by referring to the methods described above
- Adding openjdk-8 to L4.19.35-1.1.0(Ubuntu 18.04 LTS Platform)
In fact, the steps to add openjdk-8 to l4.19.35 are the same as those described above, and the following steps have been verified. Before adding openjdk-8, i.mx8qxp full image has been compiled with 2 commands below, so we only need to add openjdk-8 here.
# DISTRO=fsl-imx-xwayland MACHINE=imx8qxpmek source fsl-setup-release.sh -b build-xwayland
# bitbake imx-image-full
# cd sources
# git clone git://git.yoctoproject.org/meta-java
# cd meta-java
# git checkout -b warrior origin/warrior
Release L4.19.35_1.1.0 is released for Yocto Project 2.7 (Warrior).
# cd ~/imx-release-bsp-l4.19.35
# source setup-environment build-xwayland-imx8qxpmek
# gedit ./conf/bblayers.conf
Add meta-java to it.
……
${BSPDIR}/sources/meta-java \
……
Save and exit.
# gedit ./conf/local.conf
Add these lines to it.
# Possible provider: cacao-initial-native and jamvm-initial-native
PREFERRED_PROVIDER_virtual/java-initial-native = "cacao-initial-native"
# Possible provider: cacao-native and jamvm-native
PREFERRED_PROVIDER_virtual/java-native = "cacao-native"
# Optional since there is only one provider for now
PREFERRED_PROVIDER_virtual/javac-native = "ecj-bootstrap-native"
IMAGE_INSTALL_append = " openjdk-8"
Save and exit.
# cd ~/imx-release-bsp-l4.19.35/build-xwayland-imx8qxpmek
# bitbake openjdk-8 -c fetch
# bitbake openjdk-8 -c compile
[Errors]
[Solution]
# gedit ./ tmp/work/x86_64-linux/openjdk-8-native/172b11-r0/jdk8u-33d274a7dda0/hotspot/make/linux/Makefile
Comment the following lines:
-----------------------------------------
check_os_version:
#ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
# $(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1;
#endif
-----------------------------------------
Then continue
# cd ~/imx-release-bsp-l4.19.35/build-xwayland-imx8qxpmek
# bitbake openjdk-8 -c compile
[comment]
Probably similar errors will be encountered during compiling other packages, we can use the same way like above to solve it, see bellow, please!
Done:
At last, install openjdk-8 to images.
# bitbake imx-image-full
Installation is done.
NXP TIC Team
Weidong Sun
12/31/2019
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I followed the same steps but while compilation am getting below error.
| glob/libglob.a(glob.o): In function `glob_in_dir':
| glob.c:(.text+0x2c1): undefined reference to `__alloca'
| glob.c:(.text+0x43e): undefined reference to `__alloca'
| glob.c:(.text+0x5f8): undefined reference to `__alloca'
| glob.c:(.text+0x658): undefined reference to `__alloca'
| glob/libglob.a(glob.o): In function `glob':
| glob.c:(.text+0x95b): undefined reference to `__alloca'
| glob/libglob.a(glob.o):glob.c:(.text+0x101a): more undefined references to `__alloca' follow
| collect2: error: ld returned 1 exit status
| Makefile:648: recipe for target 'make' failed
| make[2]: *** [make] Error 1