![]() |
#1 |
Member
![]() Posts: 20
Karma: 10
Join Date: Jun 2025
Device: Kindle PW5
|
![]()
Hello,
I am quite new here, and wanted to try porting an application (not made by me) on the PW5. The application that I want to port is called "mgba" (it can be found on GitHub). It is a fast and lightweight GBA emulator, which is why I chose it. (of course if someone knows of a better (i.e. Faster and lightweight) emulator, I'd gladly make the switch) The big problem is: I've never coded C++ before (however I have some theory), let alone created an app for a Kindle. I would like to know what modifications (in a large sense, I'm not asking that someone does all the work for me (though that would be nice ![]() I know that I would need to rewrite the whole GUI and resize the screen/adjust ratios, and add an rgb to grayscale conversion (probably precomputed to optimize speed) On the other hand, I have no idea what I should change in the actual emulation code, and which functions don't run with the kindle. I know this is an ambitious project and might turn out to be a complete failure, but if I don't give it a try, it'll fail anyway ![]() ![]() Edit - I should also add that I cannot compile anything on my computer, so if anyone knows of a free online compiler that will give me the executable file for my Kindle or is kind enough to compiile my project for me, thanks a lot! Last edited by HenriHenry; 06-26-2025 at 07:19 PM. Reason: added precisions. |
![]() |
![]() |
![]() |
#2 |
Member
![]() Posts: 20
Karma: 10
Join Date: Jun 2025
Device: Kindle PW5
|
Or is there something like kite to run linux apps but for PW5?
|
![]() |
![]() |
![]() |
#3 |
Member
![]() Posts: 20
Karma: 10
Join Date: Jun 2025
Device: Kindle PW5
|
After extensive online research it seems to me that the simplest way would be to use arch_linux to run the emulator.
And as for the emulator, I'm thinking of using gpSP as it seems more adapted. |
![]() |
![]() |
![]() |
#4 |
Member
![]() Posts: 20
Karma: 10
Join Date: Jun 2025
Device: Kindle PW5
|
If someone could give me detailed instructions of how to do this, I would be immensely grateful.
Thanks! |
![]() |
![]() |
![]() |
#5 |
Member
![]() Posts: 20
Karma: 10
Join Date: Jun 2025
Device: Kindle PW5
|
![]()
I'd need someone to compile gpSP for PW5 (armv7) and test it.
cannot guarantee that it'll work ![]() needed: - Jailbroken Kindle with KTerm (or similar) installed - At least ~30 MB free in your chroot (/usr/bin, /usr/lib, /lib) - USB or scp access to copy files - Linux Userland (chroot): - A minimal ARMv7h rootfs (e.g. Arch Linux ARM glibc 2.35) mounted under / via chroot - Core utilities: /bin/sh, cp, ls, tar, etc. - gpSP Files (/usr/bin/gpsp – Standalone ARMv7h ELF (EABI5) built with SDL2 (i.e. what I need someone to compile) /usr/bin/gba_bios.bin – Official GBA BIOS dump (16 KB)) - Shared Libraries (drop into /usr/lib or /lib) After you run ldd gpsp on your build machine, you’ll see something like: libSDL2.so.0 => /usr/lib/libSDL2.so.0 libz.so.1 => /usr/lib/libz.so.1 libpng16.so.16 => /usr/lib/libpng16.so.16 libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 libdl.so.2 => /lib/libdl.so.2 libpthread.so.0=> /lib/libpthread.so.0 libm.so.6 => /lib/libm.so.6 librt.so.1 => /lib/librt.so.1 libc.so.6 => /lib/libc.so.6 [program interpreter] => /lib/ld-linux-armhf.so.3 Compile gpSP for ARMv7 : Prepare your build host (WSL Ubuntu) 1. Open Windows Terminal → select your Ubuntu profile. 2. Update & install toolchain + deps: sudo apt update sudo apt install -y \ gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \ make git pkg-config \ libsdl2-dev:armhf zlib1g-dev:armhf libpng-dev:armhf • This gives you 'arm-linux-gnueabihf-gcc', 'make', SDL2 headers/libs, zlib/png for ARMv7. Grab gpSP & libretro-common : cd $HOME git clone https://github.com/libretro/common.git git clone https://github.com/libretro/gpsp.git cd libretro-gpsp Add a tiny SDL2 "launcher": Create 'main_sdl2.c' in 'libretro-gpsp/' with this exact contents: #include <stdio.h> #include <SDL.h> #include "libretro.h" // forward core symbols extern void retro_init(void); extern void retro_load_game(const struct retro_game_info *); extern void retro_run(void); extern void retro_unload_game(void); extern void retro_deinit(void); extern void retro_set_environment(retro_environment_t); extern void retro_set_video_refresh(retro_video_refresh_t); extern void retro_set_audio_sample(retro_audio_sample_t); extern void retro_set_audio_sample_batch(retro_audio_sample_ba tch_t); extern void retro_set_input_poll(retro_input_poll_t); extern void retro_set_input_state(retro_input_state_t); int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage: %s <game.gba>\n", argv[0]); return 1; } SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); SDL_Window *win = SDL_CreateWindow( "gpSP", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 240*2, 160*2, 0 ); SDL_Renderer *ren = SDL_CreateRenderer(win, -1, 0); SDL_Texture *tex = SDL_CreateTexture( ren, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, 240, 160 ); // wire up minimal callbacks retro_set_environment(NULL); retro_set_video_refresh( (retro_video_refresh_t)SDL_UpdateTexture ); retro_set_audio_sample(NULL); retro_set_audio_sample_batch(NULL); retro_set_input_poll(NULL); retro_set_input_state(NULL); retro_init(); struct retro_game_info game = { .path = argv[1], .data = NULL, .size = 0, .meta = NULL }; retro_load_game(&game); int running = 1; SDL_Event ev; while (running) { while (SDL_PollEvent(&ev)) if (ev.type == SDL_QUIT) running = 0; retro_run(); SDL_RenderClear(ren); SDL_RenderCopy(ren, tex, NULL, NULL); SDL_RenderPresent(ren); } retro_unload_game(); retro_deinit(); return 0; } Patch the Makefile: Edit 'Makefile' in 'libretro-gpsp/' to look exactly like this: --- a/Makefile +++ b/Makefile @@ -TARGET = gpsp_libretro.so +TARGET = gpsp CFLAGS += -O2 -Wall -fsigned-char -INCLUDES += +INCLUDES += \ + -I../libretro-common/include \ + -I../libretro-common/include/compat +# pull in SDL2 flags via pkg-config +CFLAGS += $(shell pkg-config --cflags sdl2) +LDFLAGS += $(shell pkg-config --libs sdl2) -lz -lpng -ldl -SHARED = -shared -fPIC +SHARED = # none: build an executable, not a .so OBJS = gpu_dma.o gpu_draw.o gpu_mem.o gpu_reg.o \ input.o map.o memory.o misc.o settings.o \ sound.o timer.o utilities.o video.o \ bios_gba.o runtime.o +WRAP = main_sdl2.o all: - $(CC) $(SHARED) -o $(TARGET) $(OBJS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $(TARGET) \ + $(WRAP) $(OBJS) $(LDFLAGS) ``` Make sure 'OBJS' matches what 'Makefile' lists; add or remove as needed. Build for ARMv7: cd ~/libretro-gpsp export CC=arm-linux-gnueabihf-gcc export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig make -j$(nproc) You should end up with a standalone 'gpsp' ELF. Verify & gather dependencies : 1. Check the binary: file gpsp # ELF 32-bit LSB executable, ARM, EABI5, ... 2. List runtime libs: ldd gpsp Note the full paths of each `so` (e.g. `libSDL2.so.0 => /usr/lib/arm-linux-gnueabihf/libSDL2.so.0`). 3. Copy binary + its libs into a bundle: mkdir -p ~/gpsp-bundle/usr/bin \ ~/gpsp-bundle/usr/lib \ ~/gpsp-bundle/lib cp gpsp ~/gpsp-bundle/usr/bin/ # Replace these paths with your ldd results: cp /usr/lib/arm-linux-gnueabihf/libSDL2.so.0 \ ~/gpsp-bundle/usr/lib/ cp /usr/lib/arm-linux-gnueabihf/libz.so.1 \ ~/gpsp-bundle/usr/lib/ cp /usr/lib/arm-linux-gnueabihf/libpng16.so.16 \ ~/gpsp-bundle/usr/lib/ cp /lib/arm-linux-gnueabihf/ld-linux-armhf.so.3 \ ~/gpsp-bundle/lib/ 4. Package it: cd ~/gpsp-bundle tar -czf gpsp-kindle.tar.gz . Copy `gpsp-kindle.tar.gz` back to Windows (i.e. via 'cp' into '/mnt/c/Users/...'). --------------------------------------------------------------------------------------------------- Install & Run on Kindle Transfer bundle & ROMs 1. Connect your Kindle via USB → it mounts at 'D:\' (Windows) or '/mnt/us' (chroot path). 2. Copy the tarball (on Kindle’s Kterm): cp /mnt/us/Downloads/gpsp-kindle.tar.gz /mnt/us/ cp /mnt/us/Downloads/gba_bios.bin /mnt/us/ cp /mnt/us/Downloads/mygame.gba /mnt/us/ Unpack into your chroot (in KTerm): cd / tar -xzf /mnt/us/gpsp-kindle.tar.gz -C / Ensures: /usr/bin/gpsp /usr/lib/libSDL2.so.0, libz.so.1, libpng16.so.16 /lib/ld-linux-armhf.so.3 Verify interpreter & libs: 1. Check the dynamic loader: readelf -l /usr/bin/gpsp | grep interpreter (should say: [Requesting program interpreter: /lib/ld-linux-armhf.so.3) 2. Ensure all '.so' files exist: ls /usr/lib/{libSDL2.so.0,libz.so.1,libpng16.so.16} ls /lib/ld-linux-armhf.so.3 Run gpSP cd /usr/bin ./gpsp /mnt/us/mygame.gba (where mygame.gba is the name of your rom) You should see the gpSP menu prompt, then the ROM boots in SDL2 window on your Kindle’s screen. I've probably overlooked tons of possible errors. please post back so i can correct it. there might be other ways too. ![]() Last edited by HenriHenry; 06-28-2025 at 05:23 AM. |
![]() |
![]() |
![]() |
#6 |
Member
![]() Posts: 20
Karma: 10
Join Date: Jun 2025
Device: Kindle PW5
|
Found an easier way, though i'd still need someone to compile (please? -insert puppy image here-
![]() cross-compile RetroArch 1.9.0 (armv7hf, static, fbdev --- https://github.com/libretro/RetroArch/releases?page=4) plus the mGBA libtertro core (https://github.com/FunKey-Project/mgba-libretro). Then drop the 'retroarch' ELF and the 'mgba_libretro.so' in koreader (retroarch at /mnt/us/koreader/custom/bin ------------------------------------------------------------------------------------------------- 1) Prepare your Ubuntu/Debian host sudo dpkg --add-architecture armhf sudo apt update sudo apt install \ gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \ libudev-dev:armhf libasound2-dev:armhf \ pkg-config git build-essential ----------------------------------------------------------------- 2) Grab RetroArch 1.9.0 git clone --branch v1.9.0 --depth 1 https://github.com/libretro/RetroArch.git cd RetroArch mkdir build && cd build ------------------------------------------------------------------------ 3) Set up your cross-env export PREFIX=/usr/arm-linux-gnueabihf export CC=arm-linux-gnueabihf-gcc export CXX=arm-linux-gnueabihf-g++ export AR=arm-linux-gnueabihf-ar export RANLIB=arm-linux-gnueabihf-ranlib export LD=arm-linux-gnueabihf-ld export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig ------------------------------------------------------------------ 4) Configure for static fbdev-only ../configure \ --host=arm-linux-gnueabihf \ --disable-shared \ # no .so libs --enable-static \ # bake everything into retroarch --enable-fbdev \ # use the Linux framebuffer --disable-sdl \ # skip SDL drivers --disable-wayland \ --disable-x \ --disable-opengl \ --disable-pulse \ --disable-alsa \ --disable-udev \ --disable-usb \ --disable-dynamic 5) Build & strip make -j$(nproc) $AR cru libretro-common.a libretro-common/*.o # ensure core code is in static lib $RANLIB libretro-common.a $CC -O2 -static -march=armv7-a -mfpu=neon -mfloat-abi=hard \ -o retroarch retroarch.o libretro-common.a ... # this is done by make arm-linux-gnueabihf-strip retroarch You should now have a single 'build/retroarch' binary. ------------------------------------------------------------------------------------- 6) Cross-compile the mGBA libretro core cd ~/RetroArch git clone --depth 1 https://github.com/libretro/libretro-mgba.git cd libretro-mgba make clean make -j$(nproc) \ CROSS_PREFIX=arm-linux-gnueabihf- \ HOST_CC=gcc \ HOST_CFLAGS="-O2" \ CORE=mgba \ STATIC=1 arm-linux-gnueabihf-strip mgba_libretro.so ---------------------------------------------------- 7) Install on your Kindle Mount your PW5 over USB (e.g. '/mnt/us'): mkdir -p /mnt/us/koreader/custom/{bin,libretro} cp build/retroarch /mnt/us/koreader/custom/bin/ cp libretro-mgba/mgba_libretro.so /mnt/us/koreader/custom/libretro/ chmod +x /mnt/us/koreader/custom/bin/retroarch --------------------------------------------------------- 8) Configure & launch in KOReader #1. Create '/mnt/us/koreader/custom/bin/retroarch.cfg' with: video_driver = "fbdev" libretro_directory = "/mnt/us/koreader/custom/libretro" input_analog_dpad_mode = "1" #2. In KOReader → Tools → More tools → External apps → retroarch - Load Core → mGBA - Load Content → pick your '.gba' rom. mGBA should now be running (but I'm not sure about the FPS...) If it works, please send the retroarch + mgba files so that everyone can use it. If it doesn't, please post back so that I can try to fix it. (And in the meantime, install gambatte-K2, that works perfectly (and probably better thatn gpSP/mGBA will)) ![]() |
![]() |
![]() |
![]() |
#7 |
Enthusiast
![]() ![]() ![]() Posts: 46
Karma: 200
Join Date: Feb 2025
Device: Kindle PW5
|
To create apps for Kindle, you need a cross compiler. The easiest is to install the kox toolkit on Linux, which is really for Kindle.
For the graphics, SDL is NOT supported by Kindle. You need some software that uses GTK2 toolkit, which is quite old. Kindle uses a stripped down Linux, so you might need to remove all the code that uses other libraries (or rebuild those libraries for Linux). Otherwise you'll have to rewrite the graphical part on FBInk. There are a few other things to remember, like the naming standard for the windows. The instructions are on Kindlemodding. After, it's straightforward: - Type make - Pray that it builds - Copy the executable on the Kindle - Launch it from kterm - pray that it runs - If everything is fine, write a wrapper for KUAL and publish it. Otherwise, back to point 1. Of course using a chrooted Linux can be a solution, it's much easier to put in place, but not sure that it will be as well adapted for Kindle touchscreen. Last edited by kbarni; 07-04-2025 at 12:01 PM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
REQUEST: Port of Fabled Lands Java app | carademono | Kindle Developer's Corner | 6 | 01-01-2023 11:02 AM |
Port Linux App or Java App? | cyclops0000 | Kindle Developer's Corner | 5 | 12-29-2014 01:32 PM |
Kindle 4 app development using serial port | tiniik | Kindle Developer's Corner | 3 | 10-06-2014 09:48 AM |
Classic Androind App Port/Optimizing for Nook E-ink | ppn | Nook Developer's Corner | 7 | 03-09-2012 04:41 AM |
Anyone tried to port X-Word Crossword Puzzle app yet? | brecklundin | PocketBook | 7 | 11-22-2009 03:13 AM |