buf_set_u32(code, 0, 32, ARMV5_BKPT(0x11));
}
+ /*
+ * ARMv7-A/R fetches instructions in little-endian on both LE and BE CPUs.
+ * But Cortex-R4 and Cortex-R5 big-endian require BE instructions.
+ * https://developer.arm.com/documentation/den0042/a/Coding-for-Cortex-R-Processors/Endianness
+ * https://developer.arm.com/documentation/den0013/d/Porting/Endianness
+ */
+ if ((((cortex_a->cpuid & CPUDBG_CPUID_MASK) == CPUDBG_CPUID_CORTEX_R4) ||
+ ((cortex_a->cpuid & CPUDBG_CPUID_MASK) == CPUDBG_CPUID_CORTEX_R5)) &&
+ target->endianness == TARGET_BIG_ENDIAN) {
+ // In place swapping is allowed
+ buf_bswap32(code, code, 4);
+ }
+
retval = target_read_memory(target,
breakpoint->address & 0xFFFFFFFE,
breakpoint->length, 1,
#define CORTEX_A_MIDR_PARTNUM_SHIFT 4
#define CPUDBG_CPUID 0xD00
+#define CPUDBG_CPUID_MASK 0xff00fff0
+#define CPUDBG_CPUID_CORTEX_R4 0x4100c140
+#define CPUDBG_CPUID_CORTEX_R5 0x4100c150
#define CPUDBG_CTYPR 0xD04
#define CPUDBG_TTYPR 0xD0C
#define CPUDBG_LOCKACCESS 0xFB0