All posts by gamaral

Incredibly handsome open-source software engineer, gamedev and trekkie. I also draw comics in my spare time; they aren't very popular.
IMG_2609_small

Xeno-GC Clone Mini

Xeno-GC Clone Mini

Since I wasn’t satisfied with how I laid out it’s big bother, I decided to redo the board, the Xeno-GC Clone Mini is the end result. It’s about the size of a quarter dollar and twice as sexy. Check out the images above and see for yourself.

Make your own!

The mini model, like it’s big brother, uses 0805 SMD components. No rework station or solder paste required; Just a standard soldering iron and some whiskey (Ok, the whiskey is optional).

Parts

  • 2x 100nF 0805 ceramic capacitors.
  • 2x 1kΩ 0805 resistors.
  • 2x 330Ω 0805 resistors.
  • 1x 100Ω 0805 resistor.
  • 1x Red 0805 LED.
  • 1x Green 0805 LED.
  • 1x Atmel AVR ATmega8L 32-pin TQFP.

Order

You can order your boards directly from (OSH Park)[http://oshpark.com/shared_projects/XDNLoePV]. If you have any questions, feel free to email me. Now go get your homebrew on!

IMG_2559-small

Make your own Raspberry Pi – PSU [R3]

Here’s the Raspberry Pi R3 PCB TH (Through-Hole) model fully populated.

The R3 board is shared on OSH Park which means you can order your own boards which you can assemble yourself!

Components

Here’s the current layout and component values.

rpi-psu-r3 All parts are fairly common, specially the passives. Here are a few suppliers for the parts you may have a hard time finding.

ATTiny85

SparkFun: COM-09378

Mouser: 556-ATTINY85-20PU

Programming

You will need a way to program the ATTiny, I suggest getting yourself an Atmel AVR mkII, a Pocket AVR Programmer or if you already own an Arduino you can make an ArduinoISP.

LD33V

SparkFun: COM-00526

Mouser: 511-LD1117V33

TIP125

Mouser: 511-TIP125

PN2222

Adafruit: 756

Mouser: 512-PN2222ABU

Resources

OSH Park: http://oshpark.com/shared_projects/MmabtNcO

RPi-PSU R2

Make your own Raspberry Pi – PSU [R2]

I received my Raspberry Pi PSU Revision 2 PCBs in the mail last week and I got a chance to populate and test them during the weekend.

The R2 board is shared on OSH Park which means you can order your own boards and assemble for yourself.

Components

Here’s the board, fully populated and with all the parts values highlighted.

RPi-PSU R2 - Components

All parts are fairly common, specially the passives. Here are a few suppliers for the parts you may have a hard time finding.

ATTiny85

SparkFun: COM-09378 Mouser: 556-ATTINY85-20PU

Programming

You will need a way to program the ATTiny, I suggest getting yourself an Atmel AVR mkII, a Pocket AVR Programmer or if you already own an Arduino you can make an ArduinoISP.

LD33V

SparkFun: COM-00526 Mouser: 511-LD1117V33

TIP125

Mouser: 511-TIP125

2N2222A

Mouser: 511-2N2222A Digi-Key: 497-2598-ND

OBSOLITE R3 replaces this component with the 2N3904 and PN2222

Resources

OSH Park: http://oshpark.com/shared_projects/clqtxZaD Video: http://youtu.be/xgsn7Mpjh7g

IMG_2522

GameCube Modchip (Xeno-GC Clone)

Background

I’ve been really getting into making homebrew games. I got my game engine running on the Wii last year and I thought why not give the GameCube a shot. It’s a similar architecture, Broadway (Wii) is pretty much a faster Gekko (GC).

Open-Source to the rescue

I remembered reading about how the more popular modchips (or drivechips) for the GC and Wii worked, so I started looking into making my own. After some digging I found that the Xeno-GC modchip had been open-sourced a couple of years back, so I only needed to compile it and build some compatible hardware.

IMG_2511

This little guy is the final result. I want to keep tweaking the firmware, so I made the board be just the right size to fit a small gap in the back of the GC; This would make it easy to flash and test on the actual hardware. I also made it big enough to allow for easier circuit board population.

IMG_2513

I wired the bottom of the drive unit and ran a few tests. Everything checked out fine so I soldered in the modchip and crossed my fingers. :)

