Building a working dosbox core for Raspberry Pi 2

Hi, I’m trying to build a working dosbox core for Pi2, but I always get one that segfaults immediately, no matter what.

pi@raspberrypi:~/retro $ ./retroarch_dbg -v -L cores/dosbox_libretro.so prehist2/PRE2.EXE RetroArch [INFO] :: === Build =======================================RetroArch [INFO] :: [CPUID]: Features: Built: Feb 28 2016 RetroArch [INFO] :: Version: 1.3.0 RetroArch [INFO] :: Git: 5e4e30a RetroArch [INFO] :: ================================================= RetroArch [INFO] :: [CPUID]: Features: RetroArch [INFO] :: Looking for config in: “/home/pi/.config/retroarch/retroarch.cfg”. RetroArch [WARN] :: SYSTEM DIR is empty, assume CONTENT DIR RetroArch [INFO] :: Config: loading config from: /home/pi/.config/retroarch/retroarch.cfg. RetroArch [INFO] :: Loading dynamic libretro core from: “/home/pi/retro/cores/dosbox_libretro.so” RetroArch [INFO] :: Overrides: no core-specific overrides found at /home/pi/.config/retroarch/DOSBox/DOSBox.cfg RetroArch [INFO] :: Overrides: no game-specific overrides found at /home/pi/.config/retroarch/DOSBox/PRE2.cfg RetroArch [INFO] :: Environ SET_SUPPORT_NO_GAME: no. RetroArch [INFO] :: Environ SET_VARIABLES. RetroArch [INFO] :: Environ SET_CONTROLLER_INFO. RetroArch [INFO] :: Controller port: 1 RetroArch [INFO] :: Gamepad (2buttons) (ID: 517) RetroArch [INFO] :: Gamepad (4buttons) (ID: 1285) RetroArch [INFO] :: Joystick (2axis/2buttons) (ID: 261) RetroArch [INFO] :: Joystick (4axis/4buttons) (ID: 1029) RetroArch [INFO] :: Joystick (2axis/2buttons + kbd arrows) (ID: 773) RetroArch [INFO] :: Joystick (4axis/4buttons + kbd arrows) (ID: 1541) RetroArch [INFO] :: Controller port: 2 RetroArch [INFO] :: Gamepad (2buttons) (ID: 517) RetroArch [INFO] :: Gamepad (4buttons) (ID: 1285) RetroArch [INFO] :: Joystick (2axis/2buttons) (ID: 261) RetroArch [INFO] :: Joystick (4axis/4buttons) (ID: 1029) RetroArch [WARN] :: SYSTEM DIR is empty, assume CONTENT DIR prehist2/PRE2.EXE RetroArch [INFO] :: Environ SYSTEM_DIRECTORY: “prehist2/”. RetroArch [INFO] :: Environ SAVE_DIRECTORY: “”. RetroArch [INFO] :: Environ CORE_ASSETS_DIRECTORY: “/home/pi/.config/retroarch/downloads”. RetroArch [INFO] :: Remaps: core name: DOSBox RetroArch [INFO] :: Remaps: game name: PRE2 RetroArch [INFO] :: Remaps: remap directory: /home/pi/.config/retroarch/remap RetroArch [INFO] :: Remaps: no game-specific remap found at /home/pi/.config/retroarch/remap/DOSBox/PRE2.rmp RetroArch [INFO] :: Remaps: no core-specific remap found at /home/pi/.config/retroarch/remap/DOSBox/DOSBox.rmp RetroArch [INFO] :: Environ GET_LOG_INTERFACE. RetroArch [libretro INFO] :: Logger interface initialized… RetroArch [INFO] :: Environ SET_PIXEL_FORMAT: XRGB8888. RetroArch [INFO] :: Content loading skipped. Implementation will load it on its own. RetroArch [libretro INFO] :: Loading default configuration prehist2//DOSbox/dosbox-libretro.conf RetroArch [libretro INFO] :: =>>>>>No configuration found, using core options RetroArch [INFO] :: Environ GET_VARIABLE dosbox_machine_type: RetroArch [INFO] :: hercules RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_0: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_1: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_2: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_3: RetroArch [INFO] :: 1 Segmentation fault

