June 29, 2017

Compiling RetroArch (avdmame + FBA + PSX + N64) with attract mode on Raspberry Pi 3

1. raspbian
  1.1 Download raspbian jessie lite image file
  1.2 diskutil list
  1.3 diskutil unmountDisk /dev/disk4
  1.4 sudo dd bs=1m if=raspbian-jessie.img of=/dev/rdisk4
https://www.raspberrypi.org/downloads/raspbian/
https://www.raspberrypi.org/documentation/installation/installing-images/mac.md

2. setup
id: pi
pw: raspberry
  2.1 [option] set static ip
    2.1.1 sudo vi /etc/network/interfaces
#auto lo
#iface lo inet loopback
#iface eth0 inet manual
auto eth0
iface eth0 inet static
address IP
netmask MASK
gateway GATEWAY
dns-nameservers DNS
    2.1.2 sudo /etc/init.d/networking restart
  2.2 [option] wifi setup
  2.3 config
    2.3.1 sudo raspi-config
1 Change User Password
4 Localization Options -> I3 Change Keyboard Layout -> Generic 101-key PC -> Other -> English (US)
5 Interfacing Options -> P2 SSH
7 Advanced Options -> A1 Expand Filesystem
7 Advanced Options -> A3 Memory Split -> 128
7 Advanced Options -> A4 Audio -> Force HDMI
  2.4 hdmi force output
    2.4.1 sudo vi /boot/config.txt
hdmi_force_hotplug=1
  2.5 update
    2.5.1 sudo apt-get update
    2.5.2 sudo apt-get dist-upgrade
  2.6 prepare
    2.6.2 cd ~
    2.6.2 mkdir build
http://elinux.org/Configuring_a_Static_IP_address_on_your_Raspberry_Pi
https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

3. avdmame
  3.1 cd ~/build
  3.2 sudo apt-get install git autoconf automake libasound2-dev libfreetype6-dev zlib1g-dev libexpat1-dev libslang2-dev libncurses5-dev
  3.3 git clone https://github.com/amadvance/advancemame.git
  3.4 cd advancemame
  3.5 sh autogen.sh
  3.6 ./configure
  3.7 make -j4
  3.8 sudo make install
http://www.advancemame.it/doc-build

4. sfml
  4.1 cd ~/build
  4.2 sudo apt-get install cmake libflac-dev libogg-dev libvorbis-dev libopenal-dev libjpeg8-dev libfreetype6-dev libudev-dev libraspberrypi-dev
  4.3 git clone --depth 1 https://github.com/mickelson/sfml-pi.git
  4.4 cd sfml-pi
  4.5 mkdir build
  4.6 cd build
  4.7 cmake .. -DSFML_RPI=1 -DEGL_INCLUDE_DIR=/opt/vc/include -DEGL_LIBRARY=/opt/vc/lib/libEGL.so -DGLES_INCLUDE_DIR=/opt/vc/include -DGLES_LIBRARY=/opt/vc/lib/libGLESv1_CM.so
  4.8 sudo make install
  4.9 sudo ldconfig
https://github.com/mickelson/sfml-pi

5. ffmpeg
  5.1 cd ~/build
  5.2 sudo apt-get install libomxil-bellagio-dev libmp3lame-dev
  5.3 git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git
  5.4 cd ffmpeg
  5.5 ./configure --arch=armhf --target-os=linux --enable-gpl --enable-mmal --enable-omx --enable-omx-rpi --enable-nonfree --enable-libfreetype --extra-libs=-lasound --enable-libmp3lame --disable-debug --enable-shared
  5.6 make -j4
  5.7 sudo make install
  5.8 sudo ldconfig
https://github.com/FFmpeg/FFmpeg
https://trac.ffmpeg.org/wiki/CompilationGuide/RaspberryPi

6. retroarch
  6.1 sudo vi /usr/local/lib/pkgconfig/bcm_host.pc
prefix=/opt/vc
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: bcm_host
Description: Broadcom VideoCore host API library
Version: 1
Libs: -L${libdir} -lbcm_host -lvcos -lvchiq_arm -pthread
Cflags: -I${includedir} -I${includedir}/interface/vmcs_host/linux -I${includedir}/interface/vcos/pthreads -DUSE_VCHIQ_ARM
  6.2 sudo vi /usr/local/lib/pkgconfig/egl.pc
