What's new

Configuring apcupsd

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Hi both,

So now I have an Ubuntu installed, and have started to compile Merlin's firmware by following this guide: https://github.com/RMerl/asuswrt-merlin/wiki/Compile-Firmware-from-source-using-Ubuntu

I'm now done with this stage:

git clone https://github.com/RMerl/asuswrt-merlin.git

I'm just curious at what point of the guide and how do I make the below changes to the kernel config?

Code:
CONFIG_HID_SUPPORT=y
CONFIG_HID=m
CONFIG_HIDRAW=y
CONFIG_USB_HID=m
CONFIG_USB_HIDDEV=y

Also, how do I include ryzhov_al's patch?

Please, pardon my questions as I'm really at a lost and I just wanted to learn. Thanks.
 
Thank you to ryzhov_al for the excellent patch. I got it working with the RT-AC68U router and the CyberPower 1325VA UPS.

cat /opt/var/log/apcupsd.events
Code:
2016-02-16 17:24:25 -0500  apcupsd 3.14.13 (02 February 2015) unknown startup succeeded
2016-02-16 17:25:15 -0500  Power failure.
2016-02-16 17:25:21 -0500  Running on UPS batteries.
2016-02-16 17:25:50 -0500  Mains returned. No longer on UPS batteries.
2016-02-16 17:25:50 -0500  Power is back. UPS running on mains.


I made this changes to the kernel config of the Asuswrt-Merlin firmware 380.57 for RT-AC68U router. Rebuilding the firmware will produce the three new kernel modules that will allow the router to communicate with the UPS's USB port.
~/asuswrt-merlin/release/src-rt-6.x.4708/linux/linux-2.6.36/config_base.6a
Code:
CONFIG_HID_SUPPORT=y
CONFIG_HID=m
CONFIG_HIDRAW=y
CONFIG_USB_HID=m
CONFIG_USB_HIDDEV=y


Copy the kernel modules (input-core.ko, hid.ko, usbhid.ko) to the router /jffs/bin and manually loaded them.
Code:
/sbin/insmod /jffs/bin/input-core.ko
/sbin/insmod /jffs/bin/hid.ko
/sbin/insmod /jffs/bin/usbhid.ko


The dmesg shows the kernel modules loaded OK.
Code:
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver


Connect the USB cable from the UPS to the router's USB 2.0 port. And dmesg shows that the router can see the UPS now.
Code:
usb 2-2.2: new low speed USB device using ehci_hcd and address 17
generic-usb 0003:0764:0501.0001: hiddev0,hidraw0: USB HID v1.10 Device [CPS  CP 1350C] on usb-0000:00:0a.1-2.2/input0


Install the apcupsd package from Entware-ng and change some configuration options.
/opt/etc/apcupsd/apcupsd.conf
Code:
UPSNAME cyberpower
UPSCABLE usb
UPSTYPE usb
#DEVICE /dev/ttyS0


Here's the kernel modules for RT-AC68U router. It is not for MIPS routers. Sorry I don't own an AC66U.
asuswrt-merlin-380.57-ARM-usbhid-modules.tar.gz
Code:
md5sum: a49752a82328b5b14963c3fea1bfca59
sha256sum: e45085820393e903428b8f799db1352b31eb2065f5c0addf1a35c6bb1c71580d
Hi... can you reupload the HIDs file ?
 
Hi... can you reupload the HIDs file ?
I just cut/paste this patch from a large patch file, but did not test. It will update all three ARM kernels with the capability of USB HID device. This is for router models RT-AC56U, RT-AC68U, RT-AC88U, RT-AC3100, RT-AC5300, RT-AC87U. Not for MIPS routers.

You just save the patch file to your $HOME directory and remove the ".txt" extension. Then apply the patch as follows:
Code:
cd ~/asuswrt-merlin
patch -p2 -i ~/asuswrt-enable-usb-device.patch

EDIT: just updated the patch file to include the extra kernel modules into the firmware
 

Attachments

  • asuswrt-enable-usb-device.patch.txt
    5.2 KB · Views: 521