IMG_2514

I proceeded to flash the modchip and it immediately came to life! I then popped in a homebrew game I burned earlier and it worked without a hitch, no laser adjustments needed or anything!

IMG_2520

I cut of a tab in the back of the console cover, this is where the modchip will be placed.

IMG_2521

You can see it here, snug and tight.

IMG_2522

That’s pretty much it! Now I move on to porting my game engine and making a demo.

Issues

I noticed that the modchip would sometimes fail to boot up correctly, I changed the fuses on the AVR so that the modchip would start 64ms after powering up, giving the drive unit some time to setup. I used the following fuse values: 0xE4 0xD9

Make your own!

You can order 3 boards directly from OSH Park and get all the required components from Mouser or Digi-Key. The board and schematic files are available on GitHub.

The modchip firmware can be found in here.

Mini

xeno-gc-mini

I also made a smaller version of the modchip, you can also order it from OSH Park.

IMG_0359

Raspberry Pi – PSU (rpi-pwrbtn)

PCBs

I’ve recently received the first and second revisions of my Raspberry Pi – PSU Through-Hole PCB. They came out pretty well if I do say so myself.

RPI-PSU R1

There are a couple of issues with the R1 and R2 designs that have already been addressed in R3, but since the R3 is not here yet, let’s populate an R2 board and test it out.

We will need to start with the power rail. It’s pretty straight forward – Just like my original prototype, the board takes in 5V which is used to power the Raspberry Pi directly. The micro-controller is powered by a 3v3 rail (hence the LD33V), this reduces power consumption but more importantly makes the micro compatible with the Raspberry Pi’s GPIO.

Programming

After I filled in the power stage, I proceeded to flash the micro using my MKII and some pogo pins.

IMG_0354

I tested the board and since it all checked out fine, I proceeded to populate the rest of the components.

Moment of Truth

I pulled out one of my RPis and hooked up the fully populated PSU.

IMG_0359

No blue smoke came out, which is always good, hooray! :)

IMG_0361

Revision 3

The third revision of the PSU PCB has already been sent to the fab and is under production at the moment of writing, I’ll record a video as soon as I get it showing how it works and how you can build your own!

RPI-PSU R3

Update

I got my Rev3 board in, check it out by clicking the link below:

Make your own Raspberry Pi – PSU [R3]

OSHW

The source code, schematic and board layout for this project is publicly available on GitHub.

GitHub Repository

Marshmallow on the Raspberry Pi

Raspberry Pi GPIO’s using plain C and SysFS

Talk

I recently gave a talk on the Raspberry Pi during which I mentioned using the GPIO sysfs interface instead of something like the WiringPi library, I was asked if I could provide a small example… I can.

Example

I’m about to unleash the electronic world’s version of the “Hello World!” program, a blinking LED. Remember, this example requires no special libraries since it uses the sysfs interface.

blink.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/* blink.c
 *
 * Raspberry Pi GPIO example using sysfs interface.
 * Guillermo A. Amaral B. <g@maral.me>
 *
 * This program blinks GPIO 4 (P1-07) while reading GPIO 24 (P1_18).
 */

#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define IN   0
#define OUT  1

#define LOW  0
#define HIGH 1

#define PIN  24 /* P1-18 */
#define POUT 4  /* P1-07 */

static int GPIOExport(int pin);
static int GPIOUnexport(int pin);
static int GPIODirection(int pin, int dir);
static int GPIORead(int pin);
static int GPIOWrite(int pin, int value);

int
main(int argc, char *argv[])
{
    int repeat = 9;

    /*
     * Enable GPIO pins
     */
    if (-1 == GPIOExport(POUT) || -1 == GPIOExport(PIN))
        return(1);

    /*
     * Set GPIO directions
     */
    if (-1 == GPIODirection(POUT, OUT) || -1 == GPIODirection(PIN, IN))
        return(2);

    do {
        /*
         * Write GPIO value
         */
        if (-1 == GPIOWrite(POUT, repeat % 2))
            return(3);

        /*
         * Read GPIO value
         */
        printf("I'm reading %d in GPIO %d\n", GPIORead(PIN), PIN);

        usleep(500 * 1000);
    }
    while (repeat--);

    /*
     * Disable GPIO pins
     */
    if (-1 == GPIOUnexport(POUT) || -1 == GPIOUnexport(PIN))
        return(4);

    return(0);
}

