AVR8 signature extraction and validation (from TDFs)
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Bloom\BuildScripts\TargetDescriptionFiles\Avr8;
|
|||||||
use Bloom\BuildScripts\TargetDescriptionFiles\TargetDescriptionFile;
|
use Bloom\BuildScripts\TargetDescriptionFiles\TargetDescriptionFile;
|
||||||
|
|
||||||
require_once __DIR__ . "/../TargetDescriptionFile.php";
|
require_once __DIR__ . "/../TargetDescriptionFile.php";
|
||||||
|
require_once __DIR__ . "/Signature.php";
|
||||||
|
|
||||||
class Avr8TargetDescriptionFile extends TargetDescriptionFile
|
class Avr8TargetDescriptionFile extends TargetDescriptionFile
|
||||||
{
|
{
|
||||||
@@ -20,6 +21,7 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile
|
|||||||
const AVR8_PHYSICAL_INTERFACE_UPDI = 'UPDI';
|
const AVR8_PHYSICAL_INTERFACE_UPDI = 'UPDI';
|
||||||
const AVR8_PHYSICAL_INTERFACE_DEBUG_WIRE = 'debugWire';
|
const AVR8_PHYSICAL_INTERFACE_DEBUG_WIRE = 'debugWire';
|
||||||
|
|
||||||
|
public ?Signature $signature = null;
|
||||||
public ?string $family = null;
|
public ?string $family = null;
|
||||||
public array $debugPhysicalInterface = [];
|
public array $debugPhysicalInterface = [];
|
||||||
|
|
||||||
@@ -109,6 +111,29 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile
|
|||||||
$this->debugPhysicalInterface[] = self::AVR8_PHYSICAL_INTERFACE_JTAG;
|
$this->debugPhysicalInterface[] = self::AVR8_PHYSICAL_INTERFACE_JTAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$signaturePropertyGroup = $this->propertyGroupsByName['signatures'] ?? null;
|
||||||
|
if (!empty($signaturePropertyGroup)) {
|
||||||
|
$this->signature = new Signature();
|
||||||
|
|
||||||
|
if (isset($signaturePropertyGroup->propertiesMappedByName['signature0'])) {
|
||||||
|
$this->signature->byteZero = $this->rawValueToInt(
|
||||||
|
$signaturePropertyGroup->propertiesMappedByName['signature0']->value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($signaturePropertyGroup->propertiesMappedByName['signature1'])) {
|
||||||
|
$this->signature->byteOne = $this->rawValueToInt(
|
||||||
|
$signaturePropertyGroup->propertiesMappedByName['signature1']->value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($signaturePropertyGroup->propertiesMappedByName['signature2'])) {
|
||||||
|
$this->signature->byteTwo = $this->rawValueToInt(
|
||||||
|
$signaturePropertyGroup->propertiesMappedByName['signature2']->value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$progAddressSpace = $this->addressSpacesById['prog'] ?? null;
|
$progAddressSpace = $this->addressSpacesById['prog'] ?? null;
|
||||||
if (!empty($progAddressSpace)) {
|
if (!empty($progAddressSpace)) {
|
||||||
$flashMemorySegment = $progAddressSpace->memorySegmentsByTypeAndName['flash']['flash']
|
$flashMemorySegment = $progAddressSpace->memorySegmentsByTypeAndName['flash']['flash']
|
||||||
@@ -344,6 +369,14 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile
|
|||||||
{
|
{
|
||||||
$failures = parent::validate();
|
$failures = parent::validate();
|
||||||
|
|
||||||
|
if (is_null($this->signature)
|
||||||
|
|| is_null($this->signature->byteZero)
|
||||||
|
|| is_null($this->signature->byteOne)
|
||||||
|
|| is_null($this->signature->byteTwo)
|
||||||
|
) {
|
||||||
|
$failures[] = "Missing or incomplete AVR signature.";
|
||||||
|
}
|
||||||
|
|
||||||
if (is_null($this->debugPhysicalInterface)) {
|
if (is_null($this->debugPhysicalInterface)) {
|
||||||
$failures[] = 'Target does not support any known AVR8 debug interface - the TDF will need to be deleted.'
|
$failures[] = 'Target does not support any known AVR8 debug interface - the TDF will need to be deleted.'
|
||||||
. ' Aborting validation.';
|
. ' Aborting validation.';
|
||||||
|
|||||||
21
build/scripts/TargetDescriptionFiles/AVR8/Signature.php
Normal file
21
build/scripts/TargetDescriptionFiles/AVR8/Signature.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace Bloom\BuildScripts\TargetDescriptionFiles\Avr8;
|
||||||
|
|
||||||
|
class Signature
|
||||||
|
{
|
||||||
|
public ?int $byteZero = null;
|
||||||
|
public ?int $byteOne = null;
|
||||||
|
public ?int $byteTwo = null;
|
||||||
|
|
||||||
|
public function toHex(): string
|
||||||
|
{
|
||||||
|
if (is_null($this->byteZero) || is_null($this->byteOne) || is_null($this->byteTwo)) {
|
||||||
|
throw new \Exception("Cannot generate hex string of incomplete AVR8 target signature.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return '0x' . substr('0' . dechex($this->byteZero), -2)
|
||||||
|
. substr('0' . dechex($this->byteOne), -2)
|
||||||
|
. substr('0' . dechex($this->byteTwo), -2)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user