Introduction to MIPS CPU architecture with AR7240

1 minute read

There are many CPU architectures in current embedded devices. MIPS is also a popular architecture for embedded systems. Here I'm going to play with a MIPS based  AR7240 SoC as my development environment which has a MIPS 24Kc CPU . I'm using a TPLINK-WR740N router as my development board as I don't have any other MIPS development boards. It runs OpenWRT Linux for MIPS (this is not the stock version,I have installed it). So I won't be going to much lower level and I will play at the Linux level like using Linux on Rarspberry PI.

Router specifications:
  • Atheros AR7240@400MHz RAM:32MB Flash:4MB
  • LED * 5
  • Push buttons * 2
AR7240 has following interfaces:
  • LAN * 5
  • WiFi * 1
  • UART
  • USB
  • GPIO (LEDs & Push buttons are already connected)
For testing I just wanted to blink a LED which is connected to the GPIO0 using a shell script.
I found the GPIO mappings from the OpenWRT wiki. The LEDs are already controlled by a module by default and I had to unload it using "rmmod leds_gpio" command. If you are new to Linux, here you can find about Linux kernal modules. I found a great tutorial on controlling GPIOs in any Linux system and I coded a simple shell script to blink the LED connected to GPIO0 in 1 second intervals. Raspberry PI wiki also has a good tutorial on this.

Code:

rmmod leds_gpio
echo 0 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio0/direction
                             
while [ 0 != 1 ]  
do
  echo "ON"
  echo 1 > /sys/class/gpio/gpio0/value
  sleep 1
  echo "OFF"
  echo 0 > /sys/class/gpio/gpio0/value
  sleep 1
done  

I logged into the router with "ssh 10.0.0.1 -l root" and made a shell script called blinky.sh with above code using echo command (echo "the above code" > blinky.sh). You can create the blinky.sh file on PC and upload it to router using a SFTP client too. Then I made it executable with "chmod +x blinky.sh". Finally I run the script using "./blinky.sh" and it was a success.
(In below photo, the error is because I already unloaded the leds_gpio module)





































Comments