Blame view

RIOT/boards/calliope-mini/dist/flash.sh 1.4 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  #!/bin/sh
  
  # Copyright (C) 2014 Freie Universität Berlin
  #
  # This file is subject to the terms and conditions of the GNU Lesser
  # General Public License v2.1. See the file LICENSE in the top level
  # directory for more details.
  
  # The Calliope mini can be flashed through accessing it as a mass storage
  # device. To upload a new firmware, simply copy your binary onto this device.
  #
  # Under Ubuntu/Mint the default mount-point is /media/$(USER)/MINI
  #
  # @author Hauke Petersen <hauke.petersen@fu-berlin.de>
  # @author Oliver Hahm <oliver.hahm@inria.fr>
  
  OS=`uname`
  DID_MOUNT=false
  NAME="MINI"
  
  # set the mount path depending on the OS
  if [ ${OS} = "Linux" ]
  then
      MOUNT=/media/${USER}/${NAME}
  elif [ ${OS} = "Darwin" ]
  then
      MOUNT=/Volumes/${NAME}
  else
      echo ""
      echo "ERROR: No mount point defined for your OS"
      echo "Please copy the binary manually to your Calliope mini"
      echo ""
      exit
  fi
  
  # check if device was mounted
  mount | grep ${MOUNT} > /dev/null
  if [ $? -eq 1 ]
  then
      mount ${MOUNT}
      if [ $? -eq 1 ]
      then
          echo ""
          echo "ERROR: could not mount your Calliope mini"
          echo ""
          exit
      else
          DID_MOUNT=true
      fi
  fi
  
  # copy new binary to device
  cp ${HEXFILE} ${MOUNT}
  # make sure hexfile was written
  sync
  
  # unmount the device if we have manually mounted it before
  if [ ${DID_MOUNT} = true ]
  then
      umount ${MOUNT}
  fi
  
  echo ""
  echo "UPLOAD SUCCESFUL"
  echo ""