I am able to connect to target and JLINK read the target with "No HSM flashed, no device lock", but when i try to flash the hex it shows "Locked device detected S32K324, please enter password"
Segger specifies that if an authentication key is required to enable debug access but has not yet been specified, a dialog box will appear prompting you to enter the key. For more details, please refer to the section "Specifying the authentication code using the ID Code dialog" in the following link:
If you are not seeing this behavior, could you please share a screenshot of the error message you are encountering?
Also, do you have access to another debugger that you could try using to flash the MCU? This could help determine whether the issue is related to the debugger or hardware.
BR, VaneB