This is the plarform I have defined for it on Makefile.libretro:

Raspberry Pi 2

else ifeq ($(platform), rpi2) TARGET := $(TARGET_NAME)_libretro.so LDFLAGS += -shared -Wl,–version-script=libretro/link.T fpic = -fPIC

ENDIANNESS_DEFINES := -DLSB_FIRST COMMONFLAGS += -DARM COMMONFLAGS += -mfloat-abi=hard COMMONFLAGS += -fomit-frame-pointer -fstrict-aliasing -ffast-math COMMONFLAGS += -DDISABLE_EXCEPTIONS IS_X86 := 0

I have tried disabling each one of these, I also tried using no platform at all, etc… No way to debug this either:

pi@raspberrypi:~/retro $ gdb --args ./retroarch_dbg -v -L cores/dosbox_libretro.so GNU gdb (Raspbian 7.7.1+dfsg-5) 7.7.1 Copyright © 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type “show copying” and “show warranty” for details. This GDB was configured as “arm-linux-gnueabihf”. Type “show configuration” for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type “help”. Type “apropos word” to search for commands related to “word”… Reading symbols from ./retroarch_dbg…done. (gdb) r Starting program: /home/pi/retro/retroarch_dbg -v -L cores/dosbox_libretro.so [Thread debugging using libthread_db enabled] Using host libthread_db library “/lib/arm-linux-gnueabihf/libthread_db.so.1”. [New Thread 0x76ab0460 (LWP 9206)] RetroArch [INFO] :: === Build =======================================RetroArch [INFO] :: [CPUID]: Features: Built: Feb 28 2016 RetroArch [INFO] :: Version: 1.3.0 RetroArch [INFO] :: Git: 5e4e30a RetroArch [INFO] :: ================================================= RetroArch [INFO] :: [CPUID]: Features: RetroArch [INFO] :: Looking for config in: “/home/pi/.config/retroarch/retroarch.cfg”. RetroArch [WARN] :: SYSTEM DIR is empty, assume CONTENT DIR RetroArch [INFO] :: Config: loading config from: /home/pi/.config/retroarch/retroarch.cfg. [New Thread 0x762b0460 (LWP 9207)] RetroArch [INFO] :: Loading dynamic libretro core from: “/home/pi/retro/cores/dosbox_libretro.so” RetroArch [INFO] :: Environ SET_SUPPORT_NO_GAME: no. RetroArch [INFO] :: Environ SET_VARIABLES. RetroArch [INFO] :: Environ SET_CONTROLLER_INFO. RetroArch [INFO] :: Controller port: 1 RetroArch [INFO] :: Gamepad (2buttons) (ID: 517) RetroArch [INFO] :: Gamepad (4buttons) (ID: 1285) RetroArch [INFO] :: Joystick (2axis/2buttons) (ID: 261) RetroArch [INFO] :: Joystick (4axis/4buttons) (ID: 1029) RetroArch [INFO] :: Joystick (2axis/2buttons + kbd arrows) (ID: 773) RetroArch [INFO] :: Joystick (4axis/4buttons + kbd arrows) (ID: 1541) RetroArch [INFO] :: Controller port: 2 RetroArch [INFO] :: Gamepad (2buttons) (ID: 517) RetroArch [INFO] :: Gamepad (4buttons) (ID: 1285) RetroArch [INFO] :: Joystick (2axis/2buttons) (ID: 261) RetroArch [INFO] :: Joystick (4axis/4buttons) (ID: 1029) RetroArch [WARN] :: SYSTEM DIR is empty, assume CONTENT DIR RetroArch [INFO] :: Environ SYSTEM_DIRECTORY: “”. RetroArch [INFO] :: Environ SAVE_DIRECTORY: “”. RetroArch [INFO] :: Environ CORE_ASSETS_DIRECTORY: “/home/pi/.config/retroarch/downloads”. RetroArch [INFO] :: Environ GET_LOG_INTERFACE. RetroArch [libretro INFO] :: Logger interface initialized… RetroArch [INFO] :: Environ SET_PIXEL_FORMAT: XRGB8888. RetroArch [INFO] :: libretro core requires content, but nothing was provided. RetroArch [libretro INFO] :: =>>>>>No configuration found, using core options RetroArch [INFO] :: Environ GET_VARIABLE dosbox_machine_type: RetroArch [INFO] :: hercules RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_0: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_1: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_2: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_3: RetroArch [INFO] :: 1

