For my part I have the M3. I used a bash code that here because works very well.

#!/bin/bash 
echo For Canon EOS-M3, version 001 created by Anthony C T LEE from Hong Kong 
#not working for 80D due to the filename of duplication of downloaded JPG  
# --capture-image-and-download does not work for M3 
echo 
echo Please set the camera 
echo 1. in bulb mode, 
echo 2. RAW and JPG format, 
echo 3. set the ISO and aperature prior to connection to raspberry pi. 
echo 
echo What is exposure time in seconds? 
read "var_exp_t" # Exposure time X echo 
echo What is total number of frames to be taken? 
read "var_frame_no" # Y 
gphoto2 --wait-event=2s 
# add a minimum of 2 sec time gap before the first shutter release since switch on to ensure the camera captures photos correctly 
# 
# eosremoterelease: 1=Press Half (OK); 2=Press Full (OK), 4=Release Full (OK), 5=Immediate (Fail, shutter cannot be Released) 
counter=1 
until [ $counter -gt $var_frame_no ] 
do
     gphoto2 --set-config eosremoterelease=2 --wait-event="$var_exp_t"s --set-config eosremoterelease=4 # --wait-event=Xs is time of exposure in X seconds
     gphoto2 --wait-event-and-download=5s --keep-raw # add a minimum of 5 sec for downloading image
     ((counter++)) 
done 
echo 
# or change it to "--wait-event=4s" (2nd wait-event with minimum of 4 sec) to ensure the camera downloads photos correctly 
echo A total of "$var_frame_no" frames with exposure of "$var_exp_t" seconds per frame were`

I also used CHDK but couldn't do anything with gphoto2.

Read More...