Killed two Teensy 4.0s with this circuit - looking for help diagnosing
There are two glaring errors:-

You only have 0.1 μF of 'bulk' capacitance across the battery input (C2). At low PWM ratio the battery current will be a series of short spikes. Without sufficient bulk capacitance to supply these current spikes, they will go through the battery wires - which have significant inductance that will induce large voltage spikes. The 5V regulator's ripple rejection may not be good enough to keep the output voltage stable and the Teensy is only rated for 6 V maximum.

The 'BATT' trace between D1 and D2 is too thin to handle the motor current, and it introduces extra inductance that makes C2 even less effective. With high inductance between the capacitor and the 'BATT' trace going to the regulator, voltage spikes will be created at the regulator input. Also with the capacitor so far away the regulator may become unstable and oscillate at a high frequency (perhaps that is why the LM317 didn't work properly?).


You should move C2 as close as possible to the regulator, and add larger low-ESR capacitors (totaling several hundred μF) directly across the battery input and close to the FETs.
Move the BATT trace from between D1 and D2 to the right-hand side of the FETs so it takes a shorter path and can be made thicker. Give priority to it and route signal wires around it or across it on the other side of the board.
Another possible issue is that some of the FET Gate drive traces are quite long. If you can't move the FETs closer to the driver IC then add some series resistance (eg. 50 Ω) to suppress ringing.