News for hackers. Stuff that matters.
Re:Moving to a RTOS on the RP2040 by bborud on Friday July 05, 2024 @04:45AM (#40880954)
Having toolchains installed system-wide in the traditional UNIX way is painful, and dare I say it, not the smartest of approaches. If it works for you: great, but if you work on a project with multiple developers, sometimes working on multiple projects that have different targets, you will spend a lot of time trying to figure out build and configuration problems.

It also doesn't help that people keep using Python for tooling. Why would you want to insist on using a language that brings its own versioning problems and which will behave differently on each developer's computer? I've done embedded development for about a decade now (both as a hobby and professionally) and it is puzzling that people think it is okay to spend a week trying to make everyone's setup do the same thing on a project and then not see how this is a problem.

It is a problem. It is annoying. It does waste time. It is unnecessary.

Tools should be statically linked binaries. I don't care what language people use to write tools, be it Rust, Go, C, C++. I just wish people would stop prioritizing ad-hoc development and start to make robust tools that can be trusted to work the same way regardless of what's installed on your computer. Python doesn't do that. And it doesn't help that people get angry and defensive instead of taking this a bit more seriously.

That being said, things like PlatformIO are a step in the right direction. I know it is a Python project (and occasionally that turns out to be a problem, but less often that for other tools), but they have the right idea: toolchains have to be managed, SDKs have to be managed, libraries have to be managed, project configuration has to be simple, builds have to be reproducible and they have to be reproducible anywhere and anytime.

I wish more of the embedded industry would realize that it would be better to have some common efforts to structure things and not always invent their own stuff. I know a lot of people who work for some of the major MCU manufacturers and I am always disheartened when I talk to them because they tend to be very near-sighted: they are mostly busy trying to solve their own immediate problems and tend to not have a great deal of focus on developers' needs.

Re:Moving to a RTOS on the RP2040 by bschwindHN on Friday July 05, 2024 @06:26AM (#40881576)
I refuse to use anything with python tooling now. I just don't. It is just so extremely rare that things work on the first try with it.

I have a keyboard project that runs on an RP2040, and the firmware is in Rust. Here are the steps to flash it if you're starting with just the repo and no Rust toolchain:

      (install rustup)
    $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    $ rustup target add thumbv6m-none-eabi
    $ cargo install elf2uf2-rs
    * Put the keyboard in bootloader mode *
    $ cargo run --release
This is relying on rustup and Cargo to do the heavy lifting of toolchain management and building, which they are fantastic at. Python projects don't even come close.
Re:Moving to a RTOS on the RP2040 by bborud on Friday July 05, 2024 @06:34AM (#40881612)
That looks quite lovely. I really hope that MCU manufacturers invest in Rust and that they both manage to do so in mechanical sympathy with the Rust community and that they realize they have to cooperate on common tooling.
Re:Moving to a RTOS on the RP2040 by franga2000 on Friday July 05, 2024 @10:22AM (#40883039)
You're comparing the "traditional Linux approach" to curl-pipe-bash, not comparing the actual environments/toolchains.

Platformio: curl https://.../get-platformio.py | python3 && pio run

Pipx: apt install pipx && pipx [build-script.py]

Pipenv: pip install --user pipenv pyenv && pipenv run [build-script.py]

Re:Moving to a RTOS on the RP2040 by bborud on Saturday July 06, 2024 @07:22AM (#40889727)
They key isn't so much how you install the tools, since that's hopefully something you only do very occasionally, but the quality of life those tools provide once installed.
Re:Moving to a RTOS on the RP2040 by bschwindHN on Saturday July 06, 2024 @07:48AM (#40889838)
As mentioned already, it's not about the method of installation. In my experience python-based tools are slower and buggier than their native counterparts, and that's only after going through the installation process.

Tools written in C / C++ / Go / Rust just don't have nearly as much fuss, and they run faster and are smaller too.

Re:Moving to a RTOS on the RP2040 by franga2000 on Saturday July 06, 2024 @08:40AM (#40890090)
Go & Rust maybe, but I've had nothing but trouble with C/C++. Bigger projects usually have their build process well documented, but smaller thing usually give you an apt-get command for Ubuntu 18 and maybe a Makefile. Good luck running that even two years later on a different distro. The package names won't match and when you find them, the new version won't be compatible and the old version won't be in the repos, so you need to build that from scratch, recursively...
Re:Moving to a RTOS on the RP2040 by bschwindHN on Sunday July 07, 2024 @12:42AM (#40895323)
Building C projects from scratch usually isn't bad. I never trust debian-based distros to have anything up to date, so that's usually a lost cause anyway. C++ on the other hand...yeah those projects aren't often fun to build.
Re:Moving to a RTOS on the RP2040 by bborud on Sunday July 07, 2024 @08:22AM (#40897108)
It isn't so much that it is hard to build things - it is more that it is hard to distribute software for Linux because there are so many targets to build for. It is unreasonably hard to build binaries for distribution to more than one Linux distro. So people are disinclined to even try.

You can, of course, build static binaries (and people really should do that more often) and distribute tarballs, but then you might run into all manner of licensing issues. (Not to mention the tedious discussion about upgrading shared libraries under the feet of applications and praying it doesn't introduce hard to detect breakages).

One direction I'd love for distro designers to explore is if Linux distributions were to abandon the traditional splatterfest style of software installs, where an application scatters lots of files across several filesystems and depends on system wide libraries, and instead puts each application in a self-contained directory. Or rather, two: one for the immutable files (binaries, libraries etc) and one for variable state. That way you could choose if you want to do static linking or dynamic. Because any shared libraries could be part of the immutable application directory.

Oh yes, it'll result in a lot more disk use, but disk drives are cheap, and libraries rarely make up that much of your disk use anyway. But there is a fair chance you could address some of that with filesystem level deduplication.

You could also have systems for distributing shared libraries from trusted sources so applications do not necessarily have to include the shared libraries, but that they can be fetched as part of the install system. And then manage shared libraries locally with hardlinks or some form of custom filesystem trickery. This would have a few added benefits (opportunities for supply chain security, reducing size of distributed packages etc).

macOS does this only partially, but applications still depend on shared libraries and you have the horror that is the Library directories which are somewhat randomly structured, resulting in lots of leftovers when you try to remove applications. macOS has some interesting ideas, but the execution of them is....inconsistent at best.

The reason package managers don't work well is that they are trying to solve a lot of problems we shouldn't be having in the first place. And because nobody wants to simplify the problem they have to solve, distribution maintainers will keep writing package management systems that are a pain in the ass.

Re:Moving to a RTOS on the RP2040 by bborud on Saturday July 06, 2024 @06:36AM (#40889520)
On closer inspection, I'm assuming you meant:

  cargo flash --release --chip <name>
Re:Moving to a RTOS on the RP2040 by bschwindHN on Saturday July 06, 2024 @07:34AM (#40889781)
Nope, it's exactly as written. I use a cargo runner, configured here:

https://github.com/bschwind/key-ripper/blob/main/firmware/.c...

Re:Moving to a RTOS on the RP2040 by bborud on Sunday July 07, 2024 @08:22AM (#40897113)
Wow, that is nice.
Re:Moving to a RTOS on the RP2040 by LtdJorge on Friday July 05, 2024 @06:03AM (#40881420)
Wouldn't Docker (or other container tools) be a good candidate? Instead of installing the toolchains locally, do the build on a container based on an image with the exact toolchain you need.
Re:Moving to a RTOS on the RP2040 by buescher on Friday July 05, 2024 @08:11AM (#40882006)
For professional embedded development, where reproducible-in-the-future builds are frequently valued, it's common, when possible, to set up your whole toolchain in a vm that's kept under version control.
Re:Moving to a RTOS on the RP2040 by amluto on Friday July 05, 2024 @07:09AM (#40881752)
It is indeed possible to make a nice container that contains a program, offers a clean interface to that program, and doesn’t package a whole pile of largely irrelevant, guaranteed-to-be-quickly-outdated crap with it.

But being possible doesn’t mean that anyone does it. Most containers I’ve ever seen are big messes. Possibly GPL-violating messes if the payload isn’t appropriately licensed. Certainly maintenance and provenance disasters. Unquestionably not reproducibly buildable and possibly not buildable at all.

Re:Moving to a RTOS on the RP2040 by yjftsjthsd-h on Friday July 05, 2024 @10:04AM (#40882834)
> and doesn’t package a whole pile of largely irrelevant, guaranteed-to-be-quickly-outdated crap with it.

> Possibly GPL-violating messes if the payload isn’t appropriately licensed. Certainly maintenance and provenance disasters. Unquestionably not reproducibly buildable and possibly not buildable at all.

If static binaries are on the table then none of these things can possibly be disqualifiers.

Re:Moving to a RTOS on the RP2040 by bborud on Friday July 05, 2024 @06:43AM (#40881645)
Yes, I used to do that for a couple of projects, but it wasn't as smooth as I had hoped. For instance I had a bunch of challenges getting USB stuff to work properly. And there were some tools that still required me to lug around a windows laptop for parts of the process.

I'd much rather have proper tooling to begin with rather than have to pull out everyone's favorite roll of duct tape (Docker) to hide the mess.

Re:Moving to a RTOS on the RP2040 by vvanders on Friday July 05, 2024 @11:58AM (#40883856)
Docker is great if you don't care about your build performance across a wide range of hosts, it's probably fine for small projects but I've seen incremental build times climb quickly where docker support wasn't the best(i.e. OSX).
Re:Moving to a RTOS on the RP2040 by nine_k on Friday July 05, 2024 @05:52PM (#40886360)
You mean, where native Docker support is completely absent, and the whole thing has to rum in a VM?
Re:Moving to a RTOS on the RP2040 by petre on Sunday July 07, 2024 @11:57PM (#40902488)
Well, OSX and Windows run it in a VM, so there you have it.
Re:Moving to a RTOS on the RP2040 by LtdJorge on Saturday July 13, 2024 @06:58PM (#40957522)
I meant it as in having a CI system that relies on Docker or whatever container image system. You submit a build via some config files, the build farm builds the image and extracts the built binaries into a repo/binhost/S3, and you get your binary from there. Or you can now use that image for another build, in a pipeline.

There’s zillions of options for doing this nowadays, many of them self-hostable, which is pretty cool.

Re:Moving to a RTOS on the RP2040 by anymouse123456 on Friday July 05, 2024 @05:50AM (#40881344)
Just want to second this entire post. It feels like I wrote it myself.
Re:Moving to a RTOS on the RP2040 by naitgacem on Friday July 05, 2024 @02:34PM (#40884975)
Working with Android app developement has got me spoiled in this area. One needs to just run a command and everything is set up and works the exact same way whether be it locally or on CI with the same version of both build tools and the libraries. It still pains me when I go back to dealing with CMake and Make and trying to get libraries installed, as opposed to say, compile 'library-name-here'.
Re:Moving to a RTOS on the RP2040 by Gibbon1 on Sunday July 07, 2024 @01:36AM (#40895493)
I have a command line tool I wrote in C# back in 2011 and it just still works.
Re:Moving to a RTOS on the RP2040 by tpudlik on Monday July 08, 2024 @12:17PM (#40906690)
I don't think people choose Python because it's virtues as a language for tooling (it's not great from that perspective, statically linked binaries would be better). They choose it because of the ecosystem of libraries. For data analysis, visualization, and scientific computing, there are no comparable offerings in any other language. And a lot of this is stuff you _really_ don't want to be reimplementing from scratch, because it's very easy to introduce bugs (around numerical stability, say) that cause your software to produce correct results 99% of the time, and plausibly-looking but totally incorrect ones 1% of the time.