OpenWrt Forum Archive

Topic: Is power management possible on Atheros AR9331 Chipset?

The content of this topic has been archived between 22 Apr 2018 and 30 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I have a TL-WR703N that I am using as the heart of a remote weather station.  The whole rig is solar powered.  Is there any way to turn on power management/CPU Frequency scaling to prolong battery life?

Looks like I found my answer...
These are the default kernel options in the "Linux/mips 3.3.8 Kernel Configuration."

[ ] Suspend to RAM and standby
[ ] Hibernation (aka 'suspend to disk')
[ ] Run-time PM core functionality

The "Run-time PM core functionality" might help, but only if the hardware supports it. We shall see.

solar powered,very cool,any photo show?

If you are not very care the performance,you can change the frequence directly,you can do it in bootloader.

check the file:
http://code.google.com/p/wr703n-uboot-w … gs/ap121.h
you can change the CFG_PLL_FREQ define.

The ap121.h code has me VERY interested.  Am I reading this write, I can change the CPU down to 32MHz?! 

CFG_PLL_FREQ == CFG_PLL_32_32_16

I will admit the ap121.h code is beyond my skill. Do I need to re-compile the image to change the CPU speed, or can I make a tweak and reboot?

Nothing cool to take pictures of yet.  Much of the system is in the mail currently.  Hope all the parts will come in next week.  All I currently have is 2  TL-WR703N.

Forgive my ignorance.

In the ap121.h code I only see 4 lines that define the speed of the CPU

#ifdef CONFIG_HORNET_EMU
    #ifdef CONFIG_HORNET_EMU_HARDI_WLAN
    #define CFG_PLL_FREQ        CFG_PLL_48_48_24
    #else
    #define CFG_PLL_FREQ        CFG_PLL_80_80_40
    #endif
#else
        #ifdef PRODUCTOR_CPU_300
        #define CFG_PLL_FREQ    CFG_PLL_300_300_150
        #else
        #define CFG_PLL_FREQ    CFG_PLL_400_400_200
        #endif
#endif

But directly following this block of code there is CFG_HZ code that has 15 different "if CFG_PPL_..."  All of those are if/then statements. Why are there so many if there are only 4 CFG_PLL_FREQ defined?  Just old/reused code, or can the CFG_PPL be set some where else?

CFG_PLL_32_32_16
CFG_PLL_48_48_24
CFG_PLL_64_64_32
CFG_PLL_80_80_40
CFG_PLL_200_200_100
CFG_PLL_266_266_133
CFG_PLL_266_266_66
CFG_PLL_300_300_150
CFG_PLL_320_320_80
CFG_PLL_333_333_166
CFG_PLL_350_350_175
CFG_PLL_362_362_181
CFG_PLL_400_400_200
CFG_PLL_410_400_200
CFG_PLL_420_400_200

Looks like the only valid CPU speeds for the Atheros AR9331 SoC are 300, or 400MHz, which is backed up by the ap121.h code.  Where does the "#ifdef PRODUCTOR_CPU_300" get read from??  Is there any way for me to trick uboot into booting at 300MHz, or will I have to change the code, recompile, and flash uboot?

You need re-compile and upgrade the uboot to let it work at 300MHz,you can refer the doc in this page do it:
http://code.google.com/p/wr703n-uboot-w … -failsafe/

You can define the "PRODUCTOR_CPU_300" in this Makefile:
http://code.google.com/p/wr703n-uboot-w … k/Makefile
There is a 'NEW_DDR_TAP_CAL" define in this Makefile,you can search it in this project,check it and you will know how it defined in Makefile then affect the *.c,*.h file.

If you are not urgent,i will verify the 300MHz case in this weekend,upgrade the bootloader is high risk to brick board,really brick,can't recover it by TTL.

Mips, I would GREATLY appreciate if you could verify the 300MHz case. Do you have a way to recover from a bad uboot flash? I don't need it, just wondering?

I see that there are several other speeds defined in the ar7240.h.  Can we try some of the slower speeds?  Such as CFG_PLL_266_266_133 or CFG_PLL_200_200_100.

Looking over the Zentel A3S56D40FTP-G5 data sheet, it does not look like the memory can go any slower then 133MHz. "200MHz @CL=3.0, 166MHz @CL=2.5, and 133MHz @CL=2.0"  That stated, I would still love to try the CFG_PLL_64_64_32.

Taking this one step further.  How hard would it be to make the clock speed a value we can define in the uboot config? setenv cpumhz 200 200 100?

