View Single Post
Old 06-28-2025, 04:56 AM   #5
HenriHenry
Enthusiast
HenriHenry began at the beginning.
 
Posts: 28
Karma: 10
Join Date: Jun 2025
Device: Kindle PW5
Lightbulb

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.
HenriHenry is offline   Reply With Quote