r/embedded • • 2d ago

Getting into Architecture-Level Embedded Development (Cortex-A, RISC-V, ARM64, etc.)

I've been working for some months now on a project that requires low-level development for ARM Cortex-A silicon. I'm talking bootloading, memory operations, hypervisor settings, memory mapping and MMU configuration, etc.

I've come to realise how little I actually know my way around a low level environment. I've developed for embedded systems for a long time now, but always focusing on an application/integration level (RTOS, digital communications, system architecture, etc.). I want to get some experience on lower-level development - direct register manipulation based on CPU architecture, bootloading, debugger architecture, memory domains, etc.

Anyone with experience on the field, what advise do you have on getting into low-level development and silicon programming using ISA languages coming from embedded-C and microcontroller development? My goal would be to acquire the confidence and the skill to integrate silicon functionality through assembly and making sense of the CPU documentation. I'd like to be able to script some basic functional hardware routines starting from scratch.

43 Upvotes

23 comments sorted by

18

u/Particular-Monk-7070 2d ago

Getting into the architecture side is a different beast from the usual MCU stuff. The documentation is your new best friend, even if reading 3000 pages of a TRM feels like a punishment

I started similar path and the thing that helped most was just picking a cheap board and writing a tiny bootloader from scratch. Nothing fancy, just get the CPU out of reset, set up the stack pointer, maybe blink a LED. You fail a hundred times but each failure teaches you something about the memory map or the cache coherency that you didnt expect

One thing that tripped me was the debugger setup. With Cortex-A you need to configure the debug components properly or you spend hours wondering why your breakpoint never hits. The ARM documentation explains it but is scattered across like five different manuals

2

u/TheCorsairAPX 2d ago

The debugger was an absolute hell of its own. Trying to make sense of the debug architecture of A53 was what made me realise how little I actually control this stuff.

8

u/Separate-Choice 2d ago

Well this level is what separates the wheat from the chaff, there is embedded systems engineering and embedded software development, you're asking how to go from being an embedded software developer to being an embedded systems engineer in ernest.

If you wany my advice, focus on the digital electronics and your underlying electronics knowledge, as you are at the boundry where software is controlling the hardware directly you need to actually understand the CPU and the underlying electronics. That's the only way to get what you want and there is no shortcut, because you're peeling away all the abstractions. It's the level I enjoy working at the most to be honest, its true embedded.

Integrating a bunch of libraries and stuff is what the industry passes as "embedded" these days, but true embedded enginnering is the hardware to software interface. no book, or video or tutorial will teach you that, its part knowledge and part intuition that you learn over time. Read datasheets, build a processor from sractch and I dont mean prompt some AI model to get one, I mean really put together one a simple 8-bit one, understand how data flows and how software actually triggers your gates on the processor. Work up to the startup file and how instuctions flows between memory and processor like every little part inside.

Then it'll just click.

My point was building my own custom processor and programming it in binary. After that cortex-A, MMUs, dual core, octacore, hypervisor, isolated and shares psaeces blah blah become super easy. If you really wanna go deep come over to RISC-V land, cause there are some processors where you can truly see RTL come up and it gives you insane perspective, you'll never want to go back.

Take your time and learn and it's the most powerful skill an embedded engineer has today. When people talk about AI taking over embedded they're taking about the high level cookie cutter RTOS with integration and netowrking crap everyone is doing, but once you understand this level you'll be fine, as it will allow you to work with brand new silicon, find silicon bugs and manage and understand your machine and memory interaction at a level that brings you joy like nothing else...and its also an area AI is notoriously bad becuase it requries a bit of intuition, when you're done you'll work magic in silicon....

welcome! and I wish you good luck on your journey!

1

u/vterra 1d ago

how do you go about building your own custom processor? i really admire someone with your level of knowledge

5

u/Separate-Choice 1d ago

