Added an assert to check there are not multiple core architectures. We don't deal with that (yet), so let's just make the current assumption checked.
@@ -51,10 +51,10 @@ impl Target {
}
}
- /// Get the architectre of the target
+ /// Get the architecture of the target
pub fn architecture(&self) -> Architecture {
- // TODO: what if they're different?
- match &self.cores[0].core_type {
+ fn get_architecture_from_core(core_type: CoreType) -> Architecture {
+ match core_type {
CoreType::M0 => Architecture::Arm,
CoreType::M3 => Architecture::Arm,
CoreType::M33 => Architecture::Arm,
@@ -64,6 +64,19 @@ impl Target {
}
}
+ let target_arch = get_architecture_from_core(self.cores[0].core_type);
+
+ assert!(
+ self.cores
+ .iter()
+ .map(|core| get_architecture_from_core(core.core_type))
+ .all(|core_arch| core_arch == target_arch),
+ "Not all cores of the target are of the same architecture. Probe-rs doesn't support this (yet). If you see this, it is a bug. Please file an issue."
+ );
+
+ target_arch
+ }
+
/// Source description of this target.
pub fn source(&self) -> &TargetDescriptionSource {
&self.source
