[Bruce Land] of Cornell University will be a familiar name to many Hackaday readers, searching the site for ‘ECE4760′ will bring up many interesting topics around embedded programming. Every year [Bruce] releases yet more of the students’ work out into the wild to our great delight. This RP2040-based project is a bit more abstract than some previous work and shows yet another implementation of an older hack to utilise the DMA hardware of the RP2040 as another CPU core. While the primary focus of the RP2040 DMA subsystem is moving data between memory spaces, with minimal CPU intervention, the DMA control blocks have some fairly complex behaviour. This allows for a Turing-complete CPU to be implemented purely with the DMA hardware and a sprinkling of memory.
The method ties up three of the twelve DMA channels, and is estimated to have a similar performance to ‘an Arduino’ but [Bruce] doesn’t specify which one of the varied models that could be. But who cares anyway? Programming the CPU is a matter of leveraging the behaviour of the hardware, which is all memory mapped and targetable by the DMA. For example, the CPU can waggle GPIO pins by using the DMA to write values to the peripheral address space. The basic flow can be seen in the image above. DMA0 is used as the program counter, which points DMA1 to an array of DMA control blocks, a sequence of which codes for some of the ‘opcodes’ of the CPU model. DMA0 chains to (hands over control to) DMA1 which reads the control blocks and configures itself accordingly. DMA1 performs whatever data move is programmed, chains to DMA2, which in turn reprograms the DMA0 program counter to point to the next block in the list to be executed by DMA1.
By also using DMA1 to modify subsequent DMA1 control blocks (that’s self-modifying code happening there!) the system can implement more useful operations such as addition, logical operations, and conditional branching. Transport-triggered operations in certain shadow registers enable atomic set, reset, and XOR operations. All clever stuff, and a wonderful student project to have been involved with. [Bruce] points out a paper (using the Pi2) from the WOOT 2015 workshop which might offer a better explanation of this whole process.
If you’re still wondering who [Bruce Land] is and want a bit of a primer on some of these topics, then check out our previous coverage. If this theoretical stuff is a bit heavy then some of the projects have a more practical bent, such as the critical task of colour-sorting skittles.
Thumbnail image: Thomas Glau, CC BY-SA 4.0.
Only thing I can see arising from all this additional complexity is it making auditing hardware for security harder. Does DMA need to be Turing complete?
I have used basically same DMA structure to automatically map a bunch of data through a lookup table on RP2040. So the features are useful, even if making a CPU out of them might not be.
In my experience the latency of the DMA setup means that this structure runs at about 10 MHz. Considering the limitations of instructions that can be implemented this way, I don’t think it would get even ATMega328 level performance.
Would waggling the GPIOs not make the interrupts giggle which in turn would toggle the DMA off ?
I thought that the dma in pic32 was advanced, but the 2040 seems equally strong. This is an extraordinary hack and great article :-)
Most people when they refer to an Arduino are still on about the uno or nano, or any of the other basic 8 bit arduinos. The others aren’t used anywhere near as much as the classic arduinos, maybe because they are seen as unnecessary, or because they are too expensive compared to other more powerful boards like STM32, teensy, pi pico or esp32.
So, do the students know that their creativity is going to be placed in the public domain?
Most universities have a clause in the student contract giving the university either ownership of or a transferable license for anything the students produce as part of an assignment or graded project.
So regardless, the university probably has the legal right to do it whether it explicitly informs students it is doing so or not.
(Note that this is not a comment or statement on the ethics of this practice. The college I attended for my BS explicitly did not have any such clause, and many professors made sure to inform students that the university had no claims on anything they produced except the right to retain and use copies for grading and other uses incidental to the evaluation of its students.)
I wish my university work were Public Domain. At my university the school had IP rights to anything we made.
I was on a team that developed an app for an Android development class. The professor was awful, we taught ourselves, and the end result app wasn’t half bad. A few weeks after the semester ended the professor reach out to us asking if we’d fly to Georgia for a conference where he’d present the app. We declined because frankly we didn’t want to help him and flying to Georgia would have been expensive and we were starving grad students.
A few months later we found out he’d grabbed 3 other grad students to stand on stage with him, and then personally sold our app to a venture capital group.
Academia is awful.
I’d be concerned about the amount of memory bus contention this might cause… On most ARM chips you have a very specific matrix of which peripherals have connections to which memory regions, but the region itself can still be subject to contention. I’m not sure what the setup is with the RP2040, not having used it.
RP2040 has a fully connected matrix, and several SRAM blocks that can be accessed simultaneously. But bus contention is a thing, and it is best to place the lookup tables in SRAM4 and SRAM5 which are two 16kB blocks each with their own interface.
On skim, my brain is saying “kinda like a blitter” but will have to absorb properly later.
Does it no consume memory bandwidth that the CPUs would need?
It is totally useless except for look what i made it do. So yeah. It locks a 125MHZ CPU off the bus and then implements a very limited 10MHz CPU.
Similar work with rdma devices: https://www.usenix.org/conference/nsdi22/presentation/reda
@The Commenter Formerly Known As Ren
Students should DEMAND their creativity is going to be in public domain.
And if they don’t then their education before that point failed them IMO.
We’ve featured _a ton_ of projects from Bruce’s ECE course. After putting in all that work, I think the students are stoked to have their stuff showcased.