New Part Day: The STM32 That Runs Linux

There are a lot of ARM microcontrollers out there, and the parts from ST are featured prominently is the high-power builds we’re seeing. The STM32F4 and ~F7 are powerhouses with great support, and the STM32F0 and the other younger children of the family make for very good, low-power microcontrollers. Now, the STM32 family is getting a big brother. It runs Linux. It’s two ARM Cortex-A7 cores and one M4 core on the same chip. The STM32MP1 is the chip you want if you still can’t figure out how to waste computing cycles by blinking LEDs.

Block diagram of the STM32MP157 Image: ST

First, that Linux support. The STM32MP157C was mainlined into Linux last summer, and there is support for Android. So yes, this chip can run Linux. There is an optional 3D GPU in this family, a MIPI-DSI controller, support for HDMI-CEC, USB 2.0, and 10/100M or Gigabit Ethernet. This brings us the inevitable question of whether you can build a Raspberry Pi clone with these parts. Maybe, champ, but if you’re asking that question it’s probably not you that’s going to build one. It looks as if this chip is designed for phones, set-top boxes, and smart TVs. That doesn’t preclude a single board computer, but the biggest problem there is maintaining software support anyway.

The chip family in question all come with dual ARM Cortex-A7 processors running at a nominal 650MHz. There’s also a Cortex-M4 running at 209MHz, and the ST literature suggests that engineers are already running Linux on the A7 and an RTOS on the M4. This chip will need external memory, but DDR3 / DDR3L / LPDDR2 / LPDDR3 are supported.

This chip is only announced right now, you can’t get it on Mouser or Digikey yet, and there’s no information on pricing. However, there are two development boards available, the Evaluation board, which features 1 GB of DDR3L, 128 MB of Flash, and an 8 GB eMMC. There’s a 5.5″ display, and enough connectors to make your heart flutter. The Discovery board is a bit more cut down, and comes with a 4″ 480×800 LCD, WiFi, Bluetooth LE, and of course it comes with GPIO expansion connectors for an Arduino and Raspberry Pi. The Discovery Board is not available at this time, but it will sell for $99 USD.

New STM32 Discovery Board Can Now Be Programmed On Linux

Last Wednesday I posted a video review of the new STM32F0-Discovery board which is built around an ARM Cortex-M0 chip. I speculated that it should work with the open source project aimed at programming these discovery boards. I tested it out and a connection could be made, but no code could be flashed. So I spent a few hours over the weekend and added support.

My updates are already in the stlink repository. After cloning the code, you can use three commands to compile the software (./autogen.sh, ./configure, make). That’s assuming you have all of the necessary dependencies (I had to installĀ libusb-1.0-0-dev) and that you add the udev rule suggested in the documentation (also found in the repository). The program st-util connects to the board and provides a listening port for an ARM debugger (I’m using arm-none-eabi-gdb from CodeSourcery G++ Lite).

When I first started testing, the chip id was reporting as 0. It turns out the register address polled for this information was wrong. After finding that in the almost-900 page reference manual I went through the painstaking process of finding the hex values necessary to properly memory map the device. From there I also updated the blink example to generate an ELF file compatible with the Cortex-M0 chip. So out of the gate you should be able to use an ARM cross compiling toolchain to compile the example, connect to the board with this utility, then use the debugger from the toolchain to connect and flash that example to RAM.

There’s lots more to be done. To fully utilize the chip it is necessary to use a startup file and linker script when compiling. I’ve done nothing in this area, but I hope to work on some tutorials as I get further along. Of course if you have your own successes developing for this board using a Linux machine we want to hear about it!

How To Develop For STM32 Discovery Boards Using Linux

Some hard work has gone into making it possible to develop for the STM32 Discovery board using a Linux system. The board boasts an ARM Cortex-M3 processor, which can be programmed via the mini-USB port on the side. But the company only supports development through their IDE’s which don’t run natively on Linux. The stlink project aims to solve this, providing a toolchain, and making it possible to flash the microcontroller via the USB connection.

The github project linked above also includes a tutorial to get you started (pdf). In addition to a walk through on compiling the software packages, it includes a simple blink program that you can use to test out your hardware. GDB, the familiar open-source debugger, is used to flash the chip. This is a bare-bones tutorial so if you end up posting about your experiences using this toolchain with the Discovery boards we’d love to hear about it.

[Thanks Texane]

Linux Fu: Forward To The Past!

Ok, so the title isn’t as catchy as “Back to the Future,” but my guess is a lot of people who are advanced Linux users have — at least — a slight interest in retrocomputing. You’d like an Altair, but not for $10,000. You can build replicas of varying fidelities, of course. You can also just emulate the machine or a similar CP/M machine in software. There are many 8080 or Z80 emulators out there, ranging from SIMH to MAME. Most of these will run on Linux or — at the least — WINE. However, depending on your goals, you should consider RunCPM. Why? It runs on many platforms, including, of course, Linux and other desktop systems. But it also will work with the Arduino, Teensy, ESP32, or STM32 processors. There is also experimental support for SAM4S and Cyclone II FPGAs.

