maandag 28 december 2020

RetroPi Handheld

Many years ago I bought (of my first real wage) an Atari Lynx:

It was the first handheld game console with a color screen, and I absolutely loved it. And I still own it, but every time I pick it up it's a bit disapointing. And that's mainly due to the screen, which was a marvel at the time, but does not really hold up to modern standards. Now there is the McWill upgrade which will replace the screen with a modern high-contrast LCD, but at 100 Euro's that's quite expensive, and actually almost more than the console is worth.

So while I'm still trying to decide if I should do this, it may be cheaper and more fun to try and build a Lynx-like console myself, using a Raspberry Pi.

Yes, this has been done before, and they are comercially available as well, but let's face it: building it yourself is the most fun.

Examples:

Pi Portable Console on Hackaday

GamePi by araymbox

The FreePlay Zero

PiCicle kit, available on Tindie

Well, simply Google 'Raspberry Pi Handheld' and you'll see what I mean. But they all lack one specific feature; the are not designed by me ! ;-)

Let's start with some inventory, and see what I have

First: the screen. It's a 5 Inch HDMI Display, 800x640, with touch controller. This model is probably a bit older, since all the models available today have 4 screw-holes at the corners and mine has none. But this one from Waveshare looks very similar.


5inch-HDMI-LCD l.jpg 

Next: A Rasberry Pi 3 A+. This fits directly to the screen (unlike the RPi Zero), yet is not a bulky as a standard Pi 3 since it lacks the extra USB connectors.

