Used program memory address space address and size for AVR8 target parameters (otherwise we'd be ignoring other memory sections in the program memory, such as boot sections)
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
|||||||
using namespace Bloom::Exceptions;
|
using namespace Bloom::Exceptions;
|
||||||
|
|
||||||
using Bloom::Targets::TargetDescription::RegisterGroup;
|
using Bloom::Targets::TargetDescription::RegisterGroup;
|
||||||
|
using Bloom::Targets::TargetDescription::AddressSpace;
|
||||||
using Bloom::Targets::TargetDescription::MemorySegment;
|
using Bloom::Targets::TargetDescription::MemorySegment;
|
||||||
using Bloom::Targets::TargetDescription::MemorySegmentType;
|
using Bloom::Targets::TargetDescription::MemorySegmentType;
|
||||||
using Bloom::Targets::TargetDescription::Register;
|
using Bloom::Targets::TargetDescription::Register;
|
||||||
@@ -177,13 +178,16 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
|||||||
const auto& peripheralModules = this->getPeripheralModulesMappedByName();
|
const auto& peripheralModules = this->getPeripheralModulesMappedByName();
|
||||||
const auto& propertyGroups = this->getPropertyGroupsMappedByName();
|
const auto& propertyGroups = this->getPropertyGroupsMappedByName();
|
||||||
|
|
||||||
auto flashMemorySegment = this->getFlashMemorySegment();
|
const auto programMemoryAddressSpace = this->getProgramMemoryAddressSpace();
|
||||||
if (flashMemorySegment.has_value()) {
|
|
||||||
targetParameters.flashSize = flashMemorySegment->size;
|
|
||||||
targetParameters.flashStartAddress = flashMemorySegment->startAddress;
|
|
||||||
|
|
||||||
if (flashMemorySegment->pageSize.has_value()) {
|
if (programMemoryAddressSpace.has_value()) {
|
||||||
targetParameters.flashPageSize = flashMemorySegment->pageSize.value();
|
targetParameters.flashSize = programMemoryAddressSpace->size;
|
||||||
|
targetParameters.flashStartAddress = programMemoryAddressSpace->startAddress;
|
||||||
|
|
||||||
|
const auto appMemorySegment = this->getFlashApplicationMemorySegment(programMemoryAddressSpace.value());
|
||||||
|
|
||||||
|
if (appMemorySegment.has_value() && appMemorySegment->pageSize.has_value()) {
|
||||||
|
targetParameters.flashPageSize = appMemorySegment->pageSize.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,20 +676,25 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<MemorySegment> TargetDescriptionFile::getFlashMemorySegment() const {
|
std::optional<AddressSpace> TargetDescriptionFile::getProgramMemoryAddressSpace() const {
|
||||||
const auto& addressMapping = this->addressSpacesMappedById;
|
if (this->addressSpacesMappedById.contains("prog")) {
|
||||||
auto programAddressSpaceIt = addressMapping.find("prog");
|
return this->addressSpacesMappedById.at("prog");
|
||||||
|
}
|
||||||
|
|
||||||
// Flash memory attributes are typically found in memory segments within the program address space.
|
return std::nullopt;
|
||||||
if (programAddressSpaceIt != addressMapping.end()) {
|
}
|
||||||
const auto& programAddressSpace = programAddressSpaceIt->second;
|
|
||||||
|
std::optional<MemorySegment> TargetDescriptionFile::getFlashApplicationMemorySegment(
|
||||||
|
const AddressSpace& programAddressSpace
|
||||||
|
) const {
|
||||||
const auto& programMemorySegments = programAddressSpace.memorySegmentsByTypeAndName;
|
const auto& programMemorySegments = programAddressSpace.memorySegmentsByTypeAndName;
|
||||||
|
|
||||||
if (programMemorySegments.find(MemorySegmentType::FLASH) != programMemorySegments.end()) {
|
if (programMemorySegments.find(MemorySegmentType::FLASH) != programMemorySegments.end()) {
|
||||||
const auto& flashMemorySegments = programMemorySegments.find(MemorySegmentType::FLASH)->second;
|
const auto& flashMemorySegments = programMemorySegments.find(MemorySegmentType::FLASH)->second;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In AVR8 TDFs, flash memory segments are typically named "APP_SECTION", "PROGMEM" or "FLASH".
|
* In AVR8 TDFs, flash application memory segments are typically named "APP_SECTION", "PROGMEM" or
|
||||||
|
* "FLASH".
|
||||||
*/
|
*/
|
||||||
auto flashSegmentIt = flashMemorySegments.find("app_section") != flashMemorySegments.end() ?
|
auto flashSegmentIt = flashMemorySegments.find("app_section") != flashMemorySegments.end() ?
|
||||||
flashMemorySegments.find("app_section")
|
flashMemorySegments.find("app_section")
|
||||||
@@ -696,7 +705,6 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
|||||||
return flashSegmentIt->second;
|
return flashSegmentIt->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,7 +192,10 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
|||||||
const std::string& fuseBitName
|
const std::string& fuseBitName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getFlashMemorySegment() const;
|
[[nodiscard]] std::optional<Targets::TargetDescription::AddressSpace> getProgramMemoryAddressSpace() const;
|
||||||
|
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getFlashApplicationMemorySegment(
|
||||||
|
const Targets::TargetDescription::AddressSpace& programAddressSpace
|
||||||
|
) const;
|
||||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getRamMemorySegment() const;
|
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getRamMemorySegment() const;
|
||||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getIoMemorySegment() const;
|
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getIoMemorySegment() const;
|
||||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getRegisterMemorySegment() const;
|
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getRegisterMemorySegment() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user