Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry 2 port #601

Closed
skmp opened this issue Feb 10, 2015 · 33 comments
Closed

Raspberry 2 port #601

skmp opened this issue Feb 10, 2015 · 33 comments
Labels

Comments

@skmp
Copy link
Member

@skmp skmp commented Feb 10, 2015

So, i'm waiting on my RaPi2, and others are already interested on this.

Let the fun begin.

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 10, 2015

If it's any help/interest, my makefile is at https://github.com/kingosticks/reicast-emulator/blob/raspberrypi/shell/rpi/Makefile
It's probably a bit over the top but it did get something. Looking forward to seeing the progress you guys make

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 10, 2015

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 10, 2015

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 10, 2015

It built fine with the arm-hardfp branch (wasted my time a bit there rolling my own) but i got the same fatal error as I got with the build from my fork: http://dpaste.com/11GQ3VT

When I tried your tegra build I got:

pi@raspberrypi ~ $ ./reicast.elf
./reicast.elf: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.15' not found (required by ./reicast.elf)

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 10, 2015

Your cross compiler seems bust, it uses newer libs that your target system. Can you test a simple hello word program?

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 10, 2015

I'm doing all my compilation on the raspberry pi. Sorry if I'm being dense
but does that explain mmap memory allocation failures?
On 10 Feb 2015 21:09, "Stefanos Kornilios Mitsis Poiitidis" <
notifications@github.com> wrote:

Your cross compiler seems bust, it uses newer libs that your target
system. Can you test a simple hello word program?


Reply to this email directly or view it on GitHub
#601 (comment)
.

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 10, 2015

My compiler is newer than your run-time, that's why it doesn't work. (Sorry missread that)

Do you have anything weird like SE linux or enabled? Is reicast run from a writable directory? Do you have /dev/shm available?

An strace would also be useful.

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 10, 2015

try running w/ root too

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 10, 2015

No SE linux or anything like that, this is stock raspbian. It is run from a writeable directory.

pi@raspberrypi ~ $ ls -l /dev/shm
lrwxrwxrwx 1 root root 8 Feb 10 00:21 /dev/shm -> /run/shm

And there is no difference when running using sudo.

http://dpaste.com/025MVM8 is the strace up until the failure, then there's a segmentation fault and everything goes a bit mental. I guess this bit is the mmap failure I pasted earlier:

write(1, "MAP 00800000 w/ 25165824\n", 25) = 25
3722 mmap2(0x56e40000, 2097152, PROT_READ, MAP_SHARED|MAP_FIXED, 3, 0x1800) = 0x56e40000
3722 mprotect(0x56e40000, 2097152, PROT_READ) = -1 EACCES (Permission denied)
3722 write(1, "MAP1 failed 13\n", 15) = 15

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 10, 2015

Would insufficient ram cause this error? How much is required? I think I've currently got a 256/768 GPU/SYS split.

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 11, 2015

reicast needs around 80 megs of ram + opengl overhead, I don't think that's the issue.

I don't see a reason why mprotect fails there. the region is already mapped as PROT_READ. ?!?

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 11, 2015

EACCES
The prot argument specifies a protection that violates the access permission the process has to the underlying memory object.

Hmm, perhaps it doesn't like the unliked shm ?

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 11, 2015

Perhaps but why would raspbian have a problem and none of the other
systems? I've no experience with that idea, is it common?
On 11 Feb 2015 08:22, "Stefanos Kornilios Mitsis Poiitidis" <
notifications@github.com> wrote:

EACCES
The prot argument specifies a protection that violates the access
permission the process has to the underlying memory object.

Hmm, perhaps it doesn't like the unliked shm ?


Reply to this email directly or view it on GitHub
#601 (comment)
.

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 11, 2015

Nope, but linux likes to fuck up these things on every 3rd kernel release (I already have a few workarounds for linaro and other arm boards messy mess).

on vmem.cpp try removing/commenting the "shm_unlink("/dcnzorz_mem");" line, build and run and tell me what happens :)

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 11, 2015

Commenting out that line fails the same way the first time I ran reicast.
But on subsequent runs, now that there's already a file at /dev/shm/dcnzorz_mem causing it to create and use a dcnzorz_mem file in the working directory, things get much further (they might even work if I had started x)!

http://dpaste.com/2JEBAQ7

So rather than being the unlink, it just looks like a problem when trying to mprotect an area of /dev/shm shared memory from READ+WRITE to READ only. Sounds like a reasonable thing to do. Perhaps it's just a permission problem on my raspbian system (the permissions are viewable in the above pasted log)?

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 12, 2015

