Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
FlapYoJacks
Feb 12, 2009
Do you like Linux, but also think to yourself:
- I want to work with embedded hardware
- I hate myself
- I enjoy pain
- I enjoy figgies more than the pain of working with embedded Linux?

Then Embedded Linux may be a thing you want to work with.

There are a few embedded Linux SDK's out there, the two biggest players are:
Yocto/Openembedded https://www.yoctoproject.org/:
Pros:
- Every company that provides embedded hardware usually provides a yocto recipe
- It has a ton of packages.
- It's flexible and extensible.
- Tons of corporate backing
- It's very clever

Cons:

Phobeste posted:

here's some bad stuff about yocto:
- don't like make? That's fine. We don't write make here. Instead, we write a DSL. The DSL looks like bash, but you can also arbitrarily start writing a python function and call it directly from the bash. or write a python function and inject it as a task
- we're going to use bash key-value stores a lot, just FYI
- oh, ps; even though we have some sort of weird key-value store thing, we're also going to do a lot of changing behavior and filtering via the name of a variable. for instance, you can have MYVAR and also MYVAR: native and also MYVAR: target and MYVAR:target:imx and MYVAR:target:imx8mm, and one will get selected based on some configuration
- we're going to be making a lot of shell-style lists that are whitespace-separated. we're going to be doing a lot of overrides based on list ordering
- build configuration that selects everything, the equivalent of buildroot's defconfig, is in all the documentation supposed to be a thing you set up on your machine in a build directory. This is insane. So we're going to be making some repos and automation that don't have a lot of good examples because everybody says, "oh yeah, just run this script, then your machine's set up." gently caress you it's 2021
- we're going to be doing a lot of submodules because of this. with a lot of layer directories.
- oh, ps, we have layers. We're going to need a lot of layers probably. All the layers will get smooshed into a giant global namespace (n.b. the namespace is "environment variables." yes, this includes the entire text of recipes). All layers can override random things in each other arbitrarily. Don't understand why something is/isn't building? Well, have you tried ripgrep? trust me; regular grep is not going to be good enough
- have any problems with any of the above? Oh, that's ok; there's a bunch of random shell scripts you're never going to remember that you need to enter a chroot to use. these can do quite a lot of things because we track bidirectional metadata (e.g., "where did this file in the target rootfs come from" is a question you can now actually answer), but again you're not going to remember this at all

Buildroot https://buildroot.org/:
Pros:
- It's far simpler to get a build going.
- Uses kconfig from the kernel, which means a menuconfig system for selecting packages.
- Tons of packages are built-in and maintained by the developers and volunteers (myself included). To date, there are 2900 packages included in the latest release of Buildroot.
- Packages are written with GNU Make.

Cons:
- Packages are written with GNU Make.
- Not as clever as Yocto
- Having more than one config means nothing to Buildroot, and both are built independently of each other, so no host-tool sharing.
- You can't easily overwrite package .mk files with other packages .mk files. (this is by design.)

Feel free to bitch about Yocto and Buildroot or just ignore the thread. :v:

Adbot
ADBOT LOVES YOU

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe
My irl name is Steve Yocto, inventer of Yocto Linux. I named it after myself, not very creative I know.

Anyhow, if you do a Linux I recommend Yocto Linux - it's the bees' nuts.

Poopernickel fucked around with this message at 22:27 on Nov 1, 2021

FlapYoJacks
Feb 12, 2009

Poopernickel posted:

My irl name is Steve Yocto, inventer of Yocto Linux. I named it after myself, not very creative I know.

Anyhow, if you do a Linux I recommend Yocto Linux - it's the bees' nuts.

My name is Adam Buildroot, inventor of Buildroot Linux. If you do an embedded Linux, I recommend Buildroot, as I have submitted way too many patches to Buildroot over the years. :v:

Silver Alicorn
Mar 30, 2008

