1
0

gen_bin.sh 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. ##
  2. ## Copyright (c) 2014 Minoca Corp.
  3. ##
  4. ## This file is licensed under the terms of the GNU General Public License
  5. ## version 3. Alternative licensing terms are available. Contact
  6. ## info@minocacorp.com for details. See the LICENSE file at the root of this
  7. ## project for complete licensing information..
  8. ##
  9. ## Script Name:
  10. ##
  11. ## gen_bin.sh
  12. ##
  13. ## Abstract:
  14. ##
  15. ## This script generates the distributed image archive containing Qemu,
  16. ## the image, the debugger, and symbols.
  17. ##
  18. ## Author:
  19. ##
  20. ## Evan Green 9-Sep-2014
  21. ##
  22. ## Environment:
  23. ##
  24. ## Build
  25. ##
  26. set -e
  27. if test -z "$SRCROOT"; then
  28. echo "Error: SRCROOT must be set."
  29. exit 1
  30. fi
  31. if test -z "$ARCH"; then
  32. echo "Error: ARCH must be set."
  33. exit 1
  34. fi
  35. BINROOT=$SRCROOT/${ARCH}${VARIANT}dbg/bin
  36. if ! test -d $BINROOT; then
  37. echo "Error: BINROOT '$BINROOT' does not exist."
  38. exit 1
  39. fi
  40. if ! test -f $BINROOT/build-revision; then
  41. echo "Error: '$BINROOT/build-revision' is missing."
  42. exit 1
  43. fi
  44. REVISION=`cat $BINROOT/build-revision`
  45. if test -z "$REVISION"; then
  46. echo "Error: $BINROOT/build-revision is empty."
  47. exit 1
  48. fi
  49. cd $BINROOT
  50. ARCHIVE_DIRECTORY="MinocaOS-Starter-$REVISION"
  51. WORKING="$BINROOT/$ARCHIVE_DIRECTORY"
  52. if test -d "$WORKING"; then
  53. echo "Error: $WORKING already exists. Clean it up first."
  54. exit 1
  55. fi
  56. ARCHIVE="MinocaOS-Starter-$REVISION.zip"
  57. if test -f "$ARCHIVE"; then
  58. echo "Error: '$ARCHIVE' already exists. Delete it first."
  59. exit 1
  60. fi
  61. FILES=`echo *`
  62. mkdir -p $WORKING
  63. ##
  64. ## Copy Qemu.
  65. ##
  66. if test "x$ARCH$VARIANT" = "xx86"; then
  67. cp -Rv $SRCROOT/tools/win32/qemu-0.13.0-windows $WORKING
  68. mv $WORKING/qemu-0.13.0-windows $WORKING/Qemu
  69. rm -rf "$WORKING/Qemu/bin"
  70. rm -f "$WORKING/Qemu/stderr.txt" "$WORKING/Qemu/stdout.txt"
  71. elif test "x$ARCH" = "xarmv7"; then
  72. cp -Rv "$SRCROOT/tools/win32/qemu-2.0.0" "$WORKING/Qemu"
  73. rm -f "$WORKING/Qemu/stderr.txt" "$WORKING/Qemu/stdout.txt"
  74. fi
  75. ##
  76. ## Copy the debugger (always from x86).
  77. ##
  78. mkdir -p $WORKING/Minoca/Debug
  79. OLDPWD="$PWD"
  80. cd "$SRCROOT/x86$DEBUG/bin"
  81. for file in debugui.exe debug.exe kexts.dll dbgext.a; do
  82. cp -pv ./$file "$WORKING/Minoca/Debug/"
  83. done
  84. cp -pv "$SRCROOT/os/include/minoca/debug/dbgext.h" "$WORKING/Minoca/Debug"
  85. cd "$OLDPWD"
  86. ##
  87. ## Copy the images.
  88. ##
  89. mkdir -p $WORKING/Minoca/Image
  90. if test "x$ARCH" = "xx86"; then
  91. cp -pv ./pc.img "$WORKING/Minoca/Image"
  92. elif test "x$ARCH" = "xarmv7"; then
  93. cp -pv ./integ.img "$WORKING/Minoca/Image"
  94. elif test "x$ARCH" = "xarmv6"; then
  95. cp -pv ./rpi.img "$WORKING/Minoca/Image"
  96. fi
  97. ##
  98. ## Copy the symbols.
  99. ##
  100. REMOVE='apps*
  101. dep
  102. skel
  103. Python*
  104. *.img
  105. *.vmdk
  106. pagefile.sys
  107. *.zip
  108. tools
  109. client.py
  110. packages'
  111. for file in $REMOVE; do
  112. FILES=`echo $FILES | sed s/$file//`
  113. done
  114. mkdir -p $WORKING/Minoca/Symbols
  115. cp -pv -- $FILES $WORKING/Minoca/Symbols
  116. ##
  117. ## Copy win32 disk imager.
  118. ##
  119. cp -Rv $SRCROOT/tools/win32/Win32DiskImager $WORKING
  120. ##
  121. ## Add the readme file.
  122. ##
  123. DATE=`date "+%B %d, %Y"`
  124. echo "Minoca OS Revision $REVISION.
  125. Created: $DATE
  126. Architecture: $ARCH
  127. Flavor: $DEBUG" > $WORKING/readme.txt
  128. cat >> $WORKING/readme.txt <<"_EOF"
  129. Website: www.minocacorp.com
  130. Contact Minoca at: info@minocacorp.com
  131. Minoca OS is a leading-edge, highly customizable, general purpose operating
  132. system. It features application level functionality such as virtual memory,
  133. networking, and POSIX compatibility, but at a significantly reduced image and
  134. memory footprint. Unique development, debugging, and real-time profiling tools
  135. make getting to the bottom of issues straightforward and easy. Direct support
  136. from the development team behind Minoca OS simplifies the process of creating
  137. OS images tailored to your application, saving on engineering resources and
  138. development time. Minoca OS is a one-stop shop for systems-level design.
  139. For a more detailed getting started guide, head to
  140. http://www.minocacorp.com/documentation/getting-started
  141. Installation
  142. ============
  143. This archive requires no installation. Extract the contents of the downloaded
  144. zip archive to the directory of your choice.
  145. Running Minoca OS under Qemu
  146. ============================
  147. On x86 or ARMv7 builds, double click run.bat to start up Qemu with MinocaOS.
  148. A kernel debugger will also start and connect to the Qemu instance via a named
  149. pipe. By default, the emulator starts with 256MB of RAM and networking enabled.
  150. Feel free to edit run.bat to change these parameters. Try breaking into the
  151. debugger by hitting Control+B. Type "k" to see the call stack where you broke
  152. in, and "g" to let the system go again. The "help" command provides an overview
  153. of debugger commands, or see the started page at:
  154. http://www.minocacorp.com/documentation/getting-started
  155. For ARMv6 builds, the provided rpi.img must be built and run on a Raspberry Pi.
  156. Running on real hardware
  157. ========================
  158. To run Minoca OS on a supported board, you'll need to write the MinocaOS
  159. image out to a USB flash drive or SD card. The drive must be at least 1GB in
  160. size.
  161. * Open up the Win32 Disk Imager tool included in the archive under
  162. Win32DiskImager\Win32DiskImager.exe
  163. * In the Disk Imager application, Select the image to write out by clicking
  164. the folder icon or typing in the path manually. The image will be located
  165. within the directory you unpacked the archive to. For x86 images, the
  166. location within the archive is Minoca\Image\pc.img. For the Raspberry Pi,
  167. it is Minoca\Image\rpi.img.
  168. * Plug in a USB stick or SD card that's at least 1GB in size and select the
  169. drive letter for that stick in the Device dropdown of the Disk Imager app.
  170. Since the image comes with a pre-formatted file system, only 1GB of the USB
  171. stick will be accessible even if the stick itself is larger than 1GB. This
  172. is normal.
  173. * Make ABSOLUTELY SURE you've selected the correct drive, as ALL DATA ON THE
  174. DRIVE WILL BE LOST.
  175. * Select "Write" to write the disk image out to the USB drive, and wait for
  176. it to complete.
  177. * For USB disks on the Gizmo 2 board, make sure to plug the USB stick into
  178. one of the black USB ports (not the blue ones). Keyboards must also be
  179. plugged into the black ports, and MUST BE PLUGGED IN BEHIND A HUB.
  180. (We haven't built OHCI yet).
  181. * For the Raspberry Pi, only SD boot is supported.
  182. * If the image was written successfully, the screen will clear to green, and
  183. you will be presented with a shell prompt. Good luck.
  184. License
  185. =======
  186. The contents of this archive are licensed under the GNU General Public License
  187. version 3.
  188. Troubleshooting
  189. ===============
  190. If you're having trouble getting up and running, definitely check out the
  191. getting started page at http://www.minocacorp.com/documentation/getting-started.
  192. It walks through these steps and more in great detail. If your question is
  193. answered neither here nor at the getting started page, feel free to shoot us an
  194. email at info@minocacorp.com.
  195. Q: When I double click run.bat, I get the message "Windows cannot find
  196. '.\Qemu\qemu.exe'. Make sure you typed the name correctly, and then try
  197. again".
  198. A: Make sure the downloaded zip file has been extracted, you cannot just double
  199. click into the archive and run it from there. Right click the zip file you
  200. downloaded, and select "Extract All". Then navigate into the directory that
  201. was created and try double-clicking run.bat again.
  202. Q: MinocaOS used to boot, but now it's breaking into the debugger when I start
  203. up, and printing menacing messages.
  204. A: It's possible that the file system was left in an inconsistent state after
  205. being unexpectedly shut down. Before turning off the simulator or system,
  206. make sure that the first number next to "Cache:" in the top banner is zero
  207. (this is the "dirty" page count). If you've corrupted your image, you'll
  208. need to re-download it and restore the original Minoca/Image/pc.img from the
  209. download.
  210. Q: The Gizmo 2 screen turns green and the OS statistics banner displays, but I
  211. never get a command prompt.
  212. A: Make sure your USB stick is plugged into one of the black USB ports
  213. (underneath the ethernet port). The blue USB 3.0 ports are not yet supported
  214. on Minoca OS.
  215. Q: Why does the debugger complain that my symbol timestamps are mismatched?
  216. A: If you used the built-in zip extraction in Windows 7 and later, then all the
  217. extracted file timestamps get reset. Don't worry, all the symbols still
  218. match up and you can debug as expected. If you don't like the prints,
  219. extract the zip archive with a more sophisticated tool like 7za.
  220. Q: I'm getting a "Fatal System Error" or "Assertion failure". What do I do?
  221. A: Please file a bug with us indicating the message and debugger output. If
  222. you're able to reproduce this issue consistently, make sure to include those
  223. steps needed to reproduce the issue.
  224. Q: When I break into the debugger, I get warnings about mismatching timestamps
  225. that read "Warning: Target timestamp for kernel is Thu Feb 19
  226. 23:38:36 2015 but file '.\Minoca\Symbols/kernel' has timestamp Fri Feb 20
  227. 11:17:46 2015."
  228. A: These warnings are safe to ignore. The default Windows archive extraction
  229. modifies the timestamps on the unzipped files (i.e. Right-Click -> Extract
  230. All). If you'd like to remove them, try a different extraction method; 7-zip
  231. works for us.
  232. _EOF
  233. ##
  234. ## Add the one-click script.
  235. ##
  236. if test "x$ARCH" = "xx86"; then
  237. QEMU_IMAGE=".\\Minoca\\Image\\pc.img"
  238. elif test "x$ARCH" = "xarmv7"; then
  239. QEMU_IMAGE=".\\Minoca\\Image\\integ.img"
  240. fi
  241. if test "$QEMU_IMAGE"; then
  242. cat > $WORKING/run.bat <<_EOF
  243. rem Fire up Qemu, which will hang invisibly waiting for something to connect
  244. rem on its named pipe.
  245. start .\\Qemu\\qemu.exe -L .\\Qemu -m 256 -hda $QEMU_IMAGE -serial pipe:minocapipe -net nic,model=i82559er -net user
  246. rem Fire up the debugger to connect to the named pipe, and we're off to the
  247. rem races. The -s parameter sets the symbol path, -e loads handy debugger
  248. rem extensions (type ! for help), and -k creates a kernel connection to the
  249. rem named pipe. Remember, for the GUI version of the debugger, use Ctrl+B to
  250. rem break in.
  251. .\\Minoca\\Debug\\debugui.exe -s .\\Minoca\\Symbols -e .\\Minoca\\debug\\kexts.dll -k \\\\.\\pipe\\minocapipe
  252. _EOF
  253. fi
  254. ##
  255. ## Add the files to the archive.
  256. ##
  257. echo "Creating archive..."
  258. 7za a -tzip -mx9 -mmt -mtc "$ARCHIVE" "$ARCHIVE_DIRECTORY"
  259. echo "Successfully created $ARCHIVE"
  260. rm -rf "$ARCHIVE_DIRECTORY"