Program received signal SIGSEGV, Segmentation fault. 0x2d544542 in ?? () (gdb) bt #0 0x2d544542 in ?? () #1 0x0a332f30 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb)

Both retroarch and the dosbox core were built with the DEBUG=1 parameter and I verified -O0 -g was passed to the compiler in both cases with verbose building when needed.

So, whoever has already gotten a dosbox core working on arm+linux, can you lend a hand? Thanks

[QUOTE=vanfanel;35006]Hi, I’m trying to build a working dosbox core for Pi2, but I always get one that segfaults immediately, no matter what.

pi@raspberrypi:~/retro $ ./retroarch_dbg -v -L cores/dosbox_libretro.so prehist2/PRE2.EXE RetroArch [INFO] :: === Build =======================================RetroArch [INFO] :: [CPUID]: Features: Built: Feb 28 2016 RetroArch [INFO] :: Version: 1.3.0 RetroArch [INFO] :: Git: 5e4e30a RetroArch [INFO] :: ================================================= RetroArch [INFO] :: [CPUID]: Features: RetroArch [INFO] :: Looking for config in: “/home/pi/.config/retroarch/retroarch.cfg”. RetroArch [WARN] :: SYSTEM DIR is empty, assume CONTENT DIR RetroArch [INFO] :: Config: loading config from: /home/pi/.config/retroarch/retroarch.cfg. RetroArch [INFO] :: Loading dynamic libretro core from: “/home/pi/retro/cores/dosbox_libretro.so” RetroArch [INFO] :: Overrides: no core-specific overrides found at /home/pi/.config/retroarch/DOSBox/DOSBox.cfg RetroArch [INFO] :: Overrides: no game-specific overrides found at /home/pi/.config/retroarch/DOSBox/PRE2.cfg RetroArch [INFO] :: Environ SET_SUPPORT_NO_GAME: no. RetroArch [INFO] :: Environ SET_VARIABLES. RetroArch [INFO] :: Environ SET_CONTROLLER_INFO. RetroArch [INFO] :: Controller port: 1 RetroArch [INFO] :: Gamepad (2buttons) (ID: 517) RetroArch [INFO] :: Gamepad (4buttons) (ID: 1285) RetroArch [INFO] :: Joystick (2axis/2buttons) (ID: 261) RetroArch [INFO] :: Joystick (4axis/4buttons) (ID: 1029) RetroArch [INFO] :: Joystick (2axis/2buttons + kbd arrows) (ID: 773) RetroArch [INFO] :: Joystick (4axis/4buttons + kbd arrows) (ID: 1541) RetroArch [INFO] :: Controller port: 2 RetroArch [INFO] :: Gamepad (2buttons) (ID: 517) RetroArch [INFO] :: Gamepad (4buttons) (ID: 1285) RetroArch [INFO] :: Joystick (2axis/2buttons) (ID: 261) RetroArch [INFO] :: Joystick (4axis/4buttons) (ID: 1029) RetroArch [WARN] :: SYSTEM DIR is empty, assume CONTENT DIR prehist2/PRE2.EXE RetroArch [INFO] :: Environ SYSTEM_DIRECTORY: “prehist2/”. RetroArch [INFO] :: Environ SAVE_DIRECTORY: “”. RetroArch [INFO] :: Environ CORE_ASSETS_DIRECTORY: “/home/pi/.config/retroarch/downloads”. RetroArch [INFO] :: Remaps: core name: DOSBox RetroArch [INFO] :: Remaps: game name: PRE2 RetroArch [INFO] :: Remaps: remap directory: /home/pi/.config/retroarch/remap RetroArch [INFO] :: Remaps: no game-specific remap found at /home/pi/.config/retroarch/remap/DOSBox/PRE2.rmp RetroArch [INFO] :: Remaps: no core-specific remap found at /home/pi/.config/retroarch/remap/DOSBox/DOSBox.rmp RetroArch [INFO] :: Environ GET_LOG_INTERFACE. RetroArch [libretro INFO] :: Logger interface initialized… RetroArch [INFO] :: Environ SET_PIXEL_FORMAT: XRGB8888. RetroArch [INFO] :: Content loading skipped. Implementation will load it on its own. RetroArch [libretro INFO] :: Loading default configuration prehist2//DOSbox/dosbox-libretro.conf RetroArch [libretro INFO] :: =>>>>>No configuration found, using core options RetroArch [INFO] :: Environ GET_VARIABLE dosbox_machine_type: RetroArch [INFO] :: hercules RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_0: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_1: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_2: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_3: RetroArch [INFO] :: 1 Segmentation fault

