Tested on Moto M XT 1663 build number XT1663_S356_170621_ROW
Recovery Mode
- Press volume down + power
- select ‘Recovery mode’ and press power button.
Unlocking Bootloader
- enable the Developer Option
- enable the OEM Unlock
- adb reboot bootloader
- fastboot oem unlock
TWRP
- TWRP 3.2.2-0 For Moto M
- fastboot flash boot_XT1663_356.img
- fastboot flash recovery TWRP_Moto_M.img
Root
- Backup boot and Nvram
- Flash Magisk from OTG