Flashing STM32 Nucleo from Raspberry Pi
Linux thinks it's just some external storage, and holds back (caches) writes while it's mounted. You can try to


umount the Nucleo interface after copying, forcing everything to be written back
issue a sync command after copying
mount it with -o sync to disable write caching.


The first two methods are preferred over -o sync (as long as they work), because writes are still cached until the system is told to write everything, using up fewer flash write cycles.

If none of the above works reliably, then install openocd or texane st-link on the pi, and use that for flashing.