diary at Telent Netowrks

Power play#

Fri, 20 Jul 2018 12:54:10 +0000

Last week in NixWRT we made kexec with uImages work despite unexpected complexity; this week we realised it's not even going to be as simple as we thought it would be after last week's work. Because u-boot is often delivered in lobotomised form on end-user devices we are using the kernel CONFIG_CMDLINE_OVERRIDE options to specify the command line and ignore whatever weird defaults the bootloader wishes to provide, but this then bites us when we want to boot the same kernel with kexec and augment the overridden command line. Argh.

But I haven't really jumped into doing anything about that yet, because I got sufficently annoyed with having to walk up and down stairs to reset the device every time I crashed it (testing kexec) that I decided to take some time out to add remote power switching to it. Which is what you see to your right (if you are reading this in HTML with CSS enabled: if you are an RSS subscriber or using Reader mode or ... I dunno, it's probably somewhere around here). This is an Arduino Yun running a sketch that turns pin 8 on or off when it gets a 1 (or y) or a 0 (or n) on its serial port, attached via a voltage divider to the base of a 2N2222 transistor, whose collector is attached to the coil of a small relay, whose switch is interposed in the path of the 5V wire of a microUSB cable. Result: I can turn my GL-MT300N off and on by running something like (echo n && sleep 1 && echo y) > /dev/ttyACM0 from the computer that the Arduino is plugged into.

The Arduino Yun, including as it does an entire embedded MIPS system , is definitely overkill to drive a single GPIO output, but it was lying on my desk and not currently doing much: it's not as though I bought it for this use.