Corrected issue with JTAG/debugWire AVR8 parameters including mapped IO memory address offset
This commit is contained in:
@@ -123,6 +123,23 @@ void EdbgAvr8Interface::setDebugWireAndJtagParameters() {
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* All addresses for registers that reside in the mapped IO memory segment include the mapped IO segment offset
|
||||
* (start address). But the EDBG protocol requires *some* of these addresses to be stripped of this offset before
|
||||
* sending them as target parameters.
|
||||
*
|
||||
* This applies to the following addresses:
|
||||
*
|
||||
* - OSCALL Address
|
||||
* - EEARL Address
|
||||
* - EEARH Address
|
||||
* - EECR Address
|
||||
* - EEDR Address
|
||||
*
|
||||
* It *doesn't* seem to apply to the SPMCR address.
|
||||
*/
|
||||
auto mappedIoStartAddress = this->targetParameters.mappedIoStartAddress.value_or(0);
|
||||
|
||||
if (this->targetParameters.ocdDataRegister.has_value()) {
|
||||
Logger::debug("Setting DEVICE_OCD_DATA_REGISTER AVR8 parameter");
|
||||
this->setParameter(
|
||||
@@ -143,7 +160,9 @@ void EdbgAvr8Interface::setDebugWireAndJtagParameters() {
|
||||
Logger::debug("Setting DEVICE_OSCCAL_ADDR AVR8 parameter");
|
||||
this->setParameter(
|
||||
Avr8EdbgParameters::DEVICE_OSCCAL_ADDR,
|
||||
this->targetParameters.osccalAddress.value()
|
||||
static_cast<std::uint8_t>(
|
||||
this->targetParameters.osccalAddress.value() - mappedIoStartAddress
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -151,7 +170,9 @@ void EdbgAvr8Interface::setDebugWireAndJtagParameters() {
|
||||
Logger::debug("Setting DEVICE_EEARL_ADDR AVR8 parameter");
|
||||
this->setParameter(
|
||||
Avr8EdbgParameters::DEVICE_EEARL_ADDR,
|
||||
this->targetParameters.eepromAddressRegisterLow.value()
|
||||
static_cast<std::uint8_t>(
|
||||
this->targetParameters.eepromAddressRegisterLow.value() - mappedIoStartAddress
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -159,7 +180,9 @@ void EdbgAvr8Interface::setDebugWireAndJtagParameters() {
|
||||
Logger::debug("Setting DEVICE_EEARH_ADDR AVR8 parameter");
|
||||
this->setParameter(
|
||||
Avr8EdbgParameters::DEVICE_EEARH_ADDR,
|
||||
this->targetParameters.eepromAddressRegisterHigh.value()
|
||||
static_cast<std::uint8_t>(
|
||||
this->targetParameters.eepromAddressRegisterHigh.value() - mappedIoStartAddress
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -167,7 +190,9 @@ void EdbgAvr8Interface::setDebugWireAndJtagParameters() {
|
||||
Logger::debug("Setting DEVICE_EECR_ADDR AVR8 parameter");
|
||||
this->setParameter(
|
||||
Avr8EdbgParameters::DEVICE_EECR_ADDR,
|
||||
this->targetParameters.eepromControlRegisterAddress.value()
|
||||
static_cast<std::uint8_t>(
|
||||
this->targetParameters.eepromControlRegisterAddress.value() - mappedIoStartAddress
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -175,7 +200,9 @@ void EdbgAvr8Interface::setDebugWireAndJtagParameters() {
|
||||
Logger::debug("Setting DEVICE_EEDR_ADDR AVR8 parameter");
|
||||
this->setParameter(
|
||||
Avr8EdbgParameters::DEVICE_EEDR_ADDR,
|
||||
this->targetParameters.eepromDataRegisterAddress.value()
|
||||
static_cast<std::uint8_t>(
|
||||
this->targetParameters.eepromDataRegisterAddress.value() - mappedIoStartAddress
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,11 @@ void Avr8::loadTargetParameters() {
|
||||
this->targetParameters->ramStartAddress = ramMemorySegment->startAddress;
|
||||
}
|
||||
|
||||
auto ioMemorySegment = this->targetDescriptionFile->getIoMemorySegment();
|
||||
if (ioMemorySegment.has_value()) {
|
||||
this->targetParameters->mappedIoStartAddress = ioMemorySegment->startAddress;
|
||||
}
|
||||
|
||||
auto registerMemorySegment = this->targetDescriptionFile->getRegisterMemorySegment();
|
||||
if (registerMemorySegment.has_value()) {
|
||||
this->targetParameters->gpRegisterSize = registerMemorySegment->size;
|
||||
|
||||
@@ -226,6 +226,26 @@ std::optional<MemorySegment> TargetDescriptionFile::getRamMemorySegment() const
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<MemorySegment> TargetDescriptionFile::getIoMemorySegment() const {
|
||||
auto& addressMapping = this->addressSpacesMappedById;
|
||||
|
||||
if (addressMapping.contains("data")) {
|
||||
auto& dataAddressSpace = addressMapping.at("data");
|
||||
auto& dataMemorySegments = dataAddressSpace.memorySegmentsByTypeAndName;
|
||||
|
||||
if (dataMemorySegments.contains(MemorySegmentType::IO)) {
|
||||
auto& ramMemorySegments = dataMemorySegments.at(MemorySegmentType::IO);
|
||||
auto ramMemorySegmentIt = ramMemorySegments.begin();
|
||||
|
||||
if (ramMemorySegmentIt != ramMemorySegments.end()) {
|
||||
return ramMemorySegmentIt->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<MemorySegment> TargetDescriptionFile::getRegisterMemorySegment() const {
|
||||
auto& addressMapping = this->addressSpacesMappedById;
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getFlashMemorySegment() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getRamMemorySegment() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getIoMemorySegment() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getRegisterMemorySegment() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getEepromMemorySegment() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getFirstBootSectionMemorySegment() const;
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
{
|
||||
struct TargetParameters
|
||||
{
|
||||
std::optional<std::uint32_t> mappedIoStartAddress;
|
||||
std::optional<std::uint32_t> bootSectionStartAddress;
|
||||
std::optional<std::uint32_t> gpRegisterStartAddress;
|
||||
std::optional<std::uint32_t> gpRegisterSize;
|
||||
@@ -20,7 +21,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
std::optional<std::uint32_t> ramSize;
|
||||
std::optional<std::uint16_t> eepromStartAddress;
|
||||
std::optional<std::uint16_t> eepromSize;
|
||||
std::optional<std::uint16_t> eepromPageSize;
|
||||
std::optional<std::uint8_t> eepromPageSize;
|
||||
std::optional<std::uint8_t> eepromAddressRegisterHigh;
|
||||
std::optional<std::uint8_t> eepromAddressRegisterLow;
|
||||
std::optional<std::uint8_t> eepromDataRegisterAddress;
|
||||
|
||||
Reference in New Issue
Block a user