For many months I struggled with this hard drive never sleeping issue.
Worked ok on other Odroids but not XU4. My view was that it was the software/functions that come prepackaged from the manufacturer on the hard drive to enable security/passport/recovery etc. If you can, try a different (basic) hard drive or try deleting all supplier functionality and prepackaged files from the hard drive and ideally then reformarting the whole drive.
Mine is working fine now with a Seagate drive, don’t remember which but I got the most basic possible with no preinstalled fancy stuff. (It was Westen Digital Pasport that gave me all the headaches).