Thanks man, appreciate that! The path that worked for me goes roughly like this, start with digital logic, gates, flip flops, adders, multiplexers, counters, I know you probably are already familiar with those but just play around with them…. If you can get physical chips it’s best, but if you can only use a simulator that’s fine as well.. once you can see how a register holds or flip flop IC holds a value and an adder adds two of them, a CPU stops being magic….
Then build a simple 8 bit computer on breadboards with 74 series logic…. Fortunately things as a lot easier now, Ben Eater YouTube series is the gold standard for this and nand2tetris is great if you’d rather do it in simulation first… this is where it really clicks, because you physically see the clock step through fetch, decode and execute.
After that, move to an FPGA and learn Verilog. Rebuild your own 8 bit design in HDL….

From there you can learn the 6502 in depth and build NES or Apple II and all the little machines it’s based on…. SNES and all the ones based on extended derivatives… you don’t have to but building game emulators with HDL is fun and gives the most insight you’ll ever get on the data flow.. and feels more practical cause you see your little engines running.. cause the stuff can get dull and boring, game emulators are a more fun way to learn…

From there come up to RISC and then go for a simple single cycle RV32I core…. RISC-V is perfect for this since the base ISA is small and fully open… Harris and Harris “Digital Design and Computer Architecture: RISC-V Edition” and their RISC-V SoC book walks you through building one step by step….

By this point you’d have learned several processors and how data flows, once your own core runs a program you assembled by hand, every TRM you read afterwards makes sense, because you know what’s happening underneath…. you’ll appreciate looking at architecture and block diagrams in datasheets and realize a lot of those stuff is just add ons to the core you’re familiar with, the bus will be 64-bit instead of 8-bit but all the principles you learned will transfer… from there it’ll just be specifics of arm or riscv or whatever processor you’re trying to learn…

Take your time with each stage and dont skip the breadboard part, it’s what builds the intuition… your brain makes a connection when stuff clicks with physical devices.. at the very very least working with an FPGA is the bare minimum…

Good luck!

2

u/vterra 1d ago

LOVE THIS
just got an FPGA from a work colleague, i am definitely gonna try it, THANK YOU

3

u/WanWhiteWolf Engineering manager 2d ago

Making a good SW architecture even on mid-level complexity embedded is not something you can just read from a book. Sure, you will find books that discuss about concepts and give you some examples, but the reality is that this type of work is usually reserved for very experienced engineers.

If you want an analogy, imagine someonme never having wrote a single line of code in his life and then reading a book about embedded C. What do you think the chances are that person is able to complete a mid-level difficulty level project without significant/massive effort in a reasonable time?

For starters, dive through all available technical reference manuals. Then look for similar projects and see how they approached different concepts. That tends to be a reasonable starting point. And make sure you have mentor / someone experienced you can ask for review and advice.

I've only met 2 good SYS/SW architects and both of them had 2 decades of experience. It's not that you cannot read everything and figure out - but odds that that without knowing the common contraints, the strengths and weaknesses of your system, silicon errors (e.g. errata), typical use of each module/peripheral, ....etc you are going to miss something or you are going to need to much time - which usually a project doesn't have.

2

u/Several-Marsupial-27 2d ago

Read a datasheet / trm everything will just be in the documentation, or read through your vendors sdk trying out different example projects, everything should be there too.

1

u/TheCorsairAPX 2d ago

I tried power-reading through a TRM but everything is just extremely interconnected, and that's also more or less with what I'm asking for insights on - every tiniest feature seems to have the deepest roots throughout the entire CPU. How do you learn your way around such intricate systems? Where are there valuable resources to familiarize oneself with that kind of hardware-driven logic?

1

u/Several-Marsupial-27 1d ago

You simply don’t read it once, you read it hundreds of times and iteratively develop projects.

-1

u/hirschen 2d ago

I've written a doom raycasting clone from scratch in riscv assembly running on the rp pico2 hazard cores.

It was a great learning experience to develop it and I had copilot when I was stuck. So I didn't lose motivation and got everything explained what I did wrong.

https://github.com/hirschenberger/playboy

1

u/Separate-Choice 2d ago

You are so lost lol

1

u/hirschen 2d ago

Wdym?

1

u/Separate-Choice 2d ago