This is the plarform I have defined for it on Makefile.libretro:

Raspberry Pi 2

else ifeq ($(platform), rpi2) TARGET := $(TARGET_NAME)_libretro.so LDFLAGS += -shared -Wl,–version-script=libretro/link.T fpic = -fPIC

ENDIANNESS_DEFINES := -DLSB_FIRST COMMONFLAGS += -DARM COMMONFLAGS += -mfloat-abi=hard COMMONFLAGS += -fomit-frame-pointer -fstrict-aliasing -ffast-math COMMONFLAGS += -DDISABLE_EXCEPTIONS IS_X86 := 0

I have tried disabling each one of these, I also tried using no platform at all, etc… No way to debug this either:

pi@raspberrypi:~/retro $ gdb --args ./retroarch_dbg -v -L cores/dosbox_libretro.so GNU gdb (Raspbian 7.7.1+dfsg-5) 7.7.1 Copyright © 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type “show copying” and “show warranty” for details. This GDB was configured as “arm-linux-gnueabihf”. Type “show configuration” for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type “help”. Type “apropos word” to search for commands related to “word”… Reading symbols from ./retroarch_dbg…done. (gdb) r Starting program: /home/pi/retro/retroarch_dbg -v -L cores/dosbox_libretro.so [Thread debugging using libthread_db enabled] Using host libthread_db library “/lib/arm-linux-gnueabihf/libthread_db.so.1”. [New Thread 0x76ab0460 (LWP 9206)] RetroArch [INFO] :: === Build =======================================RetroArch [INFO] :: [CPUID]: Features: Built: Feb 28 2016 RetroArch [INFO] :: Version: 1.3.0 RetroArch [INFO] :: Git: 5e4e30a RetroArch [INFO] :: ================================================= RetroArch [INFO] :: [CPUID]: Features: RetroArch [INFO] :: Looking for config in: “/home/pi/.config/retroarch/retroarch.cfg”. RetroArch [WARN] :: SYSTEM DIR is empty, assume CONTENT DIR RetroArch [INFO] :: Config: loading config from: /home/pi/.config/retroarch/retroarch.cfg. [New Thread 0x762b0460 (LWP 9207)] RetroArch [INFO] :: Loading dynamic libretro core from: “/home/pi/retro/cores/dosbox_libretro.so” RetroArch [INFO] :: Environ SET_SUPPORT_NO_GAME: no. RetroArch [INFO] :: Environ SET_VARIABLES. RetroArch [INFO] :: Environ SET_CONTROLLER_INFO. RetroArch [INFO] :: Controller port: 1 RetroArch [INFO] :: Gamepad (2buttons) (ID: 517) RetroArch [INFO] :: Gamepad (4buttons) (ID: 1285) RetroArch [INFO] :: Joystick (2axis/2buttons) (ID: 261) RetroArch [INFO] :: Joystick (4axis/4buttons) (ID: 1029) RetroArch [INFO] :: Joystick (2axis/2buttons + kbd arrows) (ID: 773) RetroArch [INFO] :: Joystick (4axis/4buttons + kbd arrows) (ID: 1541) RetroArch [INFO] :: Controller port: 2 RetroArch [INFO] :: Gamepad (2buttons) (ID: 517) RetroArch [INFO] :: Gamepad (4buttons) (ID: 1285) RetroArch [INFO] :: Joystick (2axis/2buttons) (ID: 261) RetroArch [INFO] :: Joystick (4axis/4buttons) (ID: 1029) RetroArch [WARN] :: SYSTEM DIR is empty, assume CONTENT DIR RetroArch [INFO] :: Environ SYSTEM_DIRECTORY: “”. RetroArch [INFO] :: Environ SAVE_DIRECTORY: “”. RetroArch [INFO] :: Environ CORE_ASSETS_DIRECTORY: “/home/pi/.config/retroarch/downloads”. RetroArch [INFO] :: Environ GET_LOG_INTERFACE. RetroArch [libretro INFO] :: Logger interface initialized… RetroArch [INFO] :: Environ SET_PIXEL_FORMAT: XRGB8888. RetroArch [INFO] :: libretro core requires content, but nothing was provided. RetroArch [libretro INFO] :: =>>>>>No configuration found, using core options RetroArch [INFO] :: Environ GET_VARIABLE dosbox_machine_type: RetroArch [INFO] :: hercules RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_0: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_1: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_2: RetroArch [INFO] :: 0 RetroArch [INFO] :: Environ GET_VARIABLE dosbox_cpu_cycles_3: RetroArch [INFO] :: 1

