Heirloom BT pairing setup

=Procedure used to prime Novena Heirloom laptops= This is run on the Novena Heirloom laptops prior to shipping to pair the BT keyboard.


 * 1) Extract the heirloom hardware kit, and assemble the hardware for booting.
 * 2) Pull out motherboard, long flex cable, PCIe card, hard drive. Return other items to box.
 * 3) Use ESD bag to line workspace.
 * 4) Attach PCIe card using a temporary screw.
 * 5) Label PCIe card with box number.
 * 6) Attach front panel board with matching numbered board
 * 7) Attach fan to front panel board
 * 8) Attach temporary speakers to front panel board
 * 9) Attach LCD panel adapter
 * 10) Label BT keyboard with corresponding box number
 * 11) Label hard drive with corresponding box number
 * 12) Attach hard drive
 * 13) Boot into temporary environment using external SD image (to avoid spoiling the first boot experience primed on the SSD)
 * 14) Insert SD card for heirloom init
 * 15) Short across the P_EXT header
 * 16) Attach temporary battery board. This should power on the system.
 * 17) It should boot to a login screen, and not a blue screen with a text menu on it
 * 18) Plug in a USB keyboard to the front panel board
 * 19) Type in 'root' and 'kosagi' to log in
 * 20) Configure BT in the temporary boot environment with the new keyboard
 * 21) Start a terminal window
 * 22) type 'bluetoothctl'. You will now be in the bluetooth shell. Here, you will pair and trust the keyboard.
 * 23) In the BT shell, type 'power on'
 * 24) In the BT shell, type 'agent KeyboardOnly'
 * 25) In the BT shell, type 'default-agent'
 * 26) In the BT shell, type 'pairable on'
 * 27) In the BT shell, type 'scan on'. At this point, flick the switch on the right hand side of the BT keyboard. You should see within a few seconds the keyboard show up, with an MAC ID starting with 90:...
 * 28) In the BT shell, type 'pair 90:' and hit tab. This should tab-complete the whole BT keyboard MAC ID.
 * 29) Follow the instructions (e.g. typing into BT keyboard the 6-digit PIN followed by enter key). If there is no prompt to pair using a PIN code, allow the pairing to abort, and try again. Do not proceed with next steps until you've been prompted to enter a PIN code.
 * 30) After typing in the PIN, the system should indicate the keyboard is paired.
 * 31) In the BT shell, type 'trust 90:' and hit tab.
 * 32) In the BT shell, type 'connect 90:' and hit tab.
 * 33) In the BT shell, type 'quit'
 * 34) You should now be back in the main terminal window environment.
 * 35) Update the firmware on the target
 * 36) Mount the SSD with 'mount /dev/sda3 /mnt'
 * 37) Insert the USB drive with firmware update into the front panel board
 * 38) mount the USB drive to 'mount /dev/sdb1 /mnt2'
 * 39) go to the drive directory with 'cd /mnt2'
 * 40) run update using 'dpkg --root=/mnt -i *.deb'
 * 41) Copy the BT configuration from the temporary boot environment onto the permanent SSD environment
 * 42) Install BT firmware with 'dpkg –root=/mnt -i ~/Downloads/firmware-atheros_0.43_all.deb'
 * 43) Copy BT configuration with 'cp -a /var/lib/bluetooth /mnt/var/lib/'
 * 44) manually install /boot contents because you can't do that on a /mnt environment
 * 45) run 'mount /dev/sda1 /mnt3'
 * 46) cp novena.dtb /mnt3; cp zimage /mnt3
 * 47) umount /mnt3
 * 48) run 'mount /dev/mmcblk1p1 /mnt3'
 * 49) cp novena.dtb /mnt3; cp zimage /mnt3
 * 50) umount /mnt3
 * 51) Test audio
 * 52) test audio by playing a song. 'mplayer -ao pulse::1 test.mp3'. You will need to unmute audio using alsamixer. Run 'alsamixer', select the imx audio device using F6, and unmute any channels that are muted.
 * 53) unmount USB drive wtih 'cd; umount /mnt2'
 * 54) Set the hardware EEPROM with heirloom flag
 * 55) use novena-eeprom to update the heirloom flag: 'novena-eeprom -f es8328,senoko,edp,pcie,gbit,hdmi,eepromoops,sataroot,heirloom -w'. A script called eeprom-cmd.sh was created for convenience.
 * 56) Unmount SSD with 'umount /mnt'
 * 57) Test the suspend function
 * 58) Select suspend from the power menu
 * 59) Use the wake-up switch to power the system back on again. Verify the BT keyboard still talks to the system.
 * 60) Remove bluetooth config on the temporary boot environment
 * 61) type 'systemctl stop bluetooth'
 * 62) type 'rm -rf /var/lib/bluetooth/*'
 * 63) Test the configuration
 * 64) Shutdown the system with 'shutdown -h now'
 * 65) Remove the SD card from the external SD card slot
 * 66) Make sure the system is in cold shutdown state (orange light off)
 * 67) Reboot the system using the power button (to test the button). It should go to a blue screen with a text menu on it.
 * 68) The fan should be spinning during power-on.
 * 69) Flick the right switch on the BT keyboard to re-initiate pairing.
 * 70) Hit the space bar on the bluetooth keyboard. It should automatically associate, and you can tell it's working by using the up/down arrow keys to navigate the menu.
 * 71) Take note if the fan is spinning. It should be stopped now if the thermal driver is working correctly.
 * 72) Turn the system off. You are now done