@qlqlo Most likely, it's the G1 H2 command at line 12 in your homex.g:
G1 H2 X-20 F12000 ; go back a few mm
This causes a diagonal move, as you're telling it to move the 'X' motor on it's own, rather than in the X axis direction. Remove the H2.
Some notes:
You shouldn't use G1 H2 on X and/or Y moves on CoreXY homing sequences, because it moves the individual motor (creating a diagonal move) rather than a move in either the X or Y axis direction, which requires both motors.
When you're using G1 H1 moves, you need to make sure both axes hit the endstop, by sending a G1 H1 X.. Y.. move, which will stop as soon as the first endtop is triggered, followed by individual G1 H1 X.. and G1 H1 Y.. to get both to home. As soon as an axis has touched home, you can use a normal G1 X.. or Y.. (no H1 or H2) to move it away from the axis, as it has homed.
All homing and these moving away moves should be done in G91 relative position mode.
See https://docs.duet3d.com/User_manual/Machine_configuration/Configuration_coreXY#homing-files
You could also do a basic configuration in the RRF configuration tool to get an example, to show where yours is going wrong: https://configtool.reprapfirmware.org/ This has had some errors in it (including adding the G1 H2 commands that your homing files have) but should be fixed now.
Ian