Author Topic: Magic Lantern USB Installation Tools  (Read 850 times)

petabyte

  • New to the forum
  • *
  • Posts: 24
Magic Lantern USB Installation Tools
« on: July 18, 2021, 01:14:50 AM »
I've been working on a utility that should help with installing Magic Lantern.
Source code: https://github.com/petabyt/mlinstall

It currently can:

- Run Canon event procedures:
Based on some research in https://github.com/petabyt/sequoia-ptpy, I've
gotten Canon's `0x9052` PTP command to work properly. This allows for
commands like "EnableBootDisk" and "DisableBootDisk" to be run via PTP.
I think this command is standard on almost all Canon cameras, so it
could possibly replace custom firmware files. (?)

- Card Tools:
I've also added a card flag enabler (BOOTDISK + EOS_DEVELOP), and an
option to disable them. (just writes an underscore on the first character of each)

Beware, little testing has been done and there is no guarantee this won't
break something or blow up your camera.
Releases: https://github.com/petabyt/mlinstall/releases

Current TODO:
 - Lots of testing, make sure it won't break stuff
- Download correct ML based on model and FW version
- Get WiFi ptp working
- Port to Mac

Walter Schulz

  • Contributor
  • Hero Member
  • *****
  • Posts: 7992
Re: Magic Lantern USB Installation Tools
« Reply #1 on: July 18, 2021, 04:14:32 AM »
Thanks!
Avoiding messing with custom firmware files and thus avoiding legal issues (without the need to access via UART) will have a big impact IMO!

Any plans to make it work on macOS?

petabyte

  • New to the forum
  • *
  • Posts: 24
Re: Magic Lantern USB Installation Tools
« Reply #2 on: July 18, 2021, 04:20:32 AM »
I think it should be pretty easy to get it to work. But the only Mac I have is an old iMac G4, which is probably too old.

Walter Schulz

  • Contributor
  • Hero Member
  • *****
  • Posts: 7992
Re: Magic Lantern USB Installation Tools
« Reply #3 on: July 18, 2021, 02:18:35 PM »
No hurry!

Another one: EOS M is not supported by gphoto2, Tornado EOS, EOS Webcam Utility. Has anyone tested your tools with EOS M?

petabyte

  • New to the forum
  • *
  • Posts: 24
Re: Magic Lantern USB Installation Tools
« Reply #4 on: July 18, 2021, 06:38:30 PM »
Not that I know of. I guess the safe way to check would be looking for the string "ExecuteEventProc" in a ram dump.

Ant123

  • Contributor
  • Member
  • *****
  • Posts: 173
Re: Magic Lantern USB Installation Tools
« Reply #5 on: July 19, 2021, 01:29:58 PM »
Does this mean that ptp command 0x9052 (36946) is not supported?
Quote
python3 ./print_device_info.py
Container:
    StandardVersion = 100
    VendorExtensionID = Microsoft
    VendorExtensionVersion = 100
    VendorExtensionDesc =
    FunctionalMode = 0
    OperationsSupported = ['GetDevicePropDesc', 'GetDevicePropValue', 'SetDevicePropValue', 'ResetDevicePropValue', 'GetDeviceInfo', 'OpenSession', 'CloseSession', 'CheckEvent', 36956, 36957, 'ChangeUSBProtocol', 'GetStorageIDs', 'GetStorageInfo', 'GetNumObjects', 'GetObjectHandles', 'GetObjectInfo', 'GetObject', 'GetThumb', 'GetPartialObject', 'SendObjectInfo', 'SendObject', 'DeleteObject', 'FormatStore', 'SetObjectProtection', 'GetObjectSize', 'GetObjectInfoEx', 'GetPartialObjectEx', 'GetObjectAttributes', 'SendPartialObject', 'GetObjectHandleByName', 'SetObjectTime', 'SetObjectArchive', 36940, 'SendObjectInfoByPath', 'SendObjectByPath', 36920, 36921, 36922, 36923, 36939, 36960, 36962, 38913, 38914, 38915, 38916, 38917, 'EOSGetEvent', 'EOSGetStorageIDs', 'EOSGetStorageInfo', 'EOSGetObjectInfo', 'EOSDeleteObject', 'EOSFormatStore', 'EOSGetPartialObject', 'EOSGetObjectInfoEx', 'EOSGetThumbEx', 'EOSSetObjectAttributes', 'EOSTransferComplete', 'EOSCancelTransfer', 37164, 37170, 37173, 37184, 37185, 37187, 'EOSPCHDDCapacity', 37183, 'EOSSetEventMode', 'EOSSetUILock', 'EOSResetUILock', 'EOSKeepDeviceOn', 37181, 37174, 37175, 'EOSSetRemoteMode', 'EOSGetViewFinderImage', 'EOSRemoteReleaseOn', 'EOSRemoteReleaseOff', 'EOSZoom', 'EOSZoomPosition', 'EOSDoAf', 'EOSAfCancel', 'EOSDriveLens', 37211, 36911, 'EOSSetDevicePropValueEx', 'EOSRequestDevicePropValue', 37250, 37251, 37252, 37253, 36944, 36945]
    EventsSupported = ['CancelTransaction', 'ObjectAdded', 'ObjectRemoved', 'StoreAdded', 'StoreRemoved', 'DevicePropChanged', 'ObjectInfoChanged', 'DeviceInfoChanged', 'RequestObjectTransfer', 'StoreFull', 'DeviceReset', 'StorageInfoChanged', 'UnreportedStatus', 49153, 49157, 49162, 49409]
    DevicePropertiesSupported = [53317, 53322, 53294, 53295, 'BatteryLevel', 53250, 'ViewfinderMode', 'UnixTime', 53319, 53318, 53296, 53321, 'CameraModel', 'CameraOwner', 'FlashMemory', 53328, 53329, 53330, 53331, 53332, 53335, 54274, 54278, 54279, 54019]
    CaptureFormats = ['EXIF_JPEG']
    ImageFormats = ['Association', 'Script', 'DPOF', 'WAV', 'EXIF_JPEG', 'UndefinedImage', 'CRW3', 47490, 45317, 48897]
    Manufacturer = Canon Inc.
    Model = Canon EOS M3
    DeviceVersion = 3-14.0.1.0
    SerialNumber = *

