Raspberry Pi A+ with internet

Recently I got my Raspberry Pi 1 A+ and camera from Farnell. As I wanted it to be small (it will be in a case) the cheaper “A” version was a better than “B” for me. The three major differences between A and B version are the following:

  • only 256 Mb Ram
  • only 1 USB (but it is full 2.0)
  • no ethernet connector

A connection to the local subnet will be mandatory, as I want to replicate this bird cam project. So I had to figure out, how to connect my Pi to the router, and also how to keep the price low. This usually means higher hack coefficient. I came up with three solutions, and at the moment two of them all three is working. These are not my work, (I only searched and tested them) they are only put together here for make life easier for those who walk in the same shoe…

ENC28J60

ENC28j60EthernetInterfaceModule1_1391867612This module was my first choice, as it can be connected via SPI over the GPIO pins. But there were kernel related problems:

  • Before the 3.18.* kernel, the driver was not compiled by default, so you had to do it manually.
  • With 3.18.* kernels came the device tree overlay. The driver is now added to the default compile config. You have to add the following lines to the /boot/config.txt file, and you are done!
dtparam=spi=on
dtoverlay=enc28j60

Pin connections (from the forum):

ENC - RPi
=======
VCC - 3v3
GND - GND
CS - CE0 (gpio 8)
SI - MOSI (gpio 10)
SCK - SCKL (gpio 11)
SO - MISO (gpio 9)
IRQ - GPIO 25
Update: 2015-02-27
The overlay and slightly tweaked module are now in the rpi-3.18.y branch. 
Build with 'dtbs' as a make target, and copy arch/arm/boot/dtbs/enc28j60-overlay.dtb
to /boot/overlays, add 'dtoverlay=enc28j60' and reboot.

dmesg:

bcm2708_spi 20204000.spi: master is unqueued, this is deprecated
enc28j60 spi0.0: enc28j60 Ethernet driver 1.01 loaded
net eth0: enc28j60 driver registered
bcm2708_spi 20204000.spi: SPI Controller at 0x20204000 (irq 80)
net eth0: link down
net eth0: normal mode
net eth0: multicast mode

And the story stops here. The cable is not detected when I plug it in. But we are near the finish line!

$ sudo ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full 
        Supported pause frame use: No
        Supports auto-negotiation: No
        Advertised link modes:  Not reported
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Speed: 10Mb/s
        Duplex: Half
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: off
        MDI-X: Unknown
        Current message level: 0x00000036 (54)
                               probe link ifdown ifup
Update 2015-03-27, after these commits 7defc7b 40185a9 from the community members:
File: enc28j60-overlay.dtb
Info: Overlay for the Microchip ENC28J60 Ethernet Controller (SPI)
Load: dtoverlay=enc28j60,=
Params: 
int_pin GPIO used for INT (default 25)
speed SPI bus speed (default 12000000)

and Phil Elwell posted a good dt overlay file. If you don’t want to compile it, you can download it from here: enc28j60-overlay.dtb or the original in base64 from Phil

You need to overwrite the /boot/overlay/enc28j60-overlay.dtb file with it, and change the line in /boot/config.txt to:

dtoverlay=enc28j60,int_pin=25

… and after reboot the device came up!

[ 20.191229] net eth0: link down
[ 20.191292] net eth0: normal mode
[ 20.191440] net eth0: multicast mode
[ 20.998920] net eth0: link up - Half duplex
[ 22.130068] net eth0: multicast mode

Speed around 250-300 KByte/sec

Update 2015-04-02: The latest build includes the new overlay

How to make the ever changing MAC settle?

The answer is from here:

Create a new script:

sudo nano /etc/init.d/mac.sh

Paste into this script (settign your MAC address as required) …

#! /bin/sh
ifconfig eth0 down hw ether 00:00:00:00:00:00
ifconfig eth0 up 

Make it executable:

sudo chmod +x /etc/init.d/mac.sh

Then run:

sudo update-rc.d mac.sh defaults

JP1082

3_JP1082On the first glimpse this is a good value/price device, which connects via USB. The linux (and also the pi) kernel has the driver for it, so it works out of the box.

Here are some lines from dmesg:

] usb 1-1.3: new full-speed USB device number 5 using dwc_otg
] usb 1-1.3: New USB device found, idVendor=0fe6, idProduct=9700
] usb 1-1.3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
] usb 1-1.3: Product: USB 2.0 10/100M Ethernet Adaptor
] dm9601 1-1.3:1.0 eth0: register 'dm9601' at usb-bcm2708_usb-1.3, Davicom DM96xx USB 10/100 Ethernet, 
] usbcore: registered new interface driver dm9601
dm9601 1-1.3:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF

But on the second try things get bad, and then even worse. The Supported Hardware site points out that it has a Kontron DM9601 chip, which is only USB 1.1. 12 Mbit/s (~1.2 MByte/s) can be enough, but the driver has a major bug! For pinging, getting ntp date/time it is ok, but after you start a bigger transfer, like a sudo apt-get update it simply dies with a kernel panic. First I thought that it is a power supply issue, but after adding an external powered hub to the pi, the problem didn’t went away. Also it wasn’t working with older kernels.

But there is a simple patch for it, and here is how to re-build the kernel. It will take around 11-12 hours on the pi even with 1000Mhz arm frequency. I’ve done it following the blog post, and it works!

Btw this is only a temporary solution. The device is way to big.

TL-WN723N

打印From the TP Link product page we can learn that the maximum speed for this adapter is 150 Mbps. Which is very good.  The wikidevi page shows that it is supported. Dmesg:

] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
] usb 1-1.1: New USB device found, idVendor=0bda, idProduct=8179
] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
] usb 1-1.1: Product: 802.11n NIC
] usb 1-1.1: Manufacturer: Realtek
] usb 1-1.1: SerialNumber: 00E04C0001
] r8188eu: module is from the staging directory, the quality is unknown, you have been warned.
] Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_A_CUT_1T1R_RomVer(0)
] usbcore: registered new interface driver r8188eu
] r8188eu 1-1.1:1.0: Direct firmware load for rtlwifi/rtl8188eufw.bin failed with error -2
] r8188eu 1-1.1:1.0: Firmware rtlwifi/rtl8188eufw.bin not available

This means, that the driver is inside the kernel, but the firmware is not packaged. In the past I have experimented with this adaptor, and used lwfinger‘s git repository to build the driver.  But before it was mainlined it was like a pain in the ass to get it working correctly. And if it went to low power mode, it simply lost the connection. But this is past, you have to get only the firmware manually from the repository, and copy it to /lib/firmware/rtlwifi/rtl8188eufw.bin. Do a reboot. Btw here is a good and long discussion about the adaptor.

Firmware that I use: rtl8188eufw.bin

If you want your pi to connect to your home network, just add the following lines to the end of file /etc/wpa_supplicant/wpa_supplicant.conf

network={
    ssid="YOUR_SSID"
    psk="YOUR_PASSWORD"
}

After a few seconds the pi will connect.

Advertisements

Author: Gajdos Tamás

A "barefoot physicist" with some IT skills in system administration.

6 thoughts on “Raspberry Pi A+ with internet”

  1. Hi,
    Really interesting post. I’d been wondering whether such a thing was possible for a while now..
    Quick question – doing some independent research (via the Github issue page) I found that the IRQ pin from the ENC28J60 module goes to GPIO 25 (physical pin 22), and the exact line used to load the device tree overlay is:

    dtoverlay=enc28j60,int_pin=25

    However, in your post, you wrote:

    dtoverlay=enc28j60,int_pin=2

    I’m a little confused. Was that a typo or does the IRQ pin of the module go to GPIO2 (physical pin 3, which is also the SDA pin for the I2C peripheral)?

    Thanks!

    1. Hi, thank you for your moderation request. That was a typo. The correct line is
      dtoverlay=enc28j60,int_pin=25
      OR just
      dtoverlay=enc28j60
      Thanks!

      1. Okay, thanks for clearing the typo thing up 🙂
        Wow, that sounds pretty good. I guess with the high SPI clock speeds and stuff the occasional failure is bound to happen. I’ll begin experimenting with the usual 15cm jumpers and hopefully go shorter with time – apparently shorter cables in high-frequency applications are generally preferred. I do however intend to try this with the new Raspbian Jessie Lite image. I expect it would work anyways..

  2. Since april the Pi is connected to the ENC28J60 module, and I had some hw failures. Usually because the PI looses the connection to the module, so I have to move the cables a bit and restart.
    Still on kernel 3.18 (Raspbian 2015-05-05).

  3. Hello,
    Just tested this with a Raspi A+ and the Debian Jessie Lite image (dated 2015-11-21 and kernel version 4.1) and I’ve confirmed it works out of the box (once you’ve edited config.txt and made the relevant connections of course). I haven’t done any stress testing but the link certainly seems steady enough…
    Thanks again for the article!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s