Last edited:
I'm also looking for the 3 UPS driver modules input-core.ko, hid.ko and usbhid.ko for an RT-AC3100. I was hoping that someone has them handy and would save me a bunch of time and effort and making a bunch of mistakes trying to create them myself, undoubtedly.

Thanks.
 
OK. I've compiled the modules successfully. I've also loaded them using insmod successfully, as described in this thread. I've copied them to a new directory on the router I created, /jffs/modules.

Now, I'm trying to figure out how to install and run apcupsd. It's not all that obvious. I've seen optware and entware mentioned in many places. Do I need to install those? Can I just install apcupsd without installing optware or entware? I tried looking at the apcupsd documentation. I've also looked through some threads here and they reference /etc and other directories but when I look at /etc, it's empty. Doesn't make sense to me.

I'm familiar with Debian and apt-get. That doesn't seem to be available on the router.

Can someone discuss or go through some of the things required to install, setup and run software like apcupsd on my RT-AC3100 router.

After I've got everything running, I'll post the modules.

Thanks in advance
 
OK. I've got everything set up now. With the help of other setup instructions and info from others I've set up Entware-ng on an external SSD. I've installed apcupsd and finally configured it properly for my UPS and have also gotten sendmail to work properly with Gmail for sending out event notices. Attached are the three modules I used for my USB attached APC UPS. These work on my RT-AC3100.
 

Attachments

  • UPS Modules.zip.txt
    515.5 KB · Views: 278
^^Can you provide step by step instructions on how to do this on the recent asuswrt v380.68_4?

I've got the router (ac68-u) backed up by a apc BX1500G ups. It would be nice for the ups to hibernate in the event of a sustained powerloss without running the batteries down.

Thanks!
 
First thing you'll have to do is to set up your router to recognize your UPS.

FYI, I'm using 380.68 on my RT-AC3100. So the version shouldn't matter. I'm not sure if the AC68-u can use the same UPS modules as the RT-AC3100. I wasn't sure I could use other modules I found so I just tried them. In the end, they weren't compatible, so I compiled my own.

You'll have to SSH into your router and try other modules or the ones I've uploaded as described in this thread. Posts 17 and 19 have the insmod commands to load the modules and to confirm/see the UPS is recognized.

How difficult this is and your success will vary on your Linux experience and/or other types of things like this you've done.

I can help, but you'll have to learn and do as much of this yourself as you can.
===
Lastly, I'm not sure I understand your comment about hibernating the UPS when there's a sustained power outage to preserve the batteries. Most UPS these days will only last from 20 minutes to 1 hour and maybe only a few minutes depending on the devices being powered. That's what the battery is for, to use when the power is off. If there's a sustained outage, most UPSes aren't much use. You need something like a generator for a sustained outage. What do you think will be gained from preserving some run time on the battery? Not being critical, just trying to understand what your thinking is. It might be better to concentrate on the devices that are being powered by the UPS after you have the UPS communicating with the router. I have mine set up to email me when there is a power outage, so that I can act on it.
 
Thanks for the response. My linux knowledge is very limited... very :) I'm pretty sure I could follow a guide on compiling if all (most) of the steps are include. I tried one of the module archives posted earlier in the thread but couldn't get the router to recognize the ups as a HID device. I'm assuming they were not compatible with the firmware I'm using. Getting the router to see the ups is the first step before doing anything with apcupsd.

------------
This is a feature I discovered by accident on my cyberpower systems ups. The ups will literally enter a hibernate state when it's completely off but comes alive automatically when power is restored. I have my firewall appliance configured to automatically start when power is applied (in the bios apm settings). This way, after a power outage, firewall gracefully shuts down, 60 or 90 seconds later the ups enters hibernation. After power is restored, ups turns back on automatically. Upon sensing power, firewall restarts too. It's a fully automated process that works very well.

Powerchute personal edition for windows performs similarly. About a minute or two after shutdown of the pc, the ups too will hibernate.

My reason for shutting the ups down is to prevent wear and tear on the batteries. Discharge/charge cycles result in diminished battery capacity over time. IOW I want the batteries to last as long as possible.
 
It's unfortunate that the modules in this thread did not work. It looks like you may need to compile yourself. Instructions can be found in the Merlin wiki here: https://github.com/RMerl/asuswrt-merlin/wiki