petabyte

  • New to the forum
  • *
  • Posts: 24
Re: Magic Lantern USB Installation Tools
« Reply #6 on: July 19, 2021, 07:21:42 PM »
I guess not, assuming Canon didin't change the command ID or anything.

Ant123

  • Contributor
  • Member
  • *****
  • Posts: 173
Re: Magic Lantern USB Installation Tools
« Reply #7 on: July 19, 2021, 07:58:08 PM »
I already found that the command 0x9052 becomes available after calling the command 0x9050 three times.

petabyte

  • New to the forum
  • *
  • Posts: 24
Re: Magic Lantern USB Installation Tools
« Reply #8 on: July 19, 2021, 07:59:45 PM »
Interesting, do you know why?

Ant123

  • Contributor
  • Member
  • *****
  • Posts: 173
Re: Magic Lantern USB Installation Tools
« Reply #9 on: July 19, 2021, 08:15:18 PM »
Just because of Canon's firmware:
Code: [Select]
uint handle_PTP_OC_0x9050
               (undefined4 param_1,undefined4 *param_2,undefined4 param_3,undefined4 param_4,
               undefined4 param_5)

{
  uint uVar1;
  uint uVar2;
  uint uVar3;
  uint uVar4;
  uint uVar5;
  uint uVar6;
  uint uVar7;
  undefined2 local_38 [2];
  undefined4 local_34;
  undefined4 uStack48;
  undefined4 local_2c;
 
  uVar7 = 0;
  j_bzero(local_38,0x24);
  uStack48 = param_5;
  local_2c = 0;
  DAT_0000ef68 += 1;
  local_34 = param_4;
  if (DAT_0000ef68 == 3) {
    uVar1 = add_ptp_handler(&DAT_00009052,handle_PTP_OC_0x9052 + 1,0);
    uVar2 = add_ptp_handler(&DAT_00009053,handle_PTP_OC_0x9053 + 1,0);
    uVar3 = add_ptp_handler(&DAT_00009057,handle_PTP_OC_0x9057 + 1,0);
    uVar4 = add_ptp_handler(&DAT_00009058,handle_PTP_OC_0x9058 + 1,0);
    uVar5 = add_ptp_handler(&DAT_00009059,handle_PTP_OC_0x9059 + 1,0);
    uVar6 = add_ptp_handler(&DAT_0000905a,handle_PTP_OC_0x905a + 1,0);
    uVar7 = add_ptp_handler(&DAT_0000905b,handle_PTP_OC_0x905b + 1,0);
    uVar7 |= uVar6 | uVar5 | uVar4 | uVar3 | uVar2 | uVar1;
    DAT_0000ef64 = 1;
  }
  if ((uVar7 & 1) == 0) {
    local_38[0] = 0x2001;
    (*(code *)param_2[3])(*param_2,local_38);
  }
  else {
    local_38[0] = 0x201f;
    (*(code *)param_2[3])(*param_2,local_38);
    uVar7 = 1;
  }
  return uVar7;
}


petabyte

  • New to the forum
  • *
  • Posts: 24
Re: Magic Lantern USB Installation Tools
« Reply #10 on: July 19, 2021, 08:24:19 PM »
I already found that the command 0x9052 becomes available after calling the command 0x9050 three times.

Have you tried calling 0x9052 after doing that?

Ant123

  • Contributor
  • Member
  • *****
  • Posts: 173
Re: Magic Lantern USB Installation Tools
« Reply #11 on: July 19, 2021, 08:28:09 PM »
Yes. It works.

Ant123

  • Contributor
  • Member
  • *****
  • Posts: 173
Re: Magic Lantern USB Installation Tools
« Reply #12 on: July 19, 2021, 09:21:11 PM »
Is there the way to run event procedures with arguments?

petabyte

  • New to the forum
  • *
  • Posts: 24
Re: Magic Lantern USB Installation Tools
« Reply #13 on: July 19, 2021, 09:36:06 PM »
Yes, I think you can send integer arguments simply via the standard PTP arguments.

I've set up https://github.com/petabyt/sequoia-ptpy to work like this:
`camera.eos_run_command("EnableBootDisk", [1, 2, 3])`

petabyte

  • New to the forum
  • *
  • Posts: 24
Re: Magic Lantern USB Installation Tools
« Reply #14 on: August 04, 2021, 07:30:25 PM »
I've added a few more features to the app:
- Redo UI with a GTK "notebook"
- Add "Make card scriptable"
- Add "Make card un-scriptable"
- Add credits and license
- Add button hints
- Better error messages

https://github.com/petabyt/mlinstall/releases/tag/0.1.3