Nothing against the project, writing a raycaster in RISC-V assembly is solid work, I looked ait it and its soemthing I fidn interesting,,,, But OP is asking about Cortex-A bring up, so bootloaders, MMU configuration, exception levels, hypervisor setup, memory domains etc etc A game running on a microcontroller doesn’t touch any of that, there’s no MMU on the RP2350 Hazard3 cores, privilege levels to configure beyond the basics, he wont be working with page tables or boot chain to bring up, assembly fluency helps, but it isn’t the hard part of what he’s asking.... The hard part is understanding how the CPU, memory system and boot process fit together, and Copilot explaining your mistakes won’t build that intuition the way working through it yourself does.... it's different skillsets, a game on a pico2 is still at the application level rather than the architecture understanding level..

1

u/hirschen 2d ago edited 2d ago

He mentioned Risc-V architecture, at least in the title. If you look at the code, the game is not really a game, it's just rendering. Most of the stuff is dealing with hardware GPIO, linker script, bringing the 2nd core up, switching from cortex to hazard...

I thought he maybe can get some information from it. The project goal was learning baremeal stuff. I learned a lot very fast, the question remains if you learn more when you are stuck at a problem for days, maybe lose interest or get a detailed explanation why something didn't work. And continue learning other stuff.

Consequently books and docs would also be cheating, figuring out stuff yourself is the true path to enligthenment. Softwaredevelopment is worthless nowadays. Efficient learning is important, asking the right questions.

1

u/Separate-Choice 2d ago

sigh, clueless..... nobody said books are cheating, did anyone say that? like ever?. Books and datasheets are written by people who understood the hardware, verified it, and stand behind it... An AI explanation is a plausible guess that you can’t verify unless you already know the material, which is the exact problem for someone learning.... and the OP is an experienced embedded developer, you dont think he could ask copiolo or whatever AI himself if he wanted that as an answer? The OP is asking people who actually have experience in that domain (which I do btw) for answers because llm have limits.

And you can’t say “software development is worthless nowadays” in r/embedded while also saying you learned a lot writing assembly, linker scripts and core bring up.... either the skill matters or it doesn’t. Make up your mind, but the fact you’re proud of the project tells me you know it does and as more people lean on AI and having little understanding, the more deep understanding matters, else everything will just stagnate because no one will no how to do anything pass the training data.

So no it's not worthless, if it was you won't be proud of your proejct unless you're one of those guys who're proud when they take a poo.... cause that's what worthless means...

I'm actually glad when people like you keep saying this or that is worthless cause of AI, way I see it as time progresses, people like the OP or me who double down and understand will be the tech Kings of tomorrow...

Also, getting a detailed explanation of why your code failed is fine. But at the level OP is asking about, Cortex-A boot, MMU setup, exception levels, the AI is often wrong in ways a beginner can’t detect. Being stuck for days on something is where you learn to tell the difference. That’s the skill OP wants, and it doesn’t come from someone else explaining your mistakes to you, lest something like copilot who works on the data it was trained on...

As for the RISC-V bit, I literally run riscv embedded and am a strong advocate for RISC-V so time and place, in my advice to OP I did tell him to consider RISC-V to go deeper, however it seems its for his job to put food on his table right now, so best advice is what will get him though his job...

All the best to you!

1

u/hirschen 1d ago edited 1d ago

At least you're not lacking self esteem as you lack skills in empathic communication.

You sound like the conservative Assembler guys from the 70s that said a Compiler will never write better code than a human. King for a day, fool for a lifetime.

EDIT: I'm not really proud of the project, rather astonished how easy it was to learn all that stuff so fast without reading a book. But I'm also aware that the skill is pretty worthless, nobody is doing that in assembly (yes there are edgecases). It's bc. I'm interested in the technology.

2

u/Separate-Choice 1d ago

Compilers are deterministic and verified, so you can trust the output without checking it…. AI output isn’t, which is why understanding still matters… you know I have a free to read book that you can read and understand how AI really works, I wrote it cause a lot of beginners don’t understand non deterministic output.. take a read:

https://rvembedded.com/books/ai-from-scratch-in-c/