My end goal is to save power.  Currently I am drawing about 0.54 watts.  I am more then happy to trade speed for less power draw. The slower I can go, the better!  That is working under the assumption that slowing the clock speed will save power.

Do you have a way to recover from a bad uboot flash? I don't need it, just wondering?

First,i un-solder the spi nor flash from wr703n,and then solder a flash socket,just like this one:
http://www.dediprog.com/Surface-Mount-S … ocket-8pin
the up link don't have the pic show how the flash socket solder on the board looks like,you can refer this link(it's for 16pin spi flash):
http://www.dediprog.com/Surface-Mount-S … cket-16pin

Then i have a spi flash programmer,just like this one:
http://www.dediprog.com/SPI-Flash-Programmer/SF600

So when i brick the bootloader,i will fetch out it from the flash socket,and then use the spi flash programmer write now code to it.and then put it to flash socket on the board and power up do test.when you want to do something about bootloader,you really need this equipment.
(My flash socket and flash programmer is not from the http://www.dediprog.com/ ,but when i search the related pic found it's good to use here,if anyone want to buy,you need think more)

I see that there are several other speeds defined in the ar7240.h.  Can we try some of the slower speeds?  Such as CFG_PLL_266_266_133 or CFG_PLL_200_200_100.

Yes,we can try the slower speeds.

Looking over the Zentel A3S56D40FTP-G5 data sheet, it does not look like the memory can go any slower then 133MHz. "200MHz @CL=3.0, 166MHz @CL=2.5, and 133MHz @CL=2.0"  That stated, I would still love to try the CFG_PLL_64_64_32.

The  Zentel A3S56D40FTP-G5 datasheet means when it work at 133MHz,the CL can be 2.0,when the clock more high,the CL should be a more large value.I think we set the clock less than 133MHz,and set the CL to 2.0 will also work.

Taking this one step further.  How hard would it be to make the clock speed a value we can define in the uboot config? setenv cpumhz 200 200 100?

Beacuse the PLL tune is a key part for the system,when the u-boot run in RAM and we can't change it any more on the fly.We can save some value in the flash just like the uboot env,but it's complex to do that,because the PLL set is in some asm code,and i really don't want to use asm parser u-boot env.we can define some new flash map do that.

(Last edited by mips on 12 Aug 2012, 16:58)

I base on the code r17 at http://code.google.com/p/wr703n-uboot-w … -failsafe/ with this change:

Index: Makefile
===================================================================
--- Makefile    (revision 17)
+++ Makefile    (working copy)
@@ -9,6 +9,11 @@
 export CONFIG_HORNET_1_1_WAR=1
 export NEW_DDR_TAP_CAL=1
 
+#not export any PRODUCTOR_CPU_*,will run 400_400_200.
+export PRODUCTOR_CPU_300=1
+#export PRODUCTOR_CPU_200=1
+#export PRODUCTOR_CPU_100=1
+
 all: decompress_toolchain uboot
     @echo tuboot.bin size: `wc -c < $(BUILD_TOPDIR)/bin/tuboot.bin`
     @if [ "`wc -c < $(BUILD_TOPDIR)/bin/tuboot.bin`" -gt "$(MAX_UBOOT_SIZE)" ]; then \
Index: u-boot/Makefile
===================================================================
--- u-boot/Makefile    (revision 17)
+++ u-boot/Makefile    (working copy)
@@ -2219,8 +2219,14 @@
 
 #add by zlp, 2011.10.31. MR11U 1.0 CPU=300Mhz.
 ifdef PRODUCTOR_CPU_300
-    @echo "#define PRODUCTOR_CPU_300 1" >>include/config.h
+    @echo "#define PRODUCTOR_CPU 300" >>include/config.h
 endif    
+ifdef PRODUCTOR_CPU_200
+    @echo "#define PRODUCTOR_CPU 200" >>include/config.h
+endif    
+ifdef PRODUCTOR_CPU_100
+    @echo "#define PRODUCTOR_CPU 100" >>include/config.h
+endif    
 
 ifeq ($(CONFIG_HORNET_XTAL), 40)
     @echo "#define CONFIG_40MHZ_XTAL_SUPPORT 1" >>include/config.h
Index: u-boot/include/configs/ap121.h
===================================================================
--- u-boot/include/configs/ap121.h    (revision 17)
+++ u-boot/include/configs/ap121.h    (working copy)
@@ -101,8 +101,12 @@
     #define CFG_PLL_FREQ    CFG_PLL_80_80_40
     #endif
 #else
-    #ifdef PRODUCTOR_CPU_300
+    #if (PRODUCTOR_CPU == 300)
     #define CFG_PLL_FREQ    CFG_PLL_300_300_150
+    #elif (PRODUCTOR_CPU == 200)
+    #define CFG_PLL_FREQ    CFG_PLL_200_200_100
+    #elif (PRODUCTOR_CPU == 100)
+    #define CFG_PLL_FREQ    CFG_PLL_100_100_50
     #else
     #define CFG_PLL_FREQ    CFG_PLL_400_400_200
     #endif
@@ -127,6 +131,12 @@
 
 #if (CFG_PLL_FREQ == CFG_PLL_200_200_100)
 #    define CFG_HZ          (200000000/2)
+        #define CPU_PLL_CONFIG_VAL1 0x40814000
+        #define CPU_PLL_CONFIG_VAL2 0x00814000
+#elif (CFG_PLL_FREQ == CFG_PLL_100_100_50)
+#    define CFG_HZ          (100000000/2)
+        #define CPU_PLL_CONFIG_VAL1 0x40812000
+        #define CPU_PLL_CONFIG_VAL2 0x00812000
 #elif (CFG_PLL_FREQ == CFG_PLL_300_300_150)
 #    define CFG_HZ          (300000000/2)
     #if CONFIG_40MHZ_XTAL_SUPPORT

I found 300_300_150 bootloader can work and boot the linux kernel,but will hang in linux kernel.
The 200_200_100 will hang the bootloader.

From the TP-link gpl source,i know maybe the tp-mr11u work at 300_300_150,so i think we have chance to make the 300_300_150 work.But about the other case,i'm not sure.

I will debug more.

(Last edited by mips on 12 Aug 2012, 16:59)

Mips, THANKS for all the hard work!

Just a fun question; even though it crashes, what does the power draw look like at the slower speeds?

Hi DingbatCA:

Because current i don't have the equipment to measure the power consumption,when i done,i will ask my friend do this measure and give report here.

Thanks Mips!

If/when you have the uboot code stable, I will gladly test, and report the power consumption.

Cptdondo.  The "Qty. 100 starts at $149"  really hurts. Trying to keep the cost below $50.  But you have the right idea.  For the longest time I was looking at using old android cell phones.  They are really cheap off of ebay.

Hi DingbatCA:

Because some rigister setting only the Atheros internal IC design people know how to set,so i can't promise the time when i can done,or if it's possible,but i will try and give you report if i done that.I'm so sorry ...

Mips, thank you for all the hard work.  I am building up my weather station based on the current power draw. I am looking forward to a slower clock speed, but I can live with out it.

Hi
your project looks very interresting. I am currently building a sligthly similar setup - but I would be using a TP-Link MR3040. I'd be grateful if you would share some pics & infos !
Thanks

Tomte

Hi Tomte. No pic's yet, but I can give you lots of info.

This whole thing comes down to power draw.
The TL-WR703N draws about 80ma @ 5v, or about 0.4 watts per hour, 9.6 watts per day
Arduino = 12ma @ 5v = 0.06 watts per hour, 1.44 watts per day (With out sleep mode enabled)
USB hub = 10ma @ 5v = 0.05 watts per hour, 1.2 watts per day
GSM modem??? Dont have one to test with, yet. Need to find a data only cell phone plan.

Now I need to build a power system that is capable of delivering 15+ watts of power a day, regardless of solar conditions (I.E. clouds). I am using 2X 4.2ah lipo cells for my battery. 4.2ah*2= 8.4ah * 3.6v = about 30 watt hours. This whole rig should give me about 48 hours of run time with out any charging.

A 10W solar panel is capable of producing 10 watts per hour, in perfect condition.  I live in Portland Oregon where it is cloudy about 270 days a year, so not perfect conditions.  I may have to get a bigger solar panel.   

My parts list:
A 10W outdoor solar panel.
LM2596 DC-DC Step Down Adjust Power Supply Moudle 4.5-35V in 1.25-30 battery LED
2X 3.7V 4200mah lithium Polymer battery Li-Po
Solar Panel USB Battery Charger
Arduino Nano V3.0 AVR ATMEGA328P-AU

My 10W solar panel produces around 20V so I need the DC-DC to step down to 5V.
The "Solar Panel USB Battery Charger" is just a charging brain. I am using it to manage my 8.4ah lipo pack.
The Arduino does all the sensor work, and interfaces to the TL-WR703N over USB.

Still waiting on the batteries.  They are in the mail.

I think the Solar Panel USB Battery Charger was a dumb move. There are cheaper solutions on ebay that have better hardware.

So currently I have a pile of parts... Nothing assembled, and no pics.  I hope to change that soon.

Ah!  Found the battery solution I was after.
5V In 3A Output 2A USB 18650 Battery Box Charger Portable Mobile Power Supply

And the 18650 Batteries are cheaper then the 4.2ah packs I bought!  Grumble grumble!!!
3000mAh 3.7v 18650 Rechargeable Battery

I have to be careful.  A 10W solar panel will be dumping 2amps @ 5v into the charger.  The cheap "Solar Panel USB Battery Charger" I bought can only handle about 1a MAX.  I have a feeling if I hooked up a 2a source, I would release the magic smoke.

Wow, that setup is indeed very interesting. I am still waiting for most parts (router, arduino) for the new system -  I already got the solar panel and a big, RV dedicated deep cycle battery that was lying around. So the plan is to set up the solar panel to a voltage regulator -> battery -> DC-DC converter to get 5V usb.

Right now I'm using a TEW-655BR3G on another site with a 20W solar panel, a 12VDC battery & voltage regulator and a W910i sony ericsson phone.( I have yet to manage to installl openwrt on that router, which is currently not supported). This set up is not a weather station yet, just a remote AP that provides internet connectivy in the wild.
A quick note about 3G dongles : I don't have the measurement handy but I found out that an second-hand, low end phone with 3G capability connected via USB - for data and charge - drains LESS power than a real USB dongle (at least with the OPTION 225) and it provides its own battery, of course.
and thanks for the USB battery charger link  - it's cheaper that eveything i've seen so far !

Let me know if you want more details & measurements and I'll do my best to provide them.

I have a similar idea too, did you find any way to get standby/hibernation/sleep mode?

Did you try the power management features of the kernel?

How can I use the power management features? Is there any documentation about it?

KammutierSpule wrote:

I have a similar idea too, did you find any way to get standby/hibernation/sleep mode?

Did you try the power management features of the kernel?

How can I use the power management features? Is there any documentation about it?

I try the lower PLL case,but current it's not stable!
From theory,It's may cause the stable issue when set the higher PLL.But now i don't know why it's un-stable in lower PLL case...

The AR9331 is target for AP/Router platform,so the power consume is not the first thing it''s think about.
If we can get the AR6XXX(Only ROC,not SoC...) based device,maybe we will have more options for power consume control!

About AR6XXX,read:
http://www.qca.qualcomm.com/technology/ … product=74

Currently working with 3 different boards:

WR703N:  Mips really knows the magic for this system.  I can not recover from a bad flash, so I have not tried anything dangerous.

Raspberry Pi Model B:  The board is more know for its graphics then its processor, or power management.  I have a B, but have not bothered powering it up yet. The SOC has a single USB port which goes into the networking/USB hub.  This networking/USB hub draws 30ma+.  I really need a model A, which is not in production, yet.

iMX233-OLinuXino-Micro: This board is my current favorite.  I have been spending a lot of time learning how to compile kernels for the ARM processor.  Still trying to figure out how to boot it at 64MHz.

It's seems the 300,300,150 case work at the version r26,see the change list for detail:
http://code.google.com/p/wr703n-uboot-w … ource/list

So welcome brave guys do test,now i do the these test under the 300,300,150 case:
1.run iperf between wlan and wr703n ethernet port.
2.repeat reboot board not hang now.

How to compile the image for the 300,300,150 case:
1.check out the souce code:

svn checkout http://wr703n-uboot-with-web-failsafe.googlecode.com/svn/trunk/ wr703n-uboot-with-web-failsafe-read-only

2.refer this patch change the Makefile:

--- Makefile    (revision 26)
+++ Makefile    (working copy)
@@ -11,7 +11,7 @@
 
 #not export any PRODUCTOR_CPU_*,will run 400_400_200.
 #export PRODUCTOR_CPU_350=1
-#export PRODUCTOR_CPU_300=1
+export PRODUCTOR_CPU_300=1
 
 all: decompress_toolchain uboot
     @echo tuboot.bin size: `wc -c < $(BUILD_TOPDIR)/bin/tuboot.bin`

3.then refer the guide in this page:
http://code.google.com/p/wr703n-uboot-w … -failsafe/

Any feedback are welcome.
Thank you.

(Last edited by mips on 15 Sep 2012, 13:33)

Hi DingbatCA:

Please still wait some time to try this.
I really don't want my bootloader brick any guys device,that means some $ lost.