Skip to content

Instantly share code, notes, and snippets.

@WoodyWoodsta
Last active November 30, 2018 16:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save WoodyWoodsta/8a366a5d988c6d919c7302f37bdd8b23 to your computer and use it in GitHub Desktop.
Save WoodyWoodsta/8a366a5d988c6d919c7302f37bdd8b23 to your computer and use it in GitHub Desktop.
What I have done to set the Intel Edison up
### Directory
alias ll="ls -lv"
alias lla="ls -alv"
alias glg="git log --pretty='format:%Cgreen%h%Creset %an - %s' --graph"
alias gl="git log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen %cr %an%Creset'"
alias gs="git status"
alias gd="git diff"
# add
alias ga="git add"
alias gaa="git add --all"
# commit
alias gca="git commit -a -m"
# tag & push/pull
alias gt="git tag"
alias gtl="git tag -l"
alias gtd="git tag -d"
alias gpt="git push --tags"
alias gp="git push"
alias gpom="git push origin master"
alias gpod="git push origin dev"
alias gpomt="git push origin master --tags"
alias gpodt="git push origin dev --tags"
alias ggom="git pull origin master"
# remote
alias gra="git remote add"
alias grao="git remote add origin"
alias grr="git remote rm"
alias grv="git remote -v"
# branch
alias gb="git branch"
alias gbd="git branch -D"
alias gba="git branch -a"
# checkout
alias gcob="git checkout -b"
alias gco="git checkout"
# ~/.bashrc
if [ -f $HOME/.bashrc ]; then
. $HOME/.bashrc
fi
# fix terminal dir colors
eval "$(dircolors ~/.dircolors)";
# Git Prompt Modifications
GIT_PROMPT_ONLY_IN_REPO=1
GIT_PROMPT_START='${debian_chroot:+($debian_chroot)}\n\[\033[1;31m\]\u\[\033[1;30m\] on
\[\033[01;32m\]\h\[\033[1;30m\] in \[\033[01;34m\]\w\[\033[00m\]'
GIT_PROMPT_SHOW_UPSTREAM=1 # uncomment to show upstream tracking branch
#source ~/.bash-git-prompt/gitprompt.sh
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# We use preexec and precmd hook functions for Bash
# If you have anything that's using the Debug Trap or PROMPT_COMMAND
# change it to use preexec or precmd
# See also https://github.com/rcaloras/bash-preexec
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\n\[\033[1;31m\]\u\[\033[1;30m\] on
\[\033[01;32m\]\h\[\033[1;30m\] in \[\033[01;34m\]\w\[\033[00m\]\n'$'\xe2\x96\xb2 '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)"
"$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# If this is an xterm set more declarative titles
# "dir: last_cmd" and "actual_cmd" during execution
# If you want to exclude a cmd from being printed see line 156
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\$(print_title)\a\]$PS1"
__el_LAST_EXECUTED_COMMAND=""
print_title ()
{
__el_FIRSTPART=""
__el_SECONDPART=""
if [ "$PWD" == "/" ]; then
__el_FIRSTPART="/"
else
__el_FIRSTPART="${PWD##*/}"
fi
if [[ "$__el_LAST_EXECUTED_COMMAND" == "" ]]; then
echo "$__el_FIRSTPART"
return
fi
#trim the command to the first segment and strip sudo
if [[ "$__el_LAST_EXECUTED_COMMAND" == sudo* ]]; then
__el_SECONDPART="${__el_LAST_EXECUTED_COMMAND:5}"
__el_SECONDPART="${__el_SECONDPART%% *}"
else
__el_SECONDPART="${__el_LAST_EXECUTED_COMMAND%% *}"
fi
printf "%s: %s" "$__el_FIRSTPART" "$__el_SECONDPART"
}
put_title()
{
__el_LAST_EXECUTED_COMMAND="${BASH_COMMAND}"
printf "\033]0;%s\007" "$1"
}
# Show the currently running command in the terminal title:
# http://www.davidpashley.com/articles/xterm-titles-with-bash.html
update_tab_command()
{
# catch blacklisted commands and nested escapes
case "$BASH_COMMAND" in
*\033]0*|update_*|echo*|printf*|clear*|cd*)
__el_LAST_EXECUTED_COMMAND=""
;;
*)
put_title "${BASH_COMMAND}"
;;
esac
}
preexec_functions+=(update_tab_command)
;;
*)
;;
esac
OTHER_WRITABLE 01;34 # dir that is other-writable (o+w) and not sticky

YOCTO POKY

Setup Device

  • Ensure firmware is flashed with the install_GUI.sh Intel untility
  • Setup SSH in the same utility
  • Setup Wifi in the same utility

SSH via Wifi

  • Plug the microUSB into the ethernet USB port and setup manual routing in the resulting ethernet connection
    • IP address: 192.168.2.50
    • Mask: 255.255.255.0
  • SSH into the Edison via USB and check Wifi IP address
ssh root@192.168.2.15
ifconfig
  • SSH into the Edison via Wifi with the obtained IP address

Update Packages

  • Add the following to /etc/opkg/base-feeds.conf
src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/edison
src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32
  • Enter the following to setup additional repos:
echo "src intel-edison-repo http://repo.opkg.net/edison/repo/edison" > /etc/opkg/opkg-repo-edison.conf
echo "src intel-edison-repo-all http://repo.opkg.net/edison/repo/edison" > /etc/opkg/opkg-repo-all.conf
echo "src intel-edison-repo-core2-32 http://repo.opkg.net/edison/repo/core2-32" > /etc/opkg/opkgrepocore2-32.conf
echo "src mraa-upm http://repo.opkg.net/edison/repo/edison" > /etc/opkg/mraa-upm.conf
  • Update the packages
opkg update && opkg upgrade
  • Change login shell to bash
chsh -s /bin/bash
  • Add custom .bashrc, .bash_aliases and .bash_profile to the home dir (can be found in this gist)

UBILINUX

Great article on initial setup and adding users.

Setup Device

  • Download Ubilinux image
  • Flash image via flashall.sh
  • Enable Wifi by replacing /etc/network/interfaces with the following
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto usb0
iface usb0 inet static
    address 192.168.2.15
    netmask 255.255.255.0

auto wlan0
iface wlan0 inet dhcp
    # For WPA2-Enterprise
    wpa-driver wext
    wpa-ssid eduroam
    wpa-ap-scan 1
    wpa-proto RSN
    wpa-pairwise CCMP
    wpa-group CCMP
    wpa-eap PEAP
    wpa-key-mgmt WPA-EAP
    wpa-identity <username>
    wpa-password <password>

    # For WPA
    #wpa-ssid eduroam
    #wpa-psk <psk>
    # For WEP
    #wireless-essid Emutex
    #wireless-mode Managed
    #wireless-key s:password
# And the following 4 lines are for when using hostapd...
#auto wlan0
#iface wlan0 inet static
#    address 192.168.42.1
#    netmask 255.255.255.0
  • Reboot

SSH via Wifi

  • SSH into the Edison via USB and check Wifi IP address
ssh root@192.168.2.15
ifconfig
  • SSH into the Edison via Wifi with the obtained IP address

Fix languages

  • Choose the correct langauge in etc/locale.gen
  • Execute locale-gen

Update packages

  • Simply run apt-get update && apt-get upgrade

Setup bash

  • Add the following lines to .profile
# fix terminal dir colors
eval "$(dircolors ~/.dircolors)";
  • Change the PS1 line in .bashrc to:
'${debian_chroot:+($debian_chroot)}\n\[\033[1;31m\]\u\[\033[1;30m\] on \[\033[01;32m\]\h\[\033[1;30m\] in \[\033[01;34m\]\w\[\033[00m\]\n'$'\xe2\x96\xb2 '
  • Add the .bash_aliases and .dircolors to the user's home dir

Setup sudo

  • Run apt-get install sudo
  • Add the user to the sudoers list by running sudo adduser <username> sudo
  • Correct the device name in /etc/hostname and add the device name to /etc/hosts

Setup udev rules for Intel MRAA and GPIO access

  • Add the following to /etc/udev/rules.d/10-mraa.rules:
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:gpio /sys/class/gpio/export /sys/class/gpio/unexport; chmod 771 /sys/class/gpio/export /sys/class/gpio/unexport'"
SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:gpio -Rh /sys/class/gpio /sys/devices/pci0000:00/0000:00:0c.0/gpio /sys/devices/pci0000:00/0000:00:08.0/i2c-1 /sys/kernel/debug/gpio_debug; chmod -R 770 /sys/class/gpio /sys/devices/pci0000:00/0000:00:0c.0/gpio /sys/devices/pci0000:00/0000:00:08.0/i2c-1 /sys/kernel/debug/gpio_debug; chmod a+rx /sys/kernel/debug'"
  • Restart by /etc/init.d/udev restart

Setup Node

  • Install nvm by executing curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash
  • Install the desired version of Node as you normally would with nvm

Setup mjpeg-streamer

  • Install build tools
apt-get install subversion libv4l-dev libjpeg8-dev imagemagick v4l-utils
  • Download and install source
svn co https://svn.code.sf.net/p/mjpg-streamer/code/mjpg-streamer/ mjpg-streamer
cd mjpg-streamer
sudo ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h
make USE_LIBV4L2=true clean all
sudo make install
  • Run mjpeg-streamer (if you want to :) )
/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -n -r 640x480 -f 30" -o "/usr/local/lib//output_http.so -n -p 8080 -w /usr/local/www"

Setup pidstat for monitor-pid node package

apt-get install sysstat psmisc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment