VoCore: A coin-sized Linux computer with Wi-Fi for USD 20

In early July I’ve found an Indiegogo project of a miniature Linux powered computer called VoCore.

It is a RaLink RT5350 (360 MHz MIPS24KEc) based board with 8 MB SPI Flash (although Vonger, the creator of the project upgraded to a 16 MB Flash for the Indiegogo batch just because he’s a nice guy) with two 10/100 Mbps Ethernet interfaces, one USB 2.0 interface, a bunch of serial interfaces (UART, I2C, I2S, PCM, JTAG) and over 20 GPIOs. All these broken out to standard 1.27 mm connectors while keeping the size at 25×25 mm!

There is a dock to provide some connectors: an Ethernet, a USB, a micro USB (for the power) and a micro SD card slot – this measues 25×25 mm as well, of course.

VoCore is running the OpenWRT firmware. It acts as an access point by default, running a network called “VoCore” (this is unfortunately an open network (i.e. no encryption set up) so changing security settings as soon as possible is recommended).

Vonger, the creator of the project is running a blog at vonger.cn, he was constantly updating it with the latest status of the VoCore development and production, both bad and good news. Thanks to this it seemed that we were witnessing all the little details, it felt like we (the backers) were parts of the whole process :)

The VoCore can be ordered from vocore.io/store. If you would like to have the VoCore main board only (with all the I/O breakouts but no connectors at all) it is USD 20, but if you’d like to have the Dock as well, plus a USB to TTL converter (note: this is missing from my pictures below!) to re-flash the firmware it is just USD 45.

I believe that the VoCore has a lot of potential thanks to its small size (25×25 mm) its low power consumption (0.6-1.2 Watts) its flexibility (20+ GPIOs and the whole bunch of connector break outs) and low cost.

I think this is a must have board for any geeks out there who have thought about hacking some hardware once in a while.

Oh, and one more thing: VoCore is open source, both software and hardware. All the schematics, circuits, firmware, 3D model for the shell/case, everything is available to download from the VoCore’s site.

 

GameBoy hardware hacking: Part 1

In the case of GameBoy and GameBoy Color systems the console itself holds just a really minimal program on the board, the so-called boot ROM (256 bytes long). It does the initialization of the components and the cartridge, also it reads the header part of the program stored on the cartridge and checks if that is valid. (Fun fact: the scrolling Nintendo logo is read from the cartridge and it is really a test to see if the cartridge can be accessed correctly. The logo is then compared to the one stored in the boot ROM to see if it was read correctly, if not that indicates some pins are not working and the CPU halts. This is when you need to blow the cartridge.).

All the other program code (i.e. the game itself and all the instructions to make it work) is located on the GameBoy Cartridge alongside with the textures, sounds and all the rest.

So the cartridge is basically the part of the system, the CPU reads it directly when it needs the next instruction and executes the code from there without copying it to its own memory.

The cartridges usually consist of the following components:

  • ROM: Read Only Memory
    Stores the program code and all the resources needed for the game. It is programmed once and then never written again.
  • MBC: Memory Bank Controller (optional)
    The Memory Bank Controller switches banks of the addressable memory space (32 kilobyte in total). The lower 16 kilobytes are always the first 16 kilobytes of the ROM while the upper 16 kilobytes are switchable between several blocks (i.e. part of the ROM or the RAM). There are several MBCs out there with their own purposes. This is a really long story, I’ll write more about this later.
  • RAM: Random Access Memory (optional)
    This is a readable and writable storage, when a game has high-score list, saved game state, etc. it holds them information in the RAM. This is a standard SRAM so this is volatile – it needs constant power to keep the data alive this is why cartridges with RAM need batteries as well.
  • Battery: (optional)
    The battery provides power for the RAM to keep the stored data alive.
  • Connector:
    Last but not least, all the cartridges have a 32 pin connector that provides a connection between the console and the components of the cartridge.

The interface between the console and the cartridge consists of 32 pins (direction is written from console perspective, out: from console to cartridge, in: from cartridge to console):

  • pin 1 [out]: VCC (+5 V)
    This is the supply pin for the cartridge and its components (i.e. the ROM, RAM, MBC).
  • pin 2 [n/c]: not connected or CPU clock
    I have not seen this pin connected so far but some documents claims this is a direct output of the CPU clock. I ran a logic analyzer on this pin, it showed a high-low pattern alternating at 1.04 MHz (0.46 µs high followed by 0.50 µs low).
  • pin 3 [out]: !write
    This is a signal line that is low when a write request is made to RAM. Otherwise this is high.
  • pin 4 [out]: !read
    This is a signal line that is low when a read reqeust is made to ROM, MBC or RAM. Otherwise this is high.
  • pin 5 [out]: !RAM select
    This line is low when the RAM or the MBC is being accessed. Both of them supports reads and writes. Otherwise this is high.
  • pin 6..21 [out]: address selection bit 0..15
    These bits sets the address that is being written or read in the RAM, ROM, or in the MBC registers.
  • pin 22-29 [out/in]: data in/out bit 0..7
    When the console wants to read from the ROM, RAM or MBC these pins are inputs, their values being set by the remote component. When the console wants to write data these are outputs, set to the data by the console.
  • pin 30 [out]: !reset
    When the console reboots it sets this pin high after about 4-5 ms. This delay is probably introduced to give the clock a few cycles to stabilize.
  • pin 31 [n/c]: not connected or analog audio input
    I have not seen this pin connected so far but some documents claims this is an analog audio input. (I think I’ve read something about a direct sound channel on the GameBoy CPU, but that might be a different story.)
  • pin 32 [out]: GND
    The ground connection for the cartridge and all the components.