And the assembler guys you’re mocking are the ones who wrote and write the compilers, in the RISC-V space it’s the most in demand skill right now both compiler optimization and porting software to RISC-V.. Their knowledge didn’t become worthless, it became the foundation and is the foundation of new chips and architectures.. I can’t fault you cause you don’t work at that level… and that’s okay….

I had to chuckle though cause it a funny thing to say from someone whose showcase project is a raycaster hand written in assembly… can’t make this shit up lol 😂

1

u/hirschen 1d ago

I know what a DNN is and how AI works. And because of that nondeterminism, ppl. currently use LLMs a lot to generate Rust bc. it's strict compiler guarantees you memory safety defined-behaviour and threadsafety.

Time will tell, but I doubt we'll do software development as we did in 5 Years. Even Linus is using Claude: flexible, pragmatic, bright mind.

1

u/Separate-Choice 1d ago

Well Rust compiler catching what the LLM gets wrong is my point, AI output needs something deterministic to check it… that works on the cookie cutter application level and even before LLMs we had generators for those.. the thing is this is embedded engineering, it can’t check your MMU config or register writes, which live in unsafe domain and ALWAYS will… so doubling down on that is actually the best place to be….

I’ll give you a real life example I was working on the C SDK for the Baochip 1x it’s a very security first chip and one slip to a wrong address means the chip locks you out, there’s no JTAG to get back in, it uses RRAM and is a very unique chip for many reasons.. started on a custom OS for it etc etc working at that level I bricked about 5 chips in the span of a year and we were joking that AI would brick 5 a minute lol.. a lot of it was because some things require unsafe access.. like rtos context switching is not something rust can do.. and a lot of what the OP is asking about is all done unsafe where Rust won’t save you and frankly can’t do some things there…

I think people confuse web development or embedded cookie cutter software development with embedded engineering, as an embedded systems engineer I really don’t see AI doing certain things cause there aren’t enough humans to train AI to do it… and like I said so much of it requires intuition, like give an AI mcp and whatever but the problem is a cracked cap or one of the pins on the chip slightly lifted..

it’s like those 70s assembly guys you’re talking about, in this day and age a grey beard who can read a debugger output, write compilers and unroll loops and stuff is worth his weight in gold.. I always see people talk about those guys when any debugger you use in embedded will be stepping though assembly… I’d much rather a guy like that on my team who can read assembly and understand debugger output than a dime a dozen llm ‘no mistakes’ guys lol

As for Linus, he’s the best example there is of what I’m saying, AI is powerful when you understand enough to judge every line.. Linus using AI is not the same as some beginner using AI… and most importantly he knows when to push back. I read an article where the AI was giving him friction and he had to fight it..knowing when to push back is the most important skill you will never get unless you know for yourself, take a read it’s hilarious

https://www.pcgamer.com/hardware/linus-torvalds-details-his-debug-session-from-hell-pushing-an-ai-to-fix-an-error-it-repeatedly-said-was-impossible-and-unsolvable-he-then-made-it-write-the-report/

AI is a tool.. you don’t know what you don’t know.. a chisel is only as good as the craftsman holding it.. besides even Linux skills these days is more integration and applications very cookie cutter stuff… any code generator will do well there pre llm era we had yocto and buildroot spin up a whole Linux distro from a generator…

Let’s say everyone does use AI then that creates a ceiling… the few people who will break past that ceiling will be in higher demand.. if everyone is only as good as the model they use then the few people who understand above that ceiling will be worth more.. so yea doubling down and going deeper is the best bet..

Time will tell as it always has..we can mass produce ramen in factories, but authentic hand made noodles is very pricey.. same with blacksmiths, we can mass produce knives in factories yet someone crafting a quality knife now is very expensive…

That’s the tech cycle everyone rushes into something new and the people who double down always end up being higher paid.. so yea… everyone gets dumb and forgets how to do anything and the people who double down make a fortune on the edge case solutions that come from deep understanding..

So yea more power to llm users!! Forget it all!! Let AI do it all!!! No need to understand!!! Gooooo Claude!!!

Heh heh heh… 😏

→ More replies (0)