Linux On Your NES Classic Edition

Nintendo look as though they may have something of a hit on their hands with their latest console offering. It’s not the next in the line of high-end consoles with immersive VR or silicon that wouldn’t have looked out of place in last year’s supercomputer, instead it’s an homage to one of their past greats. The NES Classic Edition is a reboot of the 1980s console with the familiar styling albeit a bit smaller, and 30 of the best NES games included.

You do not, however, get an original NES with a 6502 derived processor, and a stack of game cartridges. In the Classic Edition is a modern emulator, running on very modern hardware. We’re told it contains an Allwinner R16 quad-core Cortex A7 SoC, 256Mb of RAM, and 512Mb of Flash. That’s a capable system, and unsurprisingly any hacking potential it may have has attracted some interest. Reddit user [freenesclassic] for example has been investigating its potential as a Linux machine, and has put up a post showing the progress so far. It is known that there is already some form of Linux underpinning the console because Nintendo have released a set of sources as part of their compliance with the terms of the relevant open-source licences. That and the availability of a serial port via pads on the PCB gives hope that a more open distro can be installed on it.

We’re taken through the process of starting the machine up with the serial port connected to a PC, and getting it into the Allwinner FEL mode for low-level flashing work. Then we’re shown the process of loading a custom U-Boot, from which in theory a kernel of your choice can be loaded.

Of course, it’s not quite that simple. There is still some way to go before the device’s Flash can be accessed so for now, all that is possible is to use the RAM, and the current state of play has a kernel panic as it is unable to mount a filesystem. However this is a new piece of hardware in its first few days after launch, so this is very much a work in progress. We are sure that this device will in time be opened up as a fully hackable piece of hardware, and we look forward to covering the interesting things people do with it when that has happened.

If you are interested in the NES Classic, take a look at it on Nintendo’s web site. Meanwhile, here at Hackaday as a quick look at our past stories tagged “nes” shows, we’ve covered a huge number of projects involving the platform in the past.

Thanks [Doc Oct] for the tip.

Original NES console header image: Evan-Amos [Public domain], via Wikimedia Commons.