It’s pretty interesting to have one system that will work across PCs and embedded hardware. What’s more is that, at least on Linux, the file system is directly translated (sort of), so you don’t have to use tricks or special software to transfer files to and from CP/M. It is almost like giving Linux the ability to run CP/M software. You still have to have virtual disks, but they are nothing more than directories with normal files in them.

Goals

Of course, if your goal is to simulate a system and you want to have 180 kB floppies or whatever, then the direct file system isn’t a benefit. But if you want to use CP/M software for education, nostalgia, or cross-development, this is the way to go, in my opinion.

It isn’t just the file system, either. If you need a quick utility inside your bogus CP/M environment, you can write it in Lua, at least on desktop systems. On the Arduino, you can access digital and analog I/O. Theoretically, you could deploy an embedded Altair for some real purpose fairly cheaply. Continue reading “Linux Fu: Forward To The Past!”

Linux Fu: The Infinite Serial Port

Ok, the title is a bit misleading. Like most things in life, it really isn’t infinite. But I’m going to show you how you can use a very interesting Linux feature to turn one serial port from a microcontroller into a bunch of virtual ports. In theory, you could create over 200 ports, but the reality is you will probably want to stick with fewer.

The feature in question is what’s known as pseudoterminal or sometimes a pty or pts. These special files were made to feed data to programs that expect to accept data from a terminal. The files provide two faces. To the client, it looks like any other terminal device. To the creator, though, it is just another file. What you write to that file goes to the fake terminal and you can read anything that is sent from the program connected to the terminal. You use these all the time, probably, without realizing it since running a shell under X Windows, for example, doesn’t attach to a real terminal, after all.

You could, of course, do the same trick with a composite USB device, assuming you have one. Also assuming you can find a working driver and get it working. However, many microcontrollers have a serial port — even one with a USB converter built-in — but fewer have full-blown USB hardware. Even the ones that do are often at odds with strange drivers on the PC side. Serial ports work and work well even on the simplest microcontrollers.

The Plan

The plan is simple enough. A Linux program listens to a real serial port and watches for special character sequences in the data stream. Those sequences will allow you to switch data so that the data stream will go to a particular terminal. Data coming back from the terminals will go to the real serial port after sending a sequence that identifies its source.

Continue reading “Linux Fu: The Infinite Serial Port”

Hackaday Podcast 090: DIY Linux SBC, HDMI CEC, Fake Bluepills, And SCARA Arms

Hackaday editors Elliot Williams and Mike Szczys chat about our favourite hacks from the past week. We start off with a bit of news of the Bennu asteroid and the new Raspberry Pi Compute Module. We drive ourselves crazy trying to understand how bobbin holders on sewing machines work, all while drooling over the mechanical brilliance of a bobbin-winding build. SCARA is the belt and pulley champion of robot arms and this week’s example cleverly uses redundant bearings for better precision. And we wrap up the show looking in on longform articles about the peppering of microcontrollers found on the Bluepill and wondering what breakthroughs are left to be found for internal combustion.

Take a look at the links below if you want to follow along, and as always, tell us what you think about this episode in the comments!

Direct download (60 MB or so.)

Continue reading “Hackaday Podcast 090: DIY Linux SBC, HDMI CEC, Fake Bluepills, And SCARA Arms”

STM32CubeMX Makes Makefiles

When hardware manufacturers make GUI code-generation tools, the resulting files often look like a canned-spaghetti truck overturned on the highway — there’s metaphorical overcooked noodles and red sauce all over the place. Sometimes we think they’re doing this willfully to tie you into their IDE. Not so the newest version of ST’s graphical STM32CubeMX, which guides you through a pleasant pin-allocation procedure and then dumps out, as of the latest version, a clean Makefile.

Yes, that’s right. This is a manufacturer software suite that outputs something you can actually use with whatever editor, GUI, compiler, or environment that you wish — even the command line. Before this release, you had to go through a hacky but functional script to get a Makefile out of the CubeMX. Now there’s official support for real hackers. Thanks, ST!

If you’re compiling on your own, you’ll need to update the BINPATH variable to point to your compiler. (We use the excellent GNU ARM Embedded Toolchain ourselves, which is super-easy to install on almost any Linux.) If you want to use STM32CubeMX with the Eclipse IDE, [kali prasad yadav] sent us PDF instructions — it’s not hard.

If you doubt that the availability of a free, open, and non-constraining toolchain can matter for a silicon vendor, we’d point to AVR and the Arduino platform that spun off of their support of GCC. Sure, Atmel still pushes their all-in-one wonder, Atmel Studio, which is better than the Arduino IDE by most any metric. But Studio is closed, and Arduino is open. We’d love to see the number of Studio users compared with Arduino users.

Congratulations to ST for taking a big step in the right, open-toolchain, direction.