How to differenciate(detect) 4 hard disks using udev rules

Hi all,
I am using SOM and carrier board of apalis imx6. I have taken latest software image from toradex website.
version - Linux apalis-imx6 5.4.77-5.1.0 armv7l GNU/Linux.

I have connected 4 hard disks to the carrier board using one sata expander. I placed the udev rule file in /etc/udev/rules.d .
my udev rule is

sata1

KERNEL=="sd*|sr*", KERNELS=="ata1", ENV{DEVTYPE}=="disk",       ENV{ID_SERIAL}=="?*", SYMLINK+="satadrive1"
KERNEL=="sd*|sr*",KERNELS=="ata1",ENV{DEVTYPE}=="partition",ENV{ID_SERIAL}=="?*",OPTIONS="all_partitions",SYMLINK+="satadrive1_%n"

sata2

KERNEL=="sd*|sr*", KERNELS=="ata2", ENV{DEVTYPE}=="disk",       ENV{ID_SERIAL}=="?*", SYMLINK+="satadrive2"
KERNEL=="sd*|sr*", KERNELS=="ata2", ENV{DEVTYPE}=="partition",  ENV{ID_SERIAL}=="?*", OPTIONS="all_partitions", SYMLINK+="satadrive2_%n"  

sata3

KERNEL=="sd*|sr*", KERNELS=="ata3", ENV{DEVTYPE}=="disk",       ENV{ID_SERIAL}=="?*", SYMLINK+="satadrive3"
KERNEL=="sd*|sr*", KERNELS=="ata3", ENV{DEVTYPE}=="partition",  ENV{ID_SERIAL}=="?*", OPTIONS="all_partitions", SYMLINK+="satadrive3_%n"

sata4

KERNEL=="sd*|sr*", KERNELS=="ata4", ENV{DEVTYPE}=="disk",       ENV{ID_SERIAL}=="?*", SYMLINK+="satadrive4"
KERNEL=="sd*|sr*", KERNELS=="ata4", ENV{DEVTYPE}=="partition",  ENV{ID_SERIAL}=="?*", OPTIONS="all_partitions", SYMLINK+="satadrive4_%n"

It is working when i connect one hard disk to sata expander(because its KERNELS==ata1).
But when i connect four hard disks, all hard disks “KERNELS” name is ata1 only. How can i get 2nd,3rd,4th hard disk KERNELS name as ata2,ata3,ata4.

Dear @jng ,

Can you please to get platform path of your device and then add it to udev rules to verify

e.g

udevadm info /dev/sda1 | grep “ID_PATH=”

E: ID_PATH=pci-0000:00:17.0-ata-1

then add to udev rules like below

SUBSYSTEM==“ata”,ENV{ID_PATH}==“pci-0000:00:17.0-ata-1”,SYMLINK+=“any_symlink_name”

please verify subsystem, since we don’t have exact detail of port expander we can not verify same.

Best Regards

Ritesh Kumar