int
GPIOExport(int pin)
{
#define BUFFER_MAX 3
    char buffer[BUFFER_MAX];
    ssize_t bytes_written;
    int fd;

    fd = open("/sys/class/gpio/export", O_WRONLY);
    if (-1 == fd) {
        fprintf(stderr, "Failed to open export for writing!\n");
        return(-1);
    }

    bytes_written = snprintf(buffer, BUFFER_MAX, "%d", pin);
    write(fd, buffer, bytes_written);
    close(fd);
    return(0);
}

int
GPIOUnexport(int pin)
{
    char buffer[BUFFER_MAX];
    ssize_t bytes_written;
    int fd;

    fd = open("/sys/class/gpio/unexport", O_WRONLY);
    if (-1 == fd) {
        fprintf(stderr, "Failed to open unexport for writing!\n");
        return(-1);
    }

    bytes_written = snprintf(buffer, BUFFER_MAX, "%d", pin);
    write(fd, buffer, bytes_written);
    close(fd);
    return(0);
}

int
GPIODirection(int pin, int dir)
{
    static const char s_directions_str[]  = "in\0out";

#define DIRECTION_MAX 35
    char path[DIRECTION_MAX];
    int fd;

    snprintf(path, DIRECTION_MAX, "/sys/class/gpio/gpio%d/direction", pin);
    fd = open(path, O_WRONLY);
    if (-1 == fd) {
        fprintf(stderr, "Failed to open gpio direction for writing!\n");
        return(-1);
    }

    if (-1 == write(fd, &s_directions_str[IN == dir ? 0 : 3], IN == dir ? 2 : 3)) {
        fprintf(stderr, "Failed to set direction!\n");
        return(-1);
    }

    close(fd);
    return(0);
}

int
GPIORead(int pin)
{
#define VALUE_MAX 30
    char path[VALUE_MAX];
    char value_str[3];
    int fd;

    snprintf(path, VALUE_MAX, "/sys/class/gpio/gpio%d/value", pin);
    fd = open(path, O_RDONLY);
    if (-1 == fd) {
        fprintf(stderr, "Failed to open gpio value for reading!\n");
        return(-1);
    }

    if (-1 == read(fd, value_str, 3)) {
        fprintf(stderr, "Failed to read value!\n");
        return(-1);
    }

    close(fd);

    return(atoi(value_str));
}

int
GPIOWrite(int pin, int value)
{
    static const char s_values_str[] = "01";

    char path[VALUE_MAX];
    int fd;

    snprintf(path, VALUE_MAX, "/sys/class/gpio/gpio%d/value", pin);
    fd = open(path, O_WRONLY);
    if (-1 == fd) {
        fprintf(stderr, "Failed to open gpio value for writing!\n");
        return(-1);
    }

    if (1 != write(fd, &s_values_str[LOW == value ? 0 : 1], 1)) {
        fprintf(stderr, "Failed to write value!\n");
        return(-1);
    }

    close(fd);
    return(0);
}

You can download the source by clicking here.

Marshmallow on the Raspberry Pi

Raspberry Pi Buildroot – 3.8.6 Kernel Branch

I’ve added a new branch to rpi-buildroot. The 3.8 branch uses the new 3.8.6 Linux kernel provided by the Raspberry Pi Foundation.

This distro is based on Buildroot, that means it very flexible and well suited for numerous customized embedded linux applications. Makers will find it extremely useful since it can be used to create powerful custom deployments – Want to control a robot using a Raspberry Pi? then this is the distro for you – Please keep in mind that the default configuration builds a system with nothing more than the bare essentials.

Please checkout the README file for more information.

You may download the test-drive SD-card image here: http://dl.guillermoamaral.com/rpi/sdcard-3.8.img.xz (user root – no password)

