runqemu 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #!/bin/bash
  2. # Handle Poky <-> QEmu interface voodoo
  3. #
  4. # Copyright (C) 2006-2007 OpenedHand Ltd.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License version 2 as
  8. # published by the Free Software Foundation.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License along
  16. # with this program; if not, write to the Free Software Foundation, Inc.,
  17. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. if [ "x$BUILDDIR" = "x" ]; then
  19. echo "You need to source poky-init-build-env before running this script"
  20. exit 1
  21. fi
  22. INTERNAL_SCRIPT=`which poky-qemu-internal`
  23. if [ "x$1" = "x" ]; then
  24. echo
  25. echo "Run as $0 MACHINE IMAGETYPE ZIMAGE IMAGEFILE"
  26. echo "where:"
  27. echo " MACHINE - the machine to emulate (qemuarm, qemux86)"
  28. echo " IMAGETYPE - the type of image to run (ext3, nfs) (default: ext3)"
  29. echo " ZIMAGE - the kernel to use (optional)"
  30. echo " IMAGEFILE - the image file/location to use (optional)"
  31. exit 1
  32. else
  33. MACHINE=$1
  34. shift
  35. fi
  36. if [ "x$1" != "x" ]; then
  37. TYPE=$1
  38. shift
  39. else
  40. TYPE="ext3"
  41. if [ "$MACHINE" = "akita" ]; then
  42. TYPE="jffs2"
  43. fi
  44. if [ "$MACHINE" = "nokia800" ]; then
  45. TYPE="jffs2"
  46. fi
  47. if [ "$MACHINE" = "spitz" ]; then
  48. TYPE="ext3"
  49. fi
  50. fi
  51. if [ "x$1" != "x" ]; then
  52. ZIMAGE=$1
  53. shift
  54. fi
  55. if [ "x$1" != "x" ]; then
  56. HDIMAGE=$1
  57. shift
  58. fi
  59. if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "spitz" -o "$MACHINE" = "borzoi" -o "$MACHINE" = "akita" -o "$MACHINE" = "nokia800" ]; then
  60. if [ "x$ZIMAGE" = "x" ]; then
  61. ZIMAGE=$BUILDDIR/tmp/deploy/images/zImage-$MACHINE.bin
  62. fi
  63. CROSSPATH=$BUILDDIR/sysroots/$BUILD_SYS/arm-poky-linux-gnueabi/bin
  64. fi
  65. function findimage {
  66. where=$1
  67. machine=$2
  68. extension=$3
  69. names=$4
  70. for name in $names;
  71. do
  72. fullname=$where/$name-$machine.$extension
  73. if [ -e "$fullname" ]; then
  74. HDIMAGE=$fullname
  75. return
  76. fi
  77. done
  78. echo "Couldn't find image in $where. Attempted image names were:"
  79. for name in $names;
  80. do
  81. echo $name-$machine.$extension
  82. done
  83. exit 1
  84. }
  85. if [ "$MACHINE" = "qemuarm" ]; then
  86. if [ "$TYPE" = "ext3" ]; then
  87. if [ "x$HDIMAGE" = "x" ]; then
  88. T=$BUILDDIR/tmp/deploy/images
  89. findimage $T qemuarm ext3 "poky-image-sdk poky-image-sato poky-image-minimal"
  90. fi
  91. fi
  92. fi
  93. if [ "$MACHINE" = "spitz" ]; then
  94. if [ "$TYPE" = "ext3" ]; then
  95. if [ "x$HDIMAGE" = "x" ]; then
  96. HDIMAGE=$BUILDDIR/tmp/deploy/images/poky-image-sato-spitz.ext3
  97. fi
  98. fi
  99. fi
  100. if [ "$MACHINE" = "akita" ]; then
  101. if [ "$TYPE" = "jffs2" ]; then
  102. if [ "x$HDIMAGE" = "x" ]; then
  103. HDIMAGE=$BUILDDIR/tmp/deploy/images/poky-image-sato-akita.jffs2
  104. fi
  105. fi
  106. fi
  107. if [ "$MACHINE" = "nokia800" ]; then
  108. if [ "$TYPE" = "jffs2" ]; then
  109. if [ "x$HDIMAGE" = "x" ]; then
  110. HDIMAGE=$BUILDDIR/tmp/deploy/images/poky-image-sato-nokia800.jffs2
  111. fi
  112. fi
  113. fi
  114. if [ "$MACHINE" = "qemux86" ]; then
  115. if [ "x$ZIMAGE" = "x" ]; then
  116. ZIMAGE=$BUILDDIR/tmp/deploy/images/bzImage-$MACHINE.bin
  117. fi
  118. if [ "$TYPE" = "ext3" ]; then
  119. if [ "x$HDIMAGE" = "x" ]; then
  120. T=$BUILDDIR/tmp/deploy/images
  121. findimage $T qemux86 ext3 "moblin-image-sdk moblin-image-netbook poky-image-sdk poky-image-sato poky-image-minimal"
  122. fi
  123. fi
  124. CROSSPATH=$BUILDDIR/sysroots/$BUILD_SYS/i586-poky-linux/bin
  125. fi
  126. if [ ! -e $CROSSPATH/cc ]; then
  127. ln -s $CROSSPATH/gcc $CROSSPATH/cc
  128. fi
  129. CROSSPATH=$BUILDDIR/tmp/sysroots/$BUILD_SYS/usr/bin:$CROSSPATH:$BUILDDIR/tmp/cross/bin
  130. . $INTERNAL_SCRIPT