In NanopiM4v2 for sound on hdmi:
Edit the Alsa config:
nano /etc/asound.conf
Delete old content and paste the following one:
pcm.snd_card { type hw card 1 device 0 } ctl.snd_card { type hw card 1 device 0 } pcm.dmixer { type dmix ipc_key 1024 ipc_perm 0666 slave.pcm "snd_card" slave { period_time 0 period_size 1024 buffer_size 4096 rate 48000 format S16_LE channels 2 } bindings { 0 0 1 1 } }
Save the file and reboot.