clone from codeaurora's lagacy bootloader