Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Atheros ART power limit bypass, linux regulatory will be applied (e.g.: iw phy phy0 set txpower fixed 3100)
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -5142,6 +5142,11 @@ static void ar9003_hw_set_power_per_rate
scaledPower = ath9k_hw_get_scaled_power(ah, powerLimit,
antenna_reduction);
+ minCtlPower = (u8) min(MAX_RATE_POWER, scaledPower);
+ for (i = 0; i < ar9300RateSize; i++)
+ pPwrArray[i] = (u8) minCtlPower;
+ return;
+
if (is2ghz) {
/* Setup for CTL modes */
/* CTL_11B, CTL_11G, CTL_2GHT20 */
static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
struct ath9k_channel *chan,
u8 *pPwrArray, u16 cfgCtl,
u8 antenna_reduction,
u16 powerLimit)
{
struct ath_common *common = ath9k_hw_common(ah);
struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep;
u16 twiceMaxEdgePower;
int i;
u16 scaledPower = 0, minCtlPower;
static const u16 ctlModesFor11a[] = {
CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40
};
static const u16 ctlModesFor11g[] = {
CTL_11B, CTL_11G, CTL_2GHT20, CTL_11B_EXT,
CTL_11G_EXT, CTL_2GHT40
};
u16 numCtlModes;
const u16 *pCtlMode;
u16 ctlMode, freq;
struct chan_centers centers;
u8 *ctlIndex;
u8 ctlNum;
u16 twiceMinEdgePower;
bool is2ghz = IS_CHAN_2GHZ(chan);
ath9k_hw_get_channel_centers(ah, chan, &centers);
scaledPower = ath9k_hw_get_scaled_power(ah, powerLimit,
antenna_reduction);
minCtlPower = (u8) min(MAX_RATE_POWER, scaledPower); // [MOD]
for (i = 0; i < ar9300RateSize; i++) // [MOD]
pPwrArray[i] = (u8) minCtlPower; // [MOD]
return; // [MOD]
if (is2ghz) {
// [...]
@BigNerd95
Copy link
Author

BigNerd95 commented Oct 9, 2017

LEDE instruction:

  1. Clone LEDE project
    git clone https://github.com/lede-project/source.git
    cd source

  2. Build for your target
    make menuconfig (select your target)
    make package/kernel/mac80211/compile

  3. Patch the driver with my diff
    You have to edit ar9003_hw_set_power_per_rate_table function in this file:
    build_dir/target-[ARCH]/linux-ar71xx_generic/backports-[VER]/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
    (Add lines with // [MOD] comment)

  4. Build and flash the firmware
    Build the firmware
    make -j9
    (Where 9 is your cpu's threads number + 1)
    Then flash the router
    On PC: nc -l -p 1234 -q 0 < bin/targets/ar71xx/generic/lede-ar71xx-generic-[MODEL]-squashfs-sysupgrade.bin
    On router: nc 192.168.1.X 1234 > /tmp/fw.bin && sysupgrade /tmp/fw.bin

  5. Set the power
    After the router reboot:
    iw phy phy0 set txpower fixed 3100
    and then check the power:
    iwinfo phy0 txpower
    You should see

   0 dBm (   1 mW)
   1 dBm (   1 mW)
   2 dBm (   1 mW)
   3 dBm (   1 mW)
   4 dBm (   2 mW)
   5 dBm (   3 mW)
   6 dBm (   3 mW)
   7 dBm (   5 mW)
   8 dBm (   6 mW)
   9 dBm (   7 mW)
  10 dBm (  10 mW)
  11 dBm (  12 mW)
  12 dBm (  15 mW)
  13 dBm (  19 mW)
  14 dBm (  25 mW)
  15 dBm (  31 mW)
  16 dBm (  39 mW)
  17 dBm (  50 mW)
  18 dBm (  63 mW)
  19 dBm (  79 mW)
  20 dBm ( 100 mW)
  21 dBm ( 125 mW)
  22 dBm ( 158 mW)
  23 dBm ( 199 mW)
  24 dBm ( 251 mW)
  25 dBm ( 316 mW)
  26 dBm ( 398 mW)
  27 dBm ( 501 mW)
  28 dBm ( 630 mW)
  29 dBm ( 794 mW)
  30 dBm (1000 mW)
* 31 dBm (1258 mW)

I tested this mod with an instrument, at ~50 cm of distance from the antennas:

  • 20 dBm --> 8 volt/meter [original max power]
  • 25 dBm --> 17 volt/meter
  • 31 dBm --> more than 30 volt/meter

@WiredLife
Copy link

WiredLife commented Aug 16, 2020

Hey, if i dont want to compile the whole image, is it possible to compile it with make -j5 package/kernel/mac80211/compile
and install one of the kmod-ath*.ipk ?
./bin/targets/ath79/generic/packages/kmod-ath9k-common_5.4.52+5.8-1-1_mips_24kc.ipk
./bin/targets/ath79/generic/packages/kmod-ath9k_5.4.52+5.8-1-1_mips_24kc.ipk
./bin/targets/ath79/generic/packages/kmod-ath_5.4.52+5.8-1-1_mips_24kc.ipk
Which one is the right?

@WiredLife
Copy link

WiredLife commented Aug 17, 2020

kmod-ath9k_5.4.52+5.8-1-1_mips_24kc.ipk is working fine, but some channels on 5 ghz are only 14 dBm
44, 48, 52, 56, 60, 64
is there a way to fix that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment