How do I change system control registers in OpenWRT?
I'm unable to work with the GPIO pins 4, 5, 45, 46. They always measure 3.3v 3.3v 3.3v 0.0v.
According to the MT7621 datasheet those GPIO pins have a register that toggles different modes on those pins. Right now it is in UART mode and the register needs to be switched to GPIO mode.
Register 1E000060 (32bit)
zero based: bit 2 I2C_MODE needs to be toggled to fix GPIO4 and GPIO5
I2C_MODE: 0=I2c 1=GPIO
zero based: bit 1 UART1_MODE needs to be toggled to fix GPIO45 and GPIO46
URART1_MODE: 0=UART1 1=GPIO
There is no /dev/mem so the io program can't flip the bit.
Either export the GPIO in the usual Linux fashion, or I have very vague memories of a UCI command which I believe does something similar, but also links it UCI and possibly ubus.
If they're tied by the DT to a UART, you might need to change the DTS.
Bahhh...
Recompiled kernel with /dev/mem however the Register address 0x1e000060 is wrong... Now trying to find a datasheet/programmer guide for the MT7628 registers.
After make and install the gpio pins are now manageable through /sys/class/gpio/.
However the new problem I'm now having is that even though I compiled the 1-wire modues as "M" in make menuconfig. The modules are not available inside my sysupgrade.bin. I also can not install the kmod-w1* packages because they conflict with the kernel.
root@OpenWrt:/etc# opkg install kmod-w1 kmod-w1-master-gpio kmod-w1-gpio-custom
Installing kmod-w1 (4.14.103-1) to root...
Downloading http://downloads.openwrt.org/releases/18.06-SNAPSHOT/targets/ramips/mt76x8/packages/kmod-w1_4.14.103-1_mipsel_24kc.ipk
Installing kmod-w1-master-gpio (4.14.103-1) to root...
Downloading http://downloads.openwrt.org/releases/18.06-SNAPSHOT/targets/ramips/mt76x8/packages/kmod-w1-master-gpio_4.14.103-1_mipsel_24kc.ipk
Installing kmod-w1-gpio-custom (4.14.103-3) to root...
Downloading http://downloads.openwrt.org/releases/18.06-SNAPSHOT/targets/ramips/mt76x8/packages/kmod-w1-gpio-custom_4.14.103-3_mipsel_24kc.ipk
Collected errors:
* satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-w1:
* kernel (= 4.14.103-1-6b7f4bb0e839f1545297907a37980184)
* opkg_install_cmd: Cannot install package kmod-w1.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-w1-master-gpio:
* kernel (= 4.14.103-1-6b7f4bb0e839f1545297907a37980184)
* opkg_install_cmd: Cannot install package kmod-w1-master-gpio.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-w1-gpio-custom:
* kernel (= 4.14.103-1-6b7f4bb0e839f1545297907a37980184)
* opkg_install_cmd: Cannot install package kmod-w1-gpio-custom.
How do I get kernel modules into my sysupgrade.bin?
Found packes in /openwrt/openwrt/bin/targets/ramips/mt76x8/packages - manually scp them to /tmp for install. I would still like to know how to include them as part of the sysupgrade.bin.
I'm comfortable with git. Should I put in a git pull request to modify the GL-MT300N-V2.dts? The above noted change makes unused gpio pins 4 5 45 46 available for dev.
/sys/class/gpio works for pins 4 5 45 46. I can toggle 3.3v and 0.0v on all 4 pins.
After commenting out the default mirror and adding my own based on compiled packages I can now get 1-wire bus working.
I've looked at the MT300N v2 for use with a timing GPS and NTP, so I'd want serial for two pins, and a GPIO input for the PPS. If I were a gatekeeper, I'd probably ask that they could be configured independently. (To be clear, I'm not a gatekeeper and I decided not to pursue that project so I didn't look into how the serial on those lines was implemented, such as bit-bang vs. UART hardware, vs. I2C hardware.)