prefix=/opt/vc
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: EGL
Description: Fake EGL package for RPi
Version: 10
Requires: bcm_host
Libs: -L${libdir} -lEGL -lGLESv2 -lbcm_host -lvchostif
Cflags: -I${includedir} -I${includedir}/interface/vmcs_host/linux -I${includedir}/interface/vcos/pthreads
  6.3 sudo vi /usr/local/lib/pkgconfig/glesv2.pc
prefix=/opt/vc
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: GLESv2
Description: Fake GL ES 2 package for RPi
Version: 10
Requires: bcm_host
Libs: -L${libdir} -lGLESv2
Cflags: -I${includedir}
  6.4 cd ~/build
  6.5 sudo apt-get install libusb-1.0-0-dev libavresample-dev libdrm-dev libgbm-dev libxml2-dev libv4l-dev libxkbcommon-dev libdbus-1-dev
  6.6 git clone --depth 1 https://github.com/libretro/RetroArch.git
  6.7 cd RetroArch
  6.8 ./configure --enable-neon --enable-floathard --enable-alsa --enable-udev --enable-opengl --enable-opengles --enable-egl --enable-fbo --enable-dispmanx --enable-ffmpeg --disable-sdl --disable-sdl2 --disable-opengles3 --disable-vg --disable-cg --disable-x11 --disable-wayland --disable-pulse
  6.9 vi qb/config.libs.sh
line 47 HAVE_OPENGLES='auto' -> HAVE_OPENGLES='yes'
  6.10 vi config.mk
CFLAGS = -mfpu=neon-fp-armv8 -mfloat-abi=hard -march=armv8-a+crc -mtune=cortex-a53
ASFLAGS = -mfpu=neon-fp-armv8 -mfloat-abi=hard -march=armv8-a+crc -mtune=cortex-a53
  6.11 make -j4
  6.12 launch and quit retroarch once
  6.13 cd /home/pi/.config/retroarch
  6.14 rm -rd assets
  6.15 wget https://github.com/libretro/retroarch-assets/archive/master.zip
  6.16 unzip master.zip
  6.17 mv ./retroarch-assets-master/ ./assets/
  6.18 rm ./master.zip
https://github.com/libretro/RetroArch
https://www.raspberrypi.org/forums/viewtopic.php?t=56070
http://alexmax2742.blogspot.kr/2016/07/retroarch-on-raspberry-pi.html
https://github.com/raspberrypi/userland/issues/245

7. fb alpha
  7.1 cd ~/build
  7.2 git clone https://github.com/libretro/fbalpha.git
  7.3 cd fbalpha
  7.4 make -j4 -f makefile.libretro platform=rpi3
https://github.com/libretro/fbalpha

8. PSX
  8.1 cd ~/build
  8.2 git clone https://github.com/libretro/pcsx_rearmed.git
  8.3 cd pcsx_rearmed
  8.4 make -j4 -f Makefile.libretro platform=rpi3
https://github.com/libretro/pcsx_rearmed

9. N64
  9.1 cd ~/build
  9.2 git clone --depth=1 https://github.com/libretro/mupen64plus-libretro.git
  9.3 cd mupen64plus-libretro
  9.4 platform=rpi3 make -j4
https://github.com/libretro/mupen64plus-libretro

10. attract
  10.1 cd ~/build
  10.2 git clone --depth 1 https://github.com/mickelson/attract.git
  10.3 cd attract
  10.4 make -j4 USE_GLES=1
  10.5 sudo make install
Configure-->General-->Window Mode = FullScreen Mode
Configure-->General-->Video Decoder = mmal
https://github.com/mickelson/attract/wiki/Compiling-on-the-Raspberry-Pi-%28Raspbian-Jessie%29

11. [option] bluetooth
  11.1 sudo bluetoothctl
  11.2 agent on
  11.3 default-agent
  11.4 scan on
  11.5 pair xx:xx
  11.6 trust xx:xx
  11.7 connect xx:xx
https://www.cnet.com/how-to/how-to-setup-bluetooth-on-a-raspberry-pi-3/

12. [option] GPIO
https://github.com/recalbox/mk_arcade_joystick_rpi