Buildroot OpenJDK 编译配置

简介: Buildroot OpenJDK 编译配置

平台


Ubuntu 20.04 + Buildroot 2021.02 + OpenJDK 11.0.8


目标


配置Buildroot使能OpenJDK,

编译后模拟器运行如下:


~/codes/buildroot-2021.02$ ./output/images/start-qemu.sh 
VNC server running on ::1:5900
Booting Linux on physical CPU 0x0
Linux version 5.10.7 (anson@server4) (arm-buildroot-linux-gnueabihf-gcc.br_real (Buildroot 2021.02) 9.3.0, GNU ld (GNU Binutils) 2.35.2) #1 SMP Fri Jul 16 12:00:54 CST 2021
CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
OF: fdt: Machine model: V2P-CA9
Memory policy: Data cache writeback
Reserved memory: created DMA memory pool at 0x4c000000, size 8 MiB
OF: reserved mem: initialized node vram@4c000000, compatible id shared-dma-pool
cma: Reserved 16 MiB at 0x6f000000
Zone ranges:
  Normal   [mem 0x0000000060000000-0x000000006fffffff]
Movable zone start for each node
Early memory node ranges
  node   0: [mem 0x0000000060000000-0x000000006fffffff]
Initmem setup node 0 [mem 0x0000000060000000-0x000000006fffffff]
CPU: All CPU(s) started in SVC mode.
percpu: Embedded 19 pages/cpu s46156 r8192 d23476 u77824
Built 1 zonelists, mobility grouping on.  Total pages: 65024
Kernel command line: console=ttyAMA0,115200 rootwait root=/dev/mmcblk0
printk: log_buf_len individual max cpu contribution: 4096 bytes
printk: log_buf_len total cpu_extra contributions: 12288 bytes
printk: log_buf_len min size: 16384 bytes
printk: log_buf_len: 32768 bytes
printk: early log buf free: 14800(90%)
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
mem auto-init: stack:off, heap alloc:off, heap free:off
Memory: 231920K/262144K available (7168K kernel code, 583K rwdata, 1748K rodata, 1024K init, 181K bss, 13840K reserved, 16384K cma-reserved)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
rcu: Hierarchical RCU implementation.
rcu:  RCU event tracing is enabled.
rcu:  RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
GIC CPU mask not found - kernel will fail to boot.
GIC CPU mask not found - kernel will fail to boot.
L2C: platform modifies aux control register: 0x02020000 -> 0x02420000
L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 dynamic clock gating disabled, standby mode disabled
L2C-310 cache controller enabled, 8 ways, 128 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46420001
random: get_random_bytes called from start_kernel+0x384/0x538 with crng_init=0
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
Failed to initialize '/bus@4000000/motherboard/iofpga@7,00000000/timer@12000': -22
smp_twd: clock not found -2
Console: colour dummy device 80x30
Calibrating local timer... 99.89MHz.
Calibrating delay loop... 439.91 BogoMIPS (lpj=2199552)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
CPU: Testing write buffer coherency: ok
CPU0: Spectre v2: using BPIALL workaround
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x60100000 - 0x60100060
rcu: Hierarchical SRCU implementation.
smp: Bringing up secondary CPUs ...
smp: Brought up 1 node, 1 CPU
SMP: Total of 1 processors activated (439.91 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 0
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
hw-breakpoint: debug architecture 0x4 unsupported.
Serial: AMBA PL011 UART driver
irq: type mismatch, failed to map hwirq-75 for interrupt-controller@1e001000!
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arm,sp804
NET: Registered protocol family 2
tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
TCP established hash table entries: 2048 (order: 1, 8192 bytes, linear)
TCP bind hash table entries: 2048 (order: 2, 16384 bytes, linear)
TCP: Hash tables configured (established 2048 bind 2048)
UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 5 counters available
workingset: timestamp_bits=30 max_order=16 bucket_order=0
squashfs: version 4.0 (2009/01/31) Phillip Lougher
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
9p: Installing v9fs 9p2000 file system support
io scheduler mq-deadline registered
io scheduler kyber registered
i2c i2c-0: Added multiplexed i2c bus 2
physmap-flash 40000000.flash: physmap platform flash device: [mem 0x40000000-0x43ffffff]
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
physmap-flash 40000000.flash: physmap platform flash device: [mem 0x44000000-0x47ffffff]
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
Concatenating MTD devices:
(0): "40000000.flash"
(1): "40000000.flash"
into device "40000000.flash"
physmap-flash 48000000.psram: physmap platform flash device: [mem 0x48000000-0x49ffffff]
libphy: Fixed MDIO Bus: probed
libphy: smsc911x-mdio: probed
smsc911x 4e000000.ethernet eth0: MAC Address: 52:54:00:12:34:56
isp1760 4f000000.usb: bus width: 32, oc: digital
isp1760 4f000000.usb: NXP ISP1760 USB Host Controller
isp1760 4f000000.usb: new USB bus registered, assigned bus number 1
isp1760 4f000000.usb: Scratch test failed.
isp1760 4f000000.usb: can't setup: -19
isp1760 4f000000.usb: USB bus 1 deregistered
usbcore: registered new interface driver usb-storage
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
NET: Registered protocol family 17
9pnet: Installing 9P2000 support
oprofile: using arm/armv7-ca9
Registering SWP/SWPB emulation handler
aaci-pl041 10004000.aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 32
aaci-pl041 10004000.aaci: FIFO 512 entries
mmci-pl18x 10005000.mmci: Got CD GPIO
mmci-pl18x 10005000.mmci: Got WP GPIO
mmci-pl18x 10005000.mmci: mmc0: PL181 manf 41 rev0 at 0x10005000 irq 33,34 (pio)
10009000.uart: ttyAMA0 at MMIO 0x10009000 (irq = 37, base_baud = 0) is a PL011 rev1
printk: console [ttyAMA0] enabled
1000a000.uart: ttyAMA1 at MMIO 0x1000a000 (irq = 38, base_baud = 0) is a PL011 rev1
1000b000.uart: ttyAMA2 at MMIO 0x1000b000 (irq = 39, base_baud = 0) is a PL011 rev1
1000c000.uart: ttyAMA3 at MMIO 0x1000c000 (irq = 40, base_baud = 0) is a PL011 rev1
rtc-pl031 10017000.rtc: registered as rtc0
rtc-pl031 10017000.rtc: setting system clock to 2021-08-10T00:58:06 UTC (1628557086)
mmc0: new SD card at address 4567
drm-clcd-pl111 1001f000.clcd: assigned reserved memory node vram@4c000000
drm-clcd-pl111 1001f000.clcd: using device-specific reserved memory
drm-clcd-pl111 1001f000.clcd: core tile graphics present
drm-clcd-pl111 1001f000.clcd: this device will be deactivated
drm-clcd-pl111 1001f000.clcd: Versatile Express init failed - -19
drm-clcd-pl111 10020000.clcd: DVI muxed to daughterboard 1 (core tile) CLCD
mmcblk0: mmc0:4567 QEMU! 256 MiB 
drm-clcd-pl111 10020000.clcd: initializing Versatile Express PL111
drm-clcd-pl111 10020000.clcd: found bridge on endpoint 0
drm-clcd-pl111 10020000.clcd: Using non-panel bridge
input: AT Raw Set 2 keyboard as /devices/platform/bus@4000000/bus@4000000:motherboard/bus@4000000:motherboard:iofpga@7,00000000/10006000.kmi/serio0/input/input0
[drm] Initialized pl111 1.0.0 20170317 for 10020000.clcd on minor 0
Console: switching to colour frame buffer device 128x48
drm-clcd-pl111 10020000.clcd: [drm] fb0: pl111drmfb frame buffer device
ALSA device list:
  #0: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 32
input: ImExPS/2 Generic Explorer Mouse as /devices/platform/bus@4000000/bus@4000000:motherboard/bus@4000000:motherboard:iofpga@7,00000000/10007000.kmi/serio1/input/input2
random: fast init done
EXT4-fs (mmcblk0): mounted filesystem without journal. Opts: (null)
VFS: Mounted root (ext4 filesystem) readonly on device 179:0.
devtmpfs: mounted
Freeing unused kernel memory: 1024K
Run /sbin/init as init process
random: crng init done
EXT4-fs (mmcblk0): warning: mounting unchecked fs, running e2fsck is recommended
EXT4-fs (mmcblk0): re-mounted. Opts: (null)
ext4 filesystem being remounted at / supports timestamps until 2038 (0x7fffffff)
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Initializing random number generator: OK
Saving random seed: OK
Starting network: Generic PHY 4e000000.ethernet-ffffffff:01: attached PHY driver [Generic PHY] (mii_bus:phy_addr=4e000000.ethernet-ffffffff:01, irq=POLL)
smsc911x 4e000000.ethernet eth0: SMSC911x/921x identified at 0x908b0000, IRQ: 30
udhcpc: started, v1.33.0
udhcpc: sending discover
udhcpc: sending select for 10.0.2.15
udhcpc: lease of 10.0.2.15 obtained, lease time 86400
deleting routers
adding dns 10.0.2.3
OK
Starting cupsd: OK
Welcome to Buildroot
buildroot login: root
# 
# 
# 
# 
# java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+11)
OpenJDK Server VM (build 11.0.8+11, mixed mode)


参考.config


准备


OpenJDK的包处于:


~/codes/buildroot-2021.02$ ll package/openjdk
total 104
drwxrwxr-x    4 anson anson  4096 3月   7 05:16 ./
drwxrwxr-x 2495 anson anson 69632 3月   7 05:16 ../
drwxrwxr-x    2 anson anson  4096 3月   7 05:16 11.0.8+10/
drwxrwxr-x    2 anson anson  4096 3月   7 05:16 14.0.2+12/
-rw-rw-r--    1 anson anson  5178 3月   7 05:16 Config.in
-rw-rw-r--    1 anson anson   291 3月   7 05:16 openjdk.hash
-rw-rw-r--    1 anson anson  5099 3月   7 05:16 openjdk.mk


Config.in


cat package/openjdk/Config.in
config BR2_PACKAGE_HOST_OPENJDK_BIN_ARCH_SUPPORTS
  bool
  default y if BR2_HOSTARCH = "x86_64"
# Taken from make/autoconf/platform.m4
config BR2_PACKAGE_OPENJDK_ARCH_SUPPORTS
  bool
  default y if BR2_aarch64
  default y if BR2_arm
  default y if BR2_i386 || BR2_x86_64
  default y if BR2_m68k
  default y if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le
  default y if BR2_sh
config BR2_PACKAGE_OPENJDK
  bool "openjdk"
  depends on BR2_PACKAGE_HOST_OPENJDK_BIN_ARCH_SUPPORTS
  depends on BR2_PACKAGE_OPENJDK_ARCH_SUPPORTS
  depends on !BR2_SOFT_FLOAT
  depends on !BR2_STATIC_LIBS # glibc
  depends on BR2_INSTALL_LIBSTDCPP # cups
  depends on BR2_TOOLCHAIN_HAS_THREADS # alsa-lib, cups, libusb
  depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # libusb
  depends on BR2_TOOLCHAIN_USES_GLIBC
  depends on BR2_USE_MMU # cups
  depends on BR2_PACKAGE_XORG7
  select BR2_PACKAGE_ALSA_LIB
  select BR2_PACKAGE_ALSA_LIB_MIXER
  select BR2_PACKAGE_ALSA_LIB_PCM
  select BR2_PACKAGE_ALSA_LIB_RAWMIDI
  select BR2_PACKAGE_ALSA_LIB_SEQ
  select BR2_PACKAGE_CUPS
  select BR2_PACKAGE_FONTCONFIG
  select BR2_PACKAGE_GIFLIB
  select BR2_PACKAGE_JPEG
  select BR2_PACKAGE_LCMS2
  select BR2_PACKAGE_LIBPNG
  select BR2_PACKAGE_LIBUSB
  select BR2_PACKAGE_XLIB_LIBXRANDR
  select BR2_PACKAGE_XLIB_LIBXRENDER
  select BR2_PACKAGE_XLIB_LIBXT
  select BR2_PACKAGE_XLIB_LIBXTST
  select BR2_PACKAGE_ZLIB
  help
   OpenJDK is a free and open-source implementation of the
   Java Platform.
  http://openjdk.java.net/
if BR2_PACKAGE_OPENJDK
choice
  prompt "openjdk version"
  default BR2_OPENJDK_VERSION_LATEST
  help
   Select the version of OpenJDK you wish to use.
config BR2_OPENJDK_VERSION_LTS
  bool "LTS (OpenJDK 11)"
config BR2_OPENJDK_VERSION_LATEST
  bool "latest (OpenJDK 14)"
endchoice
config BR2_PACKAGE_OPENJDK_FULL_JDK
  bool "Build the full JDK"
  help
   Install the full JDK instead of just the run time.
   The full JDK includes several packages used for debugging and
   development. Some useful tools included with the JDK are:
     - javaws
       Command line tool for launching Java Web Start and setting
       various options.
     - jcmd:
       JVM Diagnostic Commands tool: Sends diagnostic command
       requests to a running Java Virtual Machine.
     - jinfo
       Configuration Info for Java: Prints configuration
       information for a given process or core file or a remote
       debug server.
     - jmap
       Memory Map for Java: Prints shared object memory maps or
       heap memory details of a given process or core file or a
       remote debug server.
     - jsadebugd
       Serviceability Agent Debug Daemon for Java: Attaches to a
       process or core file and acts as a debug server.
     - jstack
       Stack Trace for Java - Prints a stack trace of threads for
       a given process or core file or remote debug server.
     - jstat
       JVM Statistics Monitoring Tool: Attaches to an
       instrumented HotSpot Java virtual machine and collects and
       logs performance statistics as specified by the command
       line options.
     - jstatd
       JVM jstat Daemon - Launches an RMI server application that
       monitors for the creation and termination of instrumented
       HotSpot Java virtual machines and provides an interface to
       allow remote monitoring tools to attach to Java virtual
       machines running on the local system.
   Note:
   While the JDK also comes with several tools which can be used
   for developing java applications on a target, Buildroot does
   not support development on a target. Building the full JDK is
   supported for debugging purposes only.
   Selecting this option increases the file system by
   approximately 110M.
choice
  prompt "openjdk variant"
  default BR2_PACKAGE_OPENJDK_JVM_VARIANT_SERVER if !BR2_powerpc
  default BR2_PACKAGE_OPENJDK_JVM_VARIANT_ZERO if BR2_powerpc
config BR2_PACKAGE_OPENJDK_JVM_VARIANT_CLIENT
  bool "client"
  depends on !BR2_powerpc
  help
   Quick loading, but slower run-time performance.
config BR2_PACKAGE_OPENJDK_JVM_VARIANT_SERVER
  bool "server"
  depends on !BR2_powerpc
  help
   Slower loading, but faster run-time performance.
config BR2_PACKAGE_OPENJDK_JVM_VARIANT_ZERO
  bool "zero"
  select BR2_PACKAGE_LIBFFI
  help
   A non-assembler variant with wide arch support, however
   performance is less then client/server.
  http://openjdk.java.net/projects/zero
endchoice
endif
comment "openjdk needs X.Org"
  depends on BR2_PACKAGE_OPENJDK_ARCH_SUPPORTS
  depends on BR2_PACKAGE_HOST_OPENJDK_BIN_ARCH_SUPPORTS
  depends on BR2_USE_MMU
  depends on !BR2_PACKAGE_XORG7
comment "openjdk needs glibc, and a toolchain w/ wchar, dynamic library, threads, C++, gcc >= 4.9"
  depends on BR2_USE_MMU
  depends on BR2_PACKAGE_OPENJDK_ARCH_SUPPORTS
  depends on BR2_PACKAGE_HOST_OPENJDK_BIN_ARCH_SUPPORTS
  depends on BR2_STATIC_LIBS || !BR2_INSTALL_LIBSTDCPP || \
  !BR2_TOOLCHAIN_HAS_THREADS || \
  !BR2_TOOLCHAIN_USES_GLIBC || \
  !BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
comment "openjdk does not support soft float configurations"
  depends on BR2_PACKAGE_OPENJDK_ARCH_SUPPORTS
  depends on BR2_PACKAGE_HOST_OPENJDK_BIN_ARCH_SUPPORTS
  depends on BR2_USE_MMU
  depends on BR2_SOFT_FLOAT


依赖的配置不少:


depends on BR2_PACKAGE_HOST_OPENJDK_BIN_ARCH_SUPPORTS
  depends on BR2_PACKAGE_OPENJDK_ARCH_SUPPORTS
  depends on !BR2_SOFT_FLOAT
  depends on !BR2_STATIC_LIBS # glibc
  depends on BR2_INSTALL_LIBSTDCPP # cups
  depends on BR2_TOOLCHAIN_HAS_THREADS # alsa-lib, cups, libusb
  depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # libusb
  depends on BR2_TOOLCHAIN_USES_GLIBC
  depends on BR2_USE_MMU # cups
  depends on BR2_PACKAGE_XORG7


配置 menuconfig



image.pngimage.pngimage.png


一些过程

若出现 openjdk 无法勾选:


image.png


检查对应的依赖.


image.png


改下 glibc:

image.png

再去打开X.org即可


openjdk needs glibc, and a toolchain w/ wchar, dynamic library, threads, C++, gcc


勾选上:


image.png


写在最后


虽然在模拟环境下, 已经打通了任督二脉, 可惜没有办法在实际设备上做更多测试, 手上有的设备使用的是MIPS架构, 而OPENJDK对MIPS的支持早在几年前就停止了


相关文章
|
6月前
交叉编译安装tslib
交叉编译安装tslib
69 0
|
Linux
Linux安装Cmake
Linux安装Cmake
104 0
|
Ubuntu Linux
Ubuntu20.04 编译Buildroot(支持Qt编译)
Ubuntu20.04 编译Buildroot(支持Qt编译)
2074 0
Ubuntu20.04 编译Buildroot(支持Qt编译)
|
Linux Shell 编译器
用msys2与mingw编译FFmpeg
用msys2与mingw编译FFmpeg
377 0
|
Oracle Java 关系型数据库
LINUX编译OpenJDK11
LINUX编译OpenJDK11
136 0
|
Java Linux
LINUX编译OpenJDK 9
LINUX编译OpenJDK 9
105 0
|
Java Linux Windows
LINUX编译OpenJDK,也可以指定freetype
LINUX编译OpenJDK,也可以指定freetype
139 0
|
Linux
LINUX编译cmake
LINUX编译cmake
98 0
|
Java Linux
LINUX编译OpenJDK 11
LINUX编译OpenJDK 11
187 0
|
Ubuntu Java
openjdk 1.8 源码编译
openjdk 1.8 源码编译
961 0