BlitterStudio / amiberry

Optimized Amiga emulator for Linux/macOS
https://amiberry.com
GNU General Public License v3.0
626 stars 86 forks source link

Segfault on Odroid N2 (ARM 32 bits) #489

Closed shantigilbert closed 4 years ago

shantigilbert commented 5 years ago

Describe the bug Running Amiberry on Odroid N2 (in linux ARM 32bits) results in a segfault

To Reproduce Steps to reproduce the behavior: run amiberry

Expected behavior Run the game

Additional context The same version runs very good on Amlogic s905 platform but on Odroid N2 it segfauls

I compiled a version with debug symbold and I ran gdb but don't know what else to do

Reading symbols from /storage/downloads/bin/amiberry...done.
(gdb) r
Starting program: /storage/downloads/bin/amiberry -f /storage/.config/amiberry/conf/amiberry.conf -autowhdload=/storage/roms/amiga/RickDangerous_v1.3_2294.lha
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0xf6f64450 (LWP 6665)]
[New Thread 0xf65f0450 (LWP 6667)]
[New Thread 0xf4157450 (LWP 6669)]
[New Thread 0xf3956450 (LWP 6670)]
[New Thread 0xf3155450 (LWP 6671)]
[New Thread 0xf2954450 (LWP 6672)]
[New Thread 0xf2153450 (LWP 6673)]
[New Thread 0xf1952450 (LWP 6674)]
[New Thread 0xf1151450 (LWP 6675)]
[New Thread 0xf0950450 (LWP 6676)]
[New Thread 0xf014f450 (LWP 6677)]
[New Thread 0xef8c6450 (LWP 6678)]
[New Thread 0xedbfe450 (LWP 6679)]
[New Thread 0xed3fd450 (LWP 6680)]
[New Thread 0xecbfc450 (LWP 6681)]
[New Thread 0xec3fb450 (LWP 6682)]
[New Thread 0xebbfa450 (LWP 6683)]
[New Thread 0xeb3f9450 (LWP 6684)]

Thread 19 "AmigaScreen" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xeb3f9450 (LWP 6684)]
0xf459a842 in ?? () from /usr/lib/libGLESv2.so

let me know if you need any other info.

5schatten commented 5 years ago

well do you use "my" package for N2 builds? Because I guess you have to add a new platform patch then. My patch just added support for AMLGX (S905/X) but you need to make sure the N2 (S922X) cpu flags are correct since it has also ARM A73 cores and not only A53 ones. At least that could be possible, maybe it's related to the Mali G52MP which maybe needs updated drivers / handling by amiberry.

shantigilbert commented 5 years ago

well do you use "my" package for N2 builds? Because I guess you have to add a new platform patch then. My patch just added support for AMLGX (S905/X) but you need to make sure the N2 (S922X) cpu flags are correct since it has also ARM A73 cores and not only A53 ones. At least that could be possible, maybe it's related to the Mali G52MP which maybe needs updated drivers / handling by amiberry.

Yes using your (slightly modified, not yet uploaded) package and updated CPU flags, I don't think that is the problem.

CFLAGS += -march=armv8-a+crc -mtune=cortex-a73.cortex-a53 -mfpu=neon-fp-armv8

The problem as you also mentioned, seems to be in the MALI G52MP as it segfauls when trying to open the window or "AmigaScreen" but I have no idea how to proceed.

midwan commented 5 years ago

@shantigilbert Amiberry uses normal SDL2 functions to open the emulation screen and update it, which will of course talk to the GPU drivers in the system. Does the main GUI open? That also uses a similar mechanism (though it's less demanding for quick screen updates).

@5schatten What changes have you made? If they make sense to include, Pull Requests are welcome ;-)

midwan commented 5 years ago

Also worth noting here: I'm working on an update that will bring 64-bit support, so platforms like the N2 will be able to run that natively. It's also needed for the newer Android platforms.

shantigilbert commented 5 years ago