Since the IO pins on the Pi are now difficult to reach, (and because it's easier to interface ), I'll use an Arduino to read the buttons and joystick and simply emulate a USB input device. Someone callling himself 'GAMELASTER' already created a neat sketch for this, including some instructions on how to test and build it. Or maybe use the 'GamePi_Zero' code from the GamePi Zero Instructable, which also contains a great drawing on how to connect all buttons.

Power has to come from a USB Powerbank, since that is the easiest way to get a rechargeable battery in there.

For the D-Pad and Buttons I considered using these standard PCB switches:

Which has as disadvantage that they are very 'clicky', so they will make some noise while playing. Then I came across these:

They are basically the same, but hey have a silicone dome which makes them 'silent'. Not as widely available as the standard ones, but I got them from The Pi Hut.

Connecting the parts

I connected the Rawpberry Pi to the screen, created a SD card with RetroPie and started it up, just to see if it would work. Which it does, although I had to use a 5.2V 2A adapter to get it to boot without 'undervoltage detected' warning. Which indicates that the unit will eventually use quite some power.



And when connecting it to a standard USB powerbank, I get the same problem so that's not a good option either. So I think I'll use a pack of two 18650 cells. When placed in parallel they will provide approximately 19 Wh, which hopefully be enough to power the set for some time. To connect and charge the batteries I used a TP4056 module, which is capable of charging 2 cells.



(Photo taken from ACOPTEX blog)

This will give us 3.7 V, so it has to be boosted to at least 5.1 to be useable. A MT3608 boost converter takes care of that. This unit can deliver 2A, so that should be enough. And it is, once connected to the Raspberry Pi, it boots fine and shows the RetroPie screen.


 

zondag 13 november 2016

Direct Connect over Ethernet

For my PiDP8 ( a replica of the PDP8 computer) I used a Rasberry Pi model B, running pipaOS. Since the Pi is inside the box, and I did not want a monitor connected all the time the best way to connect to is would be using a direct cable connection from my laptop.
 So I followed all the instructions on ModMyPi, but could not succeed. I edited the /etc/network/interfaces file and gave it a static IP address as follows:

allow-hotplug eth0
iface eth0 inet static
address 192.168.0.200
netmask 255.255.255.0
broadcast 192.168.0.255
network 192.168.0.0
gateway 192.168.0.1

but I never found the Pi from my computer. And the 'sudo ifconfig' command on the Pi only showed the 'local loopback' connection (127.0.0.1)

By using the 'dmesg | more' command I tried to see what happened at startup, and I found  the following line:

:renamed network interface eth0 to eth1

I have no idea why he does this, but apparently the interface name is now eth1. And after modifying the interfaces file to :

allow-hotplug eth1
iface eth1 inet static
address 192.168.0.200
(...etc..)

it all seemed to work fine. That's to say, ifconfig now showed an active ethernet connection, eth1, on 192.168.0.200.
Next I modified the IPV4 settings om my laptop so it also uses a static IP address :


And now I can actually 'ping'the pi:
 And by using 'PuTTy'I can connect and login:


maandag 4 januari 2016

As Easy As RetroPie...

RetroPie, the multi system game console emulator, is definitely one of the most popular applications for the Raspberry Pi.
Installing should be super easy. And it is. Or not... There are two chances: you get the installation right in one go and everything works fine. Or something fails, and it will take a lot of effort to fix it. Lots of kudos to the RetroPie team, who definitely gone to the max to make it as user friendly as possible. At the time of writing the just released version 3, which again is a huge step forward in user-friendliness. But it is still Linux in the background and that means that almost every unexpected glitch in the installation requires the terminal screen to solve it.
No need to describe the standard installation, as this is already done in many places. Unfortunately there is lot that can go wrong so let's focus on that.

Creating the SD card

Most people will probably start from a Windows PC, download the standard image and  and use something like  the Win32DiskImager  or Fedora ARM Installer create a bootable SD card. Again, this may work for you, it did not for me. Somehow creating the card on a windows machine seems problematic. I had the same problem when I just wanted to create a Raspbian card: it just does not boot. The two LEDs on the board stay on, and nothing happens.
Since it is a Linux system after all I suppose it may be more reliable to create the card on a Linux computer. So I plugged into an old laptop on which I previously installed Xubuntu.
So far the best description of the installation using a Linux computer I've found is the RetroPie Installation Guide at LibreGeek. And even that was problematic. I still prefer the the 'easy' GUI-based solutions so I opted for 'GParted' and 'Unetbootin'. Which failed. The firtst time it actually seemed to work. The card booted, but the process ended with a fatal error and that's it.

Somehow the second time Unetbootin only created some files (each containing 0 bytes) but still nothing useable.
So finally I used Gparted to force the whole card to a single partition and formatted it to FAT32. Then I used the terminal and  the 'dd' tool to actually create a bootable card.
And, just in case this site ever disappears, here is the required command:
sudo dd bs=4M if=2016-03-12-jessie-minibian.img of=/dev/mmsblk0

'2016-03-12-jessie-minibian.img' is the name of the image.

Display settings (what to do if there's nothing on the screen)


My Pi is connected to a VGA monitor, using a HDMI to VGA converter. So after I finally got a card to boot (which I could see because the LED's on the board were blinking) my monitor did not show anything but an 'Input not Supported' message. Apparently the Pi uses a resolution that my monitor (an ACER 1912, 1280x1024)  does not support. I quickly found that the monitor settings are stored in the 'config.txt' file which can be found in the 'boot' section of the SD card. The first two lines of this file :

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

And indeed, after removing the # from the second line the card boots, and the monitor shows the 'Retropie' logo.


The gamepad


Obviously real gaming is only possible using a gamepad or joystick. A Super Nintendo-like gamepad seemed a nice solution, so I bought a (super cheap) USB gamepad...
.. which turned out also to be super-crappy. The D-Pad requires a lot of pressure, and often even fails to detect any movement to the left. Which is very frustrating in almost every game.
So I bought the Logitech F310 gamepad. Almost three times as expensive, but so much better.
Only one problem: it works fine with the EmulationStation interface, but not in any game. This turned out to be the hardest problem so far. Several forums and the wiki have some information regarding this problem, but nothing seemed to work with RetroPie Version 3.0.

UPDATE 2019: RetroPie 4 and up seem to have solved this problem. If you set the the switch on the Logitech to 'X', everything will work out of the box !

With version 3 it requires some modifications. ( Thanks to 'GhostTree3' )

In version 3 the main configuration of the emulators is stored in the file: 
/opt/retropie/configs/all/retroarch.cfg

And it contains the following lines:
# Input device driver. (Valid: linuxraw, sdl, dinput) 
input_joypad_driver = sdl2

The tricky part is that the 'comment' is incorrect (or at least incomplete).
After changing
input_joypad_driver = sdl2
to
input_joypad_driver = xinput

Then it works !. (if you set the gamepad to 'xinput' using the switch on the back)

And if the gamepad still does not work...

One additional pitfall: often the gamepad still does not work,even though the emulator says it is correctly initialized. It seems that the it somehow remains in some 'stale' state when switching from game to game. The solution is to press both the lower (analogue) shoulder buttons simultaneously. Somehow this seems to reset the pad to it's initial state and all buttons will now respond.

MadLittlePixel Complete images

 Much easier than installing everything by hand are the complete images as created by the man that probably never sleeps : MadLittlePixel. On the download page of Arcade Punks you can find links to huge collection of images that offer a complete setup, included hundreds or even thousands of games. So far I only tried one of his 16GB images and it seems to work fine for all console games. Somehow it fails on the Arcade games, but since that is less relevant to me I have not tried to solve this yet.


woensdag 13 maart 2013

Connecting a Chinese TL-WR702N TP-Link Router

The Bank card is just there to show the size. It's not that expensive....

After installing XBMC media centre on my Pi it was obvious it also needed access to my wireless network. I already bought an USB wireless dongle but it probably was the wrong type since I could not get it to work. So I guessed it would be easier to connect it to simple wireless router or bridge. Just some device with a standard Ethernet connection that would connect to my router and just pass the data on.
The cheapest option seemed to be the TL-WR702N nano router at DealExtreme. At only US$18,- this is an absolute bargain. The description mentions it comes with a Chinese user manual but an English version can be found online so what could go wrong?

Well, more than expected.
Following the instructions in the English manual does not let me connect to the router at all. The LED blinks when connecting the LAN cable but no communication seems possible.
The instructions tell you to set your PC to a fixed IP address of 192.168.0.1, Subnet Mask of 255.255.255.0, and Gateway to 192.168.0.254. It should then be possible to ping 192.168.0.254 but that does not work at all.
By monitoring the ethernet interface on my PC using WireShark I noticed that there is actually some communication but it is showing 192.168.1.253 as the source.
And indeed setting the IP address on my PC to 192.168.1.10, the subnet mask to  255.255.255.0 and the default gateway to 192.168.1.253 solves the connection problem. It can now be reached using 'ping' so the next step is to point the browser to 192.168.1.253 . The username admin and password admin brings up the routers homepage...in Chinese....:
All Chinese...But I added the translations
 
Fortunately it is pretty simple basic HTML page so you can copy and paste the Chinese texts into Google translate which reveals the texts as shown in the image above. And from there it is not too hard to recognize the menu's as they are in the English manual.
This is the operating-mode select window:
And this is the DHCP selection window:
Now it's not immediately clear what is the right mode to use. I would expect 'Client' would be the best choice, but both 'Repeater' and 'Bridge' modes also offer the LAN option on the Ethernet port so they will work as well. Probably 'Repeater' is not such a good choice since this will also try to repeat data from other wireless devices which could slow down the datastream to the Pi.
Here are the three steps you need to set up client mode:
From the main window click the 'Setup Wizard' (second item from the top):
Select 'Client' and click the continue button. Next is the 'Client mode setup' . The easiest way to select your local network is to click the 'Scan network' button. This will bring up a list of available wireless networks from which you can select the right one. This will then automatically set the SSID and MAC address.
The Chinese version
The English version (from the manual)
 Now you can select the security mode from the first drop-down box. If you select WPA2 you can enter the password for your network in the lower text-box.
Click the continue button, and the router will reboot in client mode.

zondag 21 oktober 2012

Feeding your Pi

One of the first thing to do if you ordered that Pi without a pre-configured SD card is create one yourself. How hard could that be ..? Just download the 'Raspbian' operating system. and transfer it to a card. Now the download page tells you that 'Windows users should use Win32DiskImager' to transfer the OS to an SD card, but it looks like this software does not even see my SD card. Apparently I'm not the only one with this problem so I found that some people have successfully used the 'RoadKill DiskImage' software which indeed seems to work: That is to say it recognizes the card and writes to it.

Unfortunately: after placing the card in the Pi and power up, nothing happens. The OK LED does not blink and the laptop keeps telling me the Ethernet cable is unplugged so the Ethernet chip is probably not initialised.
Maybe Transcend 32GB is not the right type. So I tried the same procedure with a 4 GB Kingston microSD card. Same result.
Another search gets me to the eLinux wiki which again mentions the problem with Win32DiskImager but then suggests to use 'flashnul' software. Now this is Russian software, runs from the command line and contains some misspelled English texts but it seems to work fine. And indeed, after copying the OS to the 4GB card the Pi actually boots, the OK LED blinks and the Ethernet lights now all come up as well.

zondag 14 oktober 2012

Pi on Display

One of the goals of the Pi was to create a computer that you could use immediately without making much additional costs because you could use peripherals that were available anyway. Now the situation in the UK may be different but there's hardly a surplus of HDMI displays here. (Unused-) VGA displays however are everywhere but not supported by the Pi.
After reading that converting HDMI to VGA is rather complicated because it requires conversion from digital to analogue I started to fear the a suitable converter would probably cost much more than the Pi itself. And indeed most available converters look like this and cost between 40 and 200 dollars ! (2015 UPDATE: Though the link above is still valid, the price of the device has gone down to US$17,- ! Things still move fast in tech-space.)
So when I found this simple 'HDMI V1.4 Male to VGA Female Converter Adapter Cable' at DealExtreme I was a little sceptical. Would a $19,- cable, shipped for free from China, really do the same ? Since $19 is not too much money I decided to take a chance and placed my first order with this Chinese company. Ordering is very simple and within a few clicks the money is transferred from your creditcard to the other end of the world. And then the waiting starts. As mentioned on their website delivery can take upto 15 working days. Which just means three long weeks. And when its shipped through China Post there is just no way you can check the status of your shipment. Even though they have a site where you can enter the tracking number it never seemed to work for me. This is a very common complaint on many forums. The most valuable advice I found was to mark the expected delivery date on your calendar and not think about it until this date has passed. Which is true. Only just before the three weeks has passed the package arrives.
And most important: it works fine. I connected it to an old 1024 x 768 LCD monitor and the text and images appear crisp and clear.

Why should you want a Pi. ?

The Raspberry Pi is probably the most hyped single board computer ever. This $35 Linux computer is selling so fast that they just cannot produce them fast enough to meet the demand. In the week of their introduction the orders were up to 700 units per second ! And why ? What's so special about this little board that makes it so desirable ? Not much actually, and I think 90% of the sales is a kind of  mass hysteria that just pops up once in a while.
Lets look at the original goal: to get young people interested in computer programming in a way the Commodore 64 and ZX-81 did so many years ago. Which is a romantic dream of some men who grew up in this era and think they can transfer their youth to the present.
But the world has changed. Twenty years ago these home computers were the only way you could ever get close or even touch a programmable device. 

Starting a Linux based PC is not easy and requires some real skills. Indeed similar to loading and starting a program on a Commodore 64 or a TRS-80 from your tape-drive or double sided floppy. But there was a compelling reason for 10 year olds to learn these cryptic commands: it was the only way to load a COMPUTER GAME !. If you read the interviews with the all these successful programmers in ' Halcyon Days' you will notice that they all started programming because they wanted to create or play their favourite game. But with about every imaginable game available for free or for a few dollars in the app store this urge definitely no longer exists. I'm sure at least 80% of the Pi's sold so far  will just be used as a cheap mediabox.
Nevertheless, I could not resist to it either so I ordered one. And here I'll try to write down my experiences. Let's see if I can take it a little further than the blinking LED example...