This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
chumby [2010/03/22 15:40] ladyada |
chumby [2010/03/23 21:06] ladyada |
||
---|---|---|---|
Line 99: | Line 99: | ||
stop_control_panel | stop_control_panel | ||
- | ./switch_output -l | + | /mnt/storage/switch_output -l |
switch_fb.sh 0 | switch_fb.sh 0 | ||
</file> | </file> | ||
Line 107: | Line 107: | ||
Also tried the old SDL tests and they're working good now. yay. | Also tried the old SDL tests and they're working good now. yay. | ||
+ | |||
+ | ==== Port SIemu ==== | ||
+ | |||
+ | The 'easiest' emulator to port by far is SIemu. Its written in straight-up C, well documented and uses SDL as an underpinning. | ||
+ | |||
+ | * Had problem with audio so commented out all the Audio procedures. | ||
+ | * Complained about screen size so changes graphics.h to use 320x240 screen | ||
+ | * Runs! | ||
+ | |||
+ | OK much success. Now to fix it so audio works. SDL doesnt seem to know about audio device - perhaps we need to install ALSA lib first? | ||
+ | |||
+ | ==== Install ALSA ==== | ||
+ | |||
+ | We configure/make'd ALSA | ||
+ | |||
+ | ==== Build SDL with OSS ==== | ||
+ | Trying to build SDL with ALSA (unpatched) didnt really work but then but then we realized that OSS is already in there so many we should just rebuild SDL? | ||
+ | |||
+ | Built SDL with following flags | ||
+ | <file> | ||
+ | ./configure --disable-esd --disable-pulseaudio --disable-video-x11 --enable-video-fbcon --disable-alsa | ||
+ | </file> | ||
+ | |||
+ | compiled cleanly, ran test/loopwave and it worked! yay! | ||
+ | |||
+ | ==== Rebuild SIemu ==== | ||
+ | |||
+ | unpatched the audio and run it with new SDL that has audio. works! and keyboard works too! kpow kpow. | ||
+ | much success. | ||
+ | |||
+ | |||
+ | (note used 'original' SDL not chumbyquake SDL!) | ||
==== download stella & ./configure ==== | ==== download stella & ./configure ==== | ||
Line 125: | Line 157: | ||
OK, grab an [[http://forum.chumby.com/viewtopic.php?id=4474|updated busybox]] and install it | OK, grab an [[http://forum.chumby.com/viewtopic.php?id=4474|updated busybox]] and install it | ||
+ | Now printf exists, try again | ||
+ | |||
+ | <file> | ||
+ | ./configure --disable-debugger --disable-cheats | ||
+ | make | ||
+ | </file> | ||
+ | |||
+ | but gcc dies :( | ||
+ | <file> | ||
+ | g++ -Wp,-MMD,"src/emucore/.deps/PropsSet.d",-MQ,"src/emucore/PropsSet.o",-MP -O2 -Wall -Wno-multichar -Wunused -fno-rtti -fomit-frame-pointer -DUNIX -DBSPF_UNIX -DHAVE_GETTIMEOFDAY -DHAVE_INTTYPES -DWINDOWED_SUPPORT -DSOUND_SUPPORT -DSNAPSHOT_SUPPORT -DJOYSTICK_SUPPORT -Isrc/emucore -Isrc/emucore/m6502/src -Isrc/emucore/m6502/src/bspf/src -Isrc/common -Isrc/gui -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Isrc/unix -c src/emucore/PropsSet.cxx -o src/emucore/PropsSet.o | ||
+ | g++: Internal error: Killed (program cc1plus) | ||
+ | Please submit a full bug report. | ||
+ | See <http://gcc.gnu.org/bugs.html> for instructions. | ||
+ | make: *** [src/emucore/PropsSet.o] Error 1 | ||
+ | </file> | ||
+ | |||
+ | dmesg says we're out of memory! | ||
+ | |||
+ | <file> | ||
+ | [ 809.010000] ntpd invoked oom-killer: gfp_mask=0x1201d2, order=0, oomkilladj=0 | ||
+ | [ 809.010000] [<c02ff9bc>] (dump_stack+0x0/0x14) from [<c00777f4>] (oom_kill_process+0x5c/0x1d8) | ||
+ | [ 809.020000] [<c0077798>] (oom_kill_process+0x0/0x1d8) from [<c0077f38>] (out_of_memory+0x1dc/0x254) | ||
+ | [ 809.030000] r8:c2aac000 r7:c0445858 r6:000001be r5:c3dec900 r4:c2a68600 | ||
+ | [ 809.040000] [<c0077d5c>] (out_of_memory+0x0/0x254) from [<c007ab98>] (__alloc_pages_internal+0x300/0x3bc) | ||
+ | [ 809.050000] [<c007a898>] (__alloc_pages_internal+0x0/0x3bc) from [<c007cd6c>] (__do_page_cache_readahead+0x118/0x264) | ||
+ | [ 809.060000] [<c007cc54>] (__do_page_cache_readahead+0x0/0x264) from [<c007cf24>] (do_page_cache_readahead+0x6c/0x74) | ||
+ | [ 809.070000] [<c007ceb8>] (do_page_cache_readahead+0x0/0x74) from [<c0075168>] (filemap_fault+0x1d8/0x448) | ||
+ | [ 809.080000] r7:00000000 r6:c2aac000 r5:00000000 r4:00000000 | ||
+ | [ 809.080000] [<c0074f90>] (filemap_fault+0x0/0x448) from [<c0084958>] (__do_fault+0x54/0x488) | ||
+ | [ 809.090000] [<c0084904>] (__do_fault+0x0/0x488) from [<c0085bf0>] (handle_mm_fault+0x2f4/0x7c0) | ||
+ | [ 809.100000] [<c00858fc>] (handle_mm_fault+0x0/0x7c0) from [<c002da64>] (do_page_fault+0xf0/0x238) | ||
+ | [ 809.110000] [<c002d974>] (do_page_fault+0x0/0x238) from [<c002dc34>] (do_translation_fault+0x18/0x80) | ||
+ | [ 809.120000] [<c002dc1c>] (do_translation_fault+0x0/0x80) from [<c0026254>] (do_PrefetchAbort+0x18/0x1c) | ||
+ | [ 809.130000] r7:00000000 r6:00053790 r5:00052acc r4:ffffffff | ||
+ | [ 809.140000] [<c002623c>] (do_PrefetchAbort+0x0/0x1c) from [<c0026dc0>] (ret_from_exception+0x0/0x10) | ||
+ | [ 809.150000] Exception stack(0xc2aadfb0 to 0xc2aadff8) | ||
+ | [ 809.150000] dfa0: 00000000 00052974 000002f6 000002f7 | ||
+ | [ 809.160000] dfc0: 00000000 00052acc 00053790 00000000 00053794 0004ecfc 0005234c bed1bb2c | ||
+ | [ 809.170000] dfe0: 00008001 bed1bb00 0002859c 00017608 60000010 ffffffff | ||
+ | [ 809.180000] Mem-info: | ||
+ | [ 809.180000] Normal per-cpu: | ||
+ | [ 809.180000] CPU 0: hi: 18, btch: 3 usd: 10 | ||
+ | [ 809.190000] Active_anon:5856 active_file:40 inactive_anon:5862 | ||
+ | [ 809.190000] inactive_file:112 unevictable:0 dirty:0 writeback:0 unstable:0 | ||
+ | [ 809.190000] free:285 slab:767 mapped:26 pagetables:110 bounce:0 | ||
+ | [ 809.210000] Normal free:1140kB min:1016kB low:1268kB high:1524kB active_anon:23424kB inactive_anon:23448kB active_file:160kB inactive_file:448kB unevictable:0kB present:65024kB pages_scanned:14 all_unreclaimable? no | ||
+ | [ 809.230000] lowmem_reserve[]: 0 0 | ||
+ | [ 809.230000] Normal: 23*4kB 7*8kB 0*16kB 1*32kB 1*64kB 1*128kB 1*256kB 1*512kB 0*1024kB 0*2048kB 0*4096kB = 1140kB | ||
+ | [ 809.240000] 377 total pagecache pages | ||
+ | [ 809.240000] 0 pages in swap cache | ||
+ | [ 809.250000] Swap cache stats: add 0, delete 0, find 0/0 | ||
+ | [ 809.250000] Free swap = 0kB | ||
+ | [ 809.250000] Total swap = 0kB | ||
+ | [ 809.260000] 16384 pages of RAM | ||
+ | [ 809.270000] 423 free pages | ||
+ | [ 809.270000] 2647 reserved pages | ||
+ | [ 809.270000] 630 slab pages | ||
+ | [ 809.270000] 108 pages shared | ||
+ | [ 809.280000] 0 pages swap cached | ||
+ | [ 809.280000] Out of memory: kill process 2683 (g++) score 446 or a child | ||
+ | [ 809.290000] Killed process 2684 (cc1plus) | ||
+ | </file> | ||
+ | |||
+ | try.. | ||
+ | |||
+ | <file> | ||
+ | if [ ! -e /mnt/storage/swap ] | ||
+ | then | ||
+ | echo "Making 256M swapfile" | ||
+ | dd if=/dev/zero of=/mnt/storage/swap bs=1M count=256 | ||
+ | mkswap /mnt/storage/swap | ||
+ | fi | ||
+ | swapon /mnt/storage/swap | ||
+ | </file> | ||
+ | |||
+ | done and...sucess! | ||
+ | |||
+ | {{http://farm3.static.flickr.com/2760/4455436625_859aa97392.jpg}} | ||
+ | |||
+ | good news: you can play ROMs if you specify them on the command line. badnews: the ROM launcher not only doesnt work, but if it tries to run it gives some assert error and then http://ladyada.net/wiki/lib/images/smaller.gifdoesnt 'release' the SDL library (or *something*) and it doesnt really work until reboot. :( | ||
+ | |||
+ | commented out the Assert in Rect.h and it all works now - this should of course be fixed but hey! | ||
+ | |||
+ | [[http://lists.libsdl.org/pipermail/sdl-libsdl.org/2006-July/056756.html|The ^C problem is discussed here]] printf! | ||
+ | |||
+ | ==== fix colormap ==== | ||
+ | |||
+ | R and B are swapped in SDL. whyso? | ||
+ | Uncommented DEBUG_FBCON in SDL, got this | ||
+ | <file> xres: 320 | ||
+ | yres: 240 | ||
+ | xres_virtual: 320 | ||
+ | yres_virtual: 240 | ||
+ | xoffset: 0 | ||
+ | yoffset: 0 | ||
+ | bits_per_pixel: 16 | ||
+ | grayscale: 0 | ||
+ | nonstd: 0 | ||
+ | activate: 0 | ||
+ | height: 240 | ||
+ | width: 320 | ||
+ | accel_flags: 0 | ||
+ | pixclock: 154000 | ||
+ | left_margin: 5 | ||
+ | right_margin: 4 | ||
+ | upper_margin: 3 | ||
+ | lower_margin: 3 | ||
+ | hsync_len: 40 | ||
+ | vsync_len: 2 | ||
+ | sync: 0 | ||
+ | vmode: 0 | ||
+ | red: 5/0 | ||
+ | green: 6/5 | ||
+ | blue: 5/11 | ||
+ | alpha: 0/0 | ||
+ | </file> | ||
+ | |||
+ | which is fetched from SDL_fbvideo.c "ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo)" (in a few places) | ||
+ | |||
+ | So it seems like the FB driver is reporting the wrong thing | ||
+ | i guess we could just hack it..? | ||
+ | |||
+ | Edited SDL_fbvideo.c, line #595 and then #1038 | ||
+ | <file> | ||
+ | // BEGIN TERRIBLE MEME HACK | ||
+ | uint32_t tempoffset = vinfo.red.offset; | ||
+ | vinfo.red.offset = vinfo.blue.offset; | ||
+ | vinfo.blue.offset = tempoffset; | ||
+ | // END TERRIBLE MEME HACK | ||
+ | | ||
+ | </file> | ||
+ | |||
+ | but...it works! should probably fix this 'upstream' somehow | ||