GL-MT300N-V2 how to use/enable I2C or I2C/RX1/TX1 pins as gpio

Hello, i’m trying to use some pins as gpio on GL-MT300N-V2 but i can’t use I2C_SCLK (gpio4) and I2C_SD (gpio5).
if i do:
echo 4 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio4/direction
echo 0 > /sys/class/gpio/gpio4/value
echo 1 > /sys/class/gpio/gpio4/value
there is no error, but using a multimeter/volt-meter the value never change.
using the same code to control leds (gpio 42,43,44) work (after you do rmmod leds-gpio).
With this code i can’t use gpio45 and 46 (rx1, tx1), again, no error but the value using a multimeter never change.
I can use rx1 and tx1 using /dev/ttyS1 and also use /dev/ttyS0 they just work.
if i use an oscilloscope i can see that the value change for a moment by doing echo AAAAAAA > /dev/ttyS1

for i2c I followed this guide:

now i’m trying this: insmod i2c-gpio-custom bus0=0,5,4
there is no error, not even in dmesg, but it just doesn’t work, the pin value never change.
do i need some other package??
i2cdetect doesn’t detect anything and it’s super fast (<1 second to finish the command)
i have tested this on two random gpio numbers and i2cdetect doesn’t detect anything but it’s quite slow (about 1 second per address).

my goal:
-using i2c pins as i2c
-using rx1,tx1 as normal gpio: set output and manually set high/low.

on the official website there is a pinout:

while here there is a different one (for the gpio), this seems wrong:

i’m using this firmware (openwrt, not oem):

Hardware specifications say:
DIY Features UART, 4GPIOs, 3.3V; 5V power port
but they also say:
The pins on the left side can be actually used for Ethernet port or EMMC. They cannot be used as GPIO.
but i don’t get why i can’t use as normal gpio… if i can’t use as gpio i want to use them as i2c; in the pinout photo and printed on the board it say “I2C” so it should be possible…

If you want to use I2C and UART pin, you have to build the firmware by yourself. If you use the official OpenWRT buildroot. Please modify the dts file target/linux/ramips/dts/GL-MT300N-V2.dts.

Append those lines to dts file.

&i2c {
	status = "okay";

Configure uart1 to GPIO.

&pinctrl {
	state_default: pinctrl0 {
		gpio {
			ralink,group = "wdt", "gpio", "wled_an", "p0led_an", "p1led_an", "i2s", "uart1";
			ralink,function = "gpio";

Please rebuild the firmware after modifying.

The modified dts file is in the attachment. (1.0 KB)

1 Like

Hello, I am very new to this and want to do the same as the OP.
I was hoping for some guidance on how to ‘rebuild the firmware’ as well as the commands to copy the .dts file over to the router over ssh.
Again sorry for the super simply question i am very new routers and building firmware.
Would appreciate any help