Skip to content

Instantly share code, notes, and snippets.

@tcr
Last active July 19, 2016 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcr/36cbec61bd8a52fd2094 to your computer and use it in GitHub Desktop.
Save tcr/36cbec61bd8a52fd2094 to your computer and use it in GitHub Desktop.
TELEC Work

Special emissions testing build of T2

Using t2-build, we can generate a special version of kmod-rt2x00-lib.ipk and kmod-rt2800-lib.ipk that allows modification of testing parameters at runtime.

Explicitly run make package/kernel/mac80211/compile V=s -C openwrt or the full build process. Find the file by running

ls ./openwrt/bin/ramips/packages/base/kmod-rt2x00-lib_*.ipk
ls ./openwrt/bin/ramips/packages/base/kmod-rt2800-lib_*.ipk

Install those onto T2 with opkg install *.ipk.

fccadventure needs to be updated to write to /proc/tcr-wifi. See https://gist.github.com/tcr/9d1c0442bd7d494c336a#file-999-tim_did_a-patch-L356 for the encoding.


Older Notes Below

How do you flash Tessel with older version of OpenWRT?

uh

RT2860 = MT7620

Why does it range from -16 to 15.5 with only four bits of info?

For encoding txpower: http://lxr.free-electrons.com/source/drivers/net/wireless/rt2x00/rt2800lib.c?v=4.4#L3612

For the corresponding registers:

  • Read that max is 0x27.
  • Might be 0x14 for 10 dBm? "WHO KNOWS"

What registers are available?

  • TX_PWR_MCS_0, 2, 4, 7, 8, 10, 12, 14, 15, (HT MCS)
  • TX_PWR_OFDM_6, 12, 24, 48, 54,
  • TX_PWR_CCK_1, 5(.5),
  • TX_PWR_STBC_0, 2, 4, 6, 7,
  • TXWI fields: TX_PWR_ADJ

Explanation:

  • MCS - n
  • OFDM - g
  • CCK - b
  • STBC - n with two antennas

TXWI fields: TX_PWR_ADJ: Transmit Power Adjustment Sets Tx power to a value from -16 dB to +7 dB. When negative, each unit represents 2 dB; when positive, each unit represents 1 dB.

Definitely: http://lxr.free-electrons.com/source/drivers/net/wireless/rt2x00/rt2800lib.c?v=3.18#L4090

Summary

  1. BBP R1 sets some deltas for TX power. See BBP1_TX_POWER_CTRL and rt2800_config_txpower_rt28xx

  2. TX power is set in the configuration registers. See rt2800_config_txpower_rt28xx and rt2800_compensate_txpower

  3. What about TX power? Maybe this TX field which isn't modified ANYWHERE. See rt2800pci_write_tx_desc

How do you write to the register?

TX_PWR_CFG_0 through 4

rt2800_register_write(rt2x00dev, TX_PWR_CFG_0-4, 7-9, (u32) reg);

How do you patch?

Patching is done through the build system. Here we are using a stock deployment of t2-build. In /work/openwrt-tessel, we find our build system. We'll find a file like this:

/work/openwrt-tessel/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/compat-wireless-2015-03-09/drivers/net/wireless/rt2x00/rt2x00queue.h

Copy "/work/openwrt-tessel/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/compat-wireless-2015-03-09" to a new folder. Instantiate this as a new git repo and add everything. Then by modifying your files, you can run git diff to create a patch similar to the following: https://gist.github.com/tcr/9d1c0442bd7d494c336a

We want to dump this patch e.g. here:

git diff HEAD~1 > /work/openwrt-tessel/openwrt/package/kernel/mac80211/patches/999-tim_did_a.patch
```

Then we can rebuild only these particular components:

```
make -j64 V=s
make package/kernel/mac80211/compile V=s -C openwrt
cp ./openwrt/bin/ramips/packages/base/kmod-rt2x00-lib_3.18.17+2015-03-09-3_ramips_24kec.ipk /vagrant/
```

Then on your Tessel:

```
opkg install kmod-rt2x00-lib_3.18.16+2015-03-09-3_ramips_24kec.ipk
```

## How to update Tessel

Write to `/tmp/openwrt.bin`

```
sysupgrade /tmp/openwrt.bin
```

To find these builds:

```
ls openwrt/bin/ramips/openwrt-ramips-mt7620-tessel-squashfs-sysupgrade.bin
```

Reference: http://blog.gaku.net/upgrading-openwrt-firmware-from-command-line/

## How to clear local Tessel changes?

```
mtd -r erase rootfs_data
```

## Requirements

1. What are the TELEC requirements for transmission power?
2. What does Tessel 2 need to do differently to pass TELEC?

Wifi modes:

* `b` needs 10 dBm or above
* `g` needs 7-10 dBm
* `n` needs 0 dDm or above, but (can be? must be?) lower than `g` mode.

We must turn up our transmission power to meet these requirements.

## RF Exploring

Spectrum comparison: <http://rfexplorer.com/models/>


### Okay now setting 

 Ranges are as follows:

* TWXI4 is 4 bits, +7 to -16 (doubled) i.e. 0x7 is +7 and, 0x8 is -2, 0xf is -16
* TX\_CFG uses 8 bits, -16 db to 15.5db with 0.5 step (-0x20 to 0x1f ???) 
* BBP sets gains of -12, -6, 0, +6 for (2, 1, 0, 3) respectively

Settings are as (TWXI4, TX_CFG, BBP). The combinations:

- (+7, 0xc, 3) => -69
- ( 0, 0x0, 2) => -60 /-59.5

Possible explanation: Don't understand TX_CFG option totally. BBP could have been set wrong (to begin with). Or TXWI is wrong, but unlikely?

TODO

- (+7, 0xc, 3) => -69
- ( 0, 0x0, 2) => -60 /-59.5
- (-16, 0xc, 3) => -60
- (+7, 0, 3) => -69.5
- (+7, 0xc, 2) => 68.5
- (+3, 0xc, 3) => 58.5
- (+1, 0xc, 0) => -59.0
- (+7, 0xc, 3) => 58.5
- (+7, 0x0, 3) => 58.5

Looks like we're not getting anywhere. I applied tape.

- (  0, 0xc, 3) => -72.5
- (-16, 0x0, 2) => -80
- (  7, 0xf, 3) => -75.5
- (  7, 0xc, 3) => -73.5
- (-16, 0xc, 3) => -75.5
- (-16, 0xc, 2) => -75.5

With unplugging:

- (-16, 0x0, 2) => -85.5
- (  7, 0xf, 3) => -71.5
- (  7, 0xf, 2) => -75.5
- (  7, 0x0, 3) => -75.0
- (  7, 0xf0, 3) => -74.5
- (-16, 0xf, 3) => -75.5
- (-16, 0x0, 3) => -76

Hm.

- (  7,  0xf, 3) => -69.5
- (-16, -0xf, 2) => -69.0
- (-16,  0x0, 2) => -84.5
- (-16,  0x2, 2) => -71.0
- (-16,  0x0, 3) => -70.0
- (  7,  0x0, 2) => -69.5
- (-16,  0x0, 2) => -84.5

Maybe unplug, plug, install, run?

- ( -2,  0x0, 2) => -84.5
- ( -2,  0x0, 1) => -71.5
- ( -2,  0x0, 2) => -
- (  2,  0x0, 2) => -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment