A custom build of OpenJDK 9 for EV3, a Lego Mindstorms programmable brick featuring a ARM926EJ-S CPU.
The output consists of these parts:
- JRE running on the EV3 -
jre-ev3.zip
- Stripped down version -- a runtime image
- JDK built for the EV3 -
jdk-ev3.zip
- Basically the full build
- Official OpenJDK linux-amd64 with EV3 jmods
- Only a stripped down version -- also a runtime image
- It can be used for creating custom JRE images. For this, jlink and the ev3 jmods are included.
- It has
javac
(jdk.compiler module). - JShell remote launcher (hackish, linux-only) is available.
First, you have to either add your pubkey to the EV3 brick's authorized_keys,
or set the SSH_ASKPASS environment variable. Then, run a script from
the amd64 JDK on your computer: bin/jshell-launch.sh <ssh args>
, where <ssh args>
is an address with an optinal
port-specifying flag. The options are just added to the SSH command line and aren't sanitized in any way.
We've managed to run JShell in a kind of "split-mode". The compiler part runs on your powerful computer, whether the not-so-demanding execution is done on the brick. This was almost supported out of the box - the default JShell configuration already uses JDI transport. The only issue is that it does not provide an intuitive way to connect to a remote host. JShell always launches a new JVM process in the JDI mode.
Our hack relies on replacing the agent in the VM started by JShell. The new dummy agent just
writes the port number it was supposed to connect to a file /tmp/jshellargs
. Then, if you make
jshellargs
a UNIX pipe, you can very easily pass the port to another application.
JShell on your computer is the listening side of the JDWP channel. To reuse the existing remote agent, which is used in the local JDI mode, we tunnel a chosen port over the SSH session. SSH connects to the JShell listening socket and itself listens on the remote side. Then, the last task is to run the JShell JDI agent on the remote side, which is handled by SSH as well.
- Clone/download this repo to your computer.
- Install Docker for your operating system.
- Adjust the JAVA_VERSION variable in
build/config.sh
to match the current OpenJDK tip: OpenJDK 9 updates - Build the jdk9 cross-compilation environment:
sudo docker build -t ev3dev-lang-java:jdk9-stretch -f build/Dockerfile.system build
sudo docker build -t ev3dev-lang-java:jdk9-build -f build/Dockerfile.scripts build
- Run the newly prepared container. You have to mount a host directory to the the
/build
directory in the container, otherwise the build would get discarded. The final build needs at least 6.5 GB of free space (in the build directory).
sudo docker run --rm -it -v <path on host, where the sources should be stored>:/build ev3dev-lang-java:jdk9-build
- Let's fetch the OpenJDK sources:
./fetch.sh
- The OpenJDK source tree should be ready. Now you can start the cross-build itself:
./build.sh
- Create the zipped images:
./zip.sh
- If the build was successful, JDK9 packages were created in
/build/jre-ev3.zip
,/build/jdk-ev3.zip
and/build/jdk-pc.zip
. If you have mounted/build
, you can access the files from the host.