Tuesday, 1 July 2014

Serial ports on the Beaglebone Black
On the BeagleBone Black, it's only the /dev/ttyO0 that is enabled by default, and it is coupled to the serial console. The other serial ports must be enabled before they can be used.

To enable the uarts 1,2,4 and/or 5 on the BeagleBone Black, rev A, B and C:
  1. Rev A/B: Open the file sudo nano/media/BEAGLEBONE/uEnv.txt
  2. Mine is Rev C: So sudo nano  /boot/uboot/uEnv.txt
  3. Add the key "capemgr.enable_partno="
  4. Add the ports you want to enable, comma separated (BB-UART1, BB-UART2. BB-UART4, BB-UART5)
  5. In my case I want to add tty04 so I can hook up to the RF Transmitter and LCD of my home automation 
  6. Reboot
An example line looks like this:


ubuntu@beaglebone:~$ sudo nano /boot/uboot/uEnv.txt
Find a suitable line to edit e.g.


##Disable HDMI

cape_disable=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN capemgr.enable_partno=BB-UART4



After reboot, the device is present in the device list:


ubuntu@beaglebone:~$ ls -l /dev/ttyO*
crw-rw---- 1 root tty     248, 0 Jul  1 20:39 /dev/ttyO0
crw-rw---- 1 root dialout 248, 4 Jul  1 20:39 /dev/ttyO4

The UARTs map to pins and devices like this:


 RX TX CTS RTS Device Remark
 UART0    J1_4 J1_5     /dev/ttyO0BeagleBone Black only
 UART1 P9_26 P9_24 P9_20 P9_19 /dev/ttyO1
 UART2 P9_22 P9_21 P8_37 P8_38 /dev/ttyO2
 UART3 P9_42 P8_36 P8_34 /dev/ttyO3 TX only
 UART4 P9_11 P9_13 P8_35 P8_33 /dev/ttyO4
 UART5 P8_38 P8_37 P8_31 P8_32 /dev/ttyO5

Saturday, 31 May 2014

Connman is annoying

Connman is the new way of doing networking apparently but why fix what isn't broken. I know the talk about 'what if the network falls' blah blah blah but if the network should fail then I'm up the Swanny anyway. A big minus side to connman is it doesn't work well with my wireless network. I don't need wireless really but I would like to make the whole hub fairly portable (just need mains supply) rather than need a network cable.
I don't want connman anywhere near my beaglebone.
How to remove connman and revert to traditional network interface start up.
DISABLE CONNMAN
systemctl disable connman.service

CREATE INTERFACES FILE
cat > /etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
 
auto eth0
iface eth0 inet static
address 192.168.0.99
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1
 
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
gateway 192.168.7.1
dns-nameservers 192.168.7.1
 
iface wlan0 inet static
address 192.168.0.98
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1
wireless_mode managed
wireless_essid “SSID NAME HERE”
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf
pre-up wpa_supplicant -B -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
post-down killall -q wpa_supplicant
EOF
CREATE RESOLV.CONF
cat >/etc/resolv.conf <<EOF
search local
nameserver 192.168.0.1
EOF
CREATE WPA_SUPPLICANT.CONF WITH PASS
cat >/etc/wpa_supplicant.conf <<EOF
ap_scan=2

network={
ssid="VM275247-2G"
proto=WPA RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk=long key for psk
}
EOF

CREATE SERVICE FOR WIFI
cat >/etc/systemd/system/net.service <<EOF
[Unit]
Description=Network interfaces
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-wlan0.device
After=sys-subsystem-net-devices-wlan0.device

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "sleep 5;ifup wlan0"
ExecStop=/bin/sh -c "ifdown wlan0"

[Install]
WantedBy=multi-user.target
EOF
START SERVICE
systemctl enable net.service
Obviously you need to enter your own details :)

Friday, 30 May 2014

backing up the BeagleBone Black eMMC


After you have got the BBB up and running how you like it, backing up is always a good idea.
If, like me, you are using it for home automation based on the Livebox, you can of course back up the ini settings, plugboard scripts etc using the web GUI but I like to keep a backup of the entire eMMC.
There are a few methods to be found on the 'net that require the use of a script on a microSD card. This is ideally the best way but requires stopping the BBB (and if SWMBO is expecting things to happen, that's never good)
So here is an option to use dd over ssh to backup to another PC (in my case a mac)
on the BBB
sudo dd if=/dev/mmcblk0 bs=1M | ssh themac@192.168.0.X "dd of=/Users/themac/Desktop/BBB_Backup_date.img bs=1m"
n.b. the block size is set on the BBB using bs=1M but on the mac HAS to be bs=1m (lowercase) (I'm not sure if this is the case :) on a pc)
To restore. This needs to be done after booting from an SD card to free up the eMMC The eMMC is then mmcblk1 not mmcblk0
ssh themac@192.168.0.X "dd of=/Users/themac/Desktop/BBB_Backup_date.img bs=1m” | sudo dd of=/dev/mmcblk1 bs=1M
Then power down, remove the SD card and reboot.