Nothing seems to open, not even the main GUI, it just crashes at startup, I use other emulators that also use SDL2 on the same platform and they seem to work fine.

64bit would be awesome, but in my case I use a 64-bit kernel, but a 32-bit userspace :)

midwan commented 5 years ago

@shantigilbert ok, then it's definitely related to something in SDL2 + GPU drivers. Did you use the MALI_GPU flag in the Makefile? It uses a workaround for the hardware cursor, which caused some crashes on other Mali-based platforms (so it basically renders it differently).

shantigilbert commented 5 years ago

@shantigilbert ok, then it's definitely related to something in SDL2 + GPU drivers. Did you use the MALI_GPU flag in the Makefile? It uses a workaround for the hardware cursor, which caused some crashes on other Mali-based platforms (so it basically renders it differently).

These is what I am using (which is also what @5schatten added)

else ifeq ($(PLATFORM),amlogic)
USE_SDL2 = 1
    CFLAGS += -march=armv8-a+crc -mtune=cortex-a73.cortex-a53 -mfpu=neon-fp-armv8
    CPPFLAGS += -DARMV6_ASSEMBLY -D_FILE_OFFSET_BITS=64 -DARMV6T2 -DUSE_ARMNEON -DARM_HAS_DIV -DUSE_SDL2 -DMALI_GPU -DUSE_RENDER_THREAD -DFASTERCYCLES
    HAVE_NEON = 1
    NAME  = amiberry
shantigilbert commented 5 years ago

Ahh I just tested without the -DMALI_GPU andit seems I got a GUI!

midwan commented 5 years ago

@shantigilbert yep, then it was the SDL2 cursor code that caused that crash. Check if it works further down, you may have issues with JIT also.

shantigilbert commented 5 years ago

I need to test with a game itself, I will update ASAP

midwan commented 5 years ago

Well, for games you don't normally need JIT anyway (it usually is a bad idea actually), but test it with Workbench.

shantigilbert commented 5 years ago

Seems I can get the GUI to open but no game :( maybe this time its me doing something wrong, I will do some more tests and report back.

5schatten commented 5 years ago

@midwan my Amlogic platform is basically a stripped vero4k platform without the optional include paths but it would make sense to add this as something like AMLGX instead of Amlogic since the newer SoCs use quite different cores & gpus :smile:

shantigilbert commented 5 years ago

No luck, only the GUI works but it does not load anything after that. any other flags I could try ?

besides these: CPPFLAGS += -DARMV6_ASSEMBLY -D_FILE_OFFSET_BITS=64 -DARMV6T2 -DUSE_ARMNEON -DARM_HAS_DIV -DUSE_SDL2 -DMALI_GPU -DUSE_RENDER_THREAD -DFASTERCYCLES

as soon as I try to run a disk/game whatever I get the same error in gdb:

Thread 1 "amiberry" received signal SIGSEGV, Segmentation fault.
0xf7127a14 in ?? () from /usr/lib/libSDL2-2.0.so.0
midwan commented 5 years ago

@shantigilbert Do you get to the Kickstart screen if you don't load any disks?

The only other flags I could think that might affect things would be the USE_ARMNEON and perhaps the USE_RENDER_THREAD.

shantigilbert commented 5 years ago

The only thing that loads is the gui, the one where you select all the options, not sure if that is the Kickstart screen. But as soon as I select a disk and click on start it crashes. Or if I give it a disk on the command line I don't even get a gui.

I will try with those flags and let you known. Thanks

midwan commented 5 years ago

@shantigilbert You do have Kickstarts in your defined path, right? Did you do a Rescan to detect them?

If all goes well, you should be able to select a Quickstart option from the GUI (e.g. A1200), then just click on Start without any disk in the drive. That will show you the Kickstart boot screen.

If you get that far, at least we'll know the emulation core and the Amiga screen works.

shantigilbert commented 5 years ago

Oh then yes, I get the GUI, Kickstart is selected, when I click on Start it gives the same error (if using gdb, else it just quits), same files work fine on my S905 so I am sure they work with Amiberry.

5schatten commented 5 years ago

@shantigilbert any progress about this? I got my Vim3 today and start to create some images too -> if there is something I can test I'm happy to do so :+1:

midwan commented 5 years ago

No, sorry. It will have to wait until I'm back from vacation I'm afraid.

On Mon, 1 Jul 2019, 14:26 5schatten notifications@github.com wrote:

@shantigilbert https://github.com/shantigilbert any progress about this? I got my Vim3 today and start to create some images too -> if there is something I can test I'm happy to do so 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/midwan/amiberry/issues/489?email_source=notifications&email_token=AA5ST5OUSFXCNGOJ7IJSCDLP5HSV5A5CNFSM4HYEVCZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY52JYQ#issuecomment-507225314, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5ST5OR77CIZK7GI4OQTQLP5HSV5ANCNFSM4HYEVCZQ .

5schatten commented 5 years ago

Have a nice time! ;-)