53 thoughts on “Linux On Your NES Classic Edition

  1. http://forums.nesdev.com/viewtopic.php?f=3&t=15073

    Examples of wrong sound effects include :

    Some percussion notes is off in SMB2, Metroid, Castlevania, Zelda 2 and Mega Man 2
    Balloon popping sound in Balloon Fight
    Enemy popping sound and fire power in Kirby’s Adventure
    Enemy defeat sound in StarTropics
    Thunderclaps and machine gun fire in Super C
    Dodging and gloves hitting gloves in Punch Out
    Hitting the candles and enemies and breakable blocks with the whip and landing in a crouch in Castlevania, also the holy water fire.
    The crushers in Metal Man’s stage (not positive about this one) and Metal Man’s metal blades in the boss battle
    Enemy defeat sound in Ninja Gaiden, gun sound when Irene shoots Ryu, windmill slash
    Block breaking in SMB3
    Dialogue text in Zelda 2

    1. Wow, there’s been NES emulators for 20-odd years. Running on much much less powerful chips. You’d think they’d be able to get a perfect version by now. I suppose Nintendo did the emulator in-house. Using open-source might oblige them into legal stuff they don’t want (or they worry it would). Buying an existing emulator would be rewarding those scumbag console-raping pirates who were previously the people who wrote emulators. Before Nintendo had a go at getting a few quid out of it.

      You’d think since they actually designed the NES, they’d be able to do a better job of it.

      Emulator consoles are usually crap. Even worse was a couple of the Atari Flashbacks, as well as a model I have, a pair of Atari-style paddles that play the paddle games. They’re not even emulators. They’re the NES-on-chip hardware that cheap clone NES’s use, with the Atari games rewritten from scratch, with a bit of extra flicker programmed in for that authentic 2600 look. Disappointing. The 2600 had so little hardware, it wouldn’t be hard to emulate, or re-do in one chip. But using Chinese clone chips I suppose is cheapest and lowest risk. And most purchasers aren’t gonna know the difference. I do though!

        1. Or the specs and stuff are in some old archaic format. Few years ago Intel decided to re-use some of the 486 silicon in a newer product (IIRC it was the Intel Edison board) but all the 486 schematics, etc.. were on old 9 track tapes, and the devs had all retired.. So they had to hire some people out of retirement along with track down some 9 track equipment in order to get the information they needed, but as a result they ended up archiving all of their old stuff they had stored on the 9 track tapes onto more modern formats, some of the spec sheets and stuff is available from Intel. Don’t remember all the details, they posted a video outlining the process on Inside Blue, but not sure if it was made public.

      1. The issue is there’s good emulation and there’s perfect emulation. This official hardware box is basically good emulation but not anywhere close to perfect emulation. Also, it is unclear exactly what GPL software they used, though they did use some as they released some of the code. To actually achieve PHYSICS based emulation of actual circuit level hardware, you need a very, very powerful set of COTS processors. In theory, quantum processors could achieve this with much less complexity but in terms of raw processing power.

        Here is an example:

        http://arstechnica.com/gaming/2011/08/accuracy-takes-power-one-mans-3ghz-quest-to-build-a-perfect-snes-emulator/

        A modern, quad core CPU cannot fully emulate Super Mario World. Think about that for a moment.

        Most emulators are actually decent enough “guesses” that are not actual hardware based but are good enough and then make game specific hacks to fix known issues. It’s an ongoing game of wack a mole as one change might break multiple other games.

        Also look up “Visual Transistor-level Simulation of the 6502 CPU”. There is even a JS emulator. It is no where close to real time even on modern quad core hardware. JS isn’t exactly a bare bones language but the 6502 CPU was released in 1975! That was 41 years of exponential CPU development and it still cannot be emulated by a modern processor. Obviously, one could in theory use a supercomputer to emulate it fully in hardware but that illustrates the divide between perfect hardware emulation and “best guess” software emulation.

        Also, look up DICE.

        DICE Sourceforge.net Project Page

        DICE is a Discrete Integrated Circuit Emulator. It emulates computer systems that lack any type of CPU, consisting only of discrete logic components.

        THAT is actual emulation. Pin Pong (Atari, 1974) uses almost a gig of ram to emulate. Without any sound emulation at all.

        1. More perspective. The MOS 6502 only had 3,510 transistors. Let that sink in. It runs at a clock rate of 1,000,000 to 2,000,000 cycles per second. It used combinatorial (clockless) logic so a single cycle isn’t necessarily a single command and some commands took different amounts of clock cycles. The two phase clock (supplying two synchronizations per cycle) can thereby control the whole machine-cycle directly. Typical instructions might take half as many cycles to complete on the 6502 than contemporary designs. Like most simple CPUs of the era, the dynamic NMOS 6502 chip is not sequenced by a microcode ROM but uses a PLA (which occupied about 15 percent of the chip area) for instruction decoding and sequencing. Like most eight-bit microprocessors, the chip does some limited overlapping of fetching and execution.

          We cannot currently emulate that fully in hardware using modern hardware in anything close to real time even after reverse engineering the physical dies and creating a transistor level simulation of the chip. “Even after the visual 6502 project took the time to created vector polygon models of each of the chip’s physical components – about 20,000 of them in total for the 6502. These components form circuits in a few simple ways according to how they contact each other, so by intersecting our polygons, we were able to create a complete digital model and transistor-level simulation of the chip.”

          http://www.visual6502.org/JSSim/index.html
          The Python gate-level sim runs about 55 half-clock steps per second, meaning the 6502 clock is going about 27 Hz.

          So the hardware level emulator runs at 27 Hz.

          Not 27 Mhz. 27,000 cycles per second.

          The actual clock speed of the 6502 is 1,000,000 to 2,000,000 cycles per second.

          It’s almost 75 times slower than real time using modern hardware, running in Python.

          MOS Technology 6502
          Max. CPU clock rate
          1 MHz to 2 MHz

          Instruction set
          MOS 6502

          Transistors
          3,510

          Instructions
          56

          Data width
          8

          Address width
          16

          1. The Visual 6502 project FAQ:

            Even running 75 times slower, it is still making all sorts of guesses and approximations about what is happening at the physics level.

            * How does the simulation differ from the real chip?
            The simulator is running an idealized “digital” circuit based on our model of the chip’s network of transistors and wires. It does not account for “analog” behavior (resistance, capacitance, leakage), has no propagation delays, and transistors switch on and off instantaneously. The real chip uses the same network of transistors (barring any mistakes we may have made in our model), but these transistors are analog devices. Our simulation uses a few simple heuristics to account for the differences in behavior between the actual analog circuits and our idealized digital model. In our simulation, if a transient short occurs from power to ground, ground wins. This may happen in our iterative solver as the simulation state is converging. Also, when two floating regions are switched together, their final voltage is taken from the region with the most components. This is a simple but completely non-physical way to account for capacitance.

          2. I was loving the technical info you were providing until I got to the part where you equate 27 Hz with 27,000 cycles per second. 27 Hz is 27 cycles per second, not 27,000. 27,000 cycles per second is 27 kHz (kilohertz.) But good read otherwise.

        2. The SNES’s PPU is tremendously more complicated than the NES’s PPU. We’ve had 99% accurate NES emulators for more than a decade, and are easily approaching another two Nines of accuracy.

          Byuu has said that Nesticle was a more accurate NES emulator than ZSNES and SNES9x are SNES emulators, if you’ll let that sink in for a bit.

        3. Way back when, I wrote what I think is the first ever Pong “simulator”. I used counters and logical comparisons, to simulate what I figured was happening in a real Pong chip. Some of the stuff I used counters for might’ve been analogue voltages on the real thing. It was all done simulated-scanline by scanline.

          I ended up with a pretty realistic result. Was old-school DOS mode 13h, so graphics not great. But it, completely to my surprise, actually ended up with a few of the weird side-effects, the artifacts, of the real machine. Things like the bats getting weirdly long when they’re very out of bounds.

          Wasn’t actual component-level simulation, but it’d run on a 486.

          For this NES thing, it doesn’t need to emulate components. It just needs to emulate the logical NES, and produce results matching the physical NES from the player’s point of view. You don’t need to emulate every transistor. You do need to put the effort in to getting everything right! Early emus had sound bugs, back in the beginning. But for something as simple as the NES, other emulators get it pretty much perfect, including all sorts of glitches and undefined behaviour. Nintendo, in this case, just haven’t done a decent job.

          1. Yes, in very much agreement. You can certainly make a ‘perfect’ emulation without resorting to physics level simulation. If you think that’s true then you must go and write an emulator this instant to wash away the fear of the unknown. One thing that does help tremendously though is those gate level reverse engineered chips mentioned like the Visual 6502 project, and they have also imaged the PPU. This helps a lot since you can in theory check your logic against the real thing.

      2. All the Atari flashback games except the second one run in an emulator on a NOAC. The Flashback 2 had a custom chip duplicating the original 2600 electronics, with all the pins brought out for the cartridge connector so it could be hacked to use original cartridges.

        Dunno why they went back to emulation.

        1. They’re not emulated, they’re just re-writes. Ports to the NOAC, but designed to look extra crappy and 2600-ish.

          Actually it takes a lot of CPU power to emulate a 2600. Well, relatively speaking, compared to other 8-bitters. Mostly because it has no screen RAM. It builds the screen up a scanline at a time, using tightly timed code, with the CPU updating a few video registers each scanline (2x 8-bit wide sprites, 2x 20-bit coarse background, and some more). So you essentially have to emulate the TV as well as the console.

          It’s a shame they went to the trouble of real compatible hardware on the version 2, then went back to the crappy porting after. It bothers obsessive nerds, who are the sort of people who tend to make the emulation scene. If people didn’t notice details like that, nobody could have written an emulator.

  2. Another horrible emulator console. Was Jeri Ellsworth too busy? Her C64DTV did a proper job, real hardware. Admittedly a custom chip doing the work of all the C64’s chips, but still hardware.

    You can get a tiny Linux computer that’ll run a NES emulator for like 5p. There’s millions of them. Don’t see why anyone would want this. Not like real NES’s have all disintegrated since the 80s, either. If I cared about the NES, I’d get a real console and a flash cart for it.

    Also wonder why it needs so much RAM on board. Maybe they needed the flash to store game images, and there wasn’t a chip with less RAM available. NES has 4K RAM, possibly a few K on the cart, and a few registers. Add in a few variables for the emulator itself, and I doubt you’d need 32K, never mind 32MB.

    Also… it’s usual to specify memory size in bytes, not bits. Unless you’re a games company trying to make your games sound bigger, but they gave that up in the 1990s along with cartridges.

    1. I think the article is just using improper capitalization. 256 MB of RAM sounds about right. 512 Mb doesn’t sound like enough for all the games and GUI. There isn’t just an emulator running, I’m sure there is a whole Linux operating system running on chip. Plus there’s other peripherals such as the controllers. They don’t interface the same as the old shift register controllers. Plus there’s HDMI and all the filters that can be applied to the output video. That all takes up more RAM.

      1. Eh? The 72 pin edge connectors you can buy new still, the caps are all standard, the logic is standard, the lockout chip has plenty of replacements available if you don’t just work around it and I’m not aware of any tracking issues with the PCB.
        Just the CPU and PPU are the parts that are hard to source outside of other NES.

        1. Well looks like you have a business plan then to undercut Nintendo, now you just have to figure out which landfills are particularly rich in them, get busy with the metal detector and shovel, dig them up, clean them up, replace whatever they need and sell them with fresh controllers and 30 legally licensed games for $50.

          1. I am reminded of this: http://hackaday.com/2016/06/06/the-worlds-supply-of-db-19-connectors/

            The primary MOS 6502 (unclear if the NES specific elements have as well) has been photographed and all of the logic traced out. Somebody *has* to have converted that into FPGA form, right? Could use that to make your own “emulated hardware”, at least strictly from the pure hardware side if you wanted it to be “true” silicon and not emulated. Easier and faster and probably cheaper to just do what Nintendo did though and just use existing commercially available hardware. Plus, things like save states are much easier to do in an emulator anyway.

            Cue comments about our emulated world and the ensuing existential crisis that delving into that can cause…..

          2. Pretty sure you can still just buy 6502s, although the NES used a special one with a couple of features removed, and a sound generator shoehorned in.

            But that doesn’t matter! There’s the NES-on-a-chip, NOAC, commonly known as. It’s what it sounds like. What all those cheap NES clones in a Playstation-looking joypad things, that infested flea markets back in the 1990s, used. NOAC, big ROM chip full of games, and a couple of passives and that’s about it.

            They’re not emulators, they’re real hardware. Accuracy wise they’re not perfect, and a GOOD emulator would do a better job. They must cost just north of nothing. There’s been plenty of cheap NES copies. Another nail in the coffin of this thing, I suppose. If this sells it’s gonna be entirely based on Nintendo hype. For the same money you could just get a tablet and run an emulator, and then you’d have a tablet.

      2. My childhood NES is still being used by a bed ridden woman. She usually ends up leaving it on and running even when she isn’t playing it. I’d guess it has about 100,000 hours on it. (on about 50% of the time for the last 30 years is my estimate)

      3. Good thing there are solid business that will repair and restore, mod, even upgrade ORIGINAL NES hardware to have a functional HDMI port. I bought my Hi-Def NES mod kit from game-tech.us and expect it to ship really soon! Then I’ll have my original top loader NES with an HDMI output!

        As an electronics technician, the most common faults in an NES are the capacitors and the 72 pin connector. You can replace the 72 pin connector for 10 bucks, or 30 if you want to upgrade to the “Blinking Light Win”, which is a much more robust connector. The capacitors are all stock standard values, and will run you a few bucks. It’s RARE for other parts to go out, but there are enough machines out there, it won’t be a problem finding parts in this generation.

  3. All I care about is if someone mods it with an openable door and removable cartridge that you have to either a) blow into, b) get the cart right on the edge of the plastic as you push the game down and into it’s ‘loaded’ position or c) rapidly lock, unlock, lock, unlock, lock the game into the ‘loaded’ position (only works if you get the right rhythm).

    …i mean… if we’re talking nostalgia and all…

  4. I was hoping for a NES-on-a-chip with some extra hardware for virtual cartrige swapping, but I guess a readily available ARM based solution was cheaper and easier to get up and running.

    And lets be honest, only the most extreme NES nerd can tell the difference between a real NES and a decent emulator. and those folks most likely own a proper NES.

    1. Presumably the joypad ports are USB, so you could plug something more current, with more buttons, in. Then it’s just a matter of loading the N64, PS2, and all the other emulators on. Assuming there’s enough flash space. Might have to remove a few of the games. Or maybe there’s somewhere to put an SD card in there. Or at least a USB flash drive.

      Or for the money get one of those Android stick HDMI things, stick an SD card in there, and run what’s probably a better NES emulator, along with all the rest.

      And with the rest of the money… I dunno, buy a new hat.

  5. I got mine yesterday.. I like it, mostly because of the controller, and also the UI is pretty good and Super Mario looks very nice. I think I agree that the emulation is not perfect, but for the price I don’t really care. (the controller cables are pretty short though).

Leave a Reply to Scott_TxCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.