DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

#1 2007-09-10 05:47:07

cwilson
Member
Registered: 2007-07-16
Posts: 19

chkbutton replacement

I've writtten a few utilities for controlling the LEDs, monitoring the front panel button, and shutting off power.  I actually wrote them for use in an hdboot, gentoo-embedded context, but I believe they would also be useful in a "normal" custom-firmware environment.  (more on that below).

The attached package contains two sets of pre-compiled binaries, along with the source code (which is GPL): compiled against uClibc-0.9.26 for use with custom firmware like sala-03, and compiled against uClibc-0.9.28 for use with gentoo-embedded (chroot or hdboot).

Here is the README from the package:

Code:

This package provides three programs for use on the
DSM-G600.  They are:

dsmg600-button:
  a utility (and daemon) to monitor the front panel
  button and execute a specified command when the 
  button is pressed for 7-12 seconds.  Ideally:
     /sbin/shutdown -h now
  This will cleanly shutdown all services, unmount
  disks, and call the kernel's poweroff function.
  However, at present the kernel doesn't know how
  to actually cut power, so it enters an infloop
  waiting for somebody to unplug it.
  
dsmg600-leds:
  a utility to control the front panel leds
  
dsmg600-poweroff:
  immediately cuts power. This is unsafe to use
  when you have mounted disks and processes 
  running...


All three utilities support '-h' for help.
Install the utilities manually into your path
(the gentoo hdboot integration -- see below --
expects that they are installed into /usr/bin)



References:
  http://forum.source.pri.ee/t164-chkbutton-buttons-leds.html
  http://forum.dsmg600.info/p3117-20070521-174259.html
  http://www.beattie-home.net/beattie/DSM-G600/
  http://wiki.rot13.org/rot13/index.cgi?dsm_g600



Gentoo hdboot integration:
=============================================================

Add the following to /etc/conf.d/local.start
to make the power led steady green once the
boot sequence is complete:
 
  (/usr/bin/dsmg600-leds -m led_power -s 1 -c g) >/dev/null 2>&1

Add the following to /etc/conf.d/local.stop
to make the power led start flashing when the
machine enters its shutdown/reboot cycle:

  (/usr/bin/dsmg600-leds -m led_power -s f -c g) >/dev/null 2>&1

To enable the dsmg600-button daemon to be invoked
during normal hdboot:

  cp gentoo-initscript   /etc/init.d/chkbutton
  cp gentoo-config-file  /etc/conf.d/chkbutton
  rc-update add chkbutton boot


To build:
=======================================================
edit the Makefile to set CC, LD, CFLAGS, and LDFLAGS
as appropriate for your build environment.  Then 'make'

Note that gentoo-embedded uses a different version of
uClibc (0.9.28) than does the DSM G600 firmware and 
Linksys-supplied cross toolchain (0.9.26).


Help output:
=============================================================

#############################################################
dsmg600-leds version 0.2.0
Utility program to control the LEDs on the DSM-G600

dsmg600-leds [options]
  -m MODE    which led to modify (power, hdd, wlan, etc)
  -s STATE   state to set the led (on, off, flash)
  -c COLOR   which color to set the led
  -g CODE    send specific three-letter code
  -n         dry-run (do not send commands)
  -d         display debug messages
  -h         display this message
  -v         display version information
  -l         display license information

Valid Modes: led_power  led_hdd   led_hddfull
             led_usb    led_wlan  poweroff

Valid States: on    (or 1)
              off   (or 0)
              flash (or f)

Valid Colors: green  (or g)
              yellow (or y)

Restrictions:
   -g cannot be combined with -m|-s|-c
   usually, all three -m|-s|-c must be specified together
     except: '-m poweroff' needs no -s or -c -- it immediately cuts power
             '-s off' needs no -c
   not all modes accept all states or colors:
     led_power:   green only, can't turn off
     led_hdd:     yellow only, no flashing
     led_hddfull: yellow only
     led_usb:     no restrictions
     led_wlan:    green only
                  flash mode blinks fast a few times, before
                  returning to previous state (on or off)

Valid Codes for -g
   SYN  --  Power led flash, HDD, HDD-Full, USB, WLAN leds off
   TSO  --  Power, HDD, USB, WLAN leds green, HDD-Full yellow
   TSR  --  Power, HDD-Full, WLAN leds off, HDD, USB leds yellow
   TSC  --  Power, HDD, HDD-Full, USB, WLAN leds off
   ZWC  --  Turn Power off
   ZWO  --  Power led solid
   ZBO  --  Power led flash
   WLO  --  WLAN led green
   WLC  --  WLAN led off
   WBO  --  WLAN flash green then off
   HDC  --  HDD-Full led off
   HBO  --  HDD-Full led flash yellow
   HDO  --  HDD-Full led yellow
   HDE  --  HDD led yellow
   HDN  --  HDD led off
   MMK  --  USB led green
   MMF  --  USB led yellow
   MMC  --  USB led off
   MMI  --  USB led blink green
   MUI  --  USB led blink yellow
   MMN  --  USB led off
   AKO  --  unknown

EXAMPLE: dsmg600-leds -m led_wlan -s on -c greeen
         dsmg600-leds -g MMC
#############################################################






#############################################################
dsmg600-button version 0.2.0
Utility program to monitor the power button on the DSM-G600

dsmg600-button [options]
  -a CMD     run specified CMD when button pressed <send msg to log>
  -n         dry-run (do not launch child action)
  -d         display or log debug messages
  -e         exit after first detected button press (no loop)
  -f         before executing CMD, flash leds
  -r         resident daemon mode (uses syslog)
  -u USER    [daemon only] run as specified user
  -p PIDFILE [daemon only] create pid file with specified path
  -h         display this message
  -v         display version information
  -l         display license information

EXAMPLE: dsmg600-button -a '/sbin/shutdown -h now' -f -r -p /var/run/my.pid

NOTE: the -f option is present becuase, in the example above, it might
      be an additional 20 or 30 seconds before init gets around to
      running /etc/conf.d/local.stop, which is the logical place to
      start blinking the power led to indicate 'shutdown in progress'.
      But that's a LONG time to hold the button down...
#############################################################





#############################################################
dsmg600-poweroff version 0.2.0
Utility program to immediately kill power on the DSM-G600

dsmg600-poweroff [options]
  -n         dry-run (do not actually poweroff)
  -d         display debug messages
  -h         display this message
  -v         display version information
  -l         display license information
#############################################################

Last edited by sala (2008-12-14 02:14:23)


Attachments:
Attachment Icon dsmg600-utils-0.2.tar.gz, Size: 113,915 bytes, Downloads: 506

Offline

 

#2 2007-09-10 05:51:44

cwilson
Member
Registered: 2007-07-16
Posts: 19

Re: chkbutton replacement

Oh, and if anybody is interested, I've posted a query, with my current patchset, on kernelnewbies asking for help to get the dsmg600 kernel to be able to actually shut off power when the platform's machine_shutdown() kernel function is called.  The post is here:
http://mail.nl.linux.org/kernelnewbies/ … 00086.html

Offline

 

#3 2007-09-11 09:18:36

sala
Member / Site Admin
From: Estonia
Registered: 2006-07-28
Posts: 731
Website

Re: chkbutton replacement

Good job!! Everything is working very well smile


DSM-G600 - NetBSD hdd-boot - 80GB Samsung SP0802N
NSA-220 - Gentoo armv5tel 20110121 hdd-boot - 2x 2TB WD WD20EADS

Offline

 

#4 2007-09-14 17:14:55

beattie
Member / Developer
From: West Coast, USA
Registered: 2006-11-17
Posts: 92
Website

Re: chkbutton replacement

to turn the power off you need to send to right string out.  The switches, LEDs and power are controlled by a small microprocessor that is connected to the CPU via ttyS1.

Offline

 

#5 2007-09-14 23:10:39

cwilson
Member
Registered: 2007-07-16
Posts: 19

Re: chkbutton replacement

Uhm, yeah.  I knew that -- I got that from your webpage and postings here.  That's what my dsmg600-leds and dsmg600-poweroff utilities DO. The problem is getting the *kernel* to do that after it no longer has access to user-space or to /dev/*, during machine_shutdown(). From talking with the guy who did a lot of work getting Kurobox support into the 2.6 kernels, it looks like I need to create/port a "micro-serial" driver that can initialize and allow direct kernel I/O to the UART without involving the kernel's filesystem layer...

I'll be working on that some this weekend.

Offline

 

#6 2007-09-15 22:19:51

cwilson
Member
Registered: 2007-07-16
Posts: 19

Re: chkbutton replacement

With the attached kernel patch, the kernel can actually turn off the DSM-G600 when you /sbin/shutdown. Thanks to Guennadi Liakhovetski for his pointers to his 2.6 implementation of a micro-uart driver, which I adapted here.

This implementation also provides a custom syscall to send messages to the microcontroller on /dev/ttyS1 -- except that it uses the in-kernel micro-uart driver instead. I added this so that I could test the in-kernel functionality easier -- and left it in.  In practice, however, it makes a lot more sense to use /dev/ttyS1 from user space, rather than a custom syscall.

Offline

 

#7 2008-06-13 23:01:13

mich123
New member
Registered: 2008-06-12
Posts: 2

Re: chkbutton replacement

Can you please resend the Dsmg600 utils package? The attachment is invalid now.
Thanks!

Offline

 

#8 2008-12-11 11:35:27

p.r.
Member
Registered: 2008-05-28
Posts: 9

Re: chkbutton replacement

cwilson
Could you update attachments links for dsmg600-utils-0.2.tar.bz2 and dsmg600-poweroff-20070915.patch?

Present attachments links are invalid.

Thank you in advance.

Offline

 

#9 2008-12-14 02:15:40

sala
Member / Site Admin
From: Estonia
Registered: 2006-07-28
Posts: 731
Website

Re: chkbutton replacement

Link is fixed at first post.
I was able to find dsmg600-utils but not kernel patch for poweroff.


DSM-G600 - NetBSD hdd-boot - 80GB Samsung SP0802N
NSA-220 - Gentoo armv5tel 20110121 hdd-boot - 2x 2TB WD WD20EADS

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB