From 6022d3100a31266d48d89c4eaa562ed58a1f1909 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 21 Jan 2014 19:01:34 +0100 Subject: mkimxboot: tool can now recreate a stub to recover from very low battery Several devices, including the Fuze+ have great trouble recovering from very low battery states, even in the presence of USB power. This is partly due to buggy Sigmatel boot stubs and Rockbox bootloader doing unsafe power operations on boot (should be fixed soon). In such a state, it is impossible to boot either the OF and Rockbox, so only the recovery mode is available. With this commit, mkimxboot can now create a very small stub which only does one thing but does it well: setup charging to recover from any situation. It does not provide a fancy charging screen or whatever, screen will just stay black and the device will slowly charge at ~100mA. When the battery is back to a normal level, just unplug and boot normally. Change-Id: Ib50880af85ed1f4f64a7eed0f2221e73c889c351 --- rbutil/mkimxboot/dualboot.c | 175 ++++++++++++++++++++++++++--------- rbutil/mkimxboot/dualboot.h | 12 +-- rbutil/mkimxboot/dualboot/dualboot.c | 38 ++++++++ rbutil/mkimxboot/main.c | 2 + rbutil/mkimxboot/mkimxboot.c | 34 +++++++ rbutil/mkimxboot/mkimxboot.h | 1 + 6 files changed, 212 insertions(+), 50 deletions(-) diff --git a/rbutil/mkimxboot/dualboot.c b/rbutil/mkimxboot/dualboot.c index b991fe3f6e..2986560046 100644 --- a/rbutil/mkimxboot/dualboot.c +++ b/rbutil/mkimxboot/dualboot.c @@ -2,38 +2,81 @@ #include "dualboot.h" -unsigned char dualboot_fuzeplus[228] = { +unsigned char dualboot_fuzeplus[460] = { 0x10, 0x40, 0x2d, 0xe9, 0x00, 0x00, 0x00, 0xeb, 0x10, 0x80, 0xbd, 0xe8, 0x30, 0x00, 0x2d, 0xe9, - 0x01, 0x50, 0xa0, 0xe1, 0xb4, 0x30, 0x9f, 0xe5, 0xc0, 0x30, 0x93, 0xe5, 0x3f, 0x34, 0x03, 0xe2, + 0x01, 0x50, 0xa0, 0xe1, 0x94, 0x31, 0x9f, 0xe5, 0x03, 0x00, 0x50, 0xe1, 0x34, 0x00, 0x00, 0x1a, + 0x8c, 0x31, 0x9f, 0xe5, 0x02, 0x21, 0xa0, 0xe3, 0x08, 0x20, 0x83, 0xe5, 0x03, 0x21, 0x82, 0xe2, + 0x08, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, 0xff, 0x24, 0xc2, 0xe3, 0x02, 0x21, 0x82, 0xe3, + 0xd0, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, 0x0f, 0x28, 0xc2, 0xe3, 0x01, 0x28, 0x82, 0xe3, + 0xd0, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, 0x7f, 0x2e, 0xc2, 0xe3, 0x0f, 0x20, 0xc2, 0xe3, + 0xc8, 0x20, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, 0x01, 0x26, 0xa0, 0xe3, 0xd4, 0x20, 0x83, 0xe5, + 0x34, 0x21, 0x83, 0xe5, 0x30, 0x11, 0x93, 0xe5, 0x03, 0x18, 0xc1, 0xe3, 0x02, 0x18, 0x81, 0xe3, + 0x30, 0x11, 0x83, 0xe5, 0x03, 0x39, 0x43, 0xe2, 0x30, 0x10, 0x93, 0xe5, 0x0f, 0x1c, 0xc1, 0xe3, + 0x01, 0x1c, 0x81, 0xe3, 0x30, 0x10, 0x83, 0xe5, 0x30, 0x10, 0x93, 0xe5, 0x3f, 0x10, 0xc1, 0xe3, + 0x10, 0x10, 0x81, 0xe3, 0x30, 0x10, 0x83, 0xe5, 0x01, 0x18, 0xa0, 0xe3, 0x38, 0x10, 0x83, 0xe5, + 0x80, 0x10, 0x93, 0xe5, 0x02, 0x15, 0x81, 0xe3, 0x80, 0x10, 0x83, 0xe5, 0x18, 0x20, 0x83, 0xe5, + 0x10, 0x20, 0x93, 0xe5, 0x3f, 0x2a, 0xc2, 0xe3, 0x01, 0x28, 0x82, 0xe3, 0x10, 0x20, 0x83, 0xe5, + 0x01, 0x39, 0x43, 0xe2, 0x00, 0x10, 0xa0, 0xe3, 0x20, 0x20, 0x93, 0xe5, 0x01, 0x2a, 0x82, 0xe3, + 0x20, 0x20, 0x83, 0xe5, 0x90, 0x1f, 0x07, 0xee, 0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1, + 0xf8, 0xff, 0xff, 0xea, 0xbc, 0x30, 0x9f, 0xe5, 0xc0, 0x30, 0x93, 0xe5, 0x3f, 0x34, 0x03, 0xe2, 0x23, 0x3c, 0xa0, 0xe1, 0x20, 0x00, 0x13, 0xe3, 0x01, 0x30, 0xa0, 0x13, 0x02, 0x00, 0x00, 0x1a, - 0x10, 0x00, 0x13, 0xe3, 0x02, 0x30, 0xa0, 0x13, 0x00, 0x30, 0xa0, 0x03, 0x90, 0x20, 0x9f, 0xe5, + 0x10, 0x00, 0x13, 0xe3, 0x02, 0x30, 0xa0, 0x13, 0x00, 0x30, 0xa0, 0x03, 0x98, 0x20, 0x9f, 0xe5, 0x10, 0x26, 0x92, 0xe5, 0x01, 0x01, 0x12, 0xe3, 0x10, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x53, 0xe3, - 0x11, 0x00, 0x00, 0x1a, 0x03, 0x40, 0xa0, 0xe1, 0x70, 0x10, 0x9f, 0xe5, 0x74, 0xc0, 0x9f, 0xe5, + 0x11, 0x00, 0x00, 0x1a, 0x03, 0x40, 0xa0, 0xe1, 0x78, 0x10, 0x9f, 0xe5, 0x7c, 0xc0, 0x9f, 0xe5, 0xc0, 0x20, 0x91, 0xe5, 0x03, 0x26, 0x02, 0xe2, 0x01, 0x06, 0x52, 0xe3, 0x01, 0x40, 0x84, 0x02, - 0x01, 0x30, 0x83, 0xe2, 0x0c, 0x00, 0x53, 0xe1, 0xf8, 0xff, 0xff, 0x1a, 0x58, 0x30, 0x9f, 0xe5, + 0x01, 0x30, 0x83, 0xe2, 0x0c, 0x00, 0x53, 0xe1, 0xf8, 0xff, 0xff, 0x1a, 0x60, 0x30, 0x9f, 0xe5, 0x03, 0x00, 0x54, 0xe1, 0x04, 0x00, 0x00, 0xca, 0x06, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0xa0, 0xe3, 0x30, 0x00, 0xbd, 0xe8, 0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x85, 0xe5, - 0x01, 0x00, 0xa0, 0xe3, 0xfa, 0xff, 0xff, 0xea, 0x24, 0x30, 0x9f, 0xe5, 0x03, 0x27, 0xa0, 0xe3, + 0x01, 0x00, 0xa0, 0xe3, 0xfa, 0xff, 0xff, 0xea, 0x2c, 0x30, 0x9f, 0xe5, 0x03, 0x27, 0xa0, 0xe3, 0x04, 0x21, 0x83, 0xe5, 0x02, 0x2c, 0xa0, 0xe3, 0x00, 0x27, 0x83, 0xe5, 0x00, 0x25, 0x83, 0xe5, - 0x18, 0x20, 0x9f, 0xe5, 0x0b, 0x39, 0x83, 0xe2, 0x00, 0x21, 0x83, 0xe5, 0xee, 0xff, 0xff, 0xea, - 0x00, 0x40, 0x04, 0x80, 0x00, 0x80, 0x01, 0x80, 0x70, 0x64, 0x08, 0x00, 0x7f, 0x1a, 0x06, 0x00, - 0x01, 0x00, 0xff, 0xff + 0x20, 0x20, 0x9f, 0xe5, 0x0b, 0x39, 0x83, 0xe2, 0x00, 0x21, 0x83, 0xe5, 0xee, 0xff, 0xff, 0xea, + 0x63, 0x68, 0x72, 0x67, 0x00, 0x00, 0x05, 0x80, 0x00, 0x40, 0x04, 0x80, 0x00, 0x80, 0x01, 0x80, + 0x70, 0x64, 0x08, 0x00, 0x7f, 0x1a, 0x06, 0x00, 0x01, 0x00, 0xff, 0xff }; -unsigned char dualboot_zenxfi2[96] = { - 0x10, 0x40, 0x2d, 0xe9, 0x00, 0x00, 0x00, 0xeb, 0x10, 0x80, 0xbd, 0xe8, 0x44, 0x30, 0x9f, 0xe5, - 0xc0, 0x30, 0x93, 0xe5, 0x02, 0x02, 0x13, 0xe3, 0x04, 0x00, 0x00, 0x1a, 0x38, 0x30, 0x9f, 0xe5, +unsigned char dualboot_zenxfi2[328] = { + 0x10, 0x40, 0x2d, 0xe9, 0x00, 0x00, 0x00, 0xeb, 0x10, 0x80, 0xbd, 0xe8, 0x24, 0x31, 0x9f, 0xe5, + 0x03, 0x00, 0x50, 0xe1, 0x34, 0x00, 0x00, 0x1a, 0x1c, 0x31, 0x9f, 0xe5, 0x02, 0x21, 0xa0, 0xe3, + 0x08, 0x20, 0x83, 0xe5, 0x03, 0x21, 0x82, 0xe2, 0x08, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, + 0xff, 0x24, 0xc2, 0xe3, 0x02, 0x21, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, + 0x0f, 0x28, 0xc2, 0xe3, 0x01, 0x28, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, + 0x7f, 0x2e, 0xc2, 0xe3, 0x0f, 0x20, 0xc2, 0xe3, 0xc8, 0x20, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, + 0x01, 0x26, 0xa0, 0xe3, 0xd4, 0x20, 0x83, 0xe5, 0x34, 0x21, 0x83, 0xe5, 0x30, 0x11, 0x93, 0xe5, + 0x03, 0x18, 0xc1, 0xe3, 0x02, 0x18, 0x81, 0xe3, 0x30, 0x11, 0x83, 0xe5, 0x03, 0x39, 0x43, 0xe2, + 0x30, 0x10, 0x93, 0xe5, 0x0f, 0x1c, 0xc1, 0xe3, 0x01, 0x1c, 0x81, 0xe3, 0x30, 0x10, 0x83, 0xe5, + 0x30, 0x10, 0x93, 0xe5, 0x3f, 0x10, 0xc1, 0xe3, 0x10, 0x10, 0x81, 0xe3, 0x30, 0x10, 0x83, 0xe5, + 0x01, 0x18, 0xa0, 0xe3, 0x38, 0x10, 0x83, 0xe5, 0x80, 0x10, 0x93, 0xe5, 0x02, 0x15, 0x81, 0xe3, + 0x80, 0x10, 0x83, 0xe5, 0x18, 0x20, 0x83, 0xe5, 0x10, 0x20, 0x93, 0xe5, 0x3f, 0x2a, 0xc2, 0xe3, + 0x01, 0x28, 0x82, 0xe3, 0x10, 0x20, 0x83, 0xe5, 0x01, 0x39, 0x43, 0xe2, 0x00, 0x10, 0xa0, 0xe3, + 0x20, 0x20, 0x93, 0xe5, 0x01, 0x2a, 0x82, 0xe3, 0x20, 0x20, 0x83, 0xe5, 0x90, 0x1f, 0x07, 0xee, + 0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1, 0xf8, 0xff, 0xff, 0xea, 0x4c, 0x30, 0x9f, 0xe5, + 0xc0, 0x30, 0x93, 0xe5, 0x02, 0x02, 0x13, 0xe3, 0x04, 0x00, 0x00, 0x1a, 0x40, 0x30, 0x9f, 0xe5, 0x00, 0x36, 0x93, 0xe5, 0x01, 0x09, 0x13, 0xe3, 0x08, 0x00, 0x00, 0x0a, 0x04, 0x00, 0x00, 0xea, - 0x20, 0x30, 0x9f, 0xe5, 0xc0, 0x30, 0x93, 0xe5, 0x03, 0x36, 0x03, 0xe2, 0x01, 0x06, 0x53, 0xe3, + 0x28, 0x30, 0x9f, 0xe5, 0xc0, 0x30, 0x93, 0xe5, 0x03, 0x36, 0x03, 0xe2, 0x01, 0x06, 0x53, 0xe3, 0x02, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x81, 0xe5, 0x01, 0x00, 0xa0, 0xe3, 0x1e, 0xff, 0x2f, 0xe1, - 0x00, 0x00, 0xa0, 0xe3, 0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x40, 0x04, 0x80, 0x00, 0x80, 0x01, 0x80 + 0x00, 0x00, 0xa0, 0xe3, 0x1e, 0xff, 0x2f, 0xe1, 0x63, 0x68, 0x72, 0x67, 0x00, 0x00, 0x05, 0x80, + 0x00, 0x40, 0x04, 0x80, 0x00, 0x80, 0x01, 0x80 }; -unsigned char dualboot_zenxfi3[56] = { - 0x10, 0x40, 0x2d, 0xe9, 0x00, 0x00, 0x00, 0xeb, 0x10, 0x80, 0xbd, 0xe8, 0x1c, 0x30, 0x9f, 0xe5, - 0xc0, 0x30, 0x93, 0xe5, 0x18, 0x30, 0x9f, 0xe5, 0x20, 0x36, 0x93, 0xe5, 0x80, 0x00, 0x13, 0xe3, +unsigned char dualboot_zenxfi3[288] = { + 0x10, 0x40, 0x2d, 0xe9, 0x00, 0x00, 0x00, 0xeb, 0x10, 0x80, 0xbd, 0xe8, 0xfc, 0x30, 0x9f, 0xe5, + 0x03, 0x00, 0x50, 0xe1, 0x34, 0x00, 0x00, 0x1a, 0xf4, 0x30, 0x9f, 0xe5, 0x02, 0x21, 0xa0, 0xe3, + 0x08, 0x20, 0x83, 0xe5, 0x03, 0x21, 0x82, 0xe2, 0x08, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, + 0xff, 0x24, 0xc2, 0xe3, 0x02, 0x21, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, + 0x0f, 0x28, 0xc2, 0xe3, 0x01, 0x28, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, + 0x7f, 0x2e, 0xc2, 0xe3, 0x0f, 0x20, 0xc2, 0xe3, 0xc8, 0x20, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, + 0x01, 0x26, 0xa0, 0xe3, 0xd4, 0x20, 0x83, 0xe5, 0x34, 0x21, 0x83, 0xe5, 0x30, 0x11, 0x93, 0xe5, + 0x03, 0x18, 0xc1, 0xe3, 0x02, 0x18, 0x81, 0xe3, 0x30, 0x11, 0x83, 0xe5, 0x03, 0x39, 0x43, 0xe2, + 0x30, 0x10, 0x93, 0xe5, 0x0f, 0x1c, 0xc1, 0xe3, 0x01, 0x1c, 0x81, 0xe3, 0x30, 0x10, 0x83, 0xe5, + 0x30, 0x10, 0x93, 0xe5, 0x3f, 0x10, 0xc1, 0xe3, 0x10, 0x10, 0x81, 0xe3, 0x30, 0x10, 0x83, 0xe5, + 0x01, 0x18, 0xa0, 0xe3, 0x38, 0x10, 0x83, 0xe5, 0x80, 0x10, 0x93, 0xe5, 0x02, 0x15, 0x81, 0xe3, + 0x80, 0x10, 0x83, 0xe5, 0x18, 0x20, 0x83, 0xe5, 0x10, 0x20, 0x93, 0xe5, 0x3f, 0x2a, 0xc2, 0xe3, + 0x01, 0x28, 0x82, 0xe3, 0x10, 0x20, 0x83, 0xe5, 0x01, 0x39, 0x43, 0xe2, 0x00, 0x10, 0xa0, 0xe3, + 0x20, 0x20, 0x93, 0xe5, 0x01, 0x2a, 0x82, 0xe3, 0x20, 0x20, 0x83, 0xe5, 0x90, 0x1f, 0x07, 0xee, + 0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1, 0xf8, 0xff, 0xff, 0xea, 0x24, 0x30, 0x9f, 0xe5, + 0xc0, 0x30, 0x93, 0xe5, 0x20, 0x30, 0x9f, 0xe5, 0x20, 0x36, 0x93, 0xe5, 0x80, 0x00, 0x13, 0xe3, 0x00, 0x00, 0xa0, 0x03, 0x00, 0x00, 0x81, 0x15, 0x01, 0x00, 0xa0, 0x13, 0x1e, 0xff, 0x2f, 0xe1, - 0x00, 0x40, 0x04, 0x80, 0x00, 0x80, 0x01, 0x80 + 0x63, 0x68, 0x72, 0x67, 0x00, 0x00, 0x05, 0x80, 0x00, 0x40, 0x04, 0x80, 0x00, 0x80, 0x01, 0x80 }; -unsigned char dualboot_nwze370[416] = { +unsigned char dualboot_nwze370[644] = { 0x10, 0x40, 0x2d, 0xe9, 0x1e, 0x00, 0x00, 0xeb, 0x10, 0x80, 0xbd, 0xe8, 0x68, 0x30, 0x9f, 0xe5, 0x01, 0x20, 0xa0, 0xe3, 0x18, 0x20, 0x83, 0xe5, 0x04, 0x20, 0x83, 0xe5, 0x03, 0x20, 0xa0, 0xe1, 0x10, 0x30, 0x92, 0xe5, 0x01, 0x00, 0x13, 0xe3, 0xfc, 0xff, 0xff, 0x0a, 0x48, 0x30, 0x9f, 0xe5, @@ -42,26 +85,41 @@ unsigned char dualboot_nwze370[416] = { 0x41, 0x2e, 0x43, 0xe2, 0x0a, 0x20, 0x42, 0xe2, 0x63, 0x00, 0x52, 0xe3, 0x02, 0x00, 0xa0, 0x93, 0x1e, 0xff, 0x2f, 0x91, 0x16, 0x3d, 0x43, 0xe2, 0x0c, 0x30, 0x43, 0xe2, 0x63, 0x00, 0x53, 0xe3, 0x00, 0x00, 0xa0, 0x83, 0x01, 0x00, 0xa0, 0x93, 0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x05, 0x80, - 0x00, 0x80, 0x01, 0x80, 0xf0, 0x41, 0x2d, 0xe9, 0x00, 0x70, 0xa0, 0xe1, 0x01, 0x60, 0xa0, 0xe1, - 0xf8, 0x30, 0x9f, 0xe5, 0xc0, 0x30, 0x93, 0xe5, 0x3f, 0x34, 0x03, 0xe2, 0x23, 0x3c, 0xa0, 0xe1, + 0x00, 0x80, 0x01, 0x80, 0xf0, 0x41, 0x2d, 0xe9, 0x00, 0x60, 0xa0, 0xe1, 0x01, 0x70, 0xa0, 0xe1, + 0xd8, 0x31, 0x9f, 0xe5, 0x03, 0x00, 0x50, 0xe1, 0x34, 0x00, 0x00, 0x1a, 0xd0, 0x31, 0x9f, 0xe5, + 0x02, 0x21, 0xa0, 0xe3, 0x08, 0x20, 0x83, 0xe5, 0x03, 0x21, 0x82, 0xe2, 0x08, 0x20, 0x83, 0xe5, + 0xd0, 0x20, 0x93, 0xe5, 0xff, 0x24, 0xc2, 0xe3, 0x02, 0x21, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, + 0xd0, 0x20, 0x93, 0xe5, 0x0f, 0x28, 0xc2, 0xe3, 0x01, 0x28, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, + 0xd0, 0x20, 0x93, 0xe5, 0x7f, 0x2e, 0xc2, 0xe3, 0x0f, 0x20, 0xc2, 0xe3, 0xc8, 0x20, 0x82, 0xe3, + 0xd0, 0x20, 0x83, 0xe5, 0x01, 0x26, 0xa0, 0xe3, 0xd4, 0x20, 0x83, 0xe5, 0x34, 0x21, 0x83, 0xe5, + 0x30, 0x11, 0x93, 0xe5, 0x03, 0x18, 0xc1, 0xe3, 0x02, 0x18, 0x81, 0xe3, 0x30, 0x11, 0x83, 0xe5, + 0x03, 0x39, 0x43, 0xe2, 0x30, 0x10, 0x93, 0xe5, 0x0f, 0x1c, 0xc1, 0xe3, 0x01, 0x1c, 0x81, 0xe3, + 0x30, 0x10, 0x83, 0xe5, 0x30, 0x10, 0x93, 0xe5, 0x3f, 0x10, 0xc1, 0xe3, 0x10, 0x10, 0x81, 0xe3, + 0x30, 0x10, 0x83, 0xe5, 0x01, 0x18, 0xa0, 0xe3, 0x38, 0x10, 0x83, 0xe5, 0x80, 0x10, 0x93, 0xe5, + 0x02, 0x15, 0x81, 0xe3, 0x80, 0x10, 0x83, 0xe5, 0x18, 0x20, 0x83, 0xe5, 0x10, 0x20, 0x93, 0xe5, + 0x3f, 0x2a, 0xc2, 0xe3, 0x01, 0x28, 0x82, 0xe3, 0x10, 0x20, 0x83, 0xe5, 0x01, 0x39, 0x43, 0xe2, + 0x00, 0x10, 0xa0, 0xe3, 0x20, 0x20, 0x93, 0xe5, 0x01, 0x2a, 0x82, 0xe3, 0x20, 0x20, 0x83, 0xe5, + 0x90, 0x1f, 0x07, 0xee, 0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1, 0xf8, 0xff, 0xff, 0xea, + 0x00, 0x31, 0x9f, 0xe5, 0xc0, 0x30, 0x93, 0xe5, 0x3f, 0x34, 0x03, 0xe2, 0x23, 0x3c, 0xa0, 0xe1, 0x20, 0x00, 0x13, 0xe3, 0x01, 0x00, 0x00, 0x1a, 0x10, 0x00, 0x13, 0xe3, 0x23, 0x00, 0x00, 0x0a, 0xdc, 0x30, 0x9f, 0xe5, 0x02, 0x21, 0xa0, 0xe3, 0x08, 0x20, 0x83, 0xe5, 0x03, 0x21, 0x82, 0xe2, 0x08, 0x20, 0x83, 0xe5, 0xff, 0x24, 0x82, 0xe2, 0x58, 0x20, 0x83, 0xe5, 0xc2, 0x24, 0x82, 0xe2, 0x24, 0x20, 0x83, 0xe5, 0x02, 0x2c, 0xa0, 0xe3, 0x0e, 0x39, 0x43, 0xe2, 0x04, 0x24, 0x83, 0xe5, - 0xc9, 0xff, 0xff, 0xeb, 0x00, 0x40, 0x50, 0xe2, 0x06, 0x00, 0x00, 0x1a, 0x0a, 0x00, 0x00, 0xea, - 0xc5, 0xff, 0xff, 0xeb, 0x00, 0x00, 0x54, 0xe1, 0x0a, 0x00, 0x00, 0x1a, 0xc0, 0x30, 0x98, 0xe5, + 0x91, 0xff, 0xff, 0xeb, 0x00, 0x40, 0x50, 0xe2, 0x06, 0x00, 0x00, 0x1a, 0x0a, 0x00, 0x00, 0xea, + 0x8d, 0xff, 0xff, 0xeb, 0x00, 0x00, 0x54, 0xe1, 0x0a, 0x00, 0x00, 0x1a, 0xc0, 0x30, 0x98, 0xe5, 0x03, 0x00, 0x55, 0xe1, 0xf9, 0xff, 0xff, 0x8a, 0x01, 0x00, 0x54, 0xe3, 0x02, 0x00, 0x00, 0x0a, - 0x02, 0x00, 0x54, 0xe3, 0x03, 0x00, 0x00, 0x1a, 0x06, 0x00, 0x00, 0xea, 0x00, 0x70, 0x86, 0xe5, - 0x01, 0x00, 0xa0, 0xe3, 0xf0, 0x81, 0xbd, 0xe8, 0x68, 0x20, 0x9f, 0xe5, 0x5c, 0x30, 0x9f, 0xe5, + 0x02, 0x00, 0x54, 0xe3, 0x03, 0x00, 0x00, 0x1a, 0x06, 0x00, 0x00, 0xea, 0x00, 0x60, 0x87, 0xe5, + 0x01, 0x00, 0xa0, 0xe3, 0xf0, 0x81, 0xbd, 0xe8, 0x6c, 0x20, 0x9f, 0xe5, 0x64, 0x30, 0x9f, 0xe5, 0x00, 0x21, 0x83, 0xe5, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0xa0, 0xe3, 0xf0, 0x81, 0xbd, 0xe8, 0x4c, 0x30, 0x9f, 0xe5, 0x02, 0x21, 0xa0, 0xe3, 0x08, 0x20, 0x83, 0xe5, 0x03, 0x21, 0x82, 0xe2, 0x08, 0x20, 0x83, 0xe5, 0xff, 0x24, 0x82, 0xe2, 0x58, 0x20, 0x83, 0xe5, 0xc2, 0x24, 0x82, 0xe2, 0x24, 0x20, 0x83, 0xe5, 0x02, 0x2c, 0xa0, 0xe3, 0x0e, 0x39, 0x43, 0xe2, 0x04, 0x24, 0x83, 0xe5, - 0xa5, 0xff, 0xff, 0xeb, 0x00, 0x40, 0xa0, 0xe1, 0x1c, 0x30, 0x9f, 0xe5, 0xc0, 0x50, 0x93, 0xe5, + 0x6d, 0xff, 0xff, 0xeb, 0x00, 0x40, 0xa0, 0xe1, 0x20, 0x30, 0x9f, 0xe5, 0xc0, 0x50, 0x93, 0xe5, 0x3d, 0x59, 0x85, 0xe2, 0x09, 0x5d, 0x85, 0xe2, 0x03, 0x80, 0xa0, 0xe1, 0xda, 0xff, 0xff, 0xea, - 0x00, 0x40, 0x04, 0x80, 0x00, 0x00, 0x05, 0x80, 0x01, 0x00, 0xff, 0xff, 0x00, 0xc0, 0x01, 0x80 + 0x63, 0x68, 0x72, 0x67, 0x00, 0x00, 0x05, 0x80, 0x00, 0x40, 0x04, 0x80, 0x01, 0x00, 0xff, 0xff, + 0x00, 0xc0, 0x01, 0x80 }; -unsigned char dualboot_nwze360[416] = { +unsigned char dualboot_nwze360[644] = { 0x10, 0x40, 0x2d, 0xe9, 0x1e, 0x00, 0x00, 0xeb, 0x10, 0x80, 0xbd, 0xe8, 0x68, 0x30, 0x9f, 0xe5, 0x01, 0x20, 0xa0, 0xe3, 0x18, 0x20, 0x83, 0xe5, 0x04, 0x20, 0x83, 0xe5, 0x03, 0x20, 0xa0, 0xe1, 0x10, 0x30, 0x92, 0xe5, 0x01, 0x00, 0x13, 0xe3, 0xfc, 0xff, 0xff, 0x0a, 0x48, 0x30, 0x9f, 0xe5, @@ -70,33 +128,62 @@ unsigned char dualboot_nwze360[416] = { 0x41, 0x2e, 0x43, 0xe2, 0x0a, 0x20, 0x42, 0xe2, 0x63, 0x00, 0x52, 0xe3, 0x02, 0x00, 0xa0, 0x93, 0x1e, 0xff, 0x2f, 0x91, 0x16, 0x3d, 0x43, 0xe2, 0x0c, 0x30, 0x43, 0xe2, 0x63, 0x00, 0x53, 0xe3, 0x00, 0x00, 0xa0, 0x83, 0x01, 0x00, 0xa0, 0x93, 0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x05, 0x80, - 0x00, 0x80, 0x01, 0x80, 0xf0, 0x41, 0x2d, 0xe9, 0x00, 0x70, 0xa0, 0xe1, 0x01, 0x60, 0xa0, 0xe1, - 0xf8, 0x30, 0x9f, 0xe5, 0xc0, 0x30, 0x93, 0xe5, 0x3f, 0x34, 0x03, 0xe2, 0x23, 0x3c, 0xa0, 0xe1, + 0x00, 0x80, 0x01, 0x80, 0xf0, 0x41, 0x2d, 0xe9, 0x00, 0x60, 0xa0, 0xe1, 0x01, 0x70, 0xa0, 0xe1, + 0xd8, 0x31, 0x9f, 0xe5, 0x03, 0x00, 0x50, 0xe1, 0x34, 0x00, 0x00, 0x1a, 0xd0, 0x31, 0x9f, 0xe5, + 0x02, 0x21, 0xa0, 0xe3, 0x08, 0x20, 0x83, 0xe5, 0x03, 0x21, 0x82, 0xe2, 0x08, 0x20, 0x83, 0xe5, + 0xd0, 0x20, 0x93, 0xe5, 0xff, 0x24, 0xc2, 0xe3, 0x02, 0x21, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, + 0xd0, 0x20, 0x93, 0xe5, 0x0f, 0x28, 0xc2, 0xe3, 0x01, 0x28, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, + 0xd0, 0x20, 0x93, 0xe5, 0x7f, 0x2e, 0xc2, 0xe3, 0x0f, 0x20, 0xc2, 0xe3, 0xc8, 0x20, 0x82, 0xe3, + 0xd0, 0x20, 0x83, 0xe5, 0x01, 0x26, 0xa0, 0xe3, 0xd4, 0x20, 0x83, 0xe5, 0x34, 0x21, 0x83, 0xe5, + 0x30, 0x11, 0x93, 0xe5, 0x03, 0x18, 0xc1, 0xe3, 0x02, 0x18, 0x81, 0xe3, 0x30, 0x11, 0x83, 0xe5, + 0x03, 0x39, 0x43, 0xe2, 0x30, 0x10, 0x93, 0xe5, 0x0f, 0x1c, 0xc1, 0xe3, 0x01, 0x1c, 0x81, 0xe3, + 0x30, 0x10, 0x83, 0xe5, 0x30, 0x10, 0x93, 0xe5, 0x3f, 0x10, 0xc1, 0xe3, 0x10, 0x10, 0x81, 0xe3, + 0x30, 0x10, 0x83, 0xe5, 0x01, 0x18, 0xa0, 0xe3, 0x38, 0x10, 0x83, 0xe5, 0x80, 0x10, 0x93, 0xe5, + 0x02, 0x15, 0x81, 0xe3, 0x80, 0x10, 0x83, 0xe5, 0x18, 0x20, 0x83, 0xe5, 0x10, 0x20, 0x93, 0xe5, + 0x3f, 0x2a, 0xc2, 0xe3, 0x01, 0x28, 0x82, 0xe3, 0x10, 0x20, 0x83, 0xe5, 0x01, 0x39, 0x43, 0xe2, + 0x00, 0x10, 0xa0, 0xe3, 0x20, 0x20, 0x93, 0xe5, 0x01, 0x2a, 0x82, 0xe3, 0x20, 0x20, 0x83, 0xe5, + 0x90, 0x1f, 0x07, 0xee, 0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1, 0xf8, 0xff, 0xff, 0xea, + 0x00, 0x31, 0x9f, 0xe5, 0xc0, 0x30, 0x93, 0xe5, 0x3f, 0x34, 0x03, 0xe2, 0x23, 0x3c, 0xa0, 0xe1, 0x20, 0x00, 0x13, 0xe3, 0x01, 0x00, 0x00, 0x1a, 0x10, 0x00, 0x13, 0xe3, 0x23, 0x00, 0x00, 0x0a, 0xdc, 0x30, 0x9f, 0xe5, 0x02, 0x21, 0xa0, 0xe3, 0x08, 0x20, 0x83, 0xe5, 0x03, 0x21, 0x82, 0xe2, 0x08, 0x20, 0x83, 0xe5, 0xff, 0x24, 0x82, 0xe2, 0x58, 0x20, 0x83, 0xe5, 0xc2, 0x24, 0x82, 0xe2, 0x24, 0x20, 0x83, 0xe5, 0x02, 0x2c, 0xa0, 0xe3, 0x0e, 0x39, 0x43, 0xe2, 0x04, 0x24, 0x83, 0xe5, - 0xc9, 0xff, 0xff, 0xeb, 0x00, 0x40, 0x50, 0xe2, 0x06, 0x00, 0x00, 0x1a, 0x0a, 0x00, 0x00, 0xea, - 0xc5, 0xff, 0xff, 0xeb, 0x00, 0x00, 0x54, 0xe1, 0x0a, 0x00, 0x00, 0x1a, 0xc0, 0x30, 0x98, 0xe5, + 0x91, 0xff, 0xff, 0xeb, 0x00, 0x40, 0x50, 0xe2, 0x06, 0x00, 0x00, 0x1a, 0x0a, 0x00, 0x00, 0xea, + 0x8d, 0xff, 0xff, 0xeb, 0x00, 0x00, 0x54, 0xe1, 0x0a, 0x00, 0x00, 0x1a, 0xc0, 0x30, 0x98, 0xe5, 0x03, 0x00, 0x55, 0xe1, 0xf9, 0xff, 0xff, 0x8a, 0x01, 0x00, 0x54, 0xe3, 0x02, 0x00, 0x00, 0x0a, - 0x02, 0x00, 0x54, 0xe3, 0x03, 0x00, 0x00, 0x1a, 0x06, 0x00, 0x00, 0xea, 0x00, 0x70, 0x86, 0xe5, - 0x01, 0x00, 0xa0, 0xe3, 0xf0, 0x81, 0xbd, 0xe8, 0x68, 0x20, 0x9f, 0xe5, 0x5c, 0x30, 0x9f, 0xe5, + 0x02, 0x00, 0x54, 0xe3, 0x03, 0x00, 0x00, 0x1a, 0x06, 0x00, 0x00, 0xea, 0x00, 0x60, 0x87, 0xe5, + 0x01, 0x00, 0xa0, 0xe3, 0xf0, 0x81, 0xbd, 0xe8, 0x6c, 0x20, 0x9f, 0xe5, 0x64, 0x30, 0x9f, 0xe5, 0x00, 0x21, 0x83, 0xe5, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0xa0, 0xe3, 0xf0, 0x81, 0xbd, 0xe8, 0x4c, 0x30, 0x9f, 0xe5, 0x02, 0x21, 0xa0, 0xe3, 0x08, 0x20, 0x83, 0xe5, 0x03, 0x21, 0x82, 0xe2, 0x08, 0x20, 0x83, 0xe5, 0xff, 0x24, 0x82, 0xe2, 0x58, 0x20, 0x83, 0xe5, 0xc2, 0x24, 0x82, 0xe2, 0x24, 0x20, 0x83, 0xe5, 0x02, 0x2c, 0xa0, 0xe3, 0x0e, 0x39, 0x43, 0xe2, 0x04, 0x24, 0x83, 0xe5, - 0xa5, 0xff, 0xff, 0xeb, 0x00, 0x40, 0xa0, 0xe1, 0x1c, 0x30, 0x9f, 0xe5, 0xc0, 0x50, 0x93, 0xe5, + 0x6d, 0xff, 0xff, 0xeb, 0x00, 0x40, 0xa0, 0xe1, 0x20, 0x30, 0x9f, 0xe5, 0xc0, 0x50, 0x93, 0xe5, 0x3d, 0x59, 0x85, 0xe2, 0x09, 0x5d, 0x85, 0xe2, 0x03, 0x80, 0xa0, 0xe1, 0xda, 0xff, 0xff, 0xea, - 0x00, 0x40, 0x04, 0x80, 0x00, 0x00, 0x05, 0x80, 0x01, 0x00, 0xff, 0xff, 0x00, 0xc0, 0x01, 0x80 + 0x63, 0x68, 0x72, 0x67, 0x00, 0x00, 0x05, 0x80, 0x00, 0x40, 0x04, 0x80, 0x01, 0x00, 0xff, 0xff, + 0x00, 0xc0, 0x01, 0x80 }; -unsigned char dualboot_zenxfistyle[136] = { - 0x10, 0x40, 0x2d, 0xe9, 0x00, 0x00, 0x00, 0xeb, 0x10, 0x80, 0xbd, 0xe8, 0x6c, 0x30, 0x9f, 0xe5, - 0xc0, 0x30, 0x93, 0xe5, 0x68, 0x30, 0x9f, 0xe5, 0x02, 0x21, 0xa0, 0xe3, 0x08, 0x20, 0x83, 0xe5, +unsigned char dualboot_zenxfistyle[360] = { + 0x10, 0x40, 0x2d, 0xe9, 0x00, 0x00, 0x00, 0xeb, 0x10, 0x80, 0xbd, 0xe8, 0x48, 0x31, 0x9f, 0xe5, + 0x03, 0x00, 0x50, 0xe1, 0x34, 0x00, 0x00, 0x1a, 0x40, 0x31, 0x9f, 0xe5, 0x02, 0x21, 0xa0, 0xe3, + 0x08, 0x20, 0x83, 0xe5, 0x03, 0x21, 0x82, 0xe2, 0x08, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, + 0xff, 0x24, 0xc2, 0xe3, 0x02, 0x21, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, + 0x0f, 0x28, 0xc2, 0xe3, 0x01, 0x28, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, 0xd0, 0x20, 0x93, 0xe5, + 0x7f, 0x2e, 0xc2, 0xe3, 0x0f, 0x20, 0xc2, 0xe3, 0xc8, 0x20, 0x82, 0xe3, 0xd0, 0x20, 0x83, 0xe5, + 0x01, 0x26, 0xa0, 0xe3, 0xd4, 0x20, 0x83, 0xe5, 0x34, 0x21, 0x83, 0xe5, 0x30, 0x11, 0x93, 0xe5, + 0x03, 0x18, 0xc1, 0xe3, 0x02, 0x18, 0x81, 0xe3, 0x30, 0x11, 0x83, 0xe5, 0x03, 0x39, 0x43, 0xe2, + 0x30, 0x10, 0x93, 0xe5, 0x0f, 0x1c, 0xc1, 0xe3, 0x01, 0x1c, 0x81, 0xe3, 0x30, 0x10, 0x83, 0xe5, + 0x30, 0x10, 0x93, 0xe5, 0x3f, 0x10, 0xc1, 0xe3, 0x10, 0x10, 0x81, 0xe3, 0x30, 0x10, 0x83, 0xe5, + 0x01, 0x18, 0xa0, 0xe3, 0x38, 0x10, 0x83, 0xe5, 0x80, 0x10, 0x93, 0xe5, 0x02, 0x15, 0x81, 0xe3, + 0x80, 0x10, 0x83, 0xe5, 0x18, 0x20, 0x83, 0xe5, 0x10, 0x20, 0x93, 0xe5, 0x3f, 0x2a, 0xc2, 0xe3, + 0x01, 0x28, 0x82, 0xe3, 0x10, 0x20, 0x83, 0xe5, 0x01, 0x39, 0x43, 0xe2, 0x00, 0x10, 0xa0, 0xe3, + 0x20, 0x20, 0x93, 0xe5, 0x01, 0x2a, 0x82, 0xe3, 0x20, 0x20, 0x83, 0xe5, 0x90, 0x1f, 0x07, 0xee, + 0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1, 0xf8, 0xff, 0xff, 0xea, 0x70, 0x30, 0x9f, 0xe5, + 0xc0, 0x30, 0x93, 0xe5, 0x64, 0x30, 0x9f, 0xe5, 0x02, 0x21, 0xa0, 0xe3, 0x08, 0x20, 0x83, 0xe5, 0x03, 0x21, 0x82, 0xe2, 0x08, 0x20, 0x83, 0xe5, 0xff, 0x24, 0x82, 0xe2, 0x78, 0x20, 0x83, 0xe5, 0xc5, 0x24, 0x82, 0xe2, 0x24, 0x20, 0x83, 0xe5, 0x04, 0x20, 0xa0, 0xe3, 0x18, 0x20, 0x83, 0xe5, - 0x04, 0x20, 0x83, 0xe5, 0x03, 0x20, 0xa0, 0xe1, 0x10, 0x30, 0x92, 0xe5, 0x04, 0x00, 0x13, 0xe3, - 0xfc, 0xff, 0xff, 0x0a, 0x28, 0x30, 0x9f, 0xe5, 0x70, 0x30, 0x93, 0xe5, 0xff, 0x34, 0xc3, 0xe3, - 0x3f, 0x37, 0xc3, 0xe3, 0xcb, 0x3f, 0x43, 0xe2, 0x03, 0x30, 0x43, 0xe2, 0x63, 0x00, 0x53, 0xe3, - 0x00, 0x00, 0xa0, 0x93, 0x00, 0x00, 0x81, 0x85, 0x01, 0x00, 0xa0, 0x83, 0x1e, 0xff, 0x2f, 0xe1, - 0x00, 0x40, 0x04, 0x80, 0x00, 0x00, 0x05, 0x80 + 0x04, 0x20, 0x83, 0xe5, 0x10, 0x20, 0x93, 0xe5, 0x04, 0x00, 0x12, 0xe3, 0xfc, 0xff, 0xff, 0x0a, + 0x28, 0x30, 0x9f, 0xe5, 0x70, 0x30, 0x93, 0xe5, 0xff, 0x34, 0xc3, 0xe3, 0x3f, 0x37, 0xc3, 0xe3, + 0xcb, 0x3f, 0x43, 0xe2, 0x03, 0x30, 0x43, 0xe2, 0x63, 0x00, 0x53, 0xe3, 0x00, 0x00, 0xa0, 0x93, + 0x00, 0x00, 0x81, 0x85, 0x01, 0x00, 0xa0, 0x83, 0x1e, 0xff, 0x2f, 0xe1, 0x63, 0x68, 0x72, 0x67, + 0x00, 0x00, 0x05, 0x80, 0x00, 0x40, 0x04, 0x80 }; diff --git a/rbutil/mkimxboot/dualboot.h b/rbutil/mkimxboot/dualboot.h index 65793811c7..28ebda087c 100644 --- a/rbutil/mkimxboot/dualboot.h +++ b/rbutil/mkimxboot/dualboot.h @@ -1,8 +1,8 @@ /* Generated by bin2c */ -extern unsigned char dualboot_fuzeplus[228]; -extern unsigned char dualboot_zenxfi2[96]; -extern unsigned char dualboot_zenxfi3[56]; -extern unsigned char dualboot_nwze370[416]; -extern unsigned char dualboot_nwze360[416]; -extern unsigned char dualboot_zenxfistyle[136]; +extern unsigned char dualboot_fuzeplus[460]; +extern unsigned char dualboot_zenxfi2[328]; +extern unsigned char dualboot_zenxfi3[288]; +extern unsigned char dualboot_nwze370[644]; +extern unsigned char dualboot_nwze360[644]; +extern unsigned char dualboot_zenxfistyle[360]; diff --git a/rbutil/mkimxboot/dualboot/dualboot.c b/rbutil/mkimxboot/dualboot/dualboot.c index e841b12d74..0e3cca2bd9 100644 --- a/rbutil/mkimxboot/dualboot/dualboot.c +++ b/rbutil/mkimxboot/dualboot/dualboot.c @@ -22,10 +22,13 @@ #include "regs-power.h" #include "regs-lradc.h" #include "regs-digctl.h" +#include "regs-clkctrl.h" #define BOOT_ROM_CONTINUE 0 /* continue boot */ #define BOOT_ROM_SECTION 1 /* switch to new section *result_id */ +#define BOOT_ARG_CHARGE ('c' | 'h' << 8 | 'r' << 16 | 'g' << 24) + typedef unsigned long uint32_t; // target specific boot context @@ -225,8 +228,43 @@ static inline enum context_t get_context(void) #endif } +/** + * Charging function + */ +static inline void do_charge(void) +{ + BF_CLR(LRADC_CTRL0, SFTRST); + BF_CLR(LRADC_CTRL0, CLKGATE); + BF_WRn(LRADC_DELAYn, 0, TRIGGER_LRADCS, 0x80); + BF_WRn(LRADC_DELAYn, 0, TRIGGER_DELAYS, 0x1); + BF_WRn(LRADC_DELAYn, 0, DELAY, 200); + BF_SETn(LRADC_DELAYn, 0, KICK); + BF_SET(LRADC_CONVERSION, AUTOMATIC); + BF_WR_V(LRADC_CONVERSION, SCALE_FACTOR, LI_ION); + BF_WR(POWER_CHARGE, STOP_ILIMIT, 1); + BF_WR(POWER_CHARGE, BATTCHRG_I, 0x10); + BF_CLR(POWER_CHARGE, PWD_BATTCHRG); +#if IMX233_SUBTARGET >= 3780 + BF_WR(POWER_DCDC4P2, ENABLE_4P2, 1); + BF_CLR(POWER_5VCTRL, PWD_CHARGE_4P2); + BF_WR(POWER_5VCTRL, CHARGE_4P2_ILIMIT, 0x10); +#endif + while(1) + { + BF_WR(CLKCTRL_CPU, INTERRUPT_WAIT, 1); + asm volatile ( + "mcr p15, 0, %0, c7, c0, 4 \n" /* Wait for interrupt */ + "nop\n" /* Datasheet unclear: "The lr sent to handler points here after RTI"*/ + "nop\n" + : : "r"(0) + ); + } +} + int main(uint32_t arg, uint32_t *result_id) { + if(arg == BOOT_ARG_CHARGE) + do_charge(); switch(boot_decision(get_context())) { case BOOT_ROCK: diff --git a/rbutil/mkimxboot/main.c b/rbutil/mkimxboot/main.c index 79f23a6778..23a15cf4ea 100644 --- a/rbutil/mkimxboot/main.c +++ b/rbutil/mkimxboot/main.c @@ -131,6 +131,8 @@ int main(int argc, char *argv[]) type = IMX_SINGLEBOOT; else if(strcmp(optarg, "recovery") == 0) type = IMX_RECOVERY; + else if(strcmp(optarg, "charge") == 0) + type = IMX_CHARGE; else { printf("Invalid boot type '%s'\n", optarg); diff --git a/rbutil/mkimxboot/mkimxboot.c b/rbutil/mkimxboot/mkimxboot.c index d1a8722a21..436b3ebff4 100644 --- a/rbutil/mkimxboot/mkimxboot.c +++ b/rbutil/mkimxboot/mkimxboot.c @@ -220,6 +220,7 @@ static const struct imx_model_desc_t imx_models[] = #define MAGIC_ROCK 0x726f636b /* 'rock' */ #define MAGIC_RECOVERY 0xfee1dead #define MAGIC_NORMAL 0xcafebabe +#define MAGIC_CHARGE 0x67726863 /* 'chrg' */ static int rb_fw_get_sb_inst_count(struct rb_fw_t *fw) { @@ -343,6 +344,39 @@ static enum imx_error_t patch_std_zero_host_play(int jump_before, int model, return IMX_SUCCESS; } + else if(type == IMX_CHARGE) + { + /* throw away everything except the dualboot stub with a special argument */ + struct sb_inst_t *new_insts = xmalloc(sizeof(struct sb_inst_t) * 2); + /* first instruction is be a load */ + struct sb_inst_t *load = &new_insts[0]; + memset(load, 0, sizeof(struct sb_inst_t)); + load->inst = SB_INST_LOAD; + load->size = imx_models[model].dualboot_size; + load->addr = imx_models[model].dualboot_addr; + /* duplicate memory because it will be free'd */ + load->data = memdup(imx_models[model].dualboot, imx_models[model].dualboot_size); + /* second instruction is a call */ + struct sb_inst_t *call = &new_insts[1]; + memset(call, 0, sizeof(struct sb_inst_t)); + call->inst = SB_INST_CALL; + call->addr = imx_models[model].dualboot_addr; + call->argument = MAGIC_CHARGE; + /* free old instruction array */ + free(sec->insts); + sec->insts = new_insts; + sec->nr_insts = 2; + /* remove all other sections */ + for(int i = 1; i < sb_file->nr_sections; i++) + sb_free_section(sb_file->sections[i]); + struct sb_section_t *new_sec = xmalloc(sizeof(struct sb_section_t)); + memcpy(new_sec, &sb_file->sections[0], sizeof(struct sb_section_t)); + free(sb_file->sections); + sb_file->sections = new_sec; + sb_file->nr_sections = 1; + + return IMX_SUCCESS; + } else { printf("[ERR] Bad output type !\n"); diff --git a/rbutil/mkimxboot/mkimxboot.h b/rbutil/mkimxboot/mkimxboot.h index 87d4f09c97..512a658c35 100644 --- a/rbutil/mkimxboot/mkimxboot.h +++ b/rbutil/mkimxboot/mkimxboot.h @@ -50,6 +50,7 @@ enum imx_output_type_t IMX_DUALBOOT = 0, IMX_RECOVERY = 1, IMX_SINGLEBOOT = 2, + IMX_CHARGE = 3, }; /* Supported models */ -- cgit v1.2.3