Zybo.Tool 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. (*
  2. The following build commands assumes that the ARM folder is reachable from the search path.
  3. If this is not the case replace all ARM/ by full qualified path to folder ARM/
  4. *)
  5. (* Execute this command to use 1920 x 1080 @ 40 Hz display settings *)
  6. FSTools.CreateFile -c -r Zybo.DisplayLinear.Replacements.tmp
  7. DisplayLinear.Width = 1920;
  8. DisplayLinear.Height = 1080;
  9. DisplayLinear.PlClkDiv0 = 10;
  10. DisplayLinear.PlClkDiv1 = 10;
  11. DisplayLinear.PlClkDiv2 = 2;
  12. DisplayLinear.HorizFrontPorch = 88;
  13. DisplayLinear.HorizSyncWidth = 44;
  14. DisplayLinear.HorizBackPorch = 148;
  15. DisplayLinear.HorizSyncPolarity = TRUE;
  16. DisplayLinear.VertFrontPorch = 36;
  17. DisplayLinear.VertSyncWidth = 5;
  18. DisplayLinear.VertBackPorch = 4;
  19. DisplayLinear.VertSyncPolarity = TRUE;
  20. ~
  21. (* Execute this command to use 1024 x 768 @ 62 Hz display settings *)
  22. FSTools.CreateFile -c -r Zybo.DisplayLinear.Replacements.tmp
  23. DisplayLinear.Width = 1024;
  24. DisplayLinear.Height = 768;
  25. DisplayLinear.PlClkDiv0 = 10;
  26. DisplayLinear.PlClkDiv1 = 15;
  27. DisplayLinear.PlClkDiv2 = 3;
  28. DisplayLinear.HorizFrontPorch = 24;
  29. DisplayLinear.HorizSyncWidth = 136;
  30. DisplayLinear.HorizBackPorch = 160;
  31. DisplayLinear.HorizSyncPolarity = TRUE;
  32. DisplayLinear.VertFrontPorch = 3;
  33. DisplayLinear.VertSyncWidth = 6;
  34. DisplayLinear.VertBackPorch = 29;
  35. DisplayLinear.VertSyncPolarity = TRUE;
  36. ~
  37. (* Execute this command to use 800 x 480 @ 65 Hz display settings *)
  38. FSTools.CreateFile -c -r Zybo.DisplayLinear.Replacements.tmp
  39. DisplayLinear.Width = 800;
  40. DisplayLinear.Height = 480;
  41. DisplayLinear.PlClkDiv0 = 10;
  42. DisplayLinear.PlClkDiv1 = 30;
  43. DisplayLinear.PlClkDiv2 = 6;
  44. DisplayLinear.HorizFrontPorch = 40;
  45. DisplayLinear.HorizSyncWidth = 48;
  46. DisplayLinear.HorizBackPorch = 88;
  47. DisplayLinear.HorizSyncPolarity = TRUE;
  48. DisplayLinear.VertFrontPorch = 13;
  49. DisplayLinear.VertSyncWidth = 3;
  50. DisplayLinear.VertBackPorch = 32;
  51. DisplayLinear.VertSyncPolarity = TRUE;
  52. ~
  53. System.DoCommands
  54. (* 1. Mount Filesystems *)
  55. FSTools.Mount MINOS RelativeFileSystem ARM/Minos~
  56. FSTools.Mount ENET RelativeFileSystem ARM/Enet~
  57. FSTools.Mount ZBL RelativeFileSystem ARM/zbl~
  58. FSTools.Mount ZYNQ RelativeFileSystem ARM/ARM.A2 ~
  59. FSTools.Mount USB RelativeFileSystem ARM/USB ~
  60. (* Cleanup bootloader-specific files *)
  61. FSTools.DeleteFiles WORK:*.Syb WORK:*.arm WORK:Init.Bin WORK:Zbl.Bin WORK:BOOT.BIN ~
  62. (*
  63. Build everything required for the bootloader
  64. *)
  65. (* 2. Build Host Tools *)
  66. (* 2.1. Compilation Tools *)
  67. Compiler.Compile --mergeSections
  68. ZBL:/tools/ZynqTools.Mod
  69. MinosLinker.Mod
  70. ~
  71. (* 2.2. Command Tools *)
  72. Compiler.Compile --mergeSections
  73. TFTPServer.Mod
  74. ZBL:/tools/BlCommands.Mod
  75. ZBL:/tools/BlTools.Mod
  76. ~
  77. (* 3. Compile Bootloader
  78. The bootloader is composed of 3 parts:
  79. - the bootstrap image, which will load the actual bootloader application
  80. - the bootloader core, which implements the command mechanism
  81. - additional feature modules, which implement transfer protocols, programming destinations and checksum algorithms
  82. *)
  83. (* 3.2. Build Bootstrap Image *)
  84. (* The first step does not depend on the board. *)
  85. Compiler.Compile -p=ARMA2 --metaData=simple
  86. ZBL:/Boot.Mos
  87. ~
  88. Linker.Link --fileName=Init.Bin --displacement=0H -a
  89. Boot
  90. ~
  91. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=Bootstrap Zybo ~
  92. MinosLinker.Link Init.Bin 0H Zbl.Bin
  93. Platform Board TclInit ZynqInitializer FPE64 Builtins PsUartMin Trace TraceDevice Caches Memory
  94. MemoryMapping Interrupts Bit Clocks KernelUtils GlobalTimer Kernel Utils Strings Heaps OFS Modules
  95. SdEnvironment Sd Disks SdDisks SdControllers OFSDiskVolumes Bootstrap ~
  96. ZynqTools.GenerateBootROM Zbl.Bin ~
  97. (* 3.3. Build Bootloader Core *)
  98. Release.Build -f=ZBL:/BootloaderRelease.Tool --build --only='EnetMinos Enet Bootloader' Zybo ~
  99. (* 3.4. Build Additional Features *)
  100. (* Additional packages give more features to the bootloader. Available packages: *)
  101. (* o A2 Boot Configuration Programmer *)
  102. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=A2ConfigProgrammer Zybo ~
  103. (* o TFTP Loader *)
  104. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=TFTPLoader Zybo ~
  105. (* o XMODEM loader *)
  106. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=XModemLoader Zybo ~
  107. (* o ZYNQ-7000 FPGA Programmer *)
  108. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=ZynqFpgaProgrammer Zybo ~
  109. (* o MD5 Checksum *)
  110. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=MD5Checksum Zybo ~
  111. (*
  112. Build everything required for the A2 on Zynq
  113. *)
  114. FSTools.CreateDirectory build/ ~
  115. FSTools.DeleteFiles build/* ~
  116. Release.Build -b --path='build/' -f=ZYNQ:/ARM.Release.Tool
  117. -o='--mergeSections --traceModule=Trace --noInitLocals --useFPU64' --only=Kernel
  118. ZynqDynamic
  119. ~
  120. Release.Build -b --path='build/' -f=ZYNQ:/ARM.Release.Tool --only='System SD BootConsole' ZynqDynamic ~
  121. Release.Build -b -z --path='build/' -f=ZYNQ:/ARM.Release.Tool
  122. --only='System SystemExt FpgaDisplay Kernel Math SD Shell SystemTools Usb DMA FS Profiler Crypto GUI Compiler Archives Gfx'
  123. --exclude="Network Enet Inga" ZynqDynamic ~
  124. Compiler.Compile -p=ARMA2 --mergeSections --useFPU64 --replacements=Zybo.DisplayLinear.Replacements.tmp --destPath='build/'
  125. ZYNQ:/Zynq.DisplayLinear.Mod
  126. ~
  127. Linker.Link --fileName=A2.Bin --displacement=100000H -a --path=build/
  128. Runtime Initializer Platform FPE64 Builtins Trace BootConfig PsUartMin PsUart TraceDevice PrivateWatchdog Machine Heaps Modules Objects Kernel KernelLog Plugins
  129. Streams Pipes Commands Reals Clock Dates Strings Files Disks Reflection TrapWriters Traps Locks Options PsConfig SdEnvironment
  130. Sd SdDisks SdControllers Caches DiskVolumes DiskFS BitSets StringPool ObjectFile Diagnostics GenericLinker Loader
  131. BootConsole ~
  132. (* ShellController Shell Displays AcAxisIo StreamVideoOut AxiDma DisplayLinear UTF8Strings CLUTs Raster WMRectangles
  133. WMRasterScale SoundDevices Configuration XMLObjects XML DynamicStrings XMLScanner XMLParser Inflate CRC Unzip FP1616 WMEvents
  134. Texts Archives Codecs WMGraphics WMDefaultFont WMFontManager OpenTypeInt OpenTypeScan OpenType WMOTFonts WMBitmapFont WMOberonFonts
  135. Debugging WMMessages WMWindowManager Inputs WMGraphicUtilities WMDefaultWindows WindowManager PNGDecoder SystemTools ProcessInfo
  136. ProcessInfo0 SystemVersion Localization Repositories UnicodeProperties TextUtilities Types Models WMProperties Events WMDropTarget
  137. WMComponents WMStandardComponents WMTrees WMMenus IngaObjects IngaContexts WMRestorable IngaViews Math GfxMatrix GfxPaths
  138. GfxRegions GfxImages GfxFonts Gfx GfxRaster GfxBuffer IngaContexts2d IngaImshow Random MathL FoxArrayBase IngaArrays IngaLine
  139. Buffers IngaRealTimePlot IngaLinePlot IngaExampleLayer ComponentViewer IngaScale FSTools WMTabComponents MainMenu ~ *)
  140. (* 5. Preparing the Boot SD Card*)
  141. (* The installation is done in a virtual disk that will be copied to the SD card: *)
  142. VirtualDisks.Create build/Zybo.ZynqA2.img 819200 512 ~
  143. VirtualDisks.Install -b=512 VDISK0 build/Zybo.ZynqA2.img ~
  144. (* First we create the 2 partitions needed by the bootloader: *)
  145. Partitions.WriteMBR VDISK0#0 BootManagerMBR.Bin BootManagerTail.Bin ~
  146. Partitions.Create VDISK0#1 11 64 ~
  147. Partitions.Create VDISK0#2 76 64 ~
  148. Partitions.Format VDISK0#1 FatFS Quick ~
  149. Partitions.Format VDISK0#2 AosFS ~
  150. (* Then we install the bootloader: *)
  151. FSTools.Mount BLFATFS FatFS VDISK0#1 ~
  152. FSTools.Mount BLAOSFS AosFS VDISK0#2 ~
  153. (* Copy Bootstrap Image *)
  154. FSTools.CopyFiles -o WORK:/BOOT.BIN => BLFATFS:/BOOT.BIN ~
  155. (* Copy the bootloader core: *)
  156. FSTools.CopyTo BLAOSFS:/ WORK:/
  157. Bootloader.arm Checksum.arm Enet.arm EnetArp.arm EnetBase.arm EnetEmacPs7.arm EnetEnvironment.arm EnetIcmp.arm
  158. EnetInterfaces.arm EnetPhy.arm EnetStreams.arm EnetTftp.arm EnetTiming.arm EnetTrace.arm EnetUdp.arm EnetUdpChannels.arm
  159. EnetUtils.arm Loader.arm Programmer.arm StreamReaders.arm StreamWriters.arm PsUartInterrupts.arm PsUart.arm UncachedHeap.arm
  160. OFSStreams.arm PrivateWatchdog.arm XModem.arm XModemLoader.arm
  161. ~
  162. (* Boot configuration for the specific hardware *)
  163. FSTools.CopyFiles -o ARM/Zybo.bootconfig.txt => BLAOSFS:bootconfig ~
  164. (* Copy additionnal bootloader packages: *)
  165. (* o TFTP: *) FSTools.CopyTo BLAOSFS:/ WORK:/ TFTPLoader.arm ~
  166. (* o ZYNQ-7000 FPGA Programmer: *) FSTools.CopyTo BLAOSFS:/ WORK:/ ZynqFpgaProgrammer.arm ~
  167. (* o MD5 Checksum: *) FSTools.CopyTo BLAOSFS:/ WORK:/ MD5.arm MD5Checksum.arm ~
  168. (* o A2ConfigProgrammer: *) FSTools.CopyTo BLAOSFS:/ WORK:/ A2ConfigProgrammer.arm ~
  169. (* Setup bootloader initialization script *)
  170. FSTools.CreateFile BLAOSFS:/init.txt netstart 10.3.34.8 255.255.255.0 0.0.0.0
  171. timeout 1
  172. setinput UDP
  173. ~
  174. (* Setup bootloader auto script *)
  175. FSTools.CreateFile BLAOSFS:/auto.txt deploy bs ZynqFpga
  176. deploy bootconfig A2Config
  177. deploy a2 memory 100000H 0 1
  178. start
  179. ~
  180. FSTools.CopyFiles
  181. WORK:/A2.Bin => BLAOSFS:/a2
  182. ZYNQ:Zybo.TestVideoOut.bin => BLAOSFS:/bs
  183. ~
  184. FSTools.Unmount BLFATFS ~
  185. FSTools.Unmount BLAOSFS ~
  186. (* Now we create a partition for A2 itself: *)
  187. Partitions.Create VDISK0#3 76 256 ~
  188. Partitions.Format VDISK0#3 AosFS ~
  189. FSTools.Mount ZYNQA2 AosFS VDISK0#3 ~
  190. ZipTool.ExtractAll --prefix=ZYNQA2: --sourcePath=build/ --overwrite --silent
  191. BootConsole.zip DMA.zip FpgaDisplay.zip FS.zip Kernel.zip Math.zip
  192. SD.zip Shell.zip System.zip SystemExt.zip SystemTools.zip Usb.zip
  193. Profiler.zip GUI.zip Gfx.zip Crypto.zip
  194. Compiler.zip PET.zip Zip.zip
  195. ~
  196. FSTools.CopyFiles -o
  197. build/DisplayLinear.Gof => ZYNQA2:/DisplayLinear.Gof
  198. build/DisplayLinear.Sym => ZYNQA2:/DisplayLinear.Sym
  199. ~
  200. FSTools.Unmount ZYNQA2 ~
  201. VirtualDisks.Uninstall VDISK0 ~
  202. System.Show 'Zybo Zynq A2 image has been built!' ~
  203. FSTools.CloseFiles build/Zybo.ZynqA2.img ~
  204. ~
  205. #
  206. # Copy all release files to already existing partitions on SD card
  207. #
  208. WinDisks.Install E: RW ~
  209. VirtualDisks.Install -b=512 VDISK0 build/Zybo.ZynqA2.img ~
  210. System.DoCommands
  211. FSTools.Mount BOOT FatFS VDISK0#1 ~
  212. FSTools.Mount BL AosFS VDISK0#2 ~
  213. FSTools.Mount AOS AosFS VDISK0#3 ~
  214. FSTools.Mount SDBOOT FatFS PhysicalDrive1#1 ~
  215. FSTools.Mount SDBL AosFS PhysicalDrive1#2 ~
  216. FSTools.Mount SDAOS AosFS PhysicalDrive1#3 ~
  217. FSTools.CopyFiles -o BOOT:*.* => SDBOOT:*.* ~
  218. FSTools.CopyFiles -o BL:*.* => SDBL:*.* ~
  219. FSTools.CopyFiles -o AOS:*.* => SDAOS:*.* ~
  220. FSTools.Unmount BOOT ~
  221. FSTools.Unmount BL ~
  222. FSTools.Unmount AOS ~
  223. FSTools.Unmount SDBOOT ~
  224. FSTools.Unmount SDBL ~
  225. FSTools.Unmount SDAOS ~
  226. (* this is to uninstall Zynq A2 image *)
  227. VirtualDisks.Uninstall VDISK0 ~
  228. WinDisks.Uninstall "PhysicalDrive1" ~
  229. ~
  230. #
  231. # !!! Write the whole release image to SD card !!!
  232. # !!! MAKE SURE THE RIGHT PhysicalDriveX IS USED !!!
  233. #
  234. Partitions.FileToPartition PhysicalDrive1#0 build/Zybo.ZynqA2.img 0 819200 ~
  235. #
  236. # Compiler options for ARM
  237. #
  238. -p=ARMA2 --mergeSections --useFPU64 --destPath='build/'