Previous Thread
Next Thread
Print Thread
Page 1 of 2 1 2
MAME compilation on ARM Linux - OLPC laptop #73469
09/27/11 12:19 AM
09/27/11 12:19 AM
Joined: Sep 2011
Posts: 5
F
fsmunoz Offline OP
Member
fsmunoz  Offline OP
Member
F
Joined: Sep 2011
Posts: 5
Hi there,

I'm having a hard time compiling MAME 0.140 on a prototype of the XO 1.75 laptop. It features a Marvell Armada 1Ghz ARMv7 processor and according to the specs it has 2x128MB RAM. It runs a custom Fedora 14-based linux distribution with a 3.0 kernel.

After having some issues with AdvanceMAME and MAME4all I decided to directly give the genuine MAME a try...

I've had to do some modifications to get this compiling:

- The first compilation try complained about the function "osd_yield_processor" not being declared. This thread suggested that it might be needed to implement is as a stub. So I modified src/osd/sdl/osinline.h as follows:

Code:
(snipped)
#endif

//<ADDED>
#else

#ifndef YieldProcessor
#define YieldProcessor() do {} while (0)
#define osd_yield_processor() YieldProcessor()
#endif
//</ADDED>


#endif /* __OSINLINE__ */


This got me through that. But more problems appeared upon compilation:

Code:
src/emu/memory.h: In member function ‘UINT16 direct_read_data::read_raw_word(offs_t, offs_t)’:
src/emu/memory.h:760:84: warning: cast from ‘UINT8*’ to ‘UINT16*’ increases required alignment of target type


This has been seen in the past and one of the posts in the forum suggested this in order to accept these warnings and keep on with the compilation instead of stopping:

Code:
make OPTIMIZE=0 DEBUG=1  


This again gets me through that stage... although I get these messages popping up upon compilation of pretty much every module of the project (apparently src/emu/memory.h is included in all of them and invokes osinline.h?) but now I have a different problem, see log below.

This looks to me like a genuine out of memory condition in GCC, so I´m in need of some advice:

- Should MAME be able to compile with these resources?
- I'm by far not a programming ninja, so I wonder... might this OOM condition be due to the fact that I'm "not optimizing" and probably leaking memory by casting "‘UINT8*’ to ‘UINT16*’"?
- Any suggestions?

This is the log of the last compilation. I had disabled X, NetworkManager and every other memory-consuming process I could think of:

Code:
-bash-4.1# make OPTIMIZE=0 DEBUG=1

