Building A Pocket Sized Python Playground

Like many of us, [Ramin Assadollahi] has a certain fondness for the computers of yesteryear. Finding his itch for nearly instant boot times and bare metal programming weren’t being adequately scratched by any of his modern devices, he decided to build the PortablePy: a pocket-sized device that can drop him directly into a Python prompt wherever and whenever the urge hits him.

The device is powered by the Adafruit PyPortal Titano, which combines a ATSAMD51J20, ESP32, an array of sensors, and a 3.5″ diagonal 320 x 480 color TFT into one turn-key unit. The PyPortal is designed to run CircuitPython, but the scripts are usually dropped on the device over USB. That’s fine for most applications, but [Ramin] wanted his portable to be usable without the need for a host computer.

For a truly mobile experience, he had to figure out a way to bang out some Python code on the device itself. The answer ended up being the M5Stack CardKB, a tiny QWERTY board that communicates over I2C. Once he verified the concept was sound, he wrote a simple file management application and minimal Python editor that could run right on the PyPortal.

The final step was packaging the whole thing up into something he could actually take off the bench. He designed a 3D printed clamshell case inspired by the classic Game Boy Advance SP, making sure to leave enough room in the bottom half to pack in a charging board and LiPo pouch battery. He did have to remove some of the connectors from the back of the PyPortal to get everything to fit inside the case, but the compact final result seems worth the effort.

While an overall success, [Ramin] notes there are a few lingering issues. For one thing, the keyboard is literally a pain to type on. He’s considering building a custom keyboard with softer buttons, but it’s a long-term goal. More immediately he’s focusing on improving the software side of things so its easier to write code and manage multiple files.

It sounds like [Ramin] isn’t looking to compromise on his goal of making the PortablePy completely standalone, but if your convictions aren’t as strong, you could always connect a device like this up to your mobile to make things a bit easier.

24 thoughts on “Building A Pocket Sized Python Playground

      1. I think rather than simply saying “no operating system”, a better definition of “bare metal” would include prohibiting abstractions and interpreting engines. In the case of this device, the Python scripts that one might create don’t run on “bare metal”. (I’m sure at some time in history there must have been a Hackaday article where someone put python into silicon, and there it *would* be running on “bare metal”.) :-)

        1. “prohibiting abstractions and interpreting engines” so if my device allows the user to select the alert color, that’s an abstracti0n and my device is no longer bare metal! If I put in code to detect button pushes and translate them to actions, that’s an “interpreting engine”. Oh man where did you come up with this definition? I;m thinking maybe you should have flushed afterward.

          1. “… if my device allows the user to…”

            “Bare metal” refers to code running on some sort of processor. It has nothing to do with your “device”.

            “…code to detect button pushes and translate them to actions…”

            In this case, if the code is, by itself, detecting button pushes and taking actions without the help of other code, then that’s code that is “bare metal” code. If the code to detect button pushes is a Python script, then script isn’t directly doing anything – it’s the Python interpreter that’s interacting with the “bare metal”. The Python interpreting engine is running on the “bare metal”, the script is not.

      2. Not really. “bare metal” is just that Bare Metal. Just hardware with NO software. It has nothing to do with having an operating system installed. It’s just plane old hardware with a blank drive or storage media.

        1. Wow, so according to your definition, “bare metal” computers don’t actually exist. Even the tiniest ARM microcontroller contains a ROM with boot code so apparently “bare metal” is just a figment of your imaginati0on.

          1. Do you even hear yourself. ” “bare metal” computers don’t actually exist. ”
            If you put together a computer with all its hardware but have not installed any software on the drive its called “bare metal” A ARM microcontroller, is a semiconductor, there is no “metal” involved. Think before you speak, you might make a better argument.

          2. did exist, some really early computers had toggle switches to set register/PC/RAM state to hand program IPL or so history books say

            still a silly definition of bare metal though

    1. Ramin here. We had the same discussion over at reddit. Micropython has so many capabilities like Wifi, shell command support etc, that it feels like an OS. To me, the most important thing is that the machine boots up nearly instantly and I can write all the UI, interactions, file organisation by myself. And that is a lot of fun. You learn a lot when you try to write a code editor, for example.

  1. Bare metal means no OS. Python is not an OS. Whether or not you like those definitions is just too bad.

    Also it does not mean NO software. Code is software. You would be defining relay logic…

    1. I didn’t know that. When I started, “bare metal” meant writing in machine code or flipping bits with toggle switches. This device obviously has something running in order to talk to the screen and read the buttons. This is the bit I would consider “bare metal” in that it could be written as machine code. The python interpreter sits on top of that interpreting the script lines in memory. Definitions change.

  2. Ok people relax. Neither Tom Nordi nor Ramin Assadollahi coined the term “bare metal” in this context. It already existed. Stop being a douche just because you weren’t aware of the term. For those that don’t know, the term “bare metal” IN THE CONTEXT OF PYTHON means you are running python without an OS.

    For example MicroPython (created by Damien George) and Adafruits’ fork of that project (CircuitPython) run on microcontrollers (PyBoard, ESP32, Teensy, and even the Raspi Zero etc.) without an OS.

    If you’re interested in running it on the Raspi Zero look on boochows github.

    1. I’m Ramin and built this thing. To me, the boot time is the most important thing and that’s ultra-short, so I’m super happy with the device. I’ve been looking into boochows implementation for the Pi Zero. Unfortunately, the Wifi driver is missing. Otherwise that would be my dream machine.

  3. Come on!
    Today’s microcontrollers are far more capable than the 80s PCs with CP/M, DOS and such but still are not self hosting?

    E.g.: Why do I need a PC to build the firmware for an ESP32?
    That’s insane!
    And produces locked in syndromes.

    Make them self-sufficient.

    As a start have something as simple as CP/M or DOS (…or a Forth-ish OS?) on them and editors, interpreters and compilers.
    With this as jump bar, better stuff may evolve soon.

    1. I think there are microcontroller Forth implementations and such, but few people care much that they need another device to compile the firmware because said other device is much more convenient to develop on.

  4. Bare Metal? Like others I’m flabbergasted at the incredible misunderstanding.

    Yes, the IT community has commandeered the term to mean no OS, because in their abstraction, that is the only thing that makes sense.

    In programming however, bare metal would mean running directly on the processor without support libraries, like a boot loader. See how the IT abstraction came about? I do not believe python can get down to the appropriate level. It will always need the python language, even if statically linked in, to function. You can’t simply use it to push bits to memory addresses, call interrupts, etc, do the things to get a modern OS up and running. It just can’t, by design. So this is anything but bare metal.

    All the people claiming it is…..you are clearly not heavily experienced outside of a world with provided libraries. How about going and starting your new education by writing a linked list in C, no library support, in fact, you must start by using malloc to allocate 128M (arbitrary – should be more than you’ll ever need for even a grueling linked list test) memory block, and then write your own “malloc” to manage the space (emulating physical ram in flat mode, we’ll assume you pick up the processor in flat mode…) Now you have some idea of what bare metal programming is. For more fun, do it in assembly. For even more fun, do it in hex. Yes, I have done all 3. Yes, I probably enjoy pain too much! Yes, I have had need at a job to write in a truly bare metal environment, I tired using assembly only, but that was untenable, and I went back and rewrote most of the assembly in C. Some assembly is required in bare metal environments. (see what I did there ;-) )

Leave a Reply to osmarksCancel 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.