Zybo.Tool 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. FSTools.CreateDirectory build/ ~
  61. ~
  62. System.DoCommands
  63. (* Cleanup bootloader-specific files *)
  64. FSTools.DeleteFiles -i -s WORK:*.Syb WORK:*.arm WORK:Init.Bin WORK:Zbl.Bin WORK:BOOT.BIN ~
  65. (*
  66. Build everything required for the bootloader
  67. *)
  68. (* 2. Build Host Tools *)
  69. (* 2.1. Compilation Tools *)
  70. Compiler.Compile --mergeSections
  71. ZBL:/tools/ZynqTools.Mod
  72. MinosLinker.Mod
  73. ~
  74. (* 2.2. Command Tools *)
  75. Compiler.Compile --mergeSections
  76. TFTPServer.Mod
  77. ZBL:/tools/BlCommands.Mod
  78. ZBL:/tools/BlTools.Mod
  79. ~
  80. (* 3. Compile Bootloader
  81. The bootloader is composed of 3 parts:
  82. - the bootstrap image, which will load the actual bootloader application
  83. - the bootloader core, which implements the command mechanism
  84. - additional feature modules, which implement transfer protocols, programming destinations and checksum algorithms
  85. *)
  86. (* 3.2. Build Bootstrap Image *)
  87. (* The first step does not depend on the board. *)
  88. Compiler.Compile -p=ARMA2 --metaData=simple
  89. ZBL:/Boot.Mos
  90. ~
  91. Linker.Link --fileName=Init.Bin --displacement=0H -a
  92. Boot
  93. ~
  94. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=Bootstrap Zybo ~
  95. MinosLinker.Link Init.Bin 0H Zbl.Bin
  96. Platform Board TclInit ZynqInitializer FPE64 Builtins PsUartMin Trace TraceDevice Caches Memory
  97. MemoryMapping Interrupts Bit Clocks KernelUtils GlobalTimer Kernel Utils Strings Heaps OFS Modules
  98. SdEnvironment Sd Disks SdDisks SdControllers OFSDiskVolumes Bootstrap ~
  99. ZynqTools.GenerateBootROM Zbl.Bin ~
  100. (* 3.3. Build Bootloader Core *)
  101. Release.Build -f=ZBL:/BootloaderRelease.Tool --build --only='EnetMinos Enet Bootloader' Zybo ~
  102. (* 3.4. Build Additional Features *)
  103. (* Additional packages give more features to the bootloader. Available packages: *)
  104. (* o A2 Boot Configuration Programmer *)
  105. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=A2ConfigProgrammer Zybo ~
  106. (* o TFTP Loader *)
  107. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=TFTPLoader Zybo ~
  108. (* o XMODEM loader *)
  109. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=XModemLoader Zybo ~
  110. (* o ZYNQ-7000 FPGA Programmer *)
  111. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=ZynqFpgaProgrammer Zybo ~
  112. (* o MD5 Checksum *)
  113. Release.Build -b -f=ZBL:/BootloaderRelease.Tool --only=MD5Checksum Zybo ~
  114. (*
  115. Build everything required for the A2 on Zynq
  116. *)
  117. FSTools.DeleteFiles -i -s build/* ~
  118. Release.Build -b --path='build/' ZynqKernel ~
  119. Release.Build -b -z --path='build/' --only='System Drivers Compiler ApplicationsMini Applications GuiApplicationsMini GuiApplications TrueTypeFonts' Zynq ~
  120. Compiler.Compile -p=ARMA2 --mergeSections --useFPU64 --replacements=Zybo.DisplayLinear.Replacements.tmp --destPath='build/'
  121. Zynq.DisplayLinear.Mod
  122. ~
  123. (* Link A2 kernel *)
  124. Linker.Link --fileName=A2.Bin --displacement=100000H -a --path=build/
  125. Initializer Platform FPE64 Builtins Trace BootConfig PsUartMin TraceDevice PrivateWatchdog Machine Heaps Modules Objects Kernel KernelLog Plugins
  126. Streams Pipes Commands Reals Clock Dates Strings Files Disks DiskCaches Reflection TrapWriters Traps Locks Options PsConfig SdEnvironment
  127. Sd SdDisks SdControllers Caches DiskVolumes DiskFS BitSets StringPool ObjectFile Diagnostics GenericLinker Loader
  128. BootConsole
  129. ~
  130. (* 5. Preparing the Boot SD Card*)
  131. (* The installation is done in a virtual disk that will be copied to the SD card: *)
  132. VirtualDisks.Create build/Zybo.ZynqA2.img 819200 512 ~
  133. VirtualDisks.Install -b=512 VDISK0 build/Zybo.ZynqA2.img ~
  134. (* First we create the 2 partitions needed by the bootloader: *)
  135. Partitions.WriteMBR VDISK0#0 BootManagerMBR.Bin BootManagerTail.Bin ~
  136. Partitions.Create VDISK0#1 11 64 ~
  137. Partitions.Create VDISK0#2 76 64 ~
  138. Partitions.Format VDISK0#1 FatFS Quick ~
  139. Partitions.Format VDISK0#2 AosFS ~
  140. (* Then we install the bootloader: *)
  141. FSTools.Mount BLFATFS FatFS VDISK0#1 ~
  142. FSTools.Mount BLAOSFS AosFS VDISK0#2 ~
  143. (* Copy Bootstrap Image *)
  144. FSTools.CopyFiles -o WORK:/BOOT.BIN => BLFATFS:/BOOT.BIN ~
  145. (* Copy the bootloader core: *)
  146. FSTools.CopyTo BLAOSFS:/ WORK:/
  147. Bootloader.arm Checksum.arm Enet.arm EnetArp.arm EnetBase.arm EnetEmacPs7.arm EnetEnvironment.arm EnetIcmp.arm
  148. EnetInterfaces.arm EnetPhy.arm EnetStreams.arm EnetTftp.arm EnetTiming.arm EnetTrace.arm EnetUdp.arm EnetUdpChannels.arm
  149. EnetUtils.arm Loader.arm Programmer.arm StreamReaders.arm StreamWriters.arm PsUartInterrupts.arm PsUart.arm UncachedHeap.arm
  150. OFSStreams.arm PrivateWatchdog.arm XModem.arm XModemLoader.arm
  151. ~
  152. (* Boot configuration for the specific hardware *)
  153. FSTools.CopyFiles -o ARM/Zybo.bootconfig.txt => BLAOSFS:bootconfig ~
  154. (* Copy additionnal bootloader packages: *)
  155. (* o TFTP: *) FSTools.CopyTo BLAOSFS:/ WORK:/ TFTPLoader.arm ~
  156. (* o ZYNQ-7000 FPGA Programmer: *) FSTools.CopyTo BLAOSFS:/ WORK:/ ZynqFpgaProgrammer.arm ~
  157. (* o MD5 Checksum: *) FSTools.CopyTo BLAOSFS:/ WORK:/ MD5.arm MD5Checksum.arm ~
  158. (* o A2ConfigProgrammer: *) FSTools.CopyTo BLAOSFS:/ WORK:/ A2ConfigProgrammer.arm ~
  159. (* Setup bootloader initialization script *)
  160. FSTools.CreateFile BLAOSFS:/init.txt timeout 3
  161. setinput UART
  162. ~
  163. (* Setup bootloader auto script *)
  164. FSTools.CreateFile BLAOSFS:/auto.txt deploy bs ZynqFpga
  165. deploy bootconfig A2Config
  166. deploy a2 memory 100000H 0 1
  167. start
  168. ~
  169. FSTools.CopyFiles
  170. WORK:/A2.Bin => BLAOSFS:/a2
  171. ZYNQ:Zybo.TestVideoOut.bin => BLAOSFS:/bs
  172. ~
  173. FSTools.Unmount BLFATFS ~
  174. FSTools.Unmount BLAOSFS ~
  175. (* Now we create a partition for A2 itself: *)
  176. Partitions.Create VDISK0#3 76 256 ~
  177. Partitions.Format VDISK0#3 AosFS ~
  178. FSTools.Mount ZYNQA2 AosFS VDISK0#3 ~
  179. ZipTool.ExtractAll --prefix=ZYNQA2: --sourcePath=build/ --overwrite --silent
  180. System.zip Drivers.zip Compiler.zip ApplicationsMini.zip Applications.zip GuiApplicationsMini.zip GuiApplications.zip TrueTypeFonts.zip
  181. ~
  182. FSTools.CopyFiles -o
  183. build/DisplayLinear.Gof => ZYNQA2:/DisplayLinear.Gof
  184. build/DisplayLinear.Sym => ZYNQA2:/DisplayLinear.Sym
  185. ~
  186. FSTools.Unmount ZYNQA2 ~
  187. VirtualDisks.Uninstall VDISK0 ~
  188. System.Show 'Zybo Zynq A2 image has been built!' ~
  189. FSTools.CloseFiles build/Zybo.ZynqA2.img ~
  190. ~
  191. #
  192. # Copy all release files to already existing partitions on SD card
  193. #
  194. WinDisks.Install E: RW ~
  195. VirtualDisks.Install -b=512 VDISK0 build/Zybo.ZynqA2.img ~
  196. System.DoCommands
  197. FSTools.Mount BOOT FatFS VDISK0#1 ~
  198. FSTools.Mount BL AosFS VDISK0#2 ~
  199. FSTools.Mount AOS AosFS VDISK0#3 ~
  200. FSTools.Mount SDBOOT FatFS PhysicalDrive1#1 ~
  201. FSTools.Mount SDBL AosFS PhysicalDrive1#2 ~
  202. FSTools.Mount SDAOS AosFS PhysicalDrive1#3 ~
  203. FSTools.CopyFiles -o BOOT:*.* => SDBOOT:*.* ~
  204. FSTools.CopyFiles -o BL:*.* => SDBL:*.* ~
  205. FSTools.CopyFiles -o AOS:*.* => SDAOS:*.* ~
  206. FSTools.Unmount BOOT ~
  207. FSTools.Unmount BL ~
  208. FSTools.Unmount AOS ~
  209. FSTools.Unmount SDBOOT ~
  210. FSTools.Unmount SDBL ~
  211. FSTools.Unmount SDAOS ~
  212. (* this is to uninstall Zynq A2 image *)
  213. VirtualDisks.Uninstall VDISK0 ~
  214. WinDisks.Uninstall "PhysicalDrive1" ~
  215. ~
  216. #
  217. # !!! Write the whole release image to SD card !!!
  218. # !!! MAKE SURE THE RIGHT PhysicalDriveX IS USED !!!
  219. #
  220. Partitions.FileToPartition PhysicalDrive1#0 build/Zybo.ZynqA2.img 0 819200 ~
  221. #
  222. # Compiler options for ARM
  223. #
  224. -p=ARMA2 --mergeSections --useFPU64 --destPath='build/'