How to build it yourself!

1
2
3
4
  git clone --depth 1 -b rpi-3.8 git://github.com/gamaral/rpi-buildroot.git
  cd rpi-buildroot
  make raspberrypi_defconfig
  make

How to flash

1
2
3
  wget http://dl.guillermoamaral.com/rpi/sdcard-3.8.img.xz
  xz -d sdcard-3.8.img.xz
  sudo dd if=sdcard-3.8.img of=/dev/**YOUR-DEV-NODE**
VIDEOGAMES2

Gameinis VIDEOGAMES 2 Taredown

I found this little console while lounging around a Walmart as I waited for a movie to start at the cinema. I should point out it was a Mexican Walmart, I’m not sure if the US ones would/could actually carry this little device since it has plenty of probably unlicensed ROMs lurking inside it’s crappy interior. Priced at 10 USD (120 MXN) who could resist!

After purchasing it, kids kept walking up to me and asked about the console, clearly excited about all the old-school games inside. They where aware it was not a PS3 or an XBOX 360, they didn’t care, it was true 8-bit love. I have to admit, that made me very happy.

Taredown

I started by removing the easily accessible screws underneath the console.

IMG_2466

Exposing what I pretty much expected, an extremely simple system held together with hot glue.

IMG_2467

From this angle you can tell that the two single sided boards on each end are just breakout boards for the different connectors required by the system; with the exception of the L7805CV regulator and it’s accompanying decoupling capacitors.

IMG_2468

The boards seem to have been screen printed, the traces also look a little oddly shaped. If you look closely, you can still see quite a lot of flux residue, dirty.

IMG_2469

The other board doesn’t look any better sadly. Also, they went and soldered all the TH components and jumpers on the bottom side. Not really sure why…

IMG_2473

The top side of the main board looks pretty much as you would expect, one big cartridge slot, what looks like a 21 Mhz crystal oscillator and a few capacitors.

IMG_2470

The real action is on the bottom. It looks to be some sort of chip-on-board design, this little guy in the middle is why I took so long to post this tare down; I wanted to maybe try to dissolve the epoxy but I kept getting distracted by work. In the end I decided against it, since I don’t have a powerful enough microscope for it to really be worth busting out the acid.

IMG_2472

Bonus

The cartridge seems to be another breakout-like board for what looks to be a NAND flash. I’m going to try to get some data off the flash memory, I’ll post and update when and if I’m successful. :)

IMG_2476

IMG_2477

What now?

I’m going to put it back together and give it away to the first kid to walk up to me at the mall next week. :)

scale11x

Marshmallow at SCaLE 11x

I’m back from another great Southern California Linux Expo, I’m quite happy with the turnout to both the Marshmallow booth and my talk. I got tons of positive feedback, beer, magic shows and game ideas; one of my favorites involved hunting down Bill Gates with drones (a reverse Duck Hunt if you will).

SCaLE 11x

I had some schwag for the event, this included t-shirts, bookmarks, stickers, buttons and random booth paraphernalia. Most of which was gone by Sunday morning due to a herd of middle-schoolers that swamped the booth on Saturday.

718A7FA6-CCCE-4EDF-BA71-EBDE4936BFA6

People kept trying to buy the booth Marshmallows off me, I guess I will have to make some extra ones for next year. :)

Talk

I was surprised to see that the room was packed when I walked in about 10 minutes prior to show time. It went well considering I lost my voice earlier that week. My throat was killing me since I had to go mic-less due to some “technological differences” (Idiocracy, 2006), I was worried it was going to start bleeding, luckily it didn’t.

If you’re interested in trying out the demo used during my talk, it’s available in both 32-bit or 64-bit versions of Linux. Simply extract and execute the “run” script found inside the resulting marshmallow_demo directory.

The demo requires a recent version of the Linux kernel along with a working OpenGL setup.

Thank You

I’d like to thank the SCaLE organizers for their support and I hope we get invited back next year. I’ll leave you with a quote from an email I got soon after arriving home.

Yours was my favorite booth at SCALE; low budget, and I got to learn about something I hadn’t heard of before. Keep up the good work on the project! -Jim Garrison