Monthly Archives: September 2015

lspci and dmidecode under MacOS X

Thanks goes to a guys from coreboot for the DirectHW kernel driver and framework that emulates the most commonly used hardware access functions on x86 machines under Mac OS X.

DirectHW is free software and released under the license ISC-L.

Build the DMG installer with kernel driver and framework:

git clone http://review.coreboot.org/p/directhw.git
cd directhw/macosx
make directhw

A couple of people having trouble building DirectHW, so you can download from mirror

Build and install pciutils-3.1.7:

PCIUTILS="pciutils-3.1.7"
rm -rf ${PCIUTILS}{,.tar.bz2}
wget -v -nd -c ftp://ftp.kernel.org/pub/software/utils/pciutils/${PCIUTILS}.tar.bz2
tar xvjf ${PCIUTILS}.tar.bz2
patch -p0 < patches/${PCIUTILS}.diff
cd ${PCIUTILS}
make OPT="-O2 -arch i386 -arch x86_64" LDFLAGS="-arch i386 -arch x86_64" install install-lib
cd -
rm -rf ${PCIUTILS}{,.tar.bz2}

Build and install dmidecode-2.11:

DMIDECODE="dmidecode-2.11"
rm -rf ${DMIDECODE}{,.tar.bz2}
wget -v -nd -c http://download-mirror.savannah.gnu.org/releases/dmidecode/${DMIDECODE}.tar.bz2
tar xvjf ${DMIDECODE}.tar.bz2
patch -p0 < patches/dmidecode-2.11.diff
cd ${DMIDECODE}
make install
cd -
rm -rf ${DMIDECODE}{,.tar.bz2}

Don’t forget to load the kernel extension:

sudo kextload /System/Library/Extensions/DirectHW.kext

Great, now you can use lspci, dmidecode, etc… don’t forget to use sudo:

update-pciids
sudo lspci -vv
sudo dmidecode
sudo biosdecode

USB to UART Bridge Controller (dongle)

Finally i’ve got TTL to USB dongle. Here is some photos:

CP2102 Front
CP2102 Back

Silicon Labs CP2102 as detected by MacOS

CP2102 MacOS USB1
CP2102 MacOS USB2

Drivers can be downloaded from the official site.
Driver version 4.1.1 successfully installed under MacOS X Yosemite 10.10.5 (14F27).

$ kextstat | tail -1
  170    0 0xffffff7f832d7000 0x6000     0x6000     com.silabs.driver.CP210xVCPDriver (4.1.1) <90 37 4 3>

driver loaded and we’re got two special character devices under the /dev directory:

$ ls -la /dev/*SLAB*
crw-rw-rw- 1 root wheel 17, 11 Sep 14 23:04 /dev/cu.SLAB_USBtoUART
crw-rw-rw- 1 root wheel 17, 10 Sep 14 23:04 /dev/tty.SLAB_USBtoUART

now we’re should perform loopback test. Short RX and TX pins, and run terminal:

sudo cu -l /dev/tty.SLAB_USBtoUART -s 115200

try to enter some text. Letters should be displayed while each key pressed.
If you’re see typed text all fine and press ~. (tilde and period) to exit terminal.

Raspberry Pi lost… and found

How to find my RPi2 on network. I use arp-scan, brewed in my MacOS shell:

$ brew update
$ brew install arp-scan

Optional steps (for proper vendor decoding):

$ get-iab -v -f /usr/local/share/arp-scan/ieee-iab.txt
Renaming /usr/local/share/arp-scan/ieee-iab.txt to /usr/local/share/arp-scan/ieee-iab.txt.bak
Fetching IAB data from http://standards.ieee.org/develop/regauth/iab/iab.txt
Fetched 2452407 bytes
Opening output file /usr/local/share/arp-scan/ieee-iab.txt
4567 IAB entries written to file /usr/local/share/arp-scan/ieee-iab.txt
$ get-oui -v -f /usr/local/share/arp-scan/ieee-oui.txt
Renaming /usr/local/share/arp-scan/ieee-oui.txt to /usr/local/share/arp-scan/ieee-oui.txt.bak
Fetching OUI data from http://standards.ieee.org/develop/regauth/oui/oui.txt
Fetched 3245695 bytes
Opening output file /usr/local/share/arp-scan/ieee-oui.txt
21123 OUI entries written to file /usr/local/share/arp-scan/ieee-oui.txt

Now scan local network (don’t forget sudo):

$ sudo arp-scan --localnet | grep -i 'b8:27:eb'
192.168.1.102	b8:27:eb:dd:e3:c6	Raspberry Pi Foundation

Found.

Bonjour networking for Raspberry Pi

I have a lot of Apple hardware (MacBook, Hackintosh, iPhone, etc.) configured with Bonjour and I want my RPi2 be resolved by network.

apt-get update
apt-get install -y avahi-daemon
update-rc.d avahi-daemon enable
service avahi-daemon stop
vi /etc/default/avahi-daemon

and change the line:

AVAHI_DAEMON_DETECT_LOCAL=1

to

AVAHI_DAEMON_DETECT_LOCAL=0

then start the Avahi-daemon with

service avahi-daemon start

Now we’re can test resolving by ping for example

$ ping raspberrypi.local
PING raspberrypi.local (192.168.1.102): 56 data bytes
64 bytes from 192.168.1.102: icmp_seq=0 ttl=64 time=0.439 ms
64 bytes from 192.168.1.102: icmp_seq=1 ttl=64 time=0.446 ms
^C
--- raspberrypi.local ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.439/0.443/0.446/0.003 ms

Problem solved.

Brew Cask cleanup orphans

find /opt/homebrew-cask/Caskroom -depth 1 -print -exec \
  sh -c "ls -1A {} | grep -v .metadata | head -n -1" \; | grep -B1 -E '^[^\/]'

output will show you extra files in directory which should be removed

/opt/homebrew-cask/Caskroom/google-chrome
.DS_Store
--
/opt/homebrew-cask/Caskroom/iterm2
.DS_Store
--
/opt/homebrew-cask/Caskroom/opera
24.0.1558.64

also it will display orphaned versions of exact Cask which should be zapped

brew cask zap opera
brew cask install opera