diff --git a/modules/dev_tools/adtglog2/Makefile b/modules/dev_tools/adtglog2/Makefile index b35938659..94d84cbca 100644 --- a/modules/dev_tools/adtglog2/Makefile +++ b/modules/dev_tools/adtglog2/Makefile @@ -3,7 +3,8 @@ MODULE_NAME = adtglog2 MODULE_OBJS = $(BUILD_DIR)/adtglog2.o \ $(BUILD_DIR)/hooks_thumb_200D.o \ $(BUILD_DIR)/hooks_thumb_6D2.o \ - $(BUILD_DIR)/hooks_arm_70D.o + $(BUILD_DIR)/hooks_arm_70D.o \ + $(BUILD_DIR)/hooks_thumb_M50.o TOP_DIR = ../../.. # include modules environment @@ -22,5 +23,8 @@ $(BUILD_DIR)/hooks_thumb_200D.o: hooks_thumb_200D.c $(BUILD_DIR)/hooks_thumb_6D2.o: hooks_thumb_6D2.c $(CC) $(CFLAGS_ARCHLESS) -mthumb -march=armv7 $(CDEPS_FLAGS) -c -o $@ $< +$(BUILD_DIR)/hooks_thumb_M50.o: hooks_thumb_M50.c + $(CC) $(CFLAGS_ARCHLESS) -mthumb -march=armv7 $(CDEPS_FLAGS) -c -o $@ $< + $(BUILD_DIR)/hooks_arm_70D.o: hooks_arm_70D.c $(CC) $(CFLAGS) $(CDEPS_FLAGS) -c -o $@ $< diff --git a/modules/dev_tools/adtglog2/adtglog2.c b/modules/dev_tools/adtglog2/adtglog2.c index fbbec9d44..367e26934 100644 --- a/modules/dev_tools/adtglog2/adtglog2.c +++ b/modules/dev_tools/adtglog2/adtglog2.c @@ -245,6 +245,34 @@ static unsigned int init() } apply_patches(patches, COUNT(f_patches)); } + else if (is_camera("M50", "1.1.0")) + { + buf_item_size = 32; + + // install hooks + struct function_hook_patch f_patches[] = { + { + .patch_addr = 0xe0824d02, // CMOS_write + .orig_content = {0x2d, 0xe9, 0xf8, 0x4f, 0x04, 0x46, 0x90, 0x4d}, + .target_function_addr = (uint32_t)hook_CMOS_write_M50, + .description = "Log ADTG CMOS writes" + }, + }; + + struct patch patches[COUNT(f_patches)] = {}; + uint8_t code_hooks[8 * COUNT(f_patches)] = {}; + + for (int i = 0; i < COUNT(f_patches); i++) + { + if (convert_f_patch_to_patch(&f_patches[i], + &patches[i], + &code_hooks[8 * i])) + { + return 1; + } + } + apply_patches(patches, COUNT(f_patches)); + } else if (is_camera("70D", "1.1.2")) { buf_item_size = 16; diff --git a/modules/dev_tools/adtglog2/hooks_thumb.h b/modules/dev_tools/adtglog2/hooks_thumb.h index 7033f8f86..f99d6142b 100644 --- a/modules/dev_tools/adtglog2/hooks_thumb.h +++ b/modules/dev_tools/adtglog2/hooks_thumb.h @@ -8,5 +8,6 @@ // one instruction in Thumb, so it's harder to be as generic as the ARM hook code. void __attribute__((noreturn,noinline,naked,aligned(4)))hook_CMOS_write_200D(void); void __attribute__((noreturn,noinline,naked,aligned(4)))hook_CMOS_write_6D2(void); +void __attribute__((noreturn,noinline,naked,aligned(4)))hook_CMOS_write_M50(void); #endif diff --git a/modules/dev_tools/adtglog2/hooks_thumb_M50.c b/modules/dev_tools/adtglog2/hooks_thumb_M50.c new file mode 100644 index 000000000..a777f71c5 --- /dev/null +++ b/modules/dev_tools/adtglog2/hooks_thumb_M50.c @@ -0,0 +1,37 @@ +#include "adtglog2.h" +#include "hooks_thumb.h" +#include "dryos.h" +#include "log.h" + +// ADTG logging + +void __attribute__((noreturn,noinline,naked,aligned(4)))hook_CMOS_write_M50(void) +{ + asm( + "push { r0-r11, lr }\n" + ); + + uint32_t *cmos_buf; + uint32_t lr; + asm __volatile__ ( + "mov %0, r0\n" + "mov %1, lr\n" : "=&r"(cmos_buf), "=&r"(lr) + ); + + log_cmos_command_buffer(cmos_buf, lr); + + asm( + "pop { r0-r11, lr }\n" + + // do overwritten instructions + //"ldr r2, =0xa5c30\n" + "push {r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}\n" + "mov r4, r0\n" + "ldr r5, =0x8ba24\n" + + + // jump back + "ldr pc, =0xe0824d0b\n" + ); +} + diff --git a/platform/M50.110/features.h b/platform/M50.110/features.h index 1282ebe2e..0e184f27a 100644 --- a/platform/M50.110/features.h +++ b/platform/M50.110/features.h @@ -34,6 +34,9 @@ // I think? If it fails to AF lock, for example. #define CONFIG_IMAGE_CAPTURE_NOT_WORKING +// Fast disk logging +#define FEATURE_DISK_LOG + #undef CONFIG_CRASH_LOG #undef CONFIG_PROP_REQUEST_CHANGE #undef CONFIG_AUTOBACKUP_ROM