Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion modules/dev_tools/adtglog2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 $@ $<
28 changes: 28 additions & 0 deletions modules/dev_tools/adtglog2/adtglog2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions modules/dev_tools/adtglog2/hooks_thumb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 37 additions & 0 deletions modules/dev_tools/adtglog2/hooks_thumb_M50.c
Original file line number Diff line number Diff line change
@@ -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"
);
}

3 changes: 3 additions & 0 deletions platform/M50.110/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -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