From 0056d5690406231c7e29f3039dfa3a041d5cb15b Mon Sep 17 00:00:00 2001 From: Nav Date: Mon, 25 Mar 2024 18:55:53 +0000 Subject: [PATCH] Corrected TDF data extraction for EDBG parameters in TDF scripts --- .../AVR8/Avr8TargetDescriptionFile.php | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/build/scripts/Targets/TargetDescriptionFiles/AVR8/Avr8TargetDescriptionFile.php b/build/scripts/Targets/TargetDescriptionFiles/AVR8/Avr8TargetDescriptionFile.php index ed111ca9..229d4075 100644 --- a/build/scripts/Targets/TargetDescriptionFiles/AVR8/Avr8TargetDescriptionFile.php +++ b/build/scripts/Targets/TargetDescriptionFiles/AVR8/Avr8TargetDescriptionFile.php @@ -132,9 +132,12 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile if ($eepromAddressRegister instanceof TargetRegister) { $output->eepromAddressRegisterLow = $eepromAddressRegister->address; - $output->eepromAddressRegisterHigh = ($eepromAddressRegister->size == 2) - ? $eepromAddressRegister->address + 1 - : $eepromAddressRegister->address; + $output->eepromAddressRegisterHigh = $eepromAddressRegister->size > 1 + ? $eepromAddressRegister->address !== null + ? $eepromAddressRegister->address >> 2 + : null + : $eepromAddressRegister->address + ; } else { $eepromAddressRegisterLow = $eepromPeripheral->getRegister('eeprom', 'eearl'); @@ -142,7 +145,11 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile if ($eepromAddressRegisterLow instanceof TargetRegister) { $output->eepromAddressRegisterLow = $eepromAddressRegisterLow->address; - $output->eepromAddressRegisterHigh = $eepromAddressRegisterLow->address; + $output->eepromAddressRegisterHigh = $eepromAddressRegisterLow->size > 1 + ? $eepromAddressRegisterLow->address !== null + ? $eepromAddressRegisterLow->address >> 2 + : null + : $eepromAddressRegisterLow->address; } if ($eepromAddressRegisterHigh instanceof TargetRegister) { @@ -276,9 +283,12 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile if ($eepromAddressRegister instanceof TargetRegister) { $output->eepromAddressRegisterLow = $eepromAddressRegister->address; - $output->eepromAddressRegisterHigh = ($eepromAddressRegister->size == 2) - ? $eepromAddressRegister->address + 1 - : $eepromAddressRegister->address; + $output->eepromAddressRegisterHigh = $eepromAddressRegister->size > 1 + ? $eepromAddressRegister->address !== null + ? $eepromAddressRegister->address >> 2 + : null + : $eepromAddressRegister->address + ; } else { $eepromAddressRegisterLow = $eepromPeripheral->getRegister('eeprom', 'eearl'); @@ -286,7 +296,6 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile if ($eepromAddressRegisterLow instanceof TargetRegister) { $output->eepromAddressRegisterLow = $eepromAddressRegisterLow->address; - $output->eepromAddressRegisterHigh = $eepromAddressRegisterLow->address; } if ($eepromAddressRegisterHigh instanceof TargetRegister) { @@ -435,26 +444,38 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile ); $signatureMemorySegment = $this->getMemorySegment( + 'signatures', + 'signatures' + ) ?? $this->getMemorySegment( 'data', 'signatures' ); + if ($signatureMemorySegment instanceof MemorySegment) { $output->signatureSegmentStartAddress = $signatureMemorySegment->startAddress; } $fuseMemorySegment = $this->getMemorySegment( + 'fuses', + 'fuses' + ) ?? $this->getMemorySegment( 'data', 'fuses' ); + if ($fuseMemorySegment instanceof MemorySegment) { $output->fuseSegmentSize = $fuseMemorySegment->size; $output->fuseSegmentStartAddress = $fuseMemorySegment->startAddress; } $lockbitsMemorySegment = $this->getMemorySegment( + 'lockbits', + 'lockbits' + ) ?? $this->getMemorySegment( 'data', 'lockbits' ); + if ($lockbitsMemorySegment instanceof MemorySegment) { $output->lockbitsSegmentStartAddress = $lockbitsMemorySegment->startAddress; } @@ -495,8 +516,8 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile private function getEepromSegment(): ?MemorySegment { - return $this->getMemorySegment('data', 'internal_eeprom') - ?? $this->getMemorySegment('eeprom', 'internal_eeprom'); + return $this->getMemorySegment('eeprom', 'internal_eeprom') + ?? $this->getMemorySegment('data', 'internal_eeprom'); } private function getBootSectionOptions(): array