Program received signal SIGSEGV, Segmentation fault. 0x2d544542 in ?? () (gdb) bt #0 0x2d544542 in ?? () #1 0x0a332f30 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb)

Both retroarch and the dosbox core were built with the DEBUG=1 parameter and I verified -O0 -g was passed to the compiler in both cases with verbose building when needed.

So, whoever has already gotten a dosbox core working on arm+linux, can you lend a hand? Thanks[/QUOTE]

Hi vanfanel ,

maybe related to the wrong libco https://github.com/libretro/dosbox-libretro/blob/master/libco/armeabi.c

could you try with ptr[8] = (uintptr_t)ptr + size + 256 - 8; /* r13, stack pointer / instead of ,ptr[8] = (uintptr_t)ptr + size + 256 - 4; / r13, stack pointer */

and with adding -marm (instead of default thumb mode) in your cflags COMMONFLAGS

@r-type: it was wrong libco… now it’s working. I guess libco should be updated on this. How can that be done, appart from the manual solution you gave me? Is there a newer libco anywhere?

yes , many cores ( i had the pb with atari800 and other cores too ) use old libco with bad align 8byte for arm , the good one is the one in https://github.com/libretro/libretro-common . so a PR to use libretro-common could be a good idea.

@r-type: can you please buid the dosbox core on the Rpi and test keyboard input? It doesn’t work at all here. Maybe it’s libco too? I don’t know anybody else building the dosbox core on arm/linux, so that’s why I am asking you to try.

don’t have rpi2 here ,but tested with a bananapi and keyboard not working at all , it works on my x86_64 linux but the key repeat until you hit another .

i don’t like the libretro keyboard callback as it never work the same under different implementation (udev/linuxraw/Xinput …) it’s why i use kind of code in my port Key_Sate[i]=input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,i) ? 0x80: 0;

here is an sample of what can be done to fix kbd poll (note that is far incomplete as not all keys are handle and no handle of key modifiers )

http://pastebin.com/ZdgbWVai

It would be better to fix it in the retroarch side of things though. This is an important bug on the drivers.

Side note, it’s working perfectly fine in windows, so it’s most likely a RetroArch bug.

@r-type: try latest RetroArch git with dosbox core on the libretro git account, on the Banana Pi, Rpi2 or what you have at hand: keyboard works now,so you can stop adding the polling method. :slight_smile: