r/homebrewcomputer • • 15d ago

How can I start programming an ARM processor completely from scratch?

/r/chipdesign/comments/1xv5yom/how_can_i_start_programming_an_arm_processor/
10 Upvotes

8 comments sorted by

6

u/AdministrationDry820 14d ago edited 14d ago

I'd recommend an inexpensive Raspberry Pi Pico 2. It has two 32-bit ARM Cortex M cores and it's very well documented, with a complete C / C++ and assembly toolchains, with tons of community examples. This is a smaller ARM core, a microcontroller really, which is a whole other beast than the 64-bit SOC monsters you might find in a modern phone, but It's an ARM core, without all the extra systems (GPU, MMU, etc) to worry about. The Pico has a built-in USB bootloader mode where it comes up like a thumb-drive and you can drop a firmware blob file onto it to reprogram it, and its all relatively easy to inspect and understand with full open-source docs and tools.

The next step up is any model of Raspberry Pi (non pico) which also has ARM cores, but is a 64-bit SoC with all the extra computer-y bits and GPU, etc, and is hugely more complex but relatively well documented and community driven.

A lot of the big fancy SoC's, especially modern ones in flagship phones, are not publically documented, and involves buying devkits and signing NDA agreements to get good documentation, sometimes even paywalled, or even, unobtainable to hobbyists, so I'd go wiith the Pi Pico first, then a bigger Pi. BTW, the big Pi has a "bare metal" community where people write apps for it that run the whole show, without relying on any traditional underlying OS, such as Linux, etc.. One such project is called Circle: https://circle-rpi.readthedocs.io/en/51.1/

2

u/flickerflak 14d ago

Thanks you mate, by the way I just wondering, any way to learn how a raspberry or any opensouce soc working, from scratch?

2

u/AdministrationDry820 14d ago edited 14d ago

All computers and SoC's can ultimately be represented by a bunch of interconnected logic gates, and that's what an FPGA is for, so I'm guessing the people who implement such things using FPGA's would have a lot to say about it. I've never tried it myself, but its like a programming language that describes how a chip should work, and people have simulated whole computers and CPU's using just FPGA, maybe with some extra RAM attached.
Making a real SoC is based on the same underlying principles, interconnected logic gates.. but there is a lower level of detail regarding how each gate is implemented (transistors..) It's easy to find tutorials about making CPU parts (logic gates, adders, SRAM) using individual transistors.
Speaking of that, check out the TraNOR! https://www.youtube.com/watch?v=VgktjP_Fcy8 A small computer made with mostly transistors!
In short, if you want to learn how to make absolutely everything from scratch, start with transistors, how those comprise logic gates, and how logic gates comprise computer building blocks such as adders, multipliers, counters, registers, RAM, and then how those blocks comprise CPU's, and finally adding peripherals to tuen a CPU into an SOC. (Some crazy people want to make even their own transistors or integrated circuit dies, but that's hard and expensive to get right consistently.)

2

u/flickerflak 14d ago

I got it mate, then I'll just scratch about FPGA may be I could find answers, by the way I also came across this GH repo, https://github.com/stnolting/neorv32/tree/main, where I could smell some HDL.

2

u/AdministrationDry820 13d ago

Hey flickerflak, here's a really good presentation to teach some fundamentals. A walkthrough of a real, working computer made out of electrical relays! I think any digital chip designer who wanted to make SOC's would need to know at least enough enough about the fundamentals to be able to do this, if they really wanted to, and a whole lot more of modern techniques too.
You may have heard that a transistor can be used as a kind of electrically-controllable switch. Well, Relays are a much earlier technology, but they are electrically-controlled switches too, and you can still make computers out of them.
https://www.youtube.com/watch?v=tsp2JntuZ3c

3

u/guantamanera 14d ago

If you want to get down and scratch the metal you can do it in assembly 

https://armasm.com/

1

u/flickerflak 14d ago

That's really great document mate, Thanks

1

u/daniilkhanin 13d ago

I have a simulator where you can build basic logic gates using transistors, just like in the video you watched, and then assemble a computer and start programming on it. There are kits with step-by-step instructions, similar to Lego, where you can build simple electronic devices.

The simulator is completely free, with no registration required and no cookies.

https://cs.khanin.info

The kits are available both for a fee and for free.

https://ch.khanin.info/en/

And here’s my story about how I built an Apple II on the simulator.

https://www.reddit.com/r/homebrewcomputer/comments/1xkh5dh/i_built_an_apple_ii_from_21180_transistors_in_a/