Yay my rapi2 is here! :3

I couldn't make sense of the shm stuff -- the exact code works fine on many other linuxes. Oh well.

Moving on from there, I get a crash from the 3D drivers under X11. Craxy taxi boots and runs when 3d is disabled, I'm now updating the drivers...

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 12, 2015

New drivers make no difference. Hrfm.

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 12, 2015

Okay, it works now :D

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 12, 2015

Crazy taxi ingame ~ 75% emulation speed, just 4 fps rendering. The gpu is .. WEAK. Or software renderered.

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 12, 2015

I'll make a video and up sauce tomorrows, gotta REALLY get back to work now

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 12, 2015

Fantastic (that it's working)! Love to know what you did to make it work.
On 12 Feb 2015 00:47, "Stefanos Kornilios Mitsis Poiitidis" <
notifications@github.com> wrote:

I'll make a video and up sauce tomorrows, gotta REALLY get back to work
now


Reply to this email directly or view it on GitHub
#601 (comment)
.

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 13, 2015

Keeping in mind that everything I know about EGL, GLES and graphics was
what I read last night, don't you have to link against /opt/vc/lib to make
use of the Rpi's videocore graphics hardware? How else could it know how to
use it? And what does update your drivers mean? With rpi-update? I think my
issue might stem from using untested dc bios files.
But Im enjoying messing around with this project even without playing
anything - so thanks!

EDIT: I've now seen that it's X11 that takes care of the platform specific stuff to get the surface and display etc.

But presumably you still need to link with /opt/vc/lib to get any RPi hardware acceleration?

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 13, 2015

Had some free time today - check the skmp/rapi2 branch. Next up: videos about it :p

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 13, 2015

I also hardcoded joystick/keyboard support. You can select the file via -config config:image=path/to/file

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 15, 2015

Does keyboard support work? After changing the path to /dev/input/event0 (I made it configurable, is this something worth adding?) I see it prints the keypress events to the console but I can't actually control anything (i.e set the time in the bios). I noticed that only TARGET_GCW0 and TARGET_PANDORA do anything much in HandleKb, is there something I'm missing?

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 15, 2015

I uncommented the pandora ifdef and used that code. Did the trick and I can hurtle around Crazy Taxi! Awesome!

With the following output, is '5.98' the frames per second and is '83.98' the emulation speed percentage?

newdc rel0/n - 11.91 (0.00) - 83.98 - V: 50.34 (1.00, NTSC480i59.95) R: 5.98+44.36 VTX: 0.00

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 15, 2015

Yeah, 83.98% is the speed, 5.98 is the actual rendered frames, 44.36 is the skipped ones because the gpu was too slow

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 16, 2015

When just sitting at the Crazy Taxi menu screen I get 19 fps and 135 sfps (!). Running htop shows 3 threads, one of which ramps up to and remains at 100% cpu utilisation. Is that what you'd expect? Is it just spinning around getting the user input?

@kingosticks

This comment has been minimized.

Copy link

@kingosticks kingosticks commented Feb 17, 2015

Also, in other news, I sort of got the bottom of that mprotect failure. It seems that mounting /dev/shm with the noexec option is part of some new-fangled security improvements. If you remount it without that option then the normal _nvmem_alloc_mem code works just fine.

Related bug in Chrome OS: http://code.google.com/p/nativeclient/issues/detail?id=1883

You might reasonably argue that mprotect is only supposed to fail if trying to set PROT_EXEC on a noexec file (which we obviously aren't). BUT we are setting PROT_READ and there's a very suspicious READ_IMPLIES_EXEC flag, apparently for security compatibility. Strangely, mmap does take noexec into account when looking if read implies exec, and hence doesn't fail, but mprotect doesn't! That was fun.

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 24, 2015

Looks like I can modify the personality w/ #include <sys/personality.h> .. I'll check if that fixes the issue

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 25, 2015

I can verify that modifing personality does fix the issue

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Feb 25, 2015

The real question is why the personality bits get set on the elf (problem w/ upstream GCC configuration?). Other system elfs (eg, bash, cat, etc) don't have the READ_IMPLIES_EXEC flag, only LIMIT_32_BIT one (which makes sense). I guess we can leave that code as extra protection for broken toolchains 👍

@skmp

This comment has been minimized.

Copy link
Member Author

@skmp skmp commented Apr 11, 2018

Rpi2 works with master, and has been for a long time now

@skmp skmp closed this Apr 11, 2018
@skmp skmp added the Tracking label Jun 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.