I'm having trouble rooting my Samsung J320P with heimdall I can't download the pit. i connected to the device with adb. i'll try downloading the pit file and heimdall will tell me

Initialising connection...
Detecting device...
Claiming interface...
Setting up interface...

Initialising protocol...
Protocol initialisation successful.

Beginning session...

Some devices may take up to 2 minutes to respond.
Please be patient!

Downloading device's PIT file...
ERROR: Failed to send request to end PIT file transfer!
ERROR: Failed to download PIT file!
ERROR: Failed to send end session packet!
Releasing device interface...


Ending session...
Rooting doesn't need you repartitioning the phone. Just flash a custom recovery and then flash the rooting files through that recovery.

I'd suggest you to install TWRP recovery.  There is a complete guide on how to flash the recovery and rooting zip files here. Just follow CAREFULLY everything, step by step. (The guide is for Odin, I think it will work for Heimdall as well).