𝓪 𝓻𝓮𝓭 𝓹𝓪𝓷𝓭𝓪 𝓲𝓼 𝓪 𝓬𝓾𝓻𝓲𝓸𝓾𝓼 𝓼𝓸𝓻𝓽 𝓸𝓯 𝓬𝓻𝓮𝓪𝓽𝓾𝓻𝓮
Linux is named after Linux Torvalds

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
i only used yocto on one project, and it was to build an embedded version of linux.

the company hired some lawyers to go over all the licenses are were drooling at the possible billable hours they were going to have going through all the packages.

i ran a single command and dumped the entire license package and sent it to them, probably nearly a 1000 licenses.

they only got a small handful of billable hours.

thats my yocto experience.

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

CRIP EATIN BREAD posted:

i only used yocto on one project, and it was to build an embedded version of linux.

the company hired some lawyers to go over all the licenses are were drooling at the possible billable hours they were going to have going through all the packages.

i ran a single command and dumped the entire license package and sent it to them, probably nearly a 1000 licenses.

they only got a small handful of billable hours.

thats my yocto experience.

yeah both buildroot and yocto are pretty good at doing this although yocto takes a more... proactive approach with a bunch of runtime checks that a license is present (whereas with buildroot, since it's more centralized, it's more of a "nobody's going to apply your patch into trunk if it doesn't have a license with it")

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe
Yocto's license management is legit if you want to make sure you're compliant and that your licenses don't change out from under you.

I like that I can set a "don't ever install gplv3" setting, and then be secure that it won't unless somebody intentionally forges license data on a package.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
linux schminux

Kazinsal
Dec 13, 2011



attempting to do a custom linux once frustrated me enough to start writing a new kernel instead

FlapYoJacks
Feb 12, 2009

Poopernickel posted:

Yocto's license management is legit if you want to make sure you're compliant and that your licenses don't change out from under you.

I like that I can set a "don't ever install gplv3" setting, and then be secure that it won't unless somebody intentionally forges license data on a package.

There has been a lot of discussion on how to implement this in Buildroot. It's a highly requested feature!
I have been poking at this kind of thing off and on for a while now!

NoneMoreNegative
Jul 20, 2000
GOTH FASCISTIC
PAIN
MASTER




shit wizard dad

Poopernickel posted:

Yocto's Bithc

Sapozhnik
Jan 2, 2005

Nap Ghost
i used to do embedded linux things and would like to again

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe

DoomTrainPhD posted:

There has been a lot of discussion on how to implement this in Buildroot. It's a highly requested feature!
I have been poking at this kind of thing off and on for a while now!

