1 <#
2 .SYNOPSIS
3 Update the ARMv8-A ports from the generic ARMv8-A port.
4
5 .DESCRIPTION
6 Generate ports, examples and tests from common files.
7
8 .EXAMPLE
9 To update the ThreadX ports for the source tree run:
10 pwsh -Command .\update.ps1 -PortSets tx -CopyCommonFiles -CopyPortFiles -CopyExample -PatchFiles
11
12 To update the ThreadX ports for the test tree run:
13 pwsh -Command .\update.ps1 -PortSets tx -CopyCommonFiles -CopyPortFiles -CopyExample -CopyValidationTest -CopyRegressionTest -PatchFiles
14
15 .LINK
16 https://azure.com/rtos
17
18 .NOTES
19 Author: Andres Mlinar
20 Date: 2021
21 #>
22
23 [CmdletBinding(PositionalBinding=$false)] Param(
24
25 [string]
26 #The script root directory, if not specified it defaults to this script's directory
27 $ScriptDir = $PSScriptRoot,
28
29 [Parameter(Mandatory)]
30 [ValidateSet(
31 "tx", "tx_smp",
32 "txm", "txm_smp"
33 )]
34 [string[]]
35 #Specify the flavor or flavors of ThreadX to generate. Options are: tx, tx_smp, txm, txm_smp
36 $PortSets,
37
38 [switch]
39 #Copy common files
40 $CopyCommonFiles = $false,
41
42 [switch]
43 #Copy port files
44 $CopyPortFiles = $false,
45
46 [switch]
47 #Copy the example
48 $CopyExample = $false,
49
50 [switch]
51 #Copy the validation tests
52 $CopyValidationTest = $false,
53
54 [switch]
55 #Copy the regression tests
56 $CopyRegressionTest = $false,
57
58 [switch]
59 #Copy port files
60 $PatchFiles = $false,
61
62 [string]
63 #The output log directory
64 $LogDir = $( Join-Path $PSScriptRoot 'log' )
65
66 )
67
68 Write-Host "Update the ARMv8 ports"
69
70 Write-Verbose ("Script directory: $ScriptDir")
71 Write-Verbose ("Port sets: $PortSets")
72 Write-Verbose ("Copy common files: $CopyCommonFiles")
73 Write-Verbose ("Copy port files: $CopyPortFiles")
74 Write-Verbose ("Copy example: $CopyExample")
75 Write-Verbose ("Copy validation test: $CopyValidationTest")
76 Write-Verbose ("Copy regression test: $CopyRegressionTest")
77 Write-Verbose ("Patch files: $PatchFiles")
78 Write-Verbose ("LogDir: $LogDir")
79
80 $cores = @("cortex_a35", "cortex_a53", "cortex_a55", "cortex_a57", "cortex_a65", "cortex_a65ae", "cortex_a72", "cortex_a73", "cortex_a75", "cortex_a76", "cortex_a76ae", "cortex_a77")
81 $compilers = @("ac6", "gnu")
82 $patches = (
83 ('example_build\sample_threadx\.cproject', (
84 (('value="cortex-a35"'), ('value="cortex-$core_short_lower"')),
85 (('Cortex-A35.AArch64.ARMv8.Neon.Crypto'), ('Cortex-$($core_short_upper).AArch64.ARMv8.Neon.Crypto'))
86 )),
87 ('example_build\tx\.cproject', (
88 (('value="cortex-a35"'), ('value="cortex-$($core_short_lower)"')),
89 (('Cortex-A35.AArch64.ARMv8.Neon.Crypto'), ('Cortex-$($core_short_upper).AArch64.ARMv8.Neon.Crypto'))
90 )),
91 ('example_build\sample_threadx\sample_threadx.launch', (
92 ('Debug Cortex-A35', 'Debug Cortex-$($core_short_upper)'),
93 ('Base_A35x1', 'Base_$($core_short_upper)x1'),
94 ('base_A35x1', 'base_$($core_short_lower)x1'),
95 ('FVP_Base_Cortex-A35x1', 'FVP_Base_Cortex-$($core_short_upper)x1'),
96 ('Base_A35x2', 'Base_$($core_short_upper)x2'),
97 ('base_A35x2', 'base_$($core_short_lower)x2'),
98 ('FVP_Base_Cortex-A35x2', 'FVP_Base_Cortex-$($core_short_upper)x2'),
99 ('Base_A35x4', 'Base_$($core_short_upper)x4'),
100 ('base_A35x4', 'base_$($core_short_lower)x4'),
101 ('FVP_Base_Cortex-A35x4', 'FVP_Base_Cortex-$($core_short_upper)x4')
102 ))
103 )
104
105 # Create the log directory if it doesn't already exists
106 If (-Not (Test-Path -Path $LogDir -PathType Container)) {
107 $LogDirObject = New-Item -Path $LogDir -ItemType Directory
108 }
109
Copy-FilesVerbosenull110 Function Copy-FilesVerbose {
111 [CmdletBinding()] Param (
112 [string] $source,
113 [string] $destination_directory
114 )
115 Write-Verbose ("Copying common files...")
116 Write-Verbose ("Copy: " + $source + " -> " + $destination_directory)
117 Copy-Item -Path $source -Destination $destination_directory -Recurse -Force
118 Write-Verbose("Done.")
119 }
120
121 ForEach ($PortSet in $PortSets) {
122 ForEach ($core in $cores) {
123 Switch ($PortSet) {
124 "tx" { $core_directory = "..\..\ports\" + $core }
125 "tx_smp" { $core_directory = "..\..\ports_smp\" + $core + "_smp" }
126 "txm" { $core_directory = "..\..\ports_module\" + $core }
127 "txm_smp" { $core_directory = "..\..\ports_module_smp\" + $core + "_smp" }
128 Default {}
129 }
130 ForEach ($compiler in $compilers) {
131 $compiler_directory = $core_directory + "\" + $compiler
132 Write-Verbose ("Compiler directory: $compiler_directory")
133 $compiler_directory_object = New-Item -Path $compiler_directory -ItemType "directory" -Force
134
135 $destination_directory = $compiler_directory
136
137 If ($CopyCommonFiles) {
138 Copy-FilesVerbose -source "threadx\common\*" -destination_directory $destination_directory
139 }
140
141 If ($CopyPortFiles) {
142 Copy-FilesVerbose -source "threadx\ports\$compiler\*" -destination_directory $destination_directory
143 }
144
145 If ($PortSet -eq 'tx_smp') {
146 If ($CopyCommonFiles) {
147 Copy-FilesVerbose -source "threadx_smp\common\*" -destination_directory $destination_directory
148 }
149 If ($CopyPortFiles) {
150 Copy-FilesVerbose -source "threadx_smp\ports\$compiler\*" -destination_directory $destination_directory
151 }
152 }
153
154 If ($PortSet -eq 'txm') {
155 }
156
157 If ($PortSet -eq 'txm_smp') {
158 }
159
160 If ($PatchFiles) {
161 ForEach ($patch in $patches) {
162 $core_short = $core -Replace "cortex_",""
163 $core_short_upper = $core_short.ToUpper()
164 $core_short_lower = $core_short.ToLower()
165 ForEach ($patch in $patches) {
166 $path = $destination_directory + "\" + $patch[0]
167 Write-Verbose("Patching file: $path")
168 If (Test-Path -Path $path -PathType leaf) {
169 $content = Get-Content -Path $path
170 ForEach ($replacement in $patch[1]) {
171 $original = $replacement[0]
172 $substitute = $replacement[1]
173 $original = $ExecutionContext.InvokeCommand.ExpandString($original)
174 $substitute = $ExecutionContext.InvokeCommand.ExpandString($substitute)
175 Write-Verbose("`tpatch: `"$original`" -> `"$substitute`"")
176 $content = $content -creplace $original,$substitute
177 }
178 Set-Content -Path $path -Value $content -Encoding ascii
179 Write-Verbose("Patched.")
180 } Else {
181 Write-Verbose("File not found.")
182 }
183 }
184 }
185 }
186 }
187 }
188 }
189