knulli-cfw / distribution

Main KNULLI distribution
https://knulli.org
Other
373 stars 27 forks source link

add freej2me emulator(maybe?) #26

Open 00svd00 opened 4 months ago

00svd00 commented 4 months ago

Knulli build version

40-dev-d8b86623f3 2024/05/30 01:50

Your architecture

RG35XX H

Issue description

Works reasonably well for me, and j2me platform is also supported by stock theme.

Detailed reproduction steps

It's never supposed to be working. But it surely can :-)

Details of any attempts to fix this yourself

No response

Details of any modifications you have made to Knulli.

  1. Buld freej2me_libretro.so for aarch64 (from this repo:https://github.com/hex007/freej2me) and put it to /usr/lib/libretro/
  2. Build freej2me-lr.jar (same repo) and put it to /userdata/bios/
  3. Add libbsd.so.0, libmd.so.0, libX11.so.6, libXau.so.6, libxcb.so.1, libXdmcp.so.6, libXext.so.6, libXi.so.6, libXrender.so.1, libXtst.so.6(all built for aarch64) to /usr/lib/
  4. /usr/share/emulationstation/es_systems.cfg:
    +  <system>
    +        <fullname>JavaME</fullname>
    +        <name>j2me</name>
    +        <manufacturer>Oracle</manufacturer>
    +        <release>2005</release>
    +        <hardware>portable</hardware>
    +        <path>/userdata/roms/j2me</path>
    +        <extension>.jar .JAR</extension>
    +        <command>/opt/j2merun.sh %ROM%</command>
    +        <platform>j2me</platform>
    +        <theme>j2me</theme>
    +        <emulators>
    +            <emulator name="libretro">
    +                <cores>
    +                    <core default="true">freej2me</core>
    +                </cores>
    +            </emulator>
    +        </emulators>
    +  </system>
  5. /usr/share/batocera/configgen/configgen-defaults.yml:
    +j2me:
    +  emulator: libretro
    +  core:     freej2me
  6. /etc/profile:
    + export JAVA_HOME="/opt/jdk"
    + export PATH="/bin:/sbin:/usr/bin:/usr/sbin:$JAVA_HOME/bin"
    • /opt/j2merun.sh:
      #!/bin/sh
      JAVA_HOME="/opt/jdk"
      CLASSPATH="${JAVA_HOME}/lib/tools.jar"
      PATH="${PATH}:${JAVA_HOME}/bin"
      export JAVA_HOME PATH CLASSPATH
      emulatorlauncher -p1index 0 -p1guid 19000000010000000100000000010000 -p1name Deeplay-keys -p1nbbuttons 17 -p1nbhats 1 -p1nbaxes 4 -p1devicepath /dev/input/event1 -system j2me -rom "$1" -gameinfoxml /tmp/game.xml -systemname JavaME

      I really don't know why, but this script make things work.

  7. Add openjdk-jre to /opt/jdk (for me, best results were with IBM Semeru builds, but differences are minimal)

Logs and data

No response

wandsmire commented 3 months ago

hi, how do you get libbsd.so.0, libmd.so.0, libX11.so.6, libXau.so.6, libxcb.so.1, libXdmcp.so.6, libXext.so.6, libXi.so.6, libXrender.so.1, libXtst.so.6(all built for aarch64) ?

00svd00 commented 3 months ago

hi, how do you get libbsd.so.0, libmd.so.0, libX11.so.6, libXau.so.6, libxcb.so.1, libXdmcp.so.6, libXext.so.6, libXi.so.6, libXrender.so.1, libXtst.so.6(all built for aarch64) ?

Hi, for now I don't think that these libs are really needed. During initial testing I was running java games through X11 forwarding and got crashes without them. But seems If you use only libretro variant(as it should be during normal usage), it runs OK without additional libs.

wandsmire commented 3 months ago

Thank you for answering. I've done all of the steps, but I could not see j2me on the emulation station list, is there any additional steps that I miss? sorry I am new to this.

edit: it seems my edit on /usr/share/emulationstation/es_systems.cfg will be overwritten on reboot.

00svd00 commented 3 months ago

Thank you for answering. I've done all of the steps, but I could not see j2me on the emulation station list, is there any additional steps that I miss? sorry I am new to this.

  1. Did you put any games in /userdata/roms/j2me ?
  2. How did you applied modifications? Knully/Batocera uses overlayfs, all rootfs modifications are lost after reboot(and you need reboot it to re-read configs). You need to modify file system image on sd card(boot/batocera file) using some linux machine (VM is perfectly fine) For example we are using Ubuntu After inserting microsd it automatically mounts to /media/user1/BATOCERA where user1 - your user name At first we create some work folders

cd ~/ mkdir fm to temp fin

After that we mount rootfs image

sudo mount /media/user1/BATOCERA/boot/batocera fm -t squashfs -o loop sudo mount -t overlay -o lowerdir=fm,upperdir=to,workdir=temp overlay fin

And after that we apply all needed changes inside fin folder FE we want to add opera_libretto core:

sudo cp opera_libretro.so fin/usr/lib/libretro/ sudo chmod 755 fin/usr/lib/libretro/opera_libretro.so

After all changes are done we need to create new FS image sudo mksquashfs fin ~/batocera

Unmount everything sudo umount fin sudo umount fm

And copy modified FS to microsd

sudo cp ~/batocera /media/user1/BATOCERA/boot/batocera (It will take time because of 1,5GB file size)

00svd00 commented 3 months ago

Also there is some instruction from batocera wiki, but I never tried it https://wiki.batocera.org/modify_the_system_while_it_s_running

wandsmire commented 3 months ago

I managed to get Java to show in emulation station by following this tutorial: https://wiki.batocera.org/emulationstation:customize_systems

the game won't boot though. I am still working on it, will update here. thanks.

wandsmire commented 3 months ago

2. you applied modifications? Knully/Batocera uses overlayfs, all rootfs modifications are lost after reboot(and you need reboot it to re-read configs).

no wonder why all of my modification lost... will try this, thanks.

00svd00 commented 3 months ago

I managed to get Java to show in emulation station by following this tutorial: https://wiki.batocera.org/emulationstation:customize_systems

the game won't boot though. I am still working on it, will update here. thanks.

You can try several things to debug in ssh session: If openjdk is installed correctly, java -version should give you version information Also you can try this command: /usr/bin/retroarch -L /usr/lib/libretro/freej2me_libretro.so --config /userdata/system/configs/retroarch/retroarchcustom.cfg --verbose /userdata/roms/j2me/your_game.jar It will run retroarch directrly. And this command: /opt/j2merun.sh /userdata/roms/j2me/your_game.jar It will do same using my start script

wandsmire commented 3 months ago

update: this thing is really useful: batocera-save-overlay (enabling us to save changes on boot folders)

anyway, java works using this tutorial (https://wiki.batocera.org/systems:ports), your script works now (/opt/j2merun.sh /userdata/roms/j2me/your_game.jar),

but somehow it cannot run using emulation station,

will keep updating my progress. hopefully it will help someone else too.

thank you.

00svd00 commented 3 months ago

update: this thing is really useful: batocera-save-overlay (enabling us to save changes on boot folders)

anyway, java works using this tutorial (https://wiki.batocera.org/systems:ports), your script works now (/opt/j2merun.sh /userdata/roms/j2me/your_game.jar),

but somehow it cannot run using emulation station,

will keep updating my progress. hopefully it will help someone else too.

thank you.

I dont'know why, but it's REALLY mandatory to set CLASSPATH inside startup shell script to make things work through emulation station You can't set it in user envs through /etc/profile, you also can't set it inside python emulatorlauncher script. You absolutelly must use shell script with export CLASSPATH="${JAVA_HOME}/lib/tools.jar". I can't explain it, it's strange but it works. And my startup script expects java installation at /opt/jdk If it's somewhere else on your system - you should symlink it there

wandsmire commented 3 months ago

yay it works!! turns out I only need to change the JAVA_HOME="/opt/jdk" in /opt/j2merun.sh to where it is installed (I put it in /userdata/system/java/jdk/).

thanks a lot man, finally I can run java on this RG35xx H :)

00svd00 commented 3 months ago

yay it works!! turns out I only need to change the JAVA_HOME="/opt/jdk" in /opt/j2merun.sh to where it is installed (I put it in /userdata/system/java/jdk/).

thanks a lot man, finally I can run java on this RG35xx H :)

Congratulations! Stay tuned for future updates, I have dialog with one java developer who works now with this fork https://github.com/zb3/freej2me to make it compatible with libretro core. We already have working build with minor bugs which runs java 3D games. I'll post here when it will be ready

wandsmire commented 3 months ago

hi, any updates? I am really looking forward to this...