shantigilbert commented 5 years ago

No, unfortunately I could not find anything to solve this issue, but I also noted that the RA also has problems with amiberry on the odroid N2, so I am guessing it's something related to the new GPU.

midwan commented 4 years ago

Could someone please test the latest dev branch and report if this is still happening? Unfortunately I don't have an N2 to test with myself...

shantigilbert commented 4 years ago

Not working :(

with -DMALI_GPU

Starting program: /storage/downloads/amiberry -f /storage/.config/amiberry/conf/AmigaA500-default.uae -autowhdload=/storage/roms/amiga/RickDangerous_v1.3_2294.lha
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0xf6be1450 (LWP 5219)]
[Detaching after vfork from child process 5220]
[New Thread 0xf6300450 (LWP 5221)]
[New Thread 0xf3e57450 (LWP 5223)]
[New Thread 0xf3656450 (LWP 5224)]
[New Thread 0xf2e55450 (LWP 5225)]
[New Thread 0xf2654450 (LWP 5226)]
[New Thread 0xf1e53450 (LWP 5227)]
[New Thread 0xf1652450 (LWP 5228)]
[New Thread 0xf0e51450 (LWP 5229)]
[New Thread 0xf0650450 (LWP 5230)]
[New Thread 0xefe4f450 (LWP 5231)]
[New Thread 0xef64e450 (LWP 5233)]
[New Thread 0xeee4d450 (LWP 5234)]
[New Thread 0xed0fe450 (LWP 5235)]
[New Thread 0xec8fd450 (LWP 5236)]
[New Thread 0xec0fc450 (LWP 5237)]
[Thread 0xef64e450 (LWP 5233) exited]
[New Thread 0xef64e450 (LWP 5239)]
[New Thread 0xeb8fb450 (LWP 5240)]

Thread 19 "AmigaScreen" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xeb8fb450 (LWP 5240)]
0xf429a842 in ?? () from /usr/lib/libGLESv2.so

without -DMALI_GPU

Starting program: /storage/downloads/amiberry -f /storage/.config/amiberry/conf/AmigaA500-default.uae -autowhdload=/storage/roms/amiga/RickDangerous_v1.3_2294.lha
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0xf6cda450 (LWP 5246)]
[Detaching after vfork from child process 5247]
[New Thread 0xf63f9450 (LWP 5248)]
[New Thread 0xf3f57450 (LWP 5250)]
[New Thread 0xf3756450 (LWP 5251)]
[New Thread 0xf2f55450 (LWP 5252)]
[New Thread 0xf2754450 (LWP 5253)]
[New Thread 0xf1f53450 (LWP 5254)]
[New Thread 0xf1752450 (LWP 5255)]
[New Thread 0xf0f51450 (LWP 5256)]
[New Thread 0xf0750450 (LWP 5257)]
[New Thread 0xeff4f450 (LWP 5258)]
[New Thread 0xef74e450 (LWP 5260)]
[New Thread 0xeeecf450 (LWP 5261)]
[New Thread 0xed1fe450 (LWP 5262)]
[New Thread 0xec9fd450 (LWP 5263)]
[New Thread 0xec1fc450 (LWP 5264)]
[Thread 0xef74e450 (LWP 5260) exited]
[New Thread 0xef74e450 (LWP 5266)]
[New Thread 0xeb9fb450 (LWP 5267)]

