Hello,
I am working on a sustainability project and want to use an old router as a development board instead of Arduino/raspberry Pi. In order to make this work I need access to as many GPIO pins and functions as possible.
current setup:
WDR4300 with extra USB mod (https://openwrt.org/toh/tp-link/tl-wdr4300_v1#hardware_modifications)
I have 16MB flash mod ( Upgrade TP-link_TL-WDR4300 from 8M to 16M flash - #24 by gergepalfi )
I am having issues using the GPIO pins that are already mapped as LEDs under /sys/class/leds/
I have rmmod gpio_button_hotplug and rmmod ledtrig_usbport but I still can’t write to the LED value files. I can only write to /sys/class/gpio/tp-link:power:usb1/value to control power on both usb ports
I was able to run gpio_test.sh to read and write the 4 JTAG pins
| GPIO | Name | comments |
|---|---|---|
| 0 | JTAG-9 | |
| 1 | JTAG-3 | |
| 2 | JTAG-5 | |
| 3 | JTAG-7 | |
| 4 | unknown | |
| 5 | SPI-CS | DO NOT USE! |
| 6 | SPI-CLK | DO NOT USE! |
| 7 | SPI-MOSI | DO NOT USE! |
| 8 | SPI-MISO | DO NOT USE! |
| 9 | UART0_SIN | DO NOT USE! |
| 10 | UART0_SOUT | DO NOT USE! |
| 11 | LED_USB1 | |
| 12 | LED_USB2 | |
| 13 | LED_2.4GHz | |
| 14 | LED_SYSTEM | |
| 15 | LED_QSS | |
| 16 | WPS_BUTTON | |
| 17 | WIFI_SW | |
| 18 | LNA0 | DO NOT USE! |
| 19 | LNA1 | DO NOT USE! |
| 20 | unknown | |
| 21 | PW_USB2 | |
| 22 | PW_USB1 |
Goals
I would like to get the following basic functions working in order of importance
| function | comment |
|---|---|
| GPIO read/write | basic IO |
| GPIO PWM | LED brightness or motor driver control |
| I2C on custom pins | hoping to use displays or sensors |
| encoder | for rotary knobs |
PWM??
I see that the LEDs have a max_brightness and brightness option, even if I can’t write to it. I assume that this is some pwm functionality. It would be nice to get pwm to work
I2C, encoder and other packages
I see there are packages for all kinds of hardware like GPIO expander chips, buzzer, encoder, I2C and more. I would like to get as much documentation as possible about these in case I can use them.
Suggestions welcome
I am not sure how all of this is even possible, I know that it will be a lot harder than Raspberri Pi or Arduino Projects, but that is what this whole thing is about, to see how far I can push the limits and repurpose a router.
Python
I have installed python on an internal USB storage on the modded USB port. I consider this to be the worst option, but if it happens to work somehow then I will take it.
Shell scripts
So far I had success using simple sh scripts to toggle and test pins, but I think it may not be possible for more complex tasks
Compiling C/C++ for MIPS
I think this is the best option, but also the hardest, I have very minimal experience setting up and using cross compilers
Device tree modification
The device tree is already modified for the 16M flash mod, so I could change other things if needed.
If you know of any interesting documentation or mods for using GPIO in weird ways like this please share the links.