An Apple ][ Emulator On An Arduino Uno

April Fools’ Day may have passed, but we really had to check the calendar on this hack. [Damian Peckett] has implemented an Apple ][, its 6502 processor, and a cassette port, all on an Arduino Uno. If that wasn’t enough, he also uses a PS/2 keyboard for input and outputs analog VGA. [Damian] is doing all this with very few additional components. A couple of resistors, a capacitor and some very clever hacking were all [Damian] needed to convince an Arduino Uno that it was an Apple.

Making all this work boiled down to a case of resource management. The original Apple ][ had 4KB of RAM and 8KB of ROM. The ATmega328 has only 2KB of RAM, but 32KB of Flash. The only way to make this hack work would be to keep as much of the emulation and other routines in Flash, using as little RAM as possible.

The core of this hack starts with the MOS 6502, the processor used in the Apple. [Damian] wrote a simple assembler which translates the 6502 opcodes and address modes to instructions which can be executed by the Arduino’s ATmega328. To keep everything in ROM and make the emulator portable, [Damian] used two large switch statements. One for address modes, and a 352 line switch statement for the opcodes themselves.

A CPU alone is not an Apple though. [Damian] still needed input, output, and the ROM which made the Apple so special. Input was through a PS/2 keyboard. The PS/2 synchronous serial clock is easy to interface with an Arduino. Output was through a custom VGA implementation, which is a hack all its own. [Damian] used the lowly ATmega16u2 to generate the video timing. The 16u2 is normally used as the Arduino Uno’s USB interface. The only external hardware needed is a single 120 ohm resistor.

The original Apples had cassette and speaker interfaces. So does this emulated Apple. [Woz’s] original cassette and speaker interface accurate loops to generate and measure frequencies. One of the trade-offs [Damian] accepted in his 6502 was cycle accuracy, so he couldn’t use the original routines. Not a problem though, as he was able to write simple functions to replace these routines and drop them in place of the Apple’s own ROM calls.

The Apple ][ ROM itself is handled as one giant character array. This includes the system monitor, Mini-Assembler, Sweet-16, and [Woz’s] own Integer Basic. [Damian] caps off this incredible project by booting his new computer, loading a  Mandelbrot set program from cassette -or in this case an audio file stored on his cell phone, and running it. The well-known fractal is displayed in all its glory on a modern LCD monitor, driven by a microcontroller, emulating a computer from nearly 40 years ago.

Continue reading “An Apple ][ Emulator On An Arduino Uno”

Hacklet 41 – Prosthetics Projects

Throughout human history, mankind has worked to enable those with disabilities. This applies especially to those who have missing limbs, either from injury or since birth. Every time technology improves, prosthetics improve along with the way. Unfortunately this now means prosthetics have become expensive systems. Hackers, makers, and engineers are working to make prosthetics more affordable, and more available to everyone. This week’s Hacklet focuses on some of the best prosthetics projects on Hackaday.io!

bionic1We start with [Open Bionics] and Affordable Bionic Hands For Amputees. The [Open Bionics] team are using 3D printers to bring the cost of a prosthetic arm and hand down from up to $100,000 USD to just $1000 USD. They’ve also reduced the time to create a custom device from weeks to just 5 days. The team’s current hand has five degrees of freedom, uses electromyography (EMG) for control, and weighs just 268 grams. [Open Bionics] discovered that many amputees are willing to trade off functions for a lighter weight device. Having a sensor and motor studded hand won’t help much if the wearer is worn out after just a couple of hours!

bionic2Next up is [yash.gajra56] and RE-ARM. RE-ARM is a prosthetic arm project which aims to help both those who have lost limbs, and those with full or partial paralysis of a limb. Movement is provided by radio control style servos. Control is via voice commands and Bluetooth from a cell phone. [Yash] has incorporated feedback into RE-ARM by using flex sensors. Processing is handled by an Arduino. We like the low-cost, low tech approach RE-ARM uses. We’d love to see everyone have access to a 3D printer, but unfortunately the world isn’t there quite yet. RE-ARM uses readily available components to build a functional prosthetic. Nice work [yash]!

bionic3[OpenBionics] brings us  Affordable Prosthetic Hands. No, you didn’t read that name wrong. There are two “Open Bionics” on Hackaday.io! This [OpenBionics] team has no space, and is based in Athens, Greece. The other [Open Bionics] team does have a space between the words, and is based in Bristol in the United Kingdom. We’re hoping the two groups can come together and collaborate now that they’re both using Hackaday.io. This [OpenBionics] team is working on prosthetic hands, in the sub $200 USD price range. The team has come up with a novel thumb design which provides nearly full functionality with only one rotating joint. [OpenBionics] also allows their users to selectively lock digits, which allows for up to 144 different grasping postures.

 

bionic4

Finally we have [Daniel Mead] with Third World Medical Equipment (Arm). [Daniel] created this project as an independent study back in high school. The idea is create a simple arm with a gripper out of cheap or freely available items. The gripper is fashioned from a bicycle brake. The fitting system is especially novel. [Daniel] used an old soda bottle to create a custom mold for the amputee’s residual limb. Plastic bottles are generally made of polyethylene terephthalate, or PET, a thermoplastic. [Daniel] placed a wet sock over his arm, and a plastic bottle over the sock. Holding the plastic bottle above a fire created enough heat to shrink the bottle to his arm. the sock provided room for padding, and insulated him from getting burned during the molding process.

Not satisfied? Want more prosthetics? Check out the Prosthetics list over on Hackaday.io! If any of these projects inspire you, don’t forget that prosthetics are a great starting point for an entry in The Hackaday Prize!

That’s about all the time we have for this week’s Hacklet. As always, see you next week. Same hack time, same hack channel, bringing you the best of Hackaday.io!

Caption CERN Contest Is A GO For Week 9

Thanks for another week of great entries in the Caption CERN Contest over at Hackaday.io! We still aren’t sure if our CERN staffer is looking at that machine pensively, amorously, or with a bit of confusion, but you all found some great words to go with the image!

The Funnies:

  • “Dr. Breman’s early attempts to create the perfect robot woman had some early success, but was later scrapped do to a tragic input/output error.” – Terry Davis
  • “You were supposed to be intelligent, my dear. What do you mean by segfault?” –elias.alberto
  • “CERN’s pioneering computer dating service didn’t quite work out as expected.” – Nick Johnson

The winner for this week is Stripeytype with the quote seen in the top image of this article. Stripeytype will be sporting a CRT head T-Shirt From The Hackaday Store at their next hackerspace meeting.

cern-9-smWe’re not done searching out they mysteries of CERN’s history. Week 9 of the Caption CERN Contest has just begun! 

Some of CERN’s experiments take place in the miles of tunnels below their labs in and around Meyrin, on the border of France and Switzerland. It looks like this image was taken in one of those tunnels. It’s definitely an interesting shot. CERN’s documentation for the image has been lost to history, so it’s up to you to explain what’s going on here! Add your humorous caption as a comment to the project log. Make sure you’re commenting on the log, not on the project itself. As always, if you actually have information about the image or the people in it, let CERN know on the original image discussion page.

Good Luck!

Caption CERN Contest Enters Week 8

The Caption CERN Contest has been going great guns thanks to the community of users over on Hackaday.io. The contest just finished up its seventh week of finding funny captions for images which CERN has in their archives. CERN has decades of great photo documentation of their projects. Unfortunately they don’t know which project each image goes with, or who exactly is in the image. We’re helping them out where we can, by letting CERN know any information we can find on their photos. We’re also having some fun along the way, by giving out a T-Shirt for the best caption each week.

Here are some of the best quotes from week 7

The Funnies:

“Are Socks and Sandals acceptable safety equipment for the Demolition Pit? Yes, because these are Kelvar socks and Zylon sandals being testing. Quite uncomfortable, but these feet will survive a close proximity blast.” – [controlmypad]

“Check it out! One tube for each Ninja Turtle” – [OzQube]

“Before the LHC, hunting for the Higgs was much less glamorous.” – [Tachyon]

The winner of course is [Tim] with the featured image at the top of this article.

week6winrarIf [Tachyon] sounds familiar, that’s because he came up with the best caption back in week 6. Runners up for week 6 were:

“Damn Mario Brothers ….. ‘gotta save the princess’ How about watching where you’re going for once. – [Scott Galvin]

“Here at CERN, you don’t get shafted. You get tubed.” – [Rollyn01]

“Thank god the separator caught him. Another 50 meters, and he’d be nothing but quarks.” – [Curtis Carlsen]

Click past the break to check out this week’s image!

Continue reading “Caption CERN Contest Enters Week 8”

Mustachioed Nintendo Virtual Boy Gone Augmented Reality

Some people just want to watch the world burn. Others want to spread peace, joy and mustaches. [Joe Grand] falls into the latter group this time around. His latest creation is Mustache Mayhem, a hack, video game, and art project all rolled into one. This is a bit of a change from deconstructing circuit boards or designing electronic badges, but not completely new for [Joe], who wrote SCSIcide and Ultra SCSIcide for the Atari 2600 back in the early 2000’s.

Mustache Mayhem is built into a Nintendo Virtual Boy housing. The Virtual Boy itself was broken, and unfortunately was beyond repair. [Joe] removed most of the stock electronics and added a BeagleBone Black, Logitech C920 webcam, an LCD screen and some custom electronics. He kept the original audio amplifier, speakers, and controller connector. Angstrom Linux boots into [Joe’s] software, which uses OpenCV to detect faces and overlay mustaches. Gameplay is simple: Point the console at one or more faces. If you see a mustache, press the A button on the controller! The more faces and mustaches on-screen at once, the more points, or “mojo” the player gets. The code is up on Github, and can be built with Xcode targeted to the Mac, or directly on the BeagleBone Black.

[Joe’s] goal for the project was to make a ridiculous game that looks like it could have come out in the 90’s. He also used Mustache Mayhem as a fun way to learn some new skills which will come in handy for more serious projects in the future.

We caught up with [Joe] for a quick interview about his new creation.

How did you come up with the idea for Mustache Mayhem?

blockI was selling a bunch of my video game collection at PRGE (Portland Retro Gaming Expo) a few years ago and had a broken Virtual Boy that no one bought. A friend of mine was at the table and said I had to do something with it. I thought “People wear cosplay and walk around at conventions, so what if I could do something with the Virtual Boy that you could walk around with?” That was the seed.

A few months later, Texas Instruments sent me the original production release of the BeagleBone Black (rev. A5A). Eighteen months after that I actually started the project. The catalyst was to do something for an upcoming Portland, OR art show (Byte Me 4.0), which is an annual event that shows off interactive technology-based artwork. I wrote up a little description and got accepted. I had less than 2 months to actually get things working and it ended up taking about a month of full-time work. It was much more work than I expected for such a silly project. I originally was going to do something along the lines of walking around in a Doom-like perspective and shooting people when their faces were detected.

That would be pretty darn cool. How did you get from Doom to Mustaches? 

I saw a TI BeagleBoard demo called “boothstache” which drew mustaches on faces and tweeted the pictures. I thought that doing something non-violent with mustaches would be more suitable (and funny) to actually show my kids. I also secretly wanted to use this project as a way to experiment with Linux, write some code, and learn about face detection and image processing with OpenCV, which I plan to use for some actual computer security research in the future. Mustache Mayhem turned out to be a super cool project and I’m really happy with it. I sort of feel guilty spending so much time on it, since it’s basically just a one-off prototype, but I just got so obsessed with making it exactly as I wanted.

You mentioned on your website that Mustache was “designed to challenge the paradigms of personal privacy and entertainment.” What exactly did you mean there?

Continue reading “Mustachioed Nintendo Virtual Boy Gone Augmented Reality”

Creative DRAM Abuse With Rowhammer

Project Zero, Google’s security analyst unit, has proved that rowhammer can be used as an exploit to gain superuser privileges on some computers. Row Hammer, or rowhammer is a method of flipping bits in DRAM by hammering rows with fast read accesses. [Mark Seaborn] and the rest of the Project Zero team learned of rowhammer by reading [Yoongu Kim’s] 2014 paper “Flipping Bits in Memory Without Accessing Them:
An Experimental Study of DRAM Disturbance Errors” (PDF link). According to [Kim], the memory industry has known about the issue since at least 2012, when Intel began filing patents for mitigation techniques.

Row hammer” by DsimicOwn work. Licensed under CC BY-SA 4.0 via Wikimedia Commons.

The technique is deceptively simple. Dynamic RAM is organized into a matrix of rows and columns. By performing fast reads on addresses in the same row, bits in adjacent rows can be flipped. In the example image to the left, fast reads on the purple row can cause bit flips in either of the yellow rows. The Project Zero team discovered an even more aggressive technique they call “double-sided hammering”. In this case, fast reads are performed on both yellow rows. The team found that double-sided hammering can cause more than 25 bits to flip in a single row on a particularly vulnerable computer.

Why does this happen? The answer lies within the internal structure of DRAM, and a bit of semiconductor physics. A DRAM memory bit is essentially a transistor and a capacitor. Data is stored by charging up the capacitor, which immediately begins to leak. DRAM must be refreshed before all the charge leaks away. Typically this refresh happens every 64ms. Higher density RAM chips have forced these capacitors to be closer together than ever before. So close in fact, that they can interact. Repeated reads of one row will cause the capacitors in adjacent rows to leak charge faster than normal. If enough charge leaks away before a refresh, the bit stored by that capacitor will flip.

Cache is not the answer

If you’re thinking that memory subsystems shouldn’t work this way due to cache, you’re right. Under normal circumstances, repeated data reads would be stored in the processor’s data cache and never touch RAM. Cache can be flushed though, which is exactly what the Project Zero team is doing. The X86 CLFLUSH opcode ensures that each read will go out to physical RAM.

Wanton bit flipping is all fine and good, but the Project Zero team’s goal was to use the technique as an exploit. To pull that off, they had to figure out which bits they were flipping, and flip them in such a way as to give elevated access to a user level process. The Project Zero team eventually came up with two working exploits. One works to escape Google’s Native Client (NaCL) sandbox. The other exploit works as a userspace program on x86-64 Linux boxes.

Native Client sandbox escape exploit

Google defines Native Client (NaCL) as ” a sandbox for running compiled C and C++ code in the browser efficiently and securely, independent of the user’s operating system.”  It was designed specifically as a way to run code in the browser, without the risk of it escaping to the host system.  Let that sink in for a moment. Now consider the fact that rowhammer is able to escape the walled garden and access physical memory. The exploit works by allocating 250MB of memory, and rowhammering on random addresses, and checking for bit flips. Once bit flips are detected, the real fun starts. The exploit hides unsafe instructions inside immediate arguments of “safe” institutions. In an example from the paper:

20EA0: 48 b8 0f 05 EB 0C F4 F4 F4 F4 movabs $0xF4F4F4F40CEB050F,%rax 

Viewed from memory address 0x20EA0, this is an absolute move of a 64 bit value to register rax. However, if we move off alignment and read the instruction from address 0x20EA02, now it’s a SYSCALL – (0F 05).  The NaCL escape exploit does exactly this, running shell commands which were hidden inside instructions that appeared to be safe.

Linux kernel privilege escalation exploit

The Project Zero team used rowhammer to give a Linux process access to all of physical memory. The process is more complex than the NaCL exploit, but the basic idea revolves around page table entries (PTE). Since the underlying structure of Linux’s page table is well known, rowhammer can be used to modify the bits which are used to translate virtual to physical addresses. By carefully controlling which bits are flipped, the attacking process can relocate its own pages anywhere in RAM. The team used this technique to redirect /bin/ping to their own shell code. Since Ping normally runs with superuser privileges, the shell code can do anything it wants.

The TL;DR

Rowhammer is a nasty vulnerability, but the sky isn’t falling just yet. Google has already patched NaCL by removing access to the CLFLUSH opcode, so NaCL is safe from any currently known rowhammer attacks. Project Zero didn’t run an exhaustive test to find out which computer and RAM manufacturers are vulnerable to rowhammer. In fact, they were only able to flip bits on laptops. The desktop machines they tried used ECC RAM, which may have corrected the bit flips as they happened. ECC RAM will help, but doesn’t guarantee protection from rowhammer – especially when multiple bit flips occur. The best protection is a new machine – New RAM technologies include mitigation techniques. The LPDDR4 standard includes “Targeted Row Refresh” (TRR) and “Maximum Activate Count” (MAC), both methods to avoid rowhammer vulnerability. That’s a good excuse to buy a new laptop if we ever heard one!

If you want to play along at home, the Project Zero team have a rowhammer test up on GitHub.

[James] Multiplies His Floor Sander By Four

Hackaday contributor and new homeowner [James Hobson] had a dilemma on his hands. He had rented a commercial drum sander to begin a floor refinishing project. Like many before him, James was a bit too aggressive with the drum sander in places. The uneven stripes didn’t show up until the sander was returned and the floor was stained. Renting the sander again would be an expensive prospect. There had to be a better answer…

That’s when [James] put on his [Hacksmith] cape and got to work. He built himself a DIY floor sander (YouTube Link) using four Ryobi orbital sanders, some scrap wood, and a bit of ingenuity. [James] screwed the four sanders to a plywood sub plate, then added a top plate with a handle. He even gave the sander its own outlet strip so he wouldn’t be dragging four power cords behind him.

[James] found that synthetic steel wool pads weren’t cutting through the floor very well, so he upgraded to 220 grit sandpaper. That did the trick, and the sander worked great. Now he won’t have to rent a drum sander when it comes time to refinish the first floor of his new house!

Continue reading “[James] Multiplies His Floor Sander By Four”