J17 (ttyTHS2) can be uses as is. J21 (ttyS0) is already set up as a serial console, and so you can’t use this without disabling serial console (and if you’ve disabled this, then probably you’d want to use “ttyTHS0” isntead of “ttyS0”…the port is compatible with two different drivers, and the “ttyTHS0” version would be the DMA-capable driver).
Disabling serial console isn’t as simple as telling Linux to not use this port because U-Boot itself also talks to this port. During boot any activity on that port could drop U-Boot into a command line mode and halt boot. If the cable is disconnected during boot, then it is as simple as changing the kernel command line (and on more recent releases this requires altering the device tree, so even that is someone complicated compared to the old days of extlinux.conf edits).
The current L4T release you are using will change how to accomplish this. If you are interested in removing serial console (which I wouldn’t advise if this isn’t a production unit…developers really should keep serial console), then there is a bit of information here (although this is for a TX1 the information is similar once you are in the more recent L4T releases, but details will differ):
You can find your current L4T release via:
head -n 1 /etc/nv_tegra_release