Please make sure that you are using "right" /etc/rc.local file.
I mean possibly your OS uses ramdisk and updating the file on live filesystem gets overwrited with unpacking ramdisk image.
Also please make sure that executing of this script does not stop somewhere before your command.
On my board I added a simple command into /etc/rc.local file:
root@imx8qmmek:~# tail -2 /etc/rc.local
echo test > /test.txt
exit 0
root@imx8qmmek:~#
Then I rebooted the board and got the result:
root@imx8qmmek:~# cat /test.txt
test
root@imx8qmmek:~#
As for autologin please try to add "-a root" (or some other user) into ExecStart option
of /etc/systemd/system/getty.target.wants/serial-getty@ttyAMA0.service file this way:
ExecStart=-/sbin/agetty -8 -a root -L %I 115200 $TERM