Compiling src/emu/cpu/tms57002/tms57002.c...
(snipped)
[  119.381701] cc1plus invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0, oom_score_adj=0
[  119.390289] [<c00339ac>] (unwind_backtrace+0x0/0x120) from [<c008b838>] (dump_header.clone.15+0x74/0x1a4)
[  119.399859] [<c008b838>] (dump_header.clone.15+0x74/0x1a4) from [<c008babc>] (oom_kill_process.clone.18+0x3c/0x270)
[  119.410255] [<c008babc>] (oom_kill_process.clone.18+0x3c/0x270) from [<c008c120>] (out_of_memory+0x2a4/0x378)
[  119.420117] [<c008c120>] (out_of_memory+0x2a4/0x378) from [<c008f46c>] (__alloc_pages_nodemask+0x4ac/0x580)
[  119.429811] [<c008f46c>] (__alloc_pages_nodemask+0x4ac/0x580) from [<c008ac88>] (filemap_fault+0x2f4/0x41c)
[  119.429830] [<c008ac88>] (filemap_fault+0x2f4/0x41c) from [<c009f668>] (__do_fault+0x50/0x404)
[  119.448068] [<c009f668>] (__do_fault+0x50/0x404) from [<c00a24bc>] (handle_pte_fault+0x278/0x690)
[  119.456906] [<c00a24bc>] (handle_pte_fault+0x278/0x690) from [<c00a29a0>] (handle_mm_fault+0xcc/0xdc)
[  119.466103] [<c00a29a0>] (handle_mm_fault+0xcc/0xdc) from [<c0035274>] (do_page_fault+0xdc/0x1c8)
[  119.474912] [<c0035274>] (do_page_fault+0xdc/0x1c8) from [<c00282f0>] (do_PrefetchAbort+0x34/0x98)
[  119.483857] [<c00282f0>] (do_PrefetchAbort+0x34/0x98) from [<c002e020>] (ret_from_exception+0x0/0x10)
[  119.493010] Exception stack(0xda6affb0 to 0xda6afff8)
[  119.493020] ffa0:                                     009e5dac 0000001c 0fe8842c 00000004
[  119.506158] ffc0: 0fe85f28 00000000 009e5da4 0114c960 0fe88410 00000071 00000000 010dda40
[  119.514304] ffe0: 00000000 be893680 003a8c14 00079aa4 80000010 ffffffff
[  119.520875] Mem-info:
[  119.520885] Normal per-cpu:
[  119.523133] CPU    0: hi:  186, btch:  31 usd:   8
[  119.530663] active_anon:101990 inactive_anon:428 isolated_anon:0
[  119.530685]  active_file:0 inactive_file:33 isolated_file:0
[  119.530694]  unevictable:8 dirty:0 writeback:0 unstable:0
[  119.530702]  free:693 slab_reclaimable:642 slab_unreclaimable:1055
[  119.530709]  mapped:397 shmem:559 pagetables:744 bounce:0
slab_unreclaimable:4220kB kernel_stack:1464kB pagetables:2976kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:316 all_unreclaimable? yes
[  119.598208] lowmem_reserve[]: 0 0
[  119.610377] 592 total pagecache pages
[  119.614542] 0 pages in swap cache
[  119.621468] Swap cache stats: add 0, delete 0, find 0/0
[  119.626645] Free swap  = 0kB
[  119.626645] Total swap = 0kB
[  119.639725] 128768 pages of RAM
[  119.652120] 5038 free pages
[  119.652128] 17304 reserved pages
[  119.654896] 1697 slab pages
[  119.660867] 960 pages shared
[  119.660874] 0 pages swap cached
[  119.666838] [ pid ]   uid  tgid total_vm      rss cpu oom_adj oom_score_adj name
[  119.674186] [  155]     0   155      447       15   0       0             0 agetty
[  119.681732] [  174]     0   174      593       95   0     -17         -1000 udevd
[  119.689184] [  212]     0   212      592       94   0     -17         -1000 udevd
[  119.696639] [  213]     0   213      592       95   0     -17         -1000 udevd
[  119.704072] [  525]     0   525      663       13   0       0             0 system-setup-ke
[  119.712384] [  578]     0   578     7522      100   0       0             0 rsyslogd
[  119.720089] [  593]    81   593      931      165   0       0             0 dbus-daemon
[  119.720105] [  608]     0   608     6918      166   0       0             0 NetworkManager
[  119.736269] [  618]     0   618     1309       97   0       0             0 modem-manager
[  119.744410] [  623]     0   623     6197      200   0       0             0 polkitd
[  119.752024] [  626]    70   626      764       50   0       0             0 avahi-daemon
[  119.760086] [  627]    70   627      764       39   0       0             0 avahi-daemon
[  119.760086] [  650]     0   650     1162      137   0       0             0 crond
[  119.775568] [  655]     0   655     1493       91   0       0             0 wpa_supplicant
[  119.783786] [  665]     0   665      767      111   0       0             0 powerd
[  119.791303] [  666]     0   666      468       34   0       0             0 olpc-kbdshim-ud
[  119.791317] [  667]     0   667      588       30   0       0             0 olpc-dm
[  119.807230] [  673]     0   673      446       15   0       0             0 mingetty
[  119.814915] [  676]     0   676      446       15   0       0             0 mingetty
[  119.822630] [  677]     0   677    19556     1408   0       0             0 X
[  119.822630] [  792]     0   792     6976      216   0       0             0 console-kit-dae
[  119.838014] [  795]     0   795     1950       97   0       0             0 powerd-dbus
[  119.845998] [  868]     0   868      444       15   0       0             0 olpc-switchd
[  119.854045] [  889]   500   889     9313      262   0       0             0 gnome-session
[  119.862176] [  897]   500   897      850       52   0       0             0 dbus-launch
[  119.870138] [  898]   500   898     1187      178   0       0             0 dbus-daemon
[  119.870138] [  967]   500   967     2255      323   0       0             0 gconfd-2
[  119.885779] [  998]   500   998     8783      126   0       0             0 gnome-keyring-d
[  119.894105] [ 1001]   500  1001    29705      435   0       0             0 gnome-settings-
[  119.902412] [ 1005]   500  1005     2058       70   0       0             0 gvfsd
[  119.909856] [ 1011]   500  1011    14779      434   0       0             0 metacity
[  119.917545] [ 1017]   500  1017     2251      120   0       0             0 gvfs-gdu-volume
[  119.925839] [ 1019]     0  1019     3761      109   0       0             0 udisks-daemon
[  119.933973] [ 1020]     0  1020     1423       53   0       0             0 udisks-daemon
[  119.942121] [ 1021]   500  1021    12760      776   0       0             0 gnome-panel
[  119.950079] [ 1024]   500  1024    20534      902   0       0             0 nautilus
[  119.950079] [ 1027]   500  1027     7136      133   0       0             0 bonobo-activati
[  119.966080] [ 1033]   500  1033    10735      505   0       0             0 wnck-applet
[  119.974040] [ 1036]   500  1036     6877      204   0       0             0 polkit-gnome-au
[  119.982332] [ 1037]   500  1037     9541      622   0       0             0 nm-applet
[  119.990118] [ 1038]   500  1038     8228     1598   0       0             0 batti
[  119.990132] [ 1044]   500  1044    13994      688   0       0             0 clock-applet
[  120.005615] [ 1046]   500  1046     9972      352   0       0             0 notification-ar
[  120.013926] [ 1058]   500  1058     2195      109   0       0             0 gvfsd-trash
[  120.021875] [ 1087]     0  1087     4617      139   0       0             0 upowerd
[  120.029492] [ 1122]     0  1122     2189      461   0       0             0 dhclient
[  120.037183] [ 1132]   500  1132     1887       69   0       0             0 gvfsd-metadata
[  120.045403] [ 1177]   500  1177    13098      616   0       0             0 gnome-terminal
[  120.053625] [ 1180]   500  1180      473       23   0       0             0 gnome-pty-helpe
[  120.061943] [ 1181]   500  1181     1246       72   0       0             0 bash
[  120.061943] [ 1247]   500  1247     2130     1143   0       0             0 make
[  120.076625] [ 1265]   500  1265      669       55   0       0             0 gcc
[  120.083916] [ 1284]   500  1284     1011       22   0       0             0 gcc
[  120.091187] [ 1285]   500  1285    92644    87679   0       0             0 cc1plus
[  120.091203] [ 1286]   500  1286     1886     1129   0       0             0 as
[  120.105989] Out of memory: Kill process 1285 (cc1plus) score 745 or sacrifice child
[  120.113606] Killed process 1285 (cc1plus) total-vm:370576kB, anon-rss:350716kB, file-rss:0kB
[  152.392582] olpc-ec-1.75: got event 04
[olpc@xo-6d-61-b9 mame]$ 


