mtdtool

Also use Expresso

It would be nice to be able to do this for automated test too - but can we simulate the same by using adb?