All MIPSy were the borogroves#
Wed, 27 Dec 2017 00:14:32 +0000
My New Year's Resolution is to blog something every Tuesday (shut up at the back there, I haven't been to bed yet so it's still nominally Tuesday in my personal timezone) whenever I haven't posted in the preceding week.
Recently I had the idea of repurposing my previous wireless router (a TL-WR842ND ) as the brain for a backup server in my study, by plugging a USB disk into it and installing rsync. In order to fulfill my yak shaving quota, I decided to do this using Nixpkgs/NixOS instead of just doing the sensible thing and installing the relevant OpenWRT package.
Story so far:
In the pursuit of getting a serial console on it, I have probably burnt out the UART by bad soldering and/or inadvertently connecting TX to the 5V rail.
But I also have an Arduino Yun lying around which has an Atheros AR9331 MIPS 32 bit SoC - more or less the same hardware as most consumer broadband routers - with an Arduino microcontroller stuck to it that can be persuaded into a role as a USB/serial converter - so I have a console and no soldering required. This felt like a waste of an Atmega, but clearly in a good cause so I pressed on.
Right now I'm at the stage where I can build a bootable kernel and an unuseably large filesystem for it. Here are some things I have learned:
- Nix finds runtime dependencies by grepping the generated package output for the store path for each build-time dependency and discarding the ones it can't find. I am in awe that this works. I know this because I was getting huge filesystem image sizes, because the "strip" invocation in package postinstallation was failing silently so the debugging symbols which had not been expunged were causing it to hang on to references to three different kinds of gcc and glibc and and Various Other Random Stuff.
- Nix cross-compilation support is in a state of flux right now. If "state of flux" is not an oxymoron, anyway. At one point I got stuck and employed the "let's just upgrade everything" fault resolution technique, which gave me a new and different fault that I opened an issue about , and learned that I should probably not expect anything to work as expected until PR #26805 is merged.
Currently I am working from the branch named in that pull request: ar
works and strip
too,
but I still have huge image sizes, now because it has decided that glibc
depends on gcc and the kernel headers - this seems to be a problem
with cross-compilation generally and not with MIPS specifically,
because ARM has the same issue.
[dan@loaclhost:~/src/nixwrt]$ nix-store -q --references /nix/store/pf047ij2z1bfzlkkyf0v7m4p273713d6-glibc-2.26-75-armv6l-unknown-linux-gnueabihf-armv6l-unknown-linux-gnueabihf/ /nix/store/3x1wd17r8fg3zhasljxdm6vabyn7qr5y-gcc-6.4.0-armv6l-unknown-linux-gnuea /nix/store/xh15qw8k4za1va29ks7z3kjbjlcfb15v-linux-headers-4.4.10-armv6l-unknown- /nix/store/pf047ij2z1bfzlkkyf0v7m4p273713d6-glibc-2.26-75-armv6l-unknown-linux-g
It is entirely possible, of course, that I will never get a GLibc-based system into 8MiB even when it's not dragging in the kitchen sink, the plumber that installed it, and the staff and plant of the factory that made the plumber's van (er, figuratively) and I should switch to uclibc or musl, but in the meantime this is all educational.
I have some clearly still very work-in-progress code at https://github.com/obsidiansystems/nixpkgs/compare/02726a2...telent:nixwrt-cross-elegant for anyone who wants to see it.
In other news, I've also been addressing my apparent need to solder stuff by having Fun With Arduinos and Neopixels
[ Postemporaneous edit: the next thrilling installment in this series is now up at https://ww.telent.net/2018/1/2/gehen_sie_bitte_mit_hier_ist_nix_zu_sehen ]