Thursday, 29 June 2017

Apple Magic Keyboard 2 on Linux

Annoyingly, the Apple Magic Keyboard 2 is only recognised as a generic Bluetooth hid keyboard so the Fn and shortcut keys don't work correctly (using hid-generic kernel module).

I've started work on a set of patches for the hid-apple kernel module to add support for this keyboard.

Using Wireshark to sniff the Bluetooth packets, I've found the following are emitted as Fn KeyDown and KeyUp events:

Fn KeyDown: a1 01 00 00 00 00 00 00 00 00 02
Fn KeyUp:   a1 01 00 00 00 00 00 00 00 00 00

I'm going to attempt to add these as a customisation in the hid-apple module and see how I get on.

Monday, 2 January 2017

External USB Audio on Raspberry Pi 3

The rpi3 could see the USB audio device but not be able to enable it. The following errors were observed in dmesg:

[    4.214503] snd_bcm2835: unknown parameter 'index' ignored
[    4.470103] snd-usb-audio 1-1.2:1.0: cannot find the slot for index 0 (range 0-0), error: -16
[    4.470134] usb 1-1.2: cannot create card instance 0
[    4.470164] snd-usb-audio: probe of 1-1.2:1.0 failed with error -16
[    4.470823] usbcore: registered new interface driver snd-usb-audio

It looks like a conflict with the card index of the internal sound codec. Because I don't want to use the interval sound codec I just blacklisted the module to prevent it from loading by adding:

blacklist snd_bcm2835

To the configuration file /etc/modprobe.d/rpi-blacklist.conf

Monday, 5 December 2016

Bash Completion on OS X

Working with the terminal in OS X for the first time I realised I was missing tab completion for common terminal tasks.  After a bit of searching I found the bash-completion package is available to install from brew.  Just use:

brew install bash-completion

Friday, 9 September 2016

No SIM card - Emergency calls only

I got a Motorola Google Nexus 6 phone which takes a nano SIM card.  I cut down my existing SIM as far as I could and it worked in the Nexus but the SIM tray wouldn't shut properly so I ordered a brand new nano SIM.

When the nano SIM came I could not get it to work at all.  The phone would not detect the presence of the SIM card.  I tried wedging paper under it, cleaning contacts, factory reset, software downgrade and nothing would work.

This same nano SIM worked perfectly in another handset, I tried another working nano SIM in the Nexus and that wouldn't work either.

I then tried pushing the SIM tray as hard as I could and surprisingly the SIM was registered by the handset and it indicated full signal.

Short Answer:
Push the SIM tray in as hard as you can!!!

This appears to be some kind of mechanical defect with the Nexus 6 as recorded in many threads.
Here: http://forum.xda-developers.com/nexus-6/help/sim-card-emergency-calls-error-verizon-t2996291
Here: https://productforums.google.com/forum/#!topic/nexus/wuIXWFdaHZQ
And Here: https://productforums.google.com/forum/#!topic/nexus/-vSXPn2obNk

Monday, 15 August 2016

Best description so far of Google Cast API

Thinking of developing a Google Cast Receiver outside of the official Android SDK?

Take a look at this documentation

Tuesday, 8 March 2016

U-boot fails to load env from I2C eeprom if SPI is enabled

U-boot failed to load environment from an I2C eeprom with the following errors:

U-Boot SPL 2015.10-00002-gfedeb03-dirty (Mar 08 2016 - 13:05:30)
reading args
spl_load_image_fat_os: error reading image args, err - -1
reading u-boot.img
reading u-boot.img


U-Boot 2015.10-00002-gfedeb03-dirty (Mar 08 2016 - 13:05:30 +0000)

       Watchdog enabled
I2C:   ready
DRAM:  512 MiB
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
i2c_read: error waiting for addr ACK (status=0x116)
*** Error - default environment is too large

Net:   <ethaddr> not set. Validating first E-fuse MAC
Phy 0 not found
cpsw
Error: cpsw address not set.
, usb_ether
Error: usb_ether address not set.

env_buf [32 bytes] too small for value of "bootcmd"
Hit any key to stop autoboot:  0 

On investigation, adding a debug output I found that the wrong I2C address was being read:
I2C read: addr:0 len:4 alen:1 chip:0x00

My configuration defines the env on an eeprom at 0x50:
/* EEPROM (24C16) */
#define CONFIG_CMD_EEPROM
#define CONFIG_ENV_IS_IN_EEPROM
#define CONFIG_I2C_ENV_EEPROM_BUS 1
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 /* Main EEPROM */
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
#define CONFIG_SYS_I2C_MULTI_EEPROMS
#define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE
#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3  /* 8 Byte write page */
#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 10
#define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW 0x07

Looking at the section of code at include/common.h:483:
#if defined(CONFIG_SPI) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR)
# define CONFIG_SYS_DEF_EEPROM_ADDR 0
#else
#if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
# define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
#endif
#endif /* CONFIG_SPI || !defined(CONFIG_SYS_I2C_EEPROM_ADDR) */

The logic is a bit confusing but appears to set CONFIG_SYS_DEF_EEPROM_ADDR to 0 if CONFIG_SPI is defined but I don't have CONFIG_SPI defined!

On closer inspection, an included default config for the SoC I was using had defined this so simply adding:
#undef CONFIG_SPI

Resolved the issue :-)