├── SDL2 ├── sdl2-changelog └── sdl2-debian-rules ├── cmdline.txt ├── xsysroot.conf ├── README.md ├── changelog.txt ├── LICENSE ├── config.txt └── pilove.py /SDL2/sdl2-changelog: -------------------------------------------------------------------------------- 1 | libsdl2 (2.0.5) UNRELEASED; urgency=low 2 | 3 | * Updated SDL package names to version 2.0.5 4 | 5 | -- Albert Casals Sat, 31 Dec 2016 12:43:22 +0000 6 | 7 | -------------------------------------------------------------------------------- /cmdline.txt: -------------------------------------------------------------------------------- 1 | dwc_otg.lpm_enable=0 logo.nologo console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 usbcore.autosuspend=-1 elevator=deadline rootwait consoleblank=0 quiet 2 | -------------------------------------------------------------------------------- /xsysroot.conf: -------------------------------------------------------------------------------- 1 | "pilove" : { 2 | "description" : "Love2D on top of pipaOS 4.3 console", 3 | "nbdev" : "/dev/nbd1", 4 | "nbdev_part" : "p2", 5 | "sysroot" : "/tmp/pilove", 6 | "boot_part" : "p1", 7 | "sysboot" : "/tmp/pilove_boot", 8 | "tmp" : "~/xtmp", 9 | "backing_image": "~/osimages/pipaos-lulo-console-4.3.img", 10 | "qcow_image": "~/osimages/pilove.qcow" 11 | } 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## PiLove 2 | 3 | Welcome to PiLove! 4 | 5 | This project builds a RaspberryPI bootable image, based on Raspbian Jessie, running the wonderful Löve2D version 0.10.0 game framework. 6 | 7 | ## Requirements 8 | 9 | You need an Intel based system with the QEmu emulator, NBD driver, and [xsysroot](https://github.com/skarbat/xsysroot) tools installed. 10 | 11 | Copy the file `xsysroot.conf` into your home directory, and download the latest pipaOS image referred to within the file. 12 | 13 | ## Build 14 | 15 | Run the script `build-pilove.sh` and sit back. The image file along with the SDL2 and Löve binaries will appear on your current directory. 16 | 17 | This is free software - See the LICENSE file for details 18 | 19 | Albert - January 2016 20 | -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | Version 0.4 2 | Date: Sat Dec 31, 2016 3 | * Based on latest Raspbian kernel 4.4.20-v7+ 4 | * Upgraded SDL to 2.0.5 5 | * Upgraded Love2d to 10.0.2 6 | * Updated luarocks components - call "luarocks list" 7 | 8 | Version 0.3 9 | Date: Wed Feb 20, 2016 10 | * Added luarocks package 11 | * luasocket and copas included via luarocks. 12 | * Lua periphery included, allows simple acces to gpio, i2c, and UART port 13 | * Lua GPIO interface included, a port of the classic Python GPIO package 14 | * Changed love binary alias to a symlink, simply call love from any user now. 15 | * Force audio be sent to HDMI output (hdmi_drive=2) 16 | 17 | Version 0.2 18 | Date: Sun Jan 17, 2016 19 | * Upgraded to latest SDL2 version 2.0.4 20 | * Improved image compactness, it should fit on most 2GB SD cards 21 | * Added more fonts available at /usr/share/fonts/truetype 22 | * Added Emacs and LUA edition mode 23 | * Added raspi2png, a tool to take screenshots from Love games 24 | 25 | Version 0.1 26 | Date: Sun Jan 9, 2016 27 | * Love2D version 0.10.0 28 | * SDL2 version 2.0.3, official branch from RetroPie 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Albert Casals 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SDL2/sdl2-debian-rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # 4 | # Custom rules debian script to build SDL2 correctly for the RaspberryPI 5 | # Note that in the Video drivers output from configure, you need to see "rpi". 6 | # 7 | # Recipe taken from the official autobot: https://wiki.libsdl.org/Installation 8 | # 9 | 10 | DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU) 11 | DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) 12 | 13 | confflags = --host=arm-raspberry-linux-gnueabihf --disable-pulseaudio \ 14 | --disable-esd --disable-video-mir --disable-video-wayland \ 15 | --disable-video-opengl 16 | 17 | %: 18 | dh $@ --parallel 19 | 20 | override_dh_auto_configure: 21 | dh_auto_configure -Bbuilddir/all -- $(confflags) 22 | 23 | override_dh_auto_build: 24 | dh_auto_build -Bbuilddir/all 25 | tar czf debian/examples.tar.gz test 26 | 27 | override_dh_auto_install: 28 | dh_auto_install -Bbuilddir/all 29 | 30 | override_dh_auto_clean: 31 | dh_auto_clean -Bbuilddir/all 32 | rm -f debian/examples.tar.gz 33 | 34 | override_dh_install: 35 | dh_install --remaining-packages --fail-missing -XlibSDL2.la 36 | 37 | override_dh_installexamples: 38 | dh_installexamples -plibsdl2-dev debian/examples.tar.gz 39 | dh_installexamples --remaining-packages 40 | 41 | override_dh_link: 42 | # to address lintian warning 43 | # W: libsdl2-2.0-0: dev-pkg-without-shlib-symlink usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.0.0 usr/lib/x86_64-linux-gnu/libSDL2-2.0.so 44 | dh_link -plibsdl2-dev usr/lib/$(DEB_HOST_MULTIARCH)/libSDL2-2.0.so.0.0.0 usr/lib/$(DEB_HOST_MULTIARCH)/libSDL2-2.0.so 45 | 46 | override_dh_strip: 47 | dh_strip --dbg-package=libsdl2-dbg 48 | -------------------------------------------------------------------------------- /config.txt: -------------------------------------------------------------------------------- 1 | # uncomment if you get no picture on HDMI for a default "safe" mode 2 | #hdmi_safe=1 3 | 4 | # pretend all audio formats unsupported by display, forcing analog output instead. 5 | #hdmi_ignore_edid_audio=1 6 | 7 | # force output to HDMI for users who plug the HDMI screen after boot 8 | #hdmi_force_hotplug=1 9 | 10 | # uncomment this if your display has a black border of unused pixels visible 11 | # and your display can output without overscan# 12 | #disable_overscan=1 13 | 14 | # uncomment the following to adjust overscan. Use positive numbers if console 15 | # goes off screen, and negative if there is too much border 16 | #overscan_left=16 17 | #overscan_right=16 18 | #overscan_top=16 19 | #overscan_bottom=16 20 | 21 | # uncomment to force a console size. By default it will be display's size minus 22 | # overscan. 23 | #framebuffer_width=800 24 | #framebuffer_height=600 25 | 26 | # uncomment if hdmi display is not detected and composite is being output 27 | #hdmi_force_hotplug=1 28 | 29 | # uncomment to force a specific HDMI mode (this will force VGA) 30 | #hdmi_group=1 31 | #hdmi_mode=1 32 | 33 | # uncomment to force a HDMI mode rather than DVI. This can make audio work in 34 | # DMT (computer monitor) modes 35 | hdmi_drive=2 36 | 37 | # uncomment to increase signal to HDMI, if you have interference, blanking, or 38 | # no display 39 | #config_hdmi_boost=4 40 | 41 | # uncomment for composite PAL 42 | #sdtv_mode=2 43 | 44 | #uncomment to overclock the arm. 700 MHz is the default. 45 | #arm_freq=800 46 | 47 | # increase if you get problems with graphics intensive apps 48 | gpu_mem=256 49 | 50 | # Uncomment this line to set the HDMI as the primary display 51 | # You might need this flag if using RaspberryPI touch screen 52 | #display_default_lcd=0 53 | 54 | # for more options see http://elinux.org/RPi_config.txt 55 | -------------------------------------------------------------------------------- /pilove.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # The MIT License (MIT) 4 | # 5 | # Copyright (c) 2016 Albert Casals - albert@mitako.eu 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | # THE SOFTWARE. 24 | # 25 | # pilove.py 26 | # 27 | # Program that builds the PiLove OS image for the Raspberry PI. 28 | # 29 | # You need to download and setup xsysroot to run this script, see README for details. 30 | # 31 | 32 | import os 33 | import sys 34 | import time 35 | import xsysroot 36 | 37 | # Release version of PiLove 38 | __version__='0.4' 39 | 40 | 41 | def test_image(pilove): 42 | 43 | count_failed=0 44 | tests = [ 45 | { 'cmd' : '/usr/local/games/love-0.10.2/src/love --version', 'msg': 'Love app does not load' }, 46 | { 'cmd' : 'raspi2png --help', 'msg': 'Raspi2png could not be found' }, 47 | { 'cmd' : 'dpkg -l | grep libsdl2:armhf', 'msg': 'libSDL2 did not install' }, 48 | { 'cmd' : 'luarocks list | grep lua-periphery', 'msg': 'LUA periphery did not install' }, 49 | { 'cmd' : 'luarocks list | grep rpi-gpio', 'msg': 'LUA RPi GPIO did not install' }, 50 | { 'cmd' : 'emacs --version', 'msg': 'Emacs did not install' }, 51 | { 'cmd' : 'find /usr/share/fonts/truetype/isabella', 'msg': 'Isabella fonts not installed' }, 52 | { 'cmd' : 'find /usr/share/fonts/truetype/fonts-georgewilliams', 'msg': 'GeorgeWilliams fonts not installed' } 53 | ] 54 | 55 | print '>>> RUNNIG TESTS' 56 | for test in tests: 57 | rc=pilove.execute(test['cmd']) 58 | if rc: 59 | print '>>> TEST FAILED: {}'.format(test['msg']) 60 | count_failed += 1 61 | else: 62 | print '>>> TEST PASSED' 63 | 64 | if count_failed: 65 | print '>>> {} TESTS FAILED'.format(count_failed) 66 | else: 67 | print '>>> ALL TESTS PASSED!' 68 | 69 | return count_failed 70 | 71 | 72 | if __name__ == '__main__': 73 | 74 | output_image='pilove-{}.img'.format(__version__) 75 | prepare_only=False 76 | 77 | # Xsysroot profile name that holds the original pipaOS image 78 | # (See the file xsysroot.conf for details) 79 | if len(sys.argv) < 2: 80 | print 'Please specify a xsysroot profile name' 81 | sys.exit(1) 82 | else: 83 | xsysroot_profile_name=sys.argv[1] 84 | 85 | # Find and activate the xsysroot profile 86 | try: 87 | pilove=xsysroot.XSysroot(profile=xsysroot_profile_name) 88 | except: 89 | print 'You need to create a Xsysroot Pilove profile' 90 | print 'Please see the README file' 91 | sys.exit(1) 92 | 93 | # start timer 94 | time_start=time.time() 95 | 96 | # make sure the image is not mounted, or not currently in use 97 | if pilove.is_mounted(): 98 | if not pilove.umount(): 99 | sys.exit(1) 100 | 101 | # renew the image so we start from scratch 102 | if not pilove.renew(): 103 | sys.exit(1) 104 | else: 105 | # once renewed, expand it to grow in size 106 | pilove.umount() 107 | if not pilove.expand(): 108 | print 'error expanding image size to {}'.format(pilove.query('qcow_size')) 109 | sys.exit(1) 110 | else: 111 | pilove.mount() 112 | 113 | # baptize the pilove version 114 | pilove.edfile('/etc/pilove_version', 'pilove v{} - {}'.format(__version__, time.ctime())) 115 | 116 | # set the system hostname 117 | pilove_hostname='pilove' 118 | pilove_hosts_file='/etc/hosts' 119 | pilove.edfile('/etc/hostname', pilove_hostname) 120 | pilove.edfile(pilove_hosts_file, '127.0.0.1 localhost') 121 | pilove.edfile(pilove_hosts_file, '127.0.0.1 {}'.format(pilove_hostname), append=True) 122 | 123 | # firmware config.txt with any special settings to smooth Love2D on the RPi 124 | src_config_txt='config.txt' 125 | dst_config_txt=os.path.join(pilove.query('sysboot'), src_config_txt) 126 | rc=os.system('sudo cp -fv {} {}'.format(src_config_txt, dst_config_txt)) 127 | if rc: 128 | print 'WARNING: could not copy config.txt rc={}'.format(rc) 129 | 130 | # custom kernel boot parameters 131 | src_cmdline='cmdline.txt' 132 | dst_cmdline=os.path.join(pilove.query('sysboot'), src_cmdline) 133 | rc=os.system('sudo cp -fv {} {}'.format(src_cmdline, dst_cmdline)) 134 | if rc: 135 | print 'WARNING: could not copy cmdline rc={}'.format(rc) 136 | 137 | # make the Pilove installation script available in the image through /tmp 138 | src_install_script='build-love2d.sh' 139 | dst_install_script=os.path.join(pilove.query('tmp'), src_install_script) 140 | print 'Copying Pilove installation script {} -> {}'.format(src_install_script, dst_install_script) 141 | rc=os.system('cp {} {}'.format(src_install_script, dst_install_script)) 142 | if rc: 143 | print 'ERROR: could not copy love build script in the image rc={}'.format(rc) 144 | sys.exit(1) 145 | 146 | # HACK : this is the custom debian rules file to build SDL2 with RPi support 147 | rc=os.system('cp {} {}'.format('SDL2/sdl2-debian-rules', pilove.query('tmp'))) 148 | rc=os.system('cp {} {}'.format('SDL2/sdl2-changelog', pilove.query('tmp'))) 149 | 150 | # run the Love2D build script 151 | rc=pilove.execute('/bin/bash -c "cd /tmp ; ./{}"'.format(src_install_script)) 152 | if rc: 153 | print 'ERROR: pilove installation script failed rc={}'.format(rc) 154 | sys.exit(1) 155 | 156 | # extract SDL2 and Loved2D built binaries from the image 157 | rc=os.system('cp {}/libsdl2*deb . '.format(os.path.join(pilove.query('tmp')))) 158 | rc=os.system('cp {}/pilove*bin.tgz . '.format(os.path.join(pilove.query('tmp')))) 159 | 160 | # start Love2D during boot, and enable sound 161 | rclocal='/etc/rc.local' 162 | pilove.edfile(rclocal, '#!/bin/bash') 163 | pilove.edfile(rclocal, 'pulseaudio --start', append=True) 164 | pilove.edfile(rclocal, '/usr/local/bin/love &', append=True) 165 | pilove.edfile(rclocal, 'exit 0', append=True) 166 | rc=pilove.execute('chmod +x {}'.format(rclocal)) 167 | 168 | # create a symlink to reach love 169 | rc=pilove.execute('ln -sfv {} {}'.format('/usr/local/games/love-0.10.2/src/love', '/usr/local/bin/love')) 170 | 171 | # Install emacs with LUA syntax mode, and additional free TrueType fonts 172 | ttf_packages='fontconfig fonts-isabella fonts-georgewilliams fonts-linuxlibertine' 173 | pilove.execute('apt-get install -y --no-install-recommends emacs24-nox lua-mode luarocks {}'.format(ttf_packages)) 174 | 175 | # Install lua rocks to access the GPIO 176 | pilove.execute('luarocks install lua-periphery') 177 | pilove.execute('luarocks install rpi-gpio') 178 | 179 | # run some basic tests on the image 180 | test_image(pilove) 181 | 182 | # unmount the image 183 | if not pilove.umount(): 184 | print 'WARNING: Image is busy, most likely installation left some running processes, skipping conversion' 185 | sys.exit(1) 186 | else: 187 | pilove.zerofree(verbose=False) 188 | 189 | # Convert the xsysroot image to a raw format ready to flash and boot 190 | qcow_image=pilove.query('qcow_image') 191 | print 'Converting image {}...'.format(qcow_image) 192 | if os.path.isfile(output_image): 193 | os.unlink(output_image) 194 | 195 | rc = os.system('qemu-img convert {} {}'.format(qcow_image, output_image)) 196 | 197 | time_end=time.time() 198 | print 'Process finished in {} secs - image ready at {}'.format(time_end - time_start, output_image) 199 | sys.exit(0) 200 | --------------------------------------------------------------------------------