fixed the lock problem by using -Os to reduce code(stack) size