Skip to content

Commit 1977fc8

Browse files
authored
Update README.md
1 parent 76b57d6 commit 1977fc8

1 file changed

Lines changed: 86 additions & 2 deletions

File tree

README.md

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,92 @@ Current (February 2022) there is no JDK17 for armv6.
2626
## Build the JDK on your own
2727

2828
You can build your JDK on your own. Go to releases on the official repository https://github.com/openjdk/jdk/tags and select your desired version. For this repo I've chosen https://github.com/openjdk/jdk/releases/tag/jdk-17-ga
29-
Download the source code and extract it
29+
Download the source code and extract it.
30+
31+
We use Debian to build the JDK. This tutorial is based on https://github.com/openjdk/jdk17/blob/master/doc/building.md#cross-compiling-with-debian-sysroots
32+
33+
### Crosscompiler for Raspberry PI Zero W
34+
35+
You need a fitting crosscompiler to compile. There is currently none working so we have to build one ourselves. That is part of another article an Repo. You find the build instructions as well a ready to go download there https://github.com/JsBergbau/GCC-cross-compiler-for-Raspberry-PI-Zero-W
36+
37+
The path of the cross compiler matters. It has to be put into `/opt/cross-pi-gcc/`
38+
39+
### System requirements for building OpenJDK for armv6
40+
41+
You need at least about 7 GB free diskspace. With packing files and stuff like that I recommend at least 10 GB free space, better 15 GB. A fast SSD is very helpful. A VirtualBox Debian is quite useful for compiling.
42+
43+
Memory, the more the better. I think it should be at least 4 GB, I've configured the VM with 15 GB, because there is enough RAM in my machine.
44+
45+
There are some prequisites required. Please install them via:
46+
`sudo apt install qemu-user-static debootstrap autoconf unzip zip libz-dev openjdk-17-jdkjava`
47+
48+
### Building OpenJDK on Debian x64 bullseye
49+
50+
`cd` to your home directory (or any other you like). In the following we use the home directory for the builds.
51+
52+
```
53+
sudo qemu-debootstrap \
54+
--arch=armhf \
55+
--verbose \
56+
--include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \
57+
--resolve-deps \
58+
buster \
59+
~/sysroot-armhf \
60+
http://httpredir.debian.org/debian/
61+
```
62+
We use buster here as sysroot and not bullseye. This JDK build will also run on Debian 11 / Bullseye. The other way round could be problematic.
63+
64+
Targetsystem where OpenJDK will be running:
65+
```
66+
uname -a
67+
Linux raspberrypi 5.10.92+ #1514 Mon Jan 17 17:35:21 GMT 2022 armv6l GNU/Linux`
68+
lsb_release -a
69+
No LSB modules are available.
70+
Distributor ID: Raspbian
71+
Description: Raspbian GNU/Linux 11 (bullseye)
72+
Release: 11
73+
Codename: bullseye
74+
```
75+
76+
Now lets make the crosscompiler
77+
`export PATH=/opt/cross-pi-gcc/bin:/opt/cross-pi-gcc/libexec/gcc/arm-linux-gnueabihf/10.1.0:$PATH`
78+
79+
```
80+
cd ~
81+
wget https://github.com/openjdk/jdk/archive/refs/tags/jdk-17-ga.tar.gz
82+
tar xfv jdk-17-ga.tar.gz
83+
cd jdk-jdk-17-ga
84+
85+
sh ./configure --openjdk-target=arm-linux-gnueabihf --with-sysroot=/home/pi/sysroot-armhf --with-abi-profile=armv6-vfp-hflt --with-num-cores=12 --with-memory-size=14000 --with-native-debug-symbols=zipped --with-jvm-variants=client
86+
make images
87+
```
88+
89+
The last step takes a while. I think about 7 to 15 minutes (didn't measure the time) on a Ryzen 5 Pro 5650GE.
90+
91+
Lets explain the options
92+
* `openjdk-target=arm-linux-gnueabihf` for Raspberry PI Zero W which is armv6hf
93+
* `--with-sysroot=/home/pi/sysroot-armhf` There are the header files for the target system
94+
* `--with-abi-profile=armv6-vfp-hflt` for Raspberry PI Zero W which is armv6hf
95+
* `-with-num-cores=12` This is just to speed up build process. The more cores, the more memory you need
96+
* `--with-memory-size=14000` maximum memory size that should be used for the build process
97+
* `--with-native-debug-symbols=zipped` in case you need Debug symbols. I've removed them in the download file.
98+
* `--with-jvm-variants=client` That is very important. Without this you will get ```Error occurred during initialization of VM
99+
Server VM is only supported on ARMv7+ VFP```
100+
101+
Your JDK is now in `~/jdk-jdk-17-ga/build/linux-arm-client-release/images/jdk`
102+
If you don't need debug information use
103+
* `find . -iname '*.diz' -delete` to delete all debug information files
104+
* `find . -exec strip --strip-debug {} +` to remove debugging information in executable files, if there are. Prints a lot of errors. If someone has a better version please open a pullrequest or issue.
105+
106+
You can now pack your distribution `tar cfz jdk.tar.gz jdk`. With this method executable bits are preserved.
107+
108+
Distribute VM to your target system and have fun.
109+
110+
I used this VM to run https://github.com/AsamK/signal-cli on a Raspberry PI Zero W and it works. You have to install rust on Raspberry PI and compile the native signal-client library on the Raspberry PI Zero W. This took about 193 minutes, about 3,25 hours. But after that it works. For more details of how to build, see https://github.com/AsamK/signal-cli/wiki/Provide-native-lib-for-libsignal
111+
112+
113+
114+
30115

31-
You need a fitting crosscompiler to compile. There is currently none working so we have to build one ourselves. That is part of another article an Repo.
32116

33117

0 commit comments

Comments
 (0)