Fix a spin flash write bug and ram optimized in BL