This error is observed when writing to flash is locked:

donal@horizonemb-build1:/data_fast/android/iMX8x/android_build$ sudo `which fastboot` flash vbmeta_b out/target/product/som_mx8q/vbmeta-imx8qx-var-som-wifi.img
target reported max download size of 419430400 bytes
Sending 'vbmeta_b' (4 KB)...
OKAY [ 0.003s]
Writing 'vbmeta_b'...
FAILED (remote: device is locked.)
Finished. Total time: 0.014s

To disable the oem lock, follow these steps:

From Android:

  1. Settings => System => About Tablet => Build number
  2. keep on tapping until you see a prompt that says “You are now a developer!”
  3. Settings => System => Advanced => Developer options => OEM unlocking

From the serial terminal:

  1. reboot to bootloader
  2. type “fastboot q” in the U-Boot command line
  3. run “sudo `which fastboot` oem unlock” from the Host PC
  4. wait until the unlock process is complete
  5. proceed for flashing