Enabling i2c on Raspbian

Add the following to /etc/modules:

i2c-bcm2708
i2c-dev

Install i2c-tools:

sudo apt-get install i2ctools

Edit /etc/modprobe.d/raspi-blacklist.conf and remove/comment out these two lines:

blacklist spi-bcm2708
blacklist i2c-bcm2708

Detect your ic2 interface with:

sudo i2cdetect -y 1 #1 = Pi model B

If you get this error:

Error: Could not open file '/dev/i2c-1' or `/dev/i2c/1': No such file or directory

Then run this first and you should be good to go:

sudo modprobe i2c-dev

More info here.

Disabling strict key checking on ssh

Key checking on ssh validates that the remote system you’re attempting to connect to is the same server that you connected to the last time, to help prevent the possibility that someone has hijacked the DNS name, IP, or the hardware itself.

However, some times you may want to avoid this checking. For example, I have a Raspberry Pi that I boot from multiple SD cards, but each is setup with the same IP. If strict key checking is enabled then your ssh client will prevent you from connecting when it detects a signature change. You’ll see this error:

RSA host key for 192.168.x.x has changed and you have requested strict checking.

To avoid this, edit or add ~/.ssh/config, and add:

Host 192.168.x.x
    StrictHostKeyChecking no

where the IP can be the IP of the machine you’re connecting to, or you can use a * wildcard too (maybe not as secure).

If you’ve already connected and have a key in your known_hosts, then I think you need to delete this entry first, and then try with this config.

 

Raspberry Pi ARM ASM syscall notes

A few notes on useful syscalls:

SWI 0 : executes instruction based on value in R7

Write to screen: R7 = 4

MOV R7, #4 @ Syscall 4 = write to screen
MOV R0, #1 @ stdout: move 1 to R0
MOV R2, #4 @ length of string to R2
LDR R1, =string
SWI 0
string:
    .ascii "testn"

Read from keyboard: R7 = 3

MOV R7, #3 @ Syscall 3 = read from keyboard
MOV R0, #0 @ stdin?: move 0 to R0
MOV R2, #4 @ length of string to ready to R2
LDR R1, =string @ load R1 value to string location 
SWI 0
string:
    .ascii ""

Debugging JAXB unmarshalling issues

JAXB appears to fail silently in some cases if the XML it’s attempting to unmarshall to mapped classes doesn’t have the necessary mapped properties.

You can get additional output by adding the following:

-Djaxb.debug=true

– displays information during JAXB initialization

Before you call unmarshall() on your Unmarshaller, call setEventHandler() and add a DefaultValidationEventHandler as follows:

Unmarshaller um = jaxbContext.createUnmarshaller();
um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());

– this will output additional failure information about missing mappings for xml elements, useful if your mapped class ends up with missing values.