Tidied AVR8 TDF validation script
This commit is contained in:
@@ -72,10 +72,11 @@ foreach ($avrTdfs as $avrTdf) {
|
|||||||
$relativeDestinationFilePath .= "/" . strtoupper($avrTdf->targetArchitecture);
|
$relativeDestinationFilePath .= "/" . strtoupper($avrTdf->targetArchitecture);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($avrTdf->family)) {
|
$avrFamily = $avrTdf->getFamily();
|
||||||
|
if (!empty($avrFamily)) {
|
||||||
// Group by family
|
// Group by family
|
||||||
$destinationFilePath .= "/" . str_replace([' '] , '_', strtoupper($avrTdf->family));
|
$destinationFilePath .= "/" . str_replace([' '] , '_', strtoupper($avrFamily));
|
||||||
$relativeDestinationFilePath .= "/" . str_replace([' '] , '_', strtoupper($avrTdf->family));
|
$relativeDestinationFilePath .= "/" . str_replace([' '] , '_', strtoupper($avrFamily));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($destinationFilePath)) {
|
if (!file_exists($destinationFilePath)) {
|
||||||
@@ -87,14 +88,14 @@ foreach ($avrTdfs as $avrTdf) {
|
|||||||
|
|
||||||
// Copy TDF to build location
|
// Copy TDF to build location
|
||||||
if (copy($avrTdf->filePath, $destinationFilePath) === false) {
|
if (copy($avrTdf->filePath, $destinationFilePath) === false) {
|
||||||
print "FATAL ERROR: Failed to TDF file to " . $destinationFilePath . "\n";
|
print "FATAL ERROR: Failed to copy TDF file to " . $destinationFilePath . "\n";
|
||||||
print "Aborting\n";
|
print "Aborting\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tdfMapping[$id] = [
|
$tdfMapping[$id] = [
|
||||||
'name' => $strippedTargetName,
|
'name' => $strippedTargetName,
|
||||||
'signature' => $avrTdf->signature->toHex(),
|
'signature' => $avrTdf->getSignature()->toHex(),
|
||||||
'tdfPath' => $relativeDestinationFilePath,
|
'tdfPath' => $relativeDestinationFilePath,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
namespace Bloom\BuildScripts\TargetDescriptionFiles\Avr8;
|
||||||
|
|
||||||
|
class DebugWireParameters
|
||||||
|
{
|
||||||
|
public ?int $ocdRevision = null;
|
||||||
|
public ?int $ocdDataRegister = null;
|
||||||
|
public ?int $spmcRegisterStartAddress = null;
|
||||||
|
public ?int $osccalAddress = null;
|
||||||
|
}
|
||||||
18
build/scripts/TargetDescriptionFiles/AVR8/IspParameters.php
Normal file
18
build/scripts/TargetDescriptionFiles/AVR8/IspParameters.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
namespace Bloom\BuildScripts\TargetDescriptionFiles\Avr8;
|
||||||
|
|
||||||
|
class IspParameters
|
||||||
|
{
|
||||||
|
public ?int $programModeTimeout = null;
|
||||||
|
public ?int $programModeStabilizationDelay = null;
|
||||||
|
public ?int $programModeCommandExecutionDelay = null;
|
||||||
|
public ?int $programModeSyncLoops = null;
|
||||||
|
public ?int $programModeByteDelay = null;
|
||||||
|
public ?int $programModePollValue = null;
|
||||||
|
public ?int $programModePollIndex = null;
|
||||||
|
public ?int $programModePreDelay = null;
|
||||||
|
public ?int $programModePostDelay = null;
|
||||||
|
public ?int $readSignaturePollIndex = null;
|
||||||
|
public ?int $readFusePollIndex = null;
|
||||||
|
public ?int $readLockPollIndex = null;
|
||||||
|
}
|
||||||
10
build/scripts/TargetDescriptionFiles/AVR8/JtagParameters.php
Normal file
10
build/scripts/TargetDescriptionFiles/AVR8/JtagParameters.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
namespace Bloom\BuildScripts\TargetDescriptionFiles\Avr8;
|
||||||
|
|
||||||
|
class JtagParameters
|
||||||
|
{
|
||||||
|
public ?int $ocdRevision = null;
|
||||||
|
public ?int $ocdDataRegister = null;
|
||||||
|
public ?int $spmcRegisterStartAddress = null;
|
||||||
|
public ?int $osccalAddress = null;
|
||||||
|
}
|
||||||
20
build/scripts/TargetDescriptionFiles/AVR8/PdiParameters.php
Normal file
20
build/scripts/TargetDescriptionFiles/AVR8/PdiParameters.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
namespace Bloom\BuildScripts\TargetDescriptionFiles\Avr8;
|
||||||
|
|
||||||
|
class PdiParameters
|
||||||
|
{
|
||||||
|
public ?int $appSectionStartAddress = null;
|
||||||
|
public ?int $appSectionSize = null;
|
||||||
|
public ?int $bootSectionStartAddress = null;
|
||||||
|
public ?int $bootSectionSize = null;
|
||||||
|
public ?int $appSectionPdiOffset = null;
|
||||||
|
public ?int $bootSectionPdiOffset = null;
|
||||||
|
public ?int $eepromPdiOffset = null;
|
||||||
|
public ?int $ramPdiOffset = null;
|
||||||
|
public ?int $fuseRegistersPdiOffset = null;
|
||||||
|
public ?int $lockRegistersPdiOffset = null;
|
||||||
|
public ?int $userSignaturesPdiOffset = null;
|
||||||
|
public ?int $productSignaturesPdiOffset = null;
|
||||||
|
public ?int $nvmModuleBaseAddress = null;
|
||||||
|
public ?int $mcuModuleBaseAddress = null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
namespace Bloom\BuildScripts\TargetDescriptionFiles\Avr8;
|
||||||
|
|
||||||
|
class TargetParameters
|
||||||
|
{
|
||||||
|
public ?int $gpRegisterStartAddress = null;
|
||||||
|
public ?int $gpRegisterSize = null;
|
||||||
|
public ?int $flashStartAddress = null;
|
||||||
|
public ?int $flashSize = null;
|
||||||
|
public ?int $flashPageSize = null;
|
||||||
|
public ?int $ramStartAddress = null;
|
||||||
|
public ?int $ramSize = null;
|
||||||
|
public ?int $eepromSize = null;
|
||||||
|
public ?int $eepromPageSize = null;
|
||||||
|
public ?int $eepromStartAddress = null;
|
||||||
|
public ?int $eepromAddressRegisterHigh = null;
|
||||||
|
public ?int $eepromAddressRegisterLow = null;
|
||||||
|
public ?int $eepromDataRegisterAddress = null;
|
||||||
|
public ?int $eepromControlRegisterAddress = null;
|
||||||
|
public ?int $statusRegisterStartAddress = null;
|
||||||
|
public ?int $statusRegisterSize = null;
|
||||||
|
public ?int $stackPointerRegisterLowAddress = null;
|
||||||
|
public ?int $stackPointerRegisterSize = null;
|
||||||
|
}
|
||||||
14
build/scripts/TargetDescriptionFiles/AVR8/UpdiParameters.php
Normal file
14
build/scripts/TargetDescriptionFiles/AVR8/UpdiParameters.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
namespace Bloom\BuildScripts\TargetDescriptionFiles\Avr8;
|
||||||
|
|
||||||
|
class UpdiParameters
|
||||||
|
{
|
||||||
|
public ?int $nvmModuleBaseAddress = null;
|
||||||
|
public ?int $ocdBaseAddress = null;
|
||||||
|
public ?int $programMemoryStartAddress = null;
|
||||||
|
public ?int $signatureSegmentStartAddress = null;
|
||||||
|
public ?int $signatureSegmentSize = null;
|
||||||
|
public ?int $fuseSegmentStartAddress = null;
|
||||||
|
public ?int $fuseSegmentSize = null;
|
||||||
|
public ?int $lockbitsSegmentStartAddress = null;
|
||||||
|
}
|
||||||
@@ -22,6 +22,9 @@ class TargetDescriptionFile
|
|||||||
public ?string $targetName = null;
|
public ?string $targetName = null;
|
||||||
public ?string $targetArchitecture = null;
|
public ?string $targetArchitecture = null;
|
||||||
|
|
||||||
|
/** @var string[] */
|
||||||
|
public array $deviceAttributesByName = [];
|
||||||
|
|
||||||
/** @var AddressSpace[] */
|
/** @var AddressSpace[] */
|
||||||
protected array $addressSpacesById = [];
|
protected array $addressSpacesById = [];
|
||||||
|
|
||||||
@@ -64,13 +67,13 @@ class TargetDescriptionFile
|
|||||||
|
|
||||||
$device = $this->xml->device;
|
$device = $this->xml->device;
|
||||||
if (!empty($device)) {
|
if (!empty($device)) {
|
||||||
$deviceAttributes = $device->attributes();
|
$this->deviceAttributesByName = current((array)$device->attributes());
|
||||||
|
|
||||||
if (!empty($deviceAttributes['name'])) {
|
if (!empty($this->deviceAttributesByName['name'])) {
|
||||||
$this->targetName = $device['name'];
|
$this->targetName = $device['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($deviceAttributes['architecture'])) {
|
if (!empty($this->deviceAttributesByName['architecture'])) {
|
||||||
$this->targetArchitecture = stristr($device['architecture'], 'avr') !== false
|
$this->targetArchitecture = stristr($device['architecture'], 'avr') !== false
|
||||||
? self::ARCHITECTURE_AVR8 : $device['architecture'];
|
? self::ARCHITECTURE_AVR8 : $device['architecture'];
|
||||||
}
|
}
|
||||||
@@ -85,13 +88,96 @@ class TargetDescriptionFile
|
|||||||
$this->loadPinouts();
|
$this->loadPinouts();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function stringToInt(string $value): ?int
|
protected function stringToInt(?string $value): ?int
|
||||||
{
|
{
|
||||||
|
if (is_null($value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return stristr($value, '0x') !== false
|
return stristr($value, '0x') !== false
|
||||||
? (int) hexdec($value)
|
? (int) hexdec($value)
|
||||||
: (strlen($value) > 0 ? (int) $value : null);
|
: (strlen($value) > 0 ? (int) $value : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getPeripheralModuleRegisterGroupOffset(
|
||||||
|
string $moduleName,
|
||||||
|
string $instanceName,
|
||||||
|
string $registerGroupName
|
||||||
|
): ?int {
|
||||||
|
if (isset($this->peripheralModulesByName[$moduleName])) {
|
||||||
|
$module = $this->peripheralModulesByName[$moduleName];
|
||||||
|
|
||||||
|
if (isset($module->instancesMappedByName[$instanceName])) {
|
||||||
|
$instance = $module->instancesMappedByName[$instanceName];
|
||||||
|
|
||||||
|
if (isset($instance->registerGroupsMappedByName[$registerGroupName])) {
|
||||||
|
return $instance->registerGroupsMappedByName[$registerGroupName]->offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPropertyValue(string $propertyGroupName, string $propertyName): ?string
|
||||||
|
{
|
||||||
|
if (isset($this->propertyGroupsByName[$propertyGroupName])) {
|
||||||
|
$propertyGroup = $this->propertyGroupsByName[$propertyGroupName];
|
||||||
|
|
||||||
|
if (isset($propertyGroup->propertiesMappedByName[$propertyName])) {
|
||||||
|
return $propertyGroup->propertiesMappedByName[$propertyName]->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getMemorySegment(
|
||||||
|
string $addressSpaceId,
|
||||||
|
string $memorySegmentType,
|
||||||
|
?string $memorySegmentName = null
|
||||||
|
): ?MemorySegment {
|
||||||
|
if (isset($this->addressSpacesById[$addressSpaceId])) {
|
||||||
|
$addressSpace = $this->addressSpacesById[$addressSpaceId];
|
||||||
|
|
||||||
|
if (isset($addressSpace->memorySegmentsByTypeAndName[$memorySegmentType])) {
|
||||||
|
$memorySegmentsByName = $addressSpace->memorySegmentsByTypeAndName[$memorySegmentType];
|
||||||
|
|
||||||
|
return !is_null($memorySegmentName)
|
||||||
|
? $memorySegmentsByName[$memorySegmentName] ?? null
|
||||||
|
: reset($memorySegmentsByName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getMemorySegmentSize(
|
||||||
|
string $addressSpaceId,
|
||||||
|
string $memorySegmentType,
|
||||||
|
?string $memorySegmentName = null
|
||||||
|
): ?int {
|
||||||
|
$memorySegment = $this->getMemorySegment($addressSpaceId, $memorySegmentType, $memorySegmentName);
|
||||||
|
return $memorySegment instanceof MemorySegment ? $this->stringToInt($memorySegment->size) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getModuleRegister(
|
||||||
|
string $moduleName,
|
||||||
|
string $registerGroupName,
|
||||||
|
string $registerName
|
||||||
|
): ?Register {
|
||||||
|
if (isset($this->modulesByName[$moduleName])) {
|
||||||
|
$module = $this->modulesByName[$moduleName];
|
||||||
|
|
||||||
|
if (isset($module->registerGroupsMappedByName[$registerGroupName])) {
|
||||||
|
return $module->registerGroupsMappedByName[$registerGroupName]->registersMappedByName[$registerName]
|
||||||
|
?? null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private function loadVariants(): void
|
private function loadVariants(): void
|
||||||
{
|
{
|
||||||
$variantElements = $this->xml->xpath('variants/variant');
|
$variantElements = $this->xml->xpath('variants/variant');
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ foreach ($avr8Tdfs as $targetDescriptionFile) {
|
|||||||
|
|
||||||
print "\033[31m";
|
print "\033[31m";
|
||||||
print "Validation for " . $targetDescriptionFile->filePath . " failed.\n";
|
print "Validation for " . $targetDescriptionFile->filePath . " failed.\n";
|
||||||
print count($validationFailures) . " errors found:\n";
|
print count($validationFailures) . " error(s) found:\n";
|
||||||
print implode("\n", $validationFailures);
|
print implode("\n", $validationFailures);
|
||||||
print "\n\n";
|
print "\n\n";
|
||||||
print "\033[0m";
|
print "\033[0m";
|
||||||
@@ -31,5 +31,5 @@ foreach ($avr8Tdfs as $targetDescriptionFile) {
|
|||||||
print "\n\n";
|
print "\n\n";
|
||||||
print "Validated " . count($avr8Tdfs) . " TDFs. ";
|
print "Validated " . count($avr8Tdfs) . " TDFs. ";
|
||||||
print (($failedValidationCount > 0) ? "\033[31m" : "\033[32m");
|
print (($failedValidationCount > 0) ? "\033[31m" : "\033[32m");
|
||||||
print $failedValidationCount . " failures." . "\033[0m" . "\n";
|
print $failedValidationCount . " failure(s)." . "\033[0m" . "\n";
|
||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user