gen_bin.sh 11 KB

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