Topic: Senoko passthrough firmware

Hi,

Is the firmware in the desktop Senoko passthrough board the same as the full battery controller? It's https://github.com/xobs/senoko-chibios-3, right?

Is there a guide to getting a working toolchain/build environment for it anywhere? The GPIO headers look handy, since the mainboard doesn't have too many exposed if the high-speed slot is otherwise occupied (e.g. with MyriadRF).

Thanks,
Damien

Re: Senoko passthrough firmware

Hi,

Yes, they are the same.  When the Senoko OS boots, it probes for the battery charger, and if it's not found it assumes it's a passthrough board.  That way the same firmware will run on both boards.

To build, check out the code, cd into senoko-chibios-3/senoko, and run "make".

I have two shell scripts I use for reflashing.  The first one, setup.sh, is run once, and simply sets up permissions on everything.  It needs root access, and runs sudo when required:

#!/bin/bash

sync

# Bring the board out of reset
sudo chmod a+rw /dev/ttymxc3
echo 149 | sudo tee /sys/class/gpio/export 2> /dev/null
echo out | sudo tee /sys/class/gpio/gpio149/direction 2> /dev/null

sudo chmod a+rw /sys/class/gpio/gpio149/value
echo 1 > /sys/class/gpio/gpio149/value

The second one actually reprograms the board.  To do this, you need to hold down the "Reflash" button and run the script.  Once the script is reflashing, let go of the button.

#!/bin/sh

# Bring the board out of reset
echo 0 > /sys/class/gpio/gpio149/value
echo 1 > /sys/class/gpio/gpio149/value

stm32flash -w build/senoko.hex -b 115200 /dev/ttymxc3

echo 0 > /sys/class/gpio/gpio149/value
echo 1 > /sys/class/gpio/gpio149/value

You'll need stm32flash, which is easy to get.  It even looks like it's in Debian now.

You actually have really good timing.  I just updated the "gpio" command to allow you to set/unset pins: https://github.com/xobs/senoko-chibios- … f8d8507e8d but note that I haven't checked pin muxing, so many GPIOs might not actually work.  If you try altering a value and it doesn't alter, that would be the reason.

Senoko is available over I2C, and I have a kernel driver started that would allow you to access those GPIOs via /sys/class/gpio/ but it is grossly incomplete.  The idea being you'd listen for an IRQ, and when it fired you'd probe Senoko for the actual value over I2C.  Much in the same way the STMPE acts as a GPIO expander.

If you wanted to muck about with accessing Senoko's GPIOs over I2C, you'll need to get your hands dirty.  Modify senoko-slave.c to set GPIOs in senokoSlaveDispatch() when offset == 0x12 or offset == 13, and poll their current value in senokoSlavePrepTransaction()

For extra brownie points, get IRQ handling working using events.  You can copy the AC plug or the power button code here.