View RSS Feed

Recent Blogs Posts

  1. Setting up Raspberry Pi with a compiled kernel using bootc's kernel branch

    Ok, now I want to compile the kernel on the Pi. Cross compiling is *much* faster, but since I plan to only make deltas to some driver files, I won't have to recompile every time. So bite the bullet now, get the object files on my Pi with my compiler, and then (hopefully) after 6-9 hours I can start doing some development on SPI drivers and/or an SAA1064 I2C driver.

    So, using the magic of Google, found out what packages I need from here. I'm pretty sure I already have some of them, but what the heck:

    Code:
    sudo apt-get -y install libncurses5-dev fakeroot wget bzip2 build-essential
    Turns out all I needed was libcurses5-dev - the others were already there.

    Now grab bootc's kernel branch. This will actually get everything there, including the mainline and such. Takes a lot more time, but will allow me to contribute patches back to him if I want to in the future.

    Code:
    cd
    mkdir raspi
    cd raspi
    git clone https://github.com/bootc/linux.git
    This failed the first time because I don't have enough memory on my Pi to decompress what I get from github. I will probably run into problems while compiling too. Hmm.

    Try adding swap partition:

    Code:
    sudo fdisk /dev/mmcblk0         #create swap partition, type 82
    sudo reboot
    sudo mkswap /dev/mmcblk0p3
    sudo swapon /dev/mmcblk0p3
    vi /etc/fstab                   # uncomment the swap mount point
    ...
    Categories
    Uncategorized
  2. Resizing the SD card...

    Well, the 2GB SD card I started with was getting a bit cramped. So I bought an 8GB one, and transplanted by filesystem.

    First, I used Win32 Disk Imager to read the 2GB SD card onto a new image on my Windows desktop. Then I popped in the 8GB card and wrote the image to it.

    I booted the Raspberry Pi with it, and I still had the 2GB images (this was expected). I then followed the instructions here, and they worked perfectly.

    Next I'm going to compile the kernel on the Pi. Cross compiling is faster, but I will end up doing small changes and relinking a lot, so it may be tolerably fast once I get it compiled once. We'll see :-)
    Categories
    Uncategorized
  3. PCA9535 kernel module working with Raspberry Pi!

    Well, the bug I found in my last blog post was found by someone else (and fixed commit1 commit2 ) in bootc's kernel branch (not in the official one though, sadly).

    So here is how I updated stuff and tested.

    First, update the firmware using the rpi-update tool installed previously:
    Code:
    $ sudo rpi-update
    $ sudo reboot
    Then install new kernel and give it a try:

    Code:
    $ wget http://apt.bootc.net/debian/pool/main/l/linux-source-3.2.21-rpi1+/linux-image-3.2.21-rpi1+_2_armel.deb
    $ sudo dpkg -i linux-image-3.2.21-rpi1+_2_armel.deb
    $ rm !$
    $ sudo cp /boot/vmlinuz-3.2.21-rpi1+ /boot/kernel.img
    $ sudo reboot
    Now, try the stuff we did before. Load up the i2c-dev driver and manually configure the I/O expander using the sysfs mechanism:

    (as root)
    Code:
    # modprobe i2c_dev
    # echo pca9535 0x20 > /sys/bus/i2c/devices/i2c-0/new_device
    # dmesg | tail -2
     
     
    [  272.400789] i2c i2c-0: new_device: Instantiated device pca9535 at 0x20
    [  272.440470] pca953x 0-0020: interrupt support not compiled in
    Yay! No error!

    Code:
    $ cd /sys/class/gpio/gpiochip240
    $ cat label base ngpio
     
     
    pca9535
    240
    16
    It auto-sets the range of gpios! The default number for ARCH_NR_GPIOS is 256, so I guess it is counting backwards as it tries to find a range.

    Try to actually allocate ...
    Categories
    Uncategorized
  4. PCA9535 and the Raspberry Pi

    The end of my last post ended with this:

    Code:
    root@raspberrypi:~# echo pca9535 0x20 > /sys/bus/i2c/devices/i2c-0/new_device
    root@raspberrypi:~# dmesg | tail -4
    [ 1007.458897] pca953x 0-0020: interrupt support not compiled in
    [ 1007.458931] gpiochip_add: gpios -1..14 (pca9535) failed to register
    [ 1007.458990] pca953x: probe of 0-0020 failed with error -28
    [ 1007.459029] i2c i2c-0: new_device: Instantiated device pca9535 at 0x20
    Well, now I know why this doesn't work.

    Update: Everything below is sort of wrong. The sequence is correct, but it turns out the default behavior is to search for an open range of gpios to assign the I/O expander (file drivers/gpio/gpiolib.c, function gpiochip_find_base). However, the system constant ARCH_NR_GPIOS (set in arch/arm/mach-bcm2708/include/mach/gpio.h) on the Raspberry Pi is set to the number of I/Os on the BCM2708 chip, NOT the number of I/Os available for the kernel to assign. So when gpiolib tries to find an open gpio range, it can't find anything, and fails. This is a bug in the platform support code from the Raspberry Pi guys, and makes it not possible to load drivers for I/O expanders (at least ones that use the gpiolib framework).


    The Linux I2C framework has several ways to "instantiate" a device and load it into the system (see here). The one we are using above is "Method 4: Instantiate from user-space". This has the benefit of being very ...
    Categories
    Uncategorized
  5. Trying to get the PCA9535 working with my Raspberry Pi

    So I am using the same setup for the PCA9535 as my previous post. Using the Raspberry Pi I/O expander diagram, I wired up my PCA9535 to the Raspberry Pi.



    When it starts, I log in, become root, and start to play. Install i2c-tools:
    Code:
    sudo apt-get -y install i2c-tools
    Now if I try to detect, it doesn't work:
    Code:
    i2cdetect -l
    Just gives blank output.

    Load up the i2c-dev kernel module:
    Code:
    modprobe i2c_dev
    Now i2cdetect shows us something:
    Code:
    root@raspberrypi:~# i2cdetect -l
    i2c-0   i2c             bcm2708_i2c.0                           I2C adapter
    i2c-1   i2c             bcm2708_i2c.1                           I2C adapter
    root@raspberrypi:~# i2cdetect -y 0
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --
    Now try some low-level stuff on the bus directly, not using a driver. When the thing powered on, the interrupt light turns on. I have to read locations ...
    Categories
    Uncategorized
Page 1 of 6 1 2 3 ... LastLast