From 66f183077d835b7d3bc2041fad89a65f04faacb9 Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Mon, 17 May 2010 21:57:46 +0000 Subject: Clip+: boot to OF if USB is connected To be sure that there is no mistake in this code, it is run *after* the known to work HOME & LEFT buttons checks, unlike other Sansas git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26122 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/mkamsboot/README | 3 +- rbutil/mkamsboot/dualboot.c | 30 +++++++++++------ rbutil/mkamsboot/dualboot.h | 2 +- rbutil/mkamsboot/dualboot/dualboot.S | 63 ++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 13 deletions(-) (limited to 'rbutil/mkamsboot') diff --git a/rbutil/mkamsboot/README b/rbutil/mkamsboot/README index fd81297e06..0504c64383 100644 --- a/rbutil/mkamsboot/README +++ b/rbutil/mkamsboot/README @@ -61,8 +61,7 @@ firmware and the new (rockbox) firmware. The player will boot into the Original Firmware as well if it is powered up by inserting an usb cable. - ***Note : on the m200v4 and Clip+, powering up by usb will cause booting into -the new firmware. + ***Note : on the m200v4 powering up by usb will cause booting into the new firmware. Hacking ------- diff --git a/rbutil/mkamsboot/dualboot.c b/rbutil/mkamsboot/dualboot.c index aab9a18c36..8f87ea8cb5 100644 --- a/rbutil/mkamsboot/dualboot.c +++ b/rbutil/mkamsboot/dualboot.c @@ -126,21 +126,31 @@ unsigned char dualboot_clipv2[280] = { 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x3c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x0b, 0xc8, 0x00, 0x00, 0x0e, 0xc8 }; -unsigned char dualboot_clipplus[216] = { - 0xc0, 0xf0, 0x9f, 0xe5, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, +unsigned char dualboot_clipplus[372] = { + 0x54, 0xf1, 0x9f, 0xe5, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x1f, 0xe5, 0x24, 0x10, 0x1f, 0xe5, 0x01, 0x20, 0x40, 0xe0, 0x18, 0x30, 0x1f, 0xe5, 0x01, 0x40, 0x50, 0xe4, 0x01, 0x40, 0x43, 0xe4, 0x00, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x2c, 0x30, 0x0f, 0xe5, - 0x64, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3, 0x00, 0x10, 0x80, 0xe5, - 0x58, 0x00, 0x9f, 0xe5, 0x20, 0x10, 0x90, 0xe5, 0x54, 0x00, 0x9f, 0xe5, 0x08, 0x20, 0x90, 0xe5, - 0x01, 0x20, 0x82, 0xe1, 0x00, 0x00, 0x52, 0xe3, 0x02, 0x00, 0x00, 0x1a, 0x64, 0x00, 0x1f, 0xe5, - 0x64, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x78, 0x00, 0x1f, 0xe5, 0x78, 0x10, 0x1f, 0xe5, - 0x70, 0x30, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0, 0x01, 0x20, 0x50, 0xe4, - 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a, 0x01, 0x00, 0x83, 0xe2, - 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x3c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x0f, 0xc8, - 0x00, 0x00, 0x0d, 0xc8, 0x00, 0x00, 0x0b, 0xc8 + 0xf8, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x18, 0x81, 0xe3, 0x00, 0x10, 0x80, 0xe5, + 0xec, 0x00, 0x9f, 0xe5, 0x20, 0x10, 0x90, 0xe5, 0xe8, 0x00, 0x9f, 0xe5, 0x08, 0x20, 0x90, 0xe5, + 0x01, 0x20, 0x82, 0xe1, 0x00, 0x00, 0x52, 0xe3, 0x27, 0x00, 0x00, 0x1a, 0xd8, 0x00, 0x9f, 0xe5, + 0x00, 0x10, 0xa0, 0xe3, 0x00, 0x10, 0x80, 0xe5, 0xc0, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, + 0x02, 0x18, 0x81, 0xe3, 0x7f, 0x10, 0xc1, 0xe3, 0x00, 0x10, 0x80, 0xe5, 0xbc, 0x00, 0x9f, 0xe5, + 0x00, 0x10, 0xa0, 0xe3, 0x24, 0x10, 0x80, 0xe5, 0x3c, 0x10, 0xa0, 0xe3, 0x1c, 0x10, 0x80, 0xe5, + 0x00, 0x10, 0xa0, 0xe3, 0x20, 0x10, 0x80, 0xe5, 0x8c, 0x10, 0xa0, 0xe3, 0x04, 0x10, 0x80, 0xe5, + 0x51, 0x20, 0xa0, 0xe3, 0x0c, 0x20, 0x80, 0xe5, 0x30, 0x10, 0x90, 0xe5, 0x01, 0x00, 0x11, 0xe3, + 0xfc, 0xff, 0xff, 0x1a, 0x02, 0x17, 0xa0, 0xe3, 0x01, 0x10, 0x51, 0xe2, 0xfd, 0xff, 0xff, 0x1a, + 0x25, 0x10, 0xa0, 0xe3, 0x44, 0x10, 0x80, 0xe5, 0x02, 0x20, 0x82, 0xe3, 0x0c, 0x20, 0x80, 0xe5, + 0x01, 0x10, 0xa0, 0xe3, 0x10, 0x10, 0x80, 0xe5, 0x10, 0x10, 0x90, 0xe5, 0x00, 0x00, 0x51, 0xe3, + 0xfc, 0xff, 0xff, 0x1a, 0x00, 0x10, 0x90, 0xe5, 0x08, 0x00, 0x11, 0xe3, 0x02, 0x00, 0x00, 0x1a, + 0xf8, 0x00, 0x1f, 0xe5, 0xf8, 0x10, 0x1f, 0xe5, 0x01, 0x00, 0x00, 0xea, 0x0c, 0x01, 0x1f, 0xe5, + 0x0c, 0x11, 0x1f, 0xe5, 0x04, 0x31, 0x1f, 0xe5, 0x02, 0x50, 0x83, 0xe2, 0x01, 0x40, 0x43, 0xe0, + 0x01, 0x20, 0x50, 0xe4, 0x01, 0x20, 0x43, 0xe4, 0x04, 0x00, 0x53, 0xe1, 0xfb, 0xff, 0xff, 0x1a, + 0x01, 0x00, 0x83, 0xe2, 0x00, 0x20, 0xa0, 0xe3, 0x15, 0xff, 0x2f, 0xe1, 0x3c, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x0f, 0xc8, 0x00, 0x00, 0x0d, 0xc8, 0x00, 0x00, 0x0b, 0xc8, 0x10, 0x00, 0x0f, 0xc8, + 0x00, 0x00, 0x07, 0xc8 }; unsigned char dualboot_fuzev2[236] = { 0xd4, 0xf0, 0x9f, 0xe5, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, diff --git a/rbutil/mkamsboot/dualboot.h b/rbutil/mkamsboot/dualboot.h index 57306def10..cada57559f 100644 --- a/rbutil/mkamsboot/dualboot.h +++ b/rbutil/mkamsboot/dualboot.h @@ -7,5 +7,5 @@ extern unsigned char dualboot_c200v2[336]; extern unsigned char dualboot_m200v4[212]; extern unsigned char dualboot_fuze[236]; extern unsigned char dualboot_clipv2[280]; -extern unsigned char dualboot_clipplus[216]; +extern unsigned char dualboot_clipplus[372]; extern unsigned char dualboot_fuzev2[236]; diff --git a/rbutil/mkamsboot/dualboot/dualboot.S b/rbutil/mkamsboot/dualboot/dualboot.S index 8bb2059d78..309aa67742 100644 --- a/rbutil/mkamsboot/dualboot/dualboot.S +++ b/rbutil/mkamsboot/dualboot/dualboot.S @@ -26,6 +26,7 @@ .set GPIOB, 0xC80C0000 .set GPIOC, 0xC80D0000 .set GPIOD, 0xC80E0000 +.set CGU_PROC, 0xC80F0010 .set CGU_PERI, 0xC80F0014 .set I2C_BASE, 0xC8070000 .set I2C_DATA, 0x00 @@ -239,6 +240,68 @@ uclcopy: cmp r2, #0 @ test input from pins bne boot_of @ branch directly to OF if either pin high + + + @ check USB connection + + ldr r0, =CGU_PROC + mov r1, #0 + str r1, [r0] @ fclk = 24MHz + + ldr r0, =CGU_PERI + ldr r1, [r0] + /* enable i2c audio master clock */ + orr r1, r1, #(1<<17) + /* pclk = fclk = 24MHz */ + bic r1, r1, #0x7f + str r1, [r0] + + ldr r0, =I2C_BASE + /* disable i2c interrupts */ + mov r1, #0 + str r1, [r0, #I2C_IMR] + /* setup prescaler */ + mov r1, #I2C_PRESCALER_LOW + str r1, [r0, #I2C_CPSR0] + mov r1, #I2C_PRESCALER_HIGH + str r1, [r0, #I2C_CPSR1] + /* setup i2c slave address */ + mov r1, #(AS3514_I2C_ADDR << 1) + str r1, [r0, #I2C_SLAD0] + mov r2, #0x51 + str r2, [r0, #I2C_CNTRL] + + /* wait for not busy */ +1: + ldr r1, [r0, #I2C_SR] + tst r1, #1 + bne 1b + + /* wait a bit (~100ms) else detection fails */ + mov r1, #0x80000 +1: subs r1, r1, #1 + bne 1b + + /* start read of irq_enrd0 */ + mov r1, #AS3514_IRQ_ENRD0 + str r1, [r0, #I2C_SADDR] + orr r2, r2, #(1 << 1) + str r2, [r0, #I2C_CNTRL] + mov r1, #1 + str r1, [r0, #I2C_DACNT] + + /* wait for transfer to finish */ +1: + ldr r1, [r0, #I2C_DACNT] + cmp r1, #0 + bne 1b + + /* load result and test USB_STATUS bit */ + ldr r1, [r0, #I2C_DATA] + tst r1, #(1 << 3) + bne boot_of + + #elif defined(SANSA_C200V2) /* check for RIGHT on C6, should changed to LEFT as soon as it * known in which pin that is in order for consistency */ -- cgit v1.2.3