Thread 19 "AmigaScreen" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xeb9fb450 (LWP 5267)]
0xf439a842 in ?? () from /usr/lib/libGLESv2.so
shantigilbert commented 4 years ago

What is the minimal configuration file I could use ? just to make sure it is not something on the conf I am passing.

midwan commented 4 years ago

@shantigilbert I'd recommend you start without a saved config first, just using Quickstart. Does selecting the default A500 model, then clicking on Start work? If not, there's something wrong in the very basics.

From what I can see above, the whole thing crashed when trying to fire up the rendering thread for the emulation screen. Have you tried without the -DUSE_RENDER_THREAD flag as well? That's the one that configures SDL2 to use multi-threading for rendering the emulation screen.

shantigilbert commented 4 years ago

Success! it seems -DUSE_RENDER_THREAD was the problem (probably all along?) this is what worked

CPPFLAGS += -DARMV6_ASSEMBLY -D_FILE_OFFSET_BITS=64 -DARMV6T2 -DUSE_ARMNEON -DARM_HAS_DIV -DUSE_SDL2 -DMALI_GPU -DFASTERCYCLES

I had to re-add -DMALI_GPU

midwan commented 4 years ago

@shantigilbert Great news! let me know how it works otherwise (e.g. JIT, JIT FPU are usual suspects).

shantigilbert commented 4 years ago

seems to be working fine, any game in particular I should try ? to check the performance ? also the Makefile will need to be changed

# Amlogic S905/S905X/S912 (AMLGXBB/AMLGXL/AMLGXM) e.g. Khadas VIM1/2 / S905X2 (AMLG12A) & S922X/A311D (AMLG12B) e.g. Khadas VIM3 - 32-bit userspace
else ifneq (,$(findstring AMLG,$(PLATFORM)))
USE_SDL2 = 1
    CFLAGS += -march=armv8-a+crc -mfloat-abi=hard -mfpu=neon-fp-armv8
    CPPFLAGS += -DARMV6_ASSEMBLY -D_FILE_OFFSET_BITS=64 -DARMV6T2 -DUSE_ARMNEON -DARM_HAS_DIV -DUSE_SDL2 -DMALI_GPU -DFASTERCYCLES
    HAVE_NEON = 1

    ifneq (,$(findstring AMLG12,$(PLATFORM)))
      ifneq (,$(findstring AMLG12B,$(PLATFORM)))
        CFLAGS += -mtune=cortex-a73.cortex-a53
        NAME  = amiberry-AMLG12B
      else
        CFLAGS += -mtune=cortex-a53
        NAME  = amiberry-AMLG12A
      endif
    else ifneq (,$(findstring AMLGX,$(PLATFORM)))
      CFLAGS += -mtune=cortex-a53
      CPPFLAGS += -DUSE_RENDER_THREAD
      NAME  = amiberry-AMLGX
    endif
midwan commented 4 years ago

@shantigilbert Is it the AMLGX target that you used? I can update the Makefile accordingly.

shantigilbert commented 4 years ago

The problem was with the AMLG12x (s922x) platform, the AMLGX (s905) has always worked

the code I posted is the Makefile already modified but let me try it in my s905 jut to make sure everything works as it should before you do the change.

shantigilbert commented 4 years ago

Yes using that modified Makefile everything runs on both platforms :) Thanks!

midwan commented 4 years ago

Awesome, thanks for the assistance!

5schatten commented 4 years ago

@midwan @shantigilbert Well who updates the Makefile then ^^?

EDIT Ah okay - it's already in the dev branch ;-)

midwan commented 4 years ago

@5schatten The Makefile is already updated in dev, as you can see from the commit above.