Pre-requisite for erasing an Android device is that USB debugging must be enabled. If the device screen is locked (e.g. PIN, password, pattern), it isn't possible to access device settings and enable USB debugging.
In this case, the device must be factory reset manually, which also removes the passcode. After manual factory reset, USB debugging can be enabled and device can be erased with B5M.
The factory reset can be done using a button combination. Please refer to device documentation or contact the manufacturer. There are also some web sites with useful information about this, for example: http://www.hardreset.info/