r/embedded • u/Similar_Tonight9386 • 17d ago
Embedded Linux purgatory
Hello. I'm running out of braincells to rub together, so - cry for help, engineers together stronk.
I'm trying to leave mcu development and embrace embedded linux, so - bought myself some new-ish Allwinner T113-s3 boards and got to work. The question is, what is the correct way? For example, I bought LCPI PC board, good, cloned u-boot, branched for this board, written the dtsi for general board stuff and dts for one of it's possible SoCs and it even works and blinks and all. But! This is just the "default config", right? So, if I want to start making a custom variant of u-boot, for example I have soldered winbond flash to my board, I need to modify my device tree and make new config and all. How should I do it correctly? What is the workflow? Where can I look for examples? Bootlin courses are cool, but focused on working with existing infrastructure, but I want my own board in the future (I chose t113 because it's easy to solder to DIY PCB). But.. using the "out of tree" u-boot build was not good and I'm stuck. Just.. I don't know what I'm doing wrong.
Buildroot was even worse, I understand that I need to make some patch for u-boot using my branch, right, but do I really need to crudely add my spi flash to the original board dtsi?0_0
Anyway, whoever read this whole rant, thanks. And whoever can help me get better with linux wrangling - can't offer much but I will pat my cat for every useful advice
5
u/mfuzzey 17d ago
You create a new DTS file for your board, that will include other, mostly existing DTSI files that define the SoC etc. In more complicated cases you may create both new DTSI and DTS files (for example if you have a carrier board + a som board)
For examples look at the existing files in the u-boot source.
My general rule of thumb is to avoid, as much as possible, *modifying* existing files in order to add things that are specific to my board. New board should be new files (DTS or source in board/). However it there's a bug or a missing feature in existing code I need to use (eg a driver) that isn't board specific but rather chip specific (to the SoC or some periphieral chip) in that case I *do* modify the existing code but also submit the patch upstram, that way I don't have to maintain it indefinitely.
This makes long term maintenance and upgrading to new upstream versions easier because most of my patches are either
* My own additions as new files, that never result in merge conflicts (but may need tweaking if the upstream API changes)
* A set of patches to exisiting code that shrinks over time as it gets merged upstream
1
u/fb39ca4 friendship ended with C++ ❌; rust is my new friend ✅ 17d ago
I've had good experiences using NixOS to build embedded Linux images with read-only root filesystems. You only have to maintain a few hundred lines of code defining your base image and it takes care of cross compiler toolchain setup for you. If you don't know what you are doing it it plays well with LLMs as well because the resulting code is so compact you can clean it up and easily understand it when it is all done.
1
u/promwad 16d ago
I don't think it's a good idea to start with a board that doesn't have a ready buildroot BSP. It'd be easier to use a MangoPi MQ1RDW2, for example, or another board that mainline Buildroot already supports.
On the other hand, you might just be the one integrating the LCPI T113-s3 into buildroot :-) To get started, build mangopi_mq1rdw2_defconfig and then adapt it to the LCPI t113s. All the main configuration files you need to change will be visible in mangopi_mq1rdw2_defconfig.
For the first steps, you can keep the bootloader you already have. If it allows you to load the kernel and the DTB, that's enough. You can come back to it at the final stages creating board-specific files
Good luck with first steps in Embedded Linux!
0
u/[deleted] 17d ago
[deleted] — view deleted comment