Thanks for taking the time to read this, and any advice is more than welcome!!

Best
F




Last edited by R. Belmont; 10/21/11 06:35 PM. Reason: more width fixes?
Re: MAME compilation on ARM Linux - OLPC laptop [Re: fsmunoz] #73470
09/27/11 12:31 AM
09/27/11 12:31 AM
Joined: Mar 2001
Posts: 16,020
USA
R
R. Belmont Offline
Very Senior Member
R. Belmont  Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,020
USA
The problem you're having is that tms57002.c is huge - GCC requires something like a 2 GB working set to process it, and so it takes literally an hour to compile on e.g. PS3 Linux with 256 MB of RAM. I strongly recommend using a cross-compiler on a better-specced PC if you have one available. Otherwise you'll need to configure your swap partition to be at least 2 GB and then compilation should complete, it will just take a very long time.

Re: MAME compilation on ARM Linux - OLPC laptop [Re: fsmunoz] #73488
09/29/11 01:10 AM
09/29/11 01:10 AM
Joined: Sep 2011
Posts: 5
F
fsmunoz Offline OP
Member
fsmunoz  Offline OP
Member
F
Joined: Sep 2011
Posts: 5
Thanks a lot for the advice! you were absolutely right: I upped the code (including the .o modules I had already compiled) onto a machine with 3GB RAM and the same processor and the compilation finished.