Model it after Yocto's with some changes. Add a config option that enables a build step after patch. The step checks to see if a recipe's license hash matches the license hash in the source tree, to ensure the recipe info is still correct. Trust the recipe author to be accurate about the license name. Fail the step if the license matches a blacklisted value (or if it's not whitelisted). Make this different for host packages, where it generally doesn't matter.

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe
If you're a "gently caress it, the defaults are probably fine" kind of guy then Buildroot is your jam.

If you want to control everything then Yocto is what you want.

Yocto has a much steeper learning curve IMO and it takes more time to get started. But it's a lot more powerful. Sometimes that's the right tradeoff, sometimes not.

Also it has broad vendor support which is nice, because they can just ship a layer which will probably be a pain in the rear end for you to integrate.

Poopernickel fucked around with this message at 22:54 on Nov 1, 2021

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man
here's my current (least) favorite embedded linux thing problem: let's say that you want an embedded linux device that has a predefined system on it so you want to use something like buildroot or yocto. let's also say that one thing you want running on it is a modern interpreted-language app. maybe it's javascript, maybe it's python, whatever (i know, i know, just come on this voyage of discovery with me). what do such "modern apps" all have in common? a shitload, an absolute shitload, of dependencies, often for a bad reason, sometimes for a good reason.

here's the thing with buildroot and yocto: they weren't written for that at all. they're written for applications that don't have that many deps, and also don't have that many unique deps. and the expectation is that those deps aren't really unified by anything so they'll all need their own build handling. so the expectation is that any shared library or header file or python module or node module has a recipe that's in your system's recipe layer, and all your recipes mark their deps, and then you enable your end application and write down the deps and it activates all the transitive ones and you've got nice hash locked versioned dependencies. cool

the thing is that python and js (again, work with me here) both already have that in terms of their language dependency ecosystem: npm and pypi. those places already have all those libraries with their dependencies marked. they have tooling bundled with the standard library or standard project tools to pull them and change them and add them and remove them, and all those deps are stored in some language specific metadata.

so yocto and buildroot all expect recipes for every individual project dependency and for all those deps to be linked, and you've got a nodejs app with a package.json and yarn.lock or a python app with a setup.py or pyproject.toml or Pipfile or whatever and they're just completely different and so you get to pick one of:

- manually maintain your recipe store and dependency links to correspond to the app's normal dependency management. just keep an eye on prs that change deps and make sure you do it on the target config too. simple as. i recommend this only if you bill by the hour.
- autogenerate one from the other but then do the above
- sidestep the language ecosystem's dependency management somehow. all the app devs will now commence ripping your guts out
- sidestep the entire, like, point of buildroot or yocto and just hack some poo poo up to have the right cross flags set in some build environment and just call pipenv or yarn or whatever and then copy poo poo from the right magic dir to the right magic dir. you've just broken the smart is-a-build-necessary logic in some way or another, the library gathering logic, probably any build hermeticity you had up to this point

seriously if one or another of this group would make it possible and ideally easy to add a python or js project or whatever and not have to write a recipe for every dep, while still being able to fetch all licenses and do smart rebuilds, so many nightmares would end

FlapYoJacks
Feb 12, 2009

Poopernickel posted:

Model it after Yocto's with some changes. Add a config option that enables a build step after patch. The step checks to see if a recipe's license hash matches the license hash in the source tree, to ensure the recipe info is still correct. Trust the recipe author to be accurate about the license name. Fail the step if the license matches a blacklisted value (or if it's not whitelisted). Make this different for host packages, where it generally doesn't matter.

All packages have a .hash file with sha256sums (or whatever is provided there) for both the tarballs and license files specified in the .mk file.

What needs to happen is a bit... more complicated.
- Parse every package for their respective ${PKG_LICENSE} macro and add them to a global list which can be used in Config.in and Config.in.host files
- Add the dependency macros to every single packages Config.{in,in.host} file.

It's not a small patch to add!

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe

I solved a similar problem (manage a build tool that manages its own deps) with some black fucken Yocto magic at my last job. I added a manually triggered recipe action that downloaded all deps using the custom tool, and then updated the .bb file's license and src_uri sections based on the result. The recipe action was called manually or by CI job whenever somebody wanted to update the package's contents.

It's nice having Python available to run arbitrary tasks, with full access to internal metadata. :)

Poopernickel fucked around with this message at 23:15 on Nov 1, 2021

FlapYoJacks
Feb 12, 2009
Funny enough, there's straight up a line in the NodeJS package in Buildroot that lets a user download packages via NPM during the build.

For Python, there's `utils/scanpypi` that you can use to import a package and it's dependencies, or you can build host-python-pip and run pip install during the build.

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man
right, both those things are various workaround options, right. like the node package in buildroot's workaround is the opting-out-of-buildroot thing. scanpypi is the recipe generation thing where you still have to manually sync there's just a tool to do it (yocto has something similar at least for python). poopernickel your way sounds like the best way. what i ended up doing was using a weird little python library to parse a pipenv lockfile and generate requirements and then install them with pip (didn't want to just edit SRC_URI because i also wanted some different install opts to basically install virtualenv blobs) for python, and just call yarn and say fuckit for the js thing. neither of these are terribly good though.

it's kind of a fundamental problem: yocto/buildroot and yarn/npm/poetry/pypi/pip overlap in the domain of dependency management, and they just straight up don't nest. the only answer is integration on a deep level and nobody wants to deal with that poo poo particularly for js

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man
like IMO the actual answer here is that yocto at least, because it has a one-phase rather than two-phase model, should probably be able to let you specify a dep spec like a yarn.lock or pipfile.lock or whatever in your SRC_URI and generate (in yocto terms) RDEPENDS and DEPENDS from it. ideally it should also generate recipe content using the (de-facto standardized) install tools. maybe there's some carveouts, that's fine.

this is of course a little harder with buildroot because it's two-phase and it's just kconfig so you'd have to do a loooot more work

FlapYoJacks
Feb 12, 2009
It comes down to how often you want to update the dependencies and for what reason.

At least for python packages buildroot has 431 python packages built-in and scanpy works quite well to import more. It's always interesting to see people who freak out that their embedded device must have all of the latest packages at all times. :shrug:

Edit* I can't speak for node, even though I recently updated the NodeJS package in Buildroot to 14.x. :v: The only reason I touched the NodeJS package is that I am actively working on removing all traces of Python2 from Buildroot, and NodeJS 12.x's build system requires Python2.

FlapYoJacks fucked around with this message at 23:34 on Nov 1, 2021

hobbesmaster
Jan 28, 2008

you know how every python installation is supposed to have certain modules available as part of the “core” language?

yocto doesn’t

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe

hobbesmaster posted:

you know how every python installation is supposed to have certain modules available as part of the “core” language?

yocto doesn’t

agreed, splitting up the stdlib was a very questionable design choice on Yocto's part.

And by "questionable" I mean "dumb as hell"

ultravoices
May 10, 2004

You are about to embark on a great journey. Are you ready, my friend?
yoctdon't

Progressive JPEG
Feb 19, 2003

btw how common is msdos in embedded environments these days

my most recent msdos experience was it controlling a building-sized telescope in 2007 or so. probably still trucking

Progressive JPEG
Feb 19, 2003

Poopernickel posted:

agreed, splitting up the stdlib was a very questionable design choice on Yocto's part.

And by "questionable" I mean "dumb as hell"

i guess it depends on what made or didn't make the cut

like the tkinter stuff could probably be cut for example

Progressive JPEG
Feb 19, 2003

Progressive JPEG posted:

btw how common is msdos in embedded environments these days

my most recent msdos experience was it controlling a building-sized telescope in 2007 or so. probably still trucking

specifically the msdos controller was what made sure that the telescope didn't accidentally swing into the walls/ceiling of the observatory or into the control room at ground level that you were sitting in

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe

Progressive JPEG posted:

i guess it depends on what made or didn't make the cut

like the tkinter stuff could probably be cut for example

a lot of the stdlib modules are split into different Yocto packages. Like if you just install "python3", you don't get some stdlib sections like multiprocessing, io, etc. Those all live in their own packages, or can all be installed with a meta-package called "python3-modules". Usually you find this out when you're working on some new Python script on-target, and then you find out that chunks of the stdlib are missing for no apparent reason.

Poopernickel fucked around with this message at 00:47 on Nov 2, 2021

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe

Progressive JPEG posted:

btw how common is msdos in embedded environments these days

my most recent msdos experience was it controlling a building-sized telescope in 2007 or so. probably still trucking

pretty uncommon, Linux has mostly pushed it out.

I'm sure somebody's still rocking freedos on an industrial PC somewhere though.

hobbesmaster
Jan 28, 2008

Progressive JPEG posted:

i guess it depends on what made or didn't make the cut

like the tkinter stuff could probably be cut for example

pip is it’s own separate package

this is as bad as it seems

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
i never used any p-langs with yocto so i cant help

but built-in toolchain and debug symbol stripping made development/debugging suuuuuper easy

our application was just some kernel drivers and a c++ application, though.

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe

CRIP EATIN BREAD posted:

i never used any p-langs with yocto so i cant help

but built-in toolchain and debug symbol stripping made development/debugging suuuuuper easy

our application was just some kernel drivers and a c++ application, though.

This is controllable on a per-package basis in Yocto, if you ever find yourself having to deal with it again.

Sapozhnik
Jan 2, 2005

Nap Ghost

Phobeste posted:

here's my current (least) favorite embedded linux thing problem: let's say that you want an embedded linux device that has a predefined system on it so you want to use something like buildroot or yocto. let's also say that one thing you want running on it is a modern interpreted-language app. maybe it's javascript, maybe it's python, whatever (i know, i know, just come on this voyage of discovery with me). what do such "modern apps" all have in common? a shitload, an absolute shitload, of dependencies, often for a bad reason, sometimes for a good reason.

here's the thing with buildroot and yocto: they weren't written for that at all. they're written for applications that don't have that many deps, and also don't have that many unique deps. and the expectation is that those deps aren't really unified by anything so they'll all need their own build handling. so the expectation is that any shared library or header file or python module or node module has a recipe that's in your system's recipe layer, and all your recipes mark their deps, and then you enable your end application and write down the deps and it activates all the transitive ones and you've got nice hash locked versioned dependencies. cool

the thing is that python and js (again, work with me here) both already have that in terms of their language dependency ecosystem: npm and pypi. those places already have all those libraries with their dependencies marked. they have tooling bundled with the standard library or standard project tools to pull them and change them and add them and remove them, and all those deps are stored in some language specific metadata.

so yocto and buildroot all expect recipes for every individual project dependency and for all those deps to be linked, and you've got a nodejs app with a package.json and yarn.lock or a python app with a setup.py or pyproject.toml or Pipfile or whatever and they're just completely different and so you get to pick one of:

- manually maintain your recipe store and dependency links to correspond to the app's normal dependency management. just keep an eye on prs that change deps and make sure you do it on the target config too. simple as. i recommend this only if you bill by the hour.
- autogenerate one from the other but then do the above
- sidestep the language ecosystem's dependency management somehow. all the app devs will now commence ripping your guts out
- sidestep the entire, like, point of buildroot or yocto and just hack some poo poo up to have the right cross flags set in some build environment and just call pipenv or yarn or whatever and then copy poo poo from the right magic dir to the right magic dir. you've just broken the smart is-a-build-necessary logic in some way or another, the library gathering logic, probably any build hermeticity you had up to this point

seriously if one or another of this group would make it possible and ideally easy to add a python or js project or whatever and not have to write a recipe for every dep, while still being able to fetch all licenses and do smart rebuilds, so many nightmares would end

i hate to say it but use docker. or podman or w/e. qemu-build your p-lang crap into an oci container and then deploy it on fedora iot or similar.

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
yeah, the problem is that yocto is designed into being very explicit about dependencies and their licenses. bringing in the free-for-all nightmare that is python and node dependencies is a nightmare.

FlapYoJacks
Feb 12, 2009

Poopernickel posted:

This is controllable on a per-package basis in Yocto, if you ever find yourself having to deal with it again.

Same with Buildroot as well.

hobbesmaster
Jan 28, 2008

ah but if you create a platform then licensing can be someone else’s problem!

I’m an FAE at a company that makes IoT gateways and in certain use cases customers need like 10 lines of code for protocol translation and there’s problems with every way to do that.

sb hermit
Dec 13, 2016





I once made a tiny midi synth that received midi data via usb and played sounds over a connected speaker. It was built on a raspberry pi platform with raspbian as the OS.

As an exercise, I'd like to convert the OS to one that could either store all program data in memory, or on a read only partition on the SD card. At any rate, nothing on the sd card would be writable and I would just mount a ramdisk on /tmp and /var.

I'm quite experienced in embedded linux (I used to use montavista when it was a thing) and did some contracting work on buildroot (which I knew pretty well at the time). Is it worth giving yocto a try for a hobbyist project? Or should I stick to buildroot for this project?

graph
Nov 22, 2006

aaag peanuts
more like yuckto

hobbesmaster
Jan 28, 2008

do you want to learn yocto? anything with an rpi is going to be how to explore it, there’s already a nice bsp so you just have to put together your puzzle pieces.

Adbot
ADBOT LOVES YOU

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

here's a nickel kid, buy yourself a real computer

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply