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