Now I've got a 58M (!) executable in /usr/games/mame, a symbolic link /usr/bin/mame, a /etc/mame/mame.ini file pointing to /usr/share/games/mame/XXX and my roms under this one.

Everything seems to be in place: executing mame (under a normal user) brings up the menu, the roms are recognized and I can type the name of the rom I want to load. There are several issues though:

- Cursor arrows don't work in the menu to select a game (the highlight doesn't move and stays on the first ROM of the list). I can type anything and it seems to work (the message after "Type name or select:" is updated.
- Pressing ENTER with the first game of the list highlighted doesn't do anything or load anything.
- If I go to command line and do "mame outrun" I get a nice Segmentation Fault. Same with outrun.zip or the full ROM path. Same with other ROMs.

Curiously enough, "sudo mame" makes a difference: it actually sets the screen black and tries to load the game. And "sudo mame tehkanwc" also sets the screen black and gets to the "Initializing" stage. The exits and sometimes gives a Segmentation Fault.

Any thoughts on where to start debugging?

Thanks a lot!

F



Re: MAME compilation on ARM Linux - OLPC laptop [Re: fsmunoz] #73489
09/29/11 02:56 AM
09/29/11 02:56 AM
Joined: Mar 2001
Posts: 16,020
USA
R
R. Belmont Offline
Very Senior Member
R. Belmont  Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,020
USA
Regarding the arrows, I would assume they're mapped the same as on normal desktop Fedora, so I'm not sure why that wouldn't work. Some laptops do weird things with F-Lock keys and the like - is there possibly something like that in play here?

Otherwise, line 1310 of src/osd/sdl/input.c should be:
Code:
			//printf("Key down %d %d %s => %d %s (scrlock keycode is %d)\n", event.key.which, event.key.keysym.scancode, devinfo->name, OSD_SDL_INDEX_KEYSYM(&event.key.keysym), sdl_key_trans_table[event.key.keysym.scancode].mame_key_name, KEYCODE_SCRLOCK);


Uncomment that and change it to this to compile on latest:

Code:
			printf("Key down %d %d %s => %d\n", event.key.which, event.key.keysym.scancode, devinfo->name, OSD_SDL_INDEX_KEYSYM(&event.key.keysym));


and see what codes you get when you press the arrow keys.

On my Fedora 15 machine, up, down, left, right prints this in the TTY with that change:

Code:
Key down 0 111 System keyboard => 273
Key down 0 116 System keyboard => 274
Key down 0 113 System keyboard => 276
Key down 0 114 System keyboard => 275



Regarding the crashes, build with SYMBOLS=1 if you haven't already and post a GDB backtrace and we'll see what we can see.

Re: MAME compilation on ARM Linux - OLPC laptop [Re: fsmunoz] #73719
10/17/11 01:12 AM
10/17/11 01:12 AM
Joined: Sep 2011
Posts: 5
F
fsmunoz Offline OP
Member
fsmunoz  Offline OP
Member
F
Joined: Sep 2011
Posts: 5
Hi again and thanks for your reply. It took me some time but I managed to get some traces. I'm not sure whether they'll be representative though:

This is running Mame and pressing the arrow keys in the menu (no effect on the MAME cursor), and pressing the name of a game (the game that matches is highlighted, but pressing ENTER doesn't work either)

Code:
[olpc@xo-6d-61-b9 Desktop]$ ./mamed 
socket(): Address family not supported by protocol
Key down 0 111 System keyboard
Key down 0 116 System keyboard
Key down 0 116 System keyboard
Key down 0 116 System keyboard
Key down 0 116 System keyboard
Key down 0 116 System keyboard
Key down 0 111 System keyboard
Key down 0 111 System keyboard
Key down 0 111 System keyboard
ALSA lib pcm.c:7316:(snd_pcm_recover) underrun occurred
Key down 0 111 System keyboard
Key down 0 111 System keyboard
Key down 0 23 System keyboard
Key down 0 23 System keyboard
Key down 0 23 System keyboard
Key down 0 23 System keyboard
Key down 0 23 System keyboard
Key down 0 38 System keyboard
Key down 0 26 System keyboard
Key down 0 54 System keyboard
Key down 0 38 System keyboard
Key down 0 40 System keyboard
ALSA lib pcm.c:7316:(snd_pcm_recover) underrun occurred
Key down 0 22 System keyboard
Key down 0 22 System keyboard
Key down 0 22 System keyboard
Key down 0 22 System keyboard
Key down 0 22 System keyboard
Key down 0 27 System keyboard
Key down 0 54 System keyboard
Key down 0 38 System keyboard
Key down 0 22 System keyboard
Key down 0 38 System keyboard
Key down 0 36 System keyboard
Key down 0 111 System keyboard
Key down 0 116 System keyboard
Key down 0 9 System keyboard
Key down 0 9 System keyboard
Key down 0 9 System keyboard
Key down 0 111 System keyboard
Key down 0 111 System keyboard
Key down 0 111 System keyboard
Key down 0 116 System keyboard
Key down 0 116 System keyboard
Key down 0 36 System keyboard
Key down 0 36 System keyboard
Key down 0 62 System keyboard
Key down 0 36 System keyboard
Key down 0 62 System keyboard
Key down 0 62 System keyboard
Key down 0 49 System keyboard
Key down 0 9 System keyboard
Key down 0 9 System keyboard
Key down 0 9 System keyboard
Key down 0 9 System keyboard
Key down 0 9 System keyboard
Key down 0 9 System keyboard
Key down 0 22 System keyboard
Key down 0 22 System keyboard
Key down 0 64 System keyboard
Key down 0 37 System keyboard
Key down 0 64 System keyboard
Key down 0 37 System keyboard
Key down 0 64 System keyboard
Key down 0 37 System keyboard
[olpc@xo-6d-61-b9 Desktop]$ 


Running a ROM directly from command-line breaks into the debugger:

Code:
[olpc@xo-6d-61-b9 Desktop]$ ./mamed roms/1942.zip 
socket(): Address family not supported by protocol
MAME exception: assert: src/emu/emualloc.c:245: entry != NULL
Attempting to fall into debugger
Trace/breakpoint trap
[olpc@xo-6d-61-b9 Desktop]$


And running gdb starts, but produces this output and the terminal window where mame is running is closed automatically:

Code:
[olpc@xo-6d-61-b9 Desktop]$ gdb ./mamed 
GNU gdb (GDB) Fedora (7.2-51.fc14)
Copyright (C) 2010 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 "armv5tel-redhat-linux-gnueabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/olpc/Desktop/mamed...done.
(gdb) set args /home/olpc/Desktop/roms/1942.zip
(gdb) run
Starting program: /home/olpc/Desktop/mamed /home/olpc/Desktop/roms/1942.zip
[Thread debugging using libthread_db enabled]
[New Thread 0x460d6310 (LWP 1792)]
[New Thread 0x468d6310 (LWP 1793)]
[New Thread 0x472ff310 (LWP 1794)]
[Thread 0x460d6310 (LWP 1792) exited]
socket(): Address family not supported by protocol
done.
(gdb) set args /home/olpc/Desktop/roms/1942.zip
(gdb) run
[Thread 0x472ff310 (LWP 1794) exited]
[Thread 0x468d6310 (LWP 1793) exited]
[New Thread 0x468d6310 (LWP 1800)]
MAME exception: assert: src/emu/emualloc.c:245: entry != NULL
Attempting to fall into debugger

Program received signal SIGTRAP, Trace/breakpoint trap.
0x40d4551c in kill () from /lib/libc.so.6
Missing separate debuginfos
(gdb) done.


any hints?

thanks a lot
F

Last edited by R. Belmont; 10/21/11 06:34 PM. Reason: trying to fix width breakage in Firefox
Re: MAME compilation on ARM Linux - OLPC laptop [Re: fsmunoz] #73725
10/17/11 12:40 PM
10/17/11 12:40 PM
Joined: Apr 2004
Posts: 1,553
J
judge Offline
Very Senior Member
judge  Offline
Very Senior Member
J
Joined: Apr 2004
Posts: 1,553
Try starting it with "mamed -rompath /path/to/your/roms 1942"

Re: MAME compilation on ARM Linux - OLPC laptop [Re: fsmunoz] #73794
10/21/11 04:51 PM
10/21/11 04:51 PM
Joined: Sep 2011
Posts: 5
F
fsmunoz Offline OP
Member
fsmunoz  Offline OP
Member
F
Joined: Sep 2011
Posts: 5
judge,

no appreciable difference:

Code:
[olpc@xo-6d-61-b9 Desktop]$ ./mamed -rompath /home/olpc/Desktop/roms/ 1942 
socket(): Address family not supported by protocol
MAME exception: assert: src/emu/emualloc.c:245: entry != NULL
Attempting to fall into debugger
Trace/breakpoint trap
[olpc@xo-6d-61-b9 Desktop]$


any other ideas?

Re: MAME compilation on ARM Linux - OLPC laptop [Re: fsmunoz] #73800
10/21/11 06:32 PM
10/21/11 06:32 PM
Joined: Mar 2001
Posts: 16,020
USA
R
R. Belmont Offline
Very Senior Member
R. Belmont  Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,020
USA
That socket() error is weird. I'd be curious where that's coming from. It suggests possibly that MAME's filename parser is thinking it's a socket rather than a filesystem path.

Is there any way I could get my hands on some actual hardware to help debug this? I have no problem paying for it or whatever, or if I'd have to send it back.

Last edited by R. Belmont; 10/21/11 06:47 PM.
Re: MAME compilation on ARM Linux - OLPC laptop [Re: fsmunoz] #73807
10/22/11 07:55 PM
10/22/11 07:55 PM
Joined: Apr 2004
Posts: 1,553
J
judge Offline
Very Senior Member
judge  Offline
Very Senior Member
J
Joined: Apr 2004
Posts: 1,553
Could it be that the defines think that backslash is the directory separator on this platform

Re: MAME compilation on ARM Linux - OLPC laptop [Re: fsmunoz] #73808
10/22/11 08:22 PM
10/22/11 08:22 PM
Joined: Mar 2001
Posts: 16,020
USA
R
R. Belmont Offline
Very Senior Member
R. Belmont  Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,020
USA
Shouldn't, from what he's shown it looks like a Fedora knockoff, and not all that customized at that.

Page 1 of 2 1 2

Moderated by  R. Belmont 

Who's Online Now
0 registered members (), 118 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Shout Box
Forum Statistics
Forums9
Topics8,587
Posts112,168
Members4,817
Most Online283
Oct 11th, 2018
Powered by UBB.threads™ PHP Forum Software 7.6.1.1
(Release build 20180111)
Page Time: 0.028s Queries: 14 (0.008s) Memory: 5.7353 MB (Peak: 5.9543 MB) Zlib enabled. Server Time: 2018-10-17 05:32:05 UTC