In the following posts I will write about the different cartridge and MBC types, and also will post schematics and circuits to build a few different homebrew GameBoy cartridges. Stay tuned.

Multiplayer gaming, part 1: Sync the future!

Last year I was writing a little game intended to be run in the browser. I was writing it in pure javascript (i.e. no graphics or whatsoever was stored, everything was dynamically generated) for the js13k Games 2013, it is the Untitled 13 (can be played here).

One of the base concepts was to build a multiplayer game. It was challenging despite I’ve written some basic games, also mulitiplayer ones, I’ve never tried to write a real-time strategy game yet (not counting a quick POC). The synchronization of the game between players was the most interesting part of it, and therefore my favorite one. I was not intended to sync the whole game state (map, objects, internal states, etc.) continuously as this can easily become a huge set of data even for tiny games at high refresh rates so I decided I will come up with a better, more resource-friendly solution.

I’ve been thinking about the game: it has some mechanics, player events events and also their effects on the gameplay and concluded one could be separated from the other – of course it turned out that I was not the first who came up with this approach. So instead of syncing everything, I was thinking about synchronizing just the map in its starting state and a list of events.

All these events were always originated from the players (i.e. buy an item, toggle a switch) or from the game mechanics (i.e. an enemy is close enough to be fired on, an object loses health, objects collide). As the game on both ends are always identical the result of mechanics should be always identical too, therefore all I left to deal with were the events from the players.

So basically all I was doing is this: my game had so-called “ticks” that were the updates for the game internal states (this event was happening with a guaranteed interval, i.e. 15 times per seconds, or if late (due to lack of CPU resources or bad timing) all the affected ticks ran anyways to catch up), and when a player did an action (i.e. clicked a switch) I stored a record in a queue about it and a “process this on the nth tick” property. I’ve also sent this record over the network to the other player. This way I introduced a slight delay (this nth tick was always about 300 milliseconds in the future) but during this delay I sent the event to the other player and when the nth tick came both players made the change on their isolated environment in the exact same moment (speaking in game time) and therefore both ends have seen the same new state, the game is deterministic.

Later I’ve learned – in a Gaffer on Games post and in another one about network programming in Age of Empires (both are must reads!) – this is a so called simultaneous simulation approach with one big difference. The handling of the lag on the network. This was the worst thing during the development and tests of the game. As I’ve been syncing future events if the notification got stuck somewhere between the players it could easily come later than it must have been executed. As the tick it was intended to be run at was passed (and the other player have executed at that time) the game became out of sync. And this is bad, really bad. (I’ve made some efforts to handle this, but these turned the game code much more complicated, i.e. to be sure that important events happen on both sides I added them as an event to the queue (and sent that over the network), that’s why the little creatures pause for a while before exploding at the target markers. But this is bad, don’t do this. Keep reading for a simpler solution instead.)

In a real simultaneous simulation the players should be aware of the lag in the propagation of events so instead of just saying “here, run this on the nth tick” there needs to be a “I have nothing for you to run on the nth tick, carry on”. And if the other player does not specify what to do (or not to do) on the nth tick when it comes the simulation should pause while it is unsure about what to do. Which is not nice but far much better than becoming out of sync. Obviously working with 15 ticks per seconds and expecting the network to transfer the data for the next tick is nearly impossible (talking about transmitting over the internet as this would permit about a 66 milliseconds deadline on a client1-server-client2 route, also sending at least 15 events every second) and would result frequent pauses, and that would be really annoying. So instead of scheduling events for any tick of the game a rule should be applied to limit the ticks that can accept events. Saying events can be scheduled only for every 5th ticks reduces the count of transmitted packets dramatically, also extends the deadline to a more sane value.

Also, when a pause occurs due to network lag the rule of scheduling could change i.e. not every 5th but every 10th tick should accept events. And likewise when the network seems reliable for a long time this number could decrease.

But this topic will be covered in another post, first I’ve to try this approach. Although I think this should work nicely as games like Age of Empires and Warcraft used this method pretty reliably.

Recommended reading:

r42.cc

Lately I’ve been designing some little PCBs and thought it would be nice to add a short URL on it leading to a page about that particular PCB (or PCB series in the future). Also, adding the short URL to any other things I (or we, as a little maker team with a few of my friends) create. Although this will probably not have any sort of impact on the early designs (made in just one copy), it’d make them more personal, I guess.

So I had to come up with a short domain name – I already have one but that is under the .hu TLD – that gives away something about the purpose of itself… It was ridiculously challenging to find one that is not already taken in the .com/.org/.cc world. In the end I’ve chosen the r42.cc. The first part stands for revision42, something that is probably reached by a successful project (and of course, 42 is the answer), and the cc stands for creative community.

So if I put here some photos and designs in the future you should check it for this URL and open it to see some related content.

Random Idea: Moving Munzees

I’ve been playing Geocaching for a while now.

Lately I’ve started to play Munzee, a game that is the little brother of Geocaching in my point of view. It is working by the same idea, you’ve given the coordinates and you have to find the hidden treasure. Although here is no treasure at all, just a QR code stuck to a surface – usually at the back of (traffic) signs and bottom of traffic lamps. So finding it is not that great challenge after a while…

The idea is the following: what if we stuck the QR codes on non fixed objects, but moving ones? I.e. you could stick it on a train (somewhere hidden, not on a window or seat, so where you could only find it if you’re looking for it). It would be more challenging, and also you could track where the object travels (could be illustrated on a “spotted here” map) also you could meet something you met earlier at a different place.

I think this could add another layer of fun to the game.