Author: simkin@simkin.org

  • Pi Zero and Camera not working

    pi-camera
    I have a few Raspberry PIs. I’m an engineer at heart and these things allow me to tinker without expending a lot of money and the SD-Card nature of the filesystem makes it easy to try something, wipe it and try something new.
    One thing that has frustrated me for weeks is a camera failing to work. I checked config and it was good, so I thought it was the cable. Bought a new cable. It wasn’t the cable.
    Thought it might be the PI. Tried a different one. It wasn’t the PI.
    Argh.
    Tried another camera. Different version. Nope.
    Then I found this: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=160611
    And one line of obscure, seemingly unrelated config later, it is working perfectly.
    Seems there is a version bug in the Pi. Apparently it relates to certain versions of the Pi Zero and my board should not be affected. I checked the revision numbers and the OTP that the Pi thinks it is and they all check out. So I shouldn’t need this fix. But it turns out I do.
    If you have a Raspberry Pi and the camera doesn’t work, giving some mmal errors, please rad the post. It may be a simple job of adding

    force_board_rev=0x900093

    to /boot/config.txt and then running

    sudo raspi-config

    and enabling the camera. One reboot later and

    sudo raspistill -o test.jpg

    will give you a view of the world as the Pi sees it.
    Hooray!

  • Windows 10 Common fixes

    I have had a handful of issues with Windows 10 but still like it. Here are some issues and fixes I found work for me:

    (more…)

  • Recovering Windows 10 RAW Partition

    This link will be useful: http://www.cgsecurity.org/wiki/TestDisk_Download
    I recently had a disk partition turn RAW. Windows would boot and then hang. Connecting the hard drive to a different system showed the main partition was now marked RAW and unreadable. Installing and running TestDisk soon had the partition readable and I was able to recover my files. Download it now so you have it handy when you need it.

  • Wifi on the Raspberry Pi

    Had a few requests about this and there are various answers on forums around the place, but this is how I did it using a PI Hut dongle:

    sudo apt-get update
    sudo apt-get upgrade
    sudo shutdown -r 0

    Those three commands make sure everything is the latest it needs to be before you try anything else. Now let’s edit two files:
    sudo nano /etc/network/interfaces

    # just add or edit the wlan sections at the bottom, leave the rest of the file as you find it
    allow-hotplug wlan0
    iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    allow-hotplug wlan1
    iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    

    sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

    #This is the entire file and it gets me onto my home wifi network, but change the ssid and the psk to the password for your network
    ctrl_interface=DIR=/var/run/wpa_supplicant
    GROUP=netdev
    update_config=1
    network={ ssid="59KnightsWay" psk="afafafafafa" }

     
    Note: If you wanted a static wifi address, the interfaces file needs a minor tweak:

    allow-hotplug wlan0
    iface wlan0 inet static
    address 192.168.1.99
    netmask 255.255.255.0
    gateway 192.168.1.1
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

    Reboot and use these two commands to check what did and didn’t work:
    ifconfig wlan0
    tail -500 /var/log/syslog | grep wlan
    If you struggle with wpa_supplicant, you can wimp out and do it all in /etc/network/interfaces

    # interfaces(5) file used by ifup(8) and ifdown(8)
    # Please note that this file is written to be used with dhcpcd
    # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
    # Include files from /etc/network/interfaces.d:
    source-directory /etc/network/interfaces.d
    auto lo
    iface lo inet loopback
    iface eth0 inet manual
    allow-hotplug wlan0
    iface wlan0 inet static
    address 192.168.1.99
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8
    wpa-ssid "MySSID"
    wpa-psk "mypassword"
    
  • Land Rover Defender Wading Plug Location

    If you own a Land Rover Defender and on occasion wade through water, you should understand where your wading plugs are.
    Wading plugs prevent water getting into bits of your engine that don’t like getting wet. They are not as critical as water getting into your air intake, but if you get the chance before you go knees deep in the wet stuff, plug those holes!
    If you don’t have any, buy a pair. If yours are permanently installed, you should consider removing them to prevent oil fouling your timing belt. But that is to be honest, a matter of opinion vs. the maintenance guides. For example: http://forums.lr4x4.com/index.php?showtopic=9219
    Fitting Wading Plugs
    Slide in behind your front wheel and you can plug the timing belt case as shown here. (Yes, I do use yellow plugs to make it easier to find them afterwards.)
    Fron Wading Plug
    I have marked the next one in red, purely to make it easier in any comments or feedback. This one is just behind the sump and into the bottom of the flywheel housing and prevents water getting onto your clutch plate. Not every engine has one here. If you do though, plug this one too.
    Rear Wading Plug
    This guide is based on a 1993 Defender 110 with a 200tdi engine and LT77s gearbox. Yours may differ if it is more modern than mine, but this still covers an awful lot of vehicles and hopefully will be useful to somebody
     
     

  • Removing old Java Versions

    If you have Java installed on your computer (and you probably do), chances are you have old versions laying about the place and some of these will be a security risk. But there is and easy way to remove them.

    First Go to Control Panel > Add/Remove Programs and remove any Java versions with a number lower than 1.4.2. Really, just uninstall them.

    Now visit http://java.com/en/download/uninstallapplet.jsp and let it do it’s work. This tool scans for older versions of Java and removes them without breaking your current version as well as checking you are up to date. Worth visiting once in a while. Or if you have better things to do, just go there now, run it once and chances are you’ll end up being that little bit safer online.

  • SLAAC and Stateless DHCPv6 on Juniper SRX routers

    If you have struggled to find the easiest guide to getting IPv6 onto an SRX router, giving out Routing Announcements (RAs) to clients to tell them what the subnet is and using DHCPv6 to only tell them about DNS servers, you’ve come to the right place.
    You have the option of using DHCPv6 in Stateful mode, assigning IP addresses and other attributes, but that removes the SLAAC functionality and instead makes your poor little router into a DHCP database, just like it was in IPv4. There really isn’t any need to do it that way. So let’s instead build it so the clients ask the router simply where the DNS servers are and otherwise just look after themselves. We call this a “Stateless” configuration.
    The trick is to ensure that the RAs go out with the DHCP “O” flag set. This tells clients that they should work out their own IP addresses using SLAAC (by far the best way to do it and the way IPv6 was designed) but that they should poll DHCP using a “DHCPINFORM” message to get the DNS resolvers or any other related info.
    Let’s start with configuring a local IPv6 address and then turn-on RA with that flag set:

    interfaces {
        fe-0/0/0  {
           unit 0 {
             family inet6 {
                address 2a01:a000:110::1/64;
             }
           }
        }
    protocols {
         router-advertisement {
             interface fe-0/0/0.0 {
                 prefix 2a01:a000:110::/64;
                other-stateful-configuration;
             }
        }
    

    Now we’ve done that, the only thing left to do is to build a DHCPv6 config. We’ll create a DHCP pool called “mypool” but we won’t give it any IP addresses as clients will already have an address from SLAAC. Instead we will just load it with the attributes we want clients to know about.
    We’ll create an optional token as a security measure so that any DHCP reset messages heard by the client will be compared to this token and ignored if they don’t match. Then we’ll put a group together called “mygroup” containing all participating interfaces, which in this case is just fe-0/0/0.
    Notice the inclusion of the “process-inform” override. Without this, DHCP will ignore requests from clients that already have an address, assuming they have been speaking to another DHCP server. With this turned on, it will instead listen to and respond to DHCPINFORM requests and respond with the dhcp attributes set in the pool that matches the subnet the client resides in.

    system {
        services {
            dhcp-local-server {
                  dhcpv6 {
                      reconfigure {
                          token 8ysIU9E32k8r;
                      }
                      group mygroup {
                         overrides {
                             interface-client-limit 200;
                               process-inform {
                                  pool mypool;
                               }
                             }
                          interface fe-0/0/0.0;
    }}}}
    access {
       address-assignment {
          pool mypool {
             family inet6 {
                 prefix 2a01:a000:110::/64;
                 dhcp-attributes {
                       maximum-lease-time 120;
                       grace-period 3600;
                       dns-server {
                          2620:0:ccc::2;
                          2620:0:ccd::2;
    }}}}}
    

    That should pretty much do it for you. Don’t forget to do an ipconfig /release6 followed by ipconfig /renew6 on any Windows clients.
    Clients that already have DHCPv4 DNS resolvers in their config won’t necessarily show they have picked up the IPv6 DNS resolvers. The only way to be sure is to turn-off IPv4 on the client and see if you can ping a site that isn’t in the local DNS cache. On the router, you can use “show dhcpv6 server statistics” to ensure you have more INFORMATION_REQUEST packets than you have drops.

  • Sky O2 Broadband and Linksys WAG54GS routers

    Contrary to what Sky will tell you about how to setup a router to use their service, it won’t work. At least not as they explain it.
    To read it for yourself, look here: http://helpforum.sky.com/t5/tkb/articleprintpage/tkb-id/sky_broadband_setupcablingconnectionwifi@tkb/article-id/14
    or here:
    http://service.o2.co.uk/IQ/SRVS/CGI-BIN/WEBCGI.EXE?New,Kb=Companion,question=ref(User):str(Broadband),T=Broadband_Case,CASE=24812
    I tried a few different ways but in the end, these worked for me:
    Encapsulation:  RFC1483 Bridged  (Your router may call this: IPoE)
    Multiplexing:  VC
    Autodetect: Disable
    VPI: 0
    VCI: 102
    Don’t auto-detect your IP address. Instead enter the static IP they gave you as a /24 with the first IP in the block as the gateway.
    DNS: 87.194.225.154
    DNS: 87.194.225.155

    If it is all working, you should see it on your status page. I could pretty much get the DSL line to come up on most settings but getting it to log a gateway was an impossible task. All good now though:

  • Land Rover Defender Headlight Wiring Upgrade

    One of the joys of owning a Land Rover Defender is that you can fix a lot of stuff on it yourself. When it is an old one like my 20yr old 200tdi, you can also turn your hand to improving it, where the original engineers didn’t have the technology or budget at the time.
    Why Upgrade the wiring?
    One key failing of the Defender up to and a little beyond my model is the lack of relays between the battery and the headlights. This generally leads to the headlight switch burning out and will give a dimmer headlight than modern cars. Also, if you upgrade your headlights or bulbs, this modification is pretty much essential.
    There is a great little video on YouTube which is a great place to start: BushmanProductionsAU Tutorial, so treat my ramblings here as what I did next after watching it…
    The Diagram
    There is a diagram of how I did it, which hopefully makes sense. It purposefully isn’t a wiring schematic using auto-electrical symbols because I expect most people reading this are enthusiasts, not electricians.

    Buy What You Need
    First thing to get right is not to waste money on a “headlight upgrade kit” because all the bits you need are easy to obtain. I strongly recommend you visit Vehicle Wiring Products to source the stuff you need.

    • 3x in-line fuse holders (or a mini fusebox)
    • 1x 20Amp fuse
    • 2x 15Amp fuses
    • 2x 5-blade changeover relays
    • 2x relay sockets
    • At least 10 female crimp connectors
    • Enough red  10AWG/25Amp cable to go from your battery to the relays
    • Enough 12AWG/15Amp cable to go from your relays to your headlight plug (brown on my diagram)
    • Same again in a different colour (Yellow on my diagram)
    • Some 12AWG to earth pin 85 on each relay and third pin on each headlight to a suitable earth (eg. bodywork)
    • Suitable crimp connectors to connect to your battery
    • 2x H4 female sockets  (these go onto the pins on your bulbs)
    • 1x H4 male plug (this takes the pins from one of your existing headlight plugs)
    • Enough 12AWG to run from your high (full) beam relay to each headlight (pale blue in the diagram)
    • Same again but a different colour for the standard (dipped) beam
    • Two blade connectors and a short length of 10AWG (see below)
    • Enough corrugated plastic shielding to protect all this cable
    • Enough shrink-fit insulation to do a good job protecting those crimps
    • 8x bullet connectors
    • 2x Double-common snap connectors

    Method
    The way I recommend doing it is to fit the two relays in the engine bay, attached to the bodyWork. Somewhere just ahead of the washer bottle is fine.
    Run cable to each headlight to power them from pin 87 of the relays. Note: you will be running two cables from one pin, so you will have a single crimp connector, a short cable to get clear of the relay pins and then your choice of how to take it from here. I had a mountain of bullet connectors handy, so I put a female crimp on a short bit of cable with a bullet on the other end into a “double-common” bullet connector. Each cable out to a headlight was terminated on a bullet connector and just plugged in. But work out your preferred method and substitute your preferred connector types.
    Take a feed from the offside headlight plug itself to pin 86 on each relay. This means you are NOT cutting into your wiring loom, so the fix is 100% removable..
    Now wire-up from the battery (with the big in-line fuse in the battery compartment) and out to pin 87a on the relays (via one fuse each, near the relays). This is the fiddly bit!
    Headlights now always on with sidelights
    So, why are the headlights on dipped beam when you turn on the sidelights?
    The answer is you have a “dim-dip” system installed. This was a legal requirement from April 1987 until 1988. Land Rover still fitted this system long after that but it is not a legal requirement any more.
    All well and good, but what does that mean to us? Inside the nearside wing of your Land Rover is a chunky resister that means when the sidelight circuits are on, some current is passed through the headlights, making them run dim. But, remember we have used a feed from the headlight plug to run some relays. This “dim” voltage is still enough to trip the relays and turn the headlights on full power. We need to disable the dim-dip feature.
    Unscrew the four screws holding on your dashboard instrument panel. Behind the jumble of wires you will see at least two relays. A Yellow one (probably YWB10027L) which stops you leaving the rear heater on when the engine is off and a pink one (YWC10050). This pink one is the troublemaker.

    You can pull the relay and your lights will stop working. You can either short the socket or buy a dim-dip bypass relay. I chose to short it. You need some 25Amp cable and two spade connectors. You simply jumper between 87 and 30 as shown here:

    Put the dashboard back together and now when you turn-on the sidelights, you will just get sidelights. When you tun on headlights, you will not be dragging two headlights full of current through your control stalk on the steering column.
    And now you can upgrade your headlights or just be happy your stock headlights are a little bit brighter.

  • How to restart your iPhone without losing everything

    Hold down the On/Off button and the Home button at the same time for at least ten seconds. Release both when the Apple logo appears.
    You won’t lose your photos, apps or settings. It is just like doing CTRL-ALT-DEL on a PC.
    If you have upgraded to IOS7 recently, you’ll have to do this at some point when you start to see Facebook crashing or the camera refusing to take pictures. Once you’ve reset, all will be well again.