It sounds like this hibernate feature is a part of the UPS. Maybe I don't understand how the hibernate feature works. However, if you have your UPSes set to hibernate already, do you still need apcupsd?
 
I'll look at that link. Thanks

UPS does not hibernate automatically. It's needs to be push into hibernation by a command - apsupsd -p (or -k). I'm still trying to figure out which works with the apc unit in question. I know the -o parameter will shut the ups down entirely after a 60 second timer.
 
I took the easy way out for now. Installed tomato or rather a fork of it since the site was down earlier this afternoon. Tomato has built in support for apcupsd. The version included was quite old so I installed entware and updated to a more recent version from 2016.

After some tweak here and there it's working as expected. After a power failure the router shuts down, 60 seconds later the ups hibernates. When power returns, the router boots back up.

At this point I just need to figure out how long I want to let it run on battery before shutting down. Our power is pretty decent here - mostly either fluctuations or short term outage (few seconds to a few minutes). Full blown extended outages of few hours or days are very rare.

My primary appeal to asuswrt (and xwrt on the r7000) is the improved wifi speeds compared to tomato and ddwrt on my 350/25 mbps pipe.

The numbers below represent a very small sample comparison. It appears current tomato wifi isn't as bad as in the past. I can definitely live with this.

More importantly, I can now configure vlans through the gui and not struggle in CLI mode :) I'll still play with the compiling the firmware as that's something I'd like to be familiar with.

Code:
asuswrt
5ghz       2ghz
281/25       119/25
317/25       147/25
297/25       150/25

tomato
5ghz       2ghz
280/25       78/25
285/25       107/25
230/25       101/25
278/25

w/frame burst
289/24       110/24
278/25       115/24
291/24       105/24
280/24
 
I do not use this patch. I am changing the configuration manual.
PS: modules compiled for 380.63 correctly working in 380.64_4 too. You do not need compiled it with each new release.
 
I got as far as setting up the environment in debian but not having success in actually compiling the firmware.

Early on in the make rt-ac68u process I get these errors.

Code:
make[5]: Entering directory '/root/asuswrt-merlin/release/src/router/shared'
cc1: fatal error: /root/asuswrt-merlin/release/src-rt-6.x.4708/router/busybox/include/autoconf.h: No such file or directory
compilation terminated.
cc1: fatal error: /root/asuswrt-merlin/release/src-rt-6.x.4708/router/busybox/include/autoconf.h: No such file or directory
compilation terminated.
cc1: fatal error: /root/asuswrt-merlin/release/src-rt-6.x.4708/router/busybox/include/autoconf.h: No such file or directory
compilation terminated.
cc1: fatal error: /root/asuswrt-merlin/release/src-rt-6.x.4708/router/busybox/include/autoconf.h: No such file or directory
compilation terminated.
cc1: fatal error: /root/asuswrt-merlin/release/src-rt-6.x.4708/router/busybox/include/autoconf.h: No such file or directory
compilation terminated.
cc1: fatal error: /root/asuswrt-merlin/release/src-rt-6.x.4708/router/busybox/include/autoconf.h: No such file or directory
compilation terminated.
cc1: fatal error: /root/asuswrt-merlin/release/src-rt-6.x.4708/router/busybox/include/autoconf.h: No such file or directory
compilation terminated.
cc1: fatal error: /root/asuswrt-merlin/release/src-rt-6.x.4708/router/busybox/include/autoconf.h: No such file or directory
compilation terminated.
cc1: fatal error: /root/asuswrt-merlin/release/src-rt-6.x.4708/router/busybox/include/autoconf.h: No such file or directory
compilation terminated.

Are you able to upload compiled modules and/or firmware compiled with the modules?

Thanks
 
PavelBab, thanks for the modules. We got a winner!

Code:
T:  Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=051d ProdID=0002 Rev= 0.90
S:  Manufacturer=American Power Conversion
S:  Product=Back-UPS BX1500G FW:866.L1 .D USB FW:L1
S:  SerialNumber=3B0922X19672
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  2mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=100ms

@RMerlin Given how popular apc units are, why not embed, or make the modules available separately for your builds?
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top