Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Something
Wednesday, December 13th, 2006 at 12:30:29am UTC 

  1. Index: bootloader/SOURCES
  2. ===================================================================
  3. RCS file: /cvsroot/rockbox/bootloader/SOURCES,v
  4. retrieving revision 1.8
  5. diff -u -r1.8 SOURCES
  6. --- bootloader/SOURCES  31 Aug 2006 19:19:35 -0000        1.8
  7. +++ bootloader/SOURCES  13 Dec 2006 00:28:20 -0000
  8. @@ -2,10 +2,8 @@
  9.  ipod.c
  10.  #elif defined(GIGABEAT_F)
  11.  gigabeat.c
  12. -#elif defined(SANSA_E200)
  13. -e200.c
  14. -#elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
  15. -h10.c
  16. +#elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || defined(SANSA_E200)
  17. +main-pp.c
  18.  #elif defined(ELIO_TPJ1022)
  19.  tpj1022.c
  20.  #else
  21. Index: bootloader/e200.c
  22. ===================================================================
  23. RCS file: bootloader/e200.c
  24. diff -N bootloader/e200.c
  25. --- bootloader/e200.c   16 Oct 2006 17:21:30 -0000 1.5
  26. +++ /dev/null   1 Jan 1970 00:00:00 -0000
  27. @@ -1,190 +0,0 @@
  28. -/***************************************************************************
  29. - *             __________               __   ___.
  30. - *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
  31. - *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
  32. - *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
  33. - *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
  34. - *                     \/            \/     \/    \/            \/
  35. - * $Id: e200.c,v 1.5 2006-10-16 17:21:30 dan_a Exp $
  36. - *
  37. - * Copyright (C) 2006 Daniel Stenberg
  38. - *
  39. - * All files in this archive are subject to the GNU General Public License.
  40. - * See the file COPYING in the source tree root for full license agreement.
  41. - *
  42. - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  43. - * KIND, either express or implied.
  44. - *
  45. - ****************************************************************************/
  46. -#include "config.h"
  47. -
  48. -#include <stdlib.h>
  49. -#include <stdio.h>
  50. -#include <string.h>
  51. -#include "cpu.h"
  52. -#include "system.h"
  53. -#include "lcd.h"
  54. -#include "kernel.h"
  55. -#include "thread.h"
  56. -#include "ata.h"
  57. -#include "fat.h"
  58. -#include "disk.h"
  59. -#include "font.h"
  60. -#include "adc.h"
  61. -#include "backlight.h"
  62. -#include "panic.h"
  63. -#include "power.h"
  64. -#include "file.h"
  65. -
  66. -static inline void blink(void)
  67. -{
  68. -    volatile unsigned int* ptr;
  69. -    int i;
  70. -    ptr = (volatile unsigned int*)0x70000020;
  71. -
  72. -    *ptr &= ~(1 << 13);
  73. -    for(i = 0; i < 0xfffff; i++)
  74. -    {
  75. -    }
  76. -    *ptr |= (1 << 13);
  77. -    for(i = 0; i < 0xfffff; i++)
  78. -    {
  79. -    }
  80. -}
  81. -
  82. -static inline void slow_blink(void)
  83. -{
  84. -    volatile unsigned int* ptr;
  85. -    int i;
  86. -    ptr = (volatile unsigned int*)0x70000020;
  87. -
  88. -    *ptr &= ~(1 << 13);
  89. -    for(i = 0; i < (0xfffff); i++)
  90. -    {
  91. -    }
  92. -    for(i = 0; i < (0xfffff); i++)
  93. -    {
  94. -    }
  95. -    for(i = 0; i < (0xfffff); i++)
  96. -    {
  97. -    }
  98. -
  99. -    *ptr |= (1 << 13);
  100. -    for(i = 0; i < (0xfffff); i++)
  101. -    {
  102. -    }
  103. -    for(i = 0; i < (0xfffff); i++)
  104. -    {
  105. -    }
  106. -    for(i = 0; i < (0xfffff); i++)
  107. -    {
  108. -    }
  109. -}
  110. -
  111. -static inline unsigned long get_pc(void)
  112. -{
  113. -    unsigned long pc;
  114. -    asm volatile (
  115. -        "mov %0, pc\n"
  116. -        : "=r"(pc)
  117. -    );
  118. -    return pc;
  119. -}
  120. -
  121. -/* These functions are present in the firmware library, but we reimplement
  122. -   them here because the originals do a lot more than we want */
  123. -
  124. -void reset_poweroff_timer(void)
  125. -{
  126. -}
  127. -
  128. -int dbg_ports(void)
  129. -{
  130. -    unsigned int gpio_a, gpio_b, gpio_c, gpio_d;
  131. -    unsigned int gpio_e, gpio_f, gpio_g, gpio_h;
  132. -    unsigned int gpio_i, gpio_j, gpio_k, gpio_l;
  133. -
  134. -    char buf[128];
  135. -    int line;
  136. -
  137. -    lcd_setmargins(0, 0);
  138. -    lcd_clear_display();
  139. -    lcd_setfont(FONT_SYSFIXED);
  140. -
  141. -    while(1)
  142. -    {
  143. -        gpio_a = GPIOA_INPUT_VAL;
  144. -        gpio_b = GPIOB_INPUT_VAL;
  145. -        gpio_c = GPIOC_INPUT_VAL;
  146. -
  147. -        gpio_g = GPIOG_INPUT_VAL;
  148. -        gpio_h = GPIOH_INPUT_VAL;
  149. -        gpio_i = GPIOI_INPUT_VAL;
  150. -
  151. -        line = 0;
  152. -        snprintf(buf, sizeof(buf), "GPIO_A: %02x GPIO_G: %02x", gpio_a, gpio_g);
  153. -        lcd_puts(0, line++, buf);
  154. -        snprintf(buf, sizeof(buf), "GPIO_B: %02x GPIO_H: %02x", gpio_b, gpio_h);
  155. -        lcd_puts(0, line++, buf);
  156. -        snprintf(buf, sizeof(buf), "GPIO_C: %02x GPIO_I: %02x", gpio_c, gpio_i);
  157. -        lcd_puts(0, line++, buf);
  158. -        line++;
  159. -
  160. -        gpio_d = GPIOD_INPUT_VAL;
  161. -        gpio_e = GPIOE_INPUT_VAL;
  162. -        gpio_f = GPIOF_INPUT_VAL;
  163. -
  164. -        gpio_j = GPIOJ_INPUT_VAL;
  165. -        gpio_k = GPIOK_INPUT_VAL;
  166. -        gpio_l = GPIOL_INPUT_VAL;
  167. -
  168. -        snprintf(buf, sizeof(buf), "GPIO_D: %02x GPIO_J: %02x", gpio_d, gpio_j);
  169. -        lcd_puts(0, line++, buf);
  170. -        snprintf(buf, sizeof(buf), "GPIO_E: %02x GPIO_K: %02x", gpio_e, gpio_k);
  171. -        lcd_puts(0, line++, buf);
  172. -        snprintf(buf, sizeof(buf), "GPIO_F: %02x GPIO_L: %02x", gpio_f, gpio_l);
  173. -        lcd_puts(0, line++, buf);
  174. -        line++;
  175. -        snprintf(buf, sizeof(buf), "ADC_1: %02x", adc_read(ADC_0));
  176. -        lcd_puts(0, line++, buf);
  177. -        snprintf(buf, sizeof(buf), "ADC_2: %02x", adc_read(ADC_1));
  178. -        lcd_puts(0, line++, buf);
  179. -        snprintf(buf, sizeof(buf), "ADC_3: %02x", adc_read(ADC_2));
  180. -        lcd_puts(0, line++, buf);
  181. -        snprintf(buf, sizeof(buf), "ADC_4: %02x", adc_read(ADC_3));
  182. -        lcd_puts(0, line++, buf);
  183. -        lcd_update();
  184. -    }
  185. -    return 0;
  186. -}
  187. -
  188. -void mpeg_stop(void)
  189. -{
  190. -}
  191. -
  192. -void usb_acknowledge(void)
  193. -{
  194. -}
  195. -
  196. -void usb_wait_for_disconnect(void)
  197. -{
  198. -}
  199. -
  200. -void sys_poweroff(void)
  201. -{
  202. -}
  203. -
  204. -void system_reboot(void)
  205. -{
  206. -
  207. -}
  208. -
  209. -void main(void)
  210. -{
  211. -    kernel_init();
  212. -    adc_init();
  213. -    lcd_init_device();
  214. -
  215. -    dbg_ports();
  216. -}
  217. -
  218. Index: bootloader/h10.c
  219. ===================================================================
  220. RCS file: bootloader/h10.c
  221. diff -N bootloader/h10.c
  222. --- bootloader/h10.c    28 Aug 2006 08:11:32 -0000  1.4
  223. +++ /dev/null   1 Jan 1970 00:00:00 -0000
  224. @@ -1,261 +0,0 @@
  225. -/***************************************************************************
  226. - *             __________               __   ___.
  227. - *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
  228. - *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
  229. - *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
  230. - *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
  231. - *                     \/            \/     \/    \/            \/
  232. - * $Id: h10.c,v 1.4 2006-08-28 08:11:32 barrywardell Exp $
  233. - *
  234. - * Copyright (C) 2006 by Barry Wardell
  235. - *
  236. - * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
  237. - * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
  238. - *
  239. - * All files in this archive are subject to the GNU General Public License.
  240. - * See the file COPYING in the source tree root for full license agreement.
  241. - *
  242. - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  243. - * KIND, either express or implied.
  244. - *
  245. - ****************************************************************************/
  246. -#include "config.h"
  247. -
  248. -#include <stdlib.h>
  249. -#include <stdio.h>
  250. -#include <string.h>
  251. -#include "cpu.h"
  252. -#include "system.h"
  253. -#include "lcd.h"
  254. -#include "kernel.h"
  255. -#include "thread.h"
  256. -#include "ata.h"
  257. -#include "fat.h"
  258. -#include "disk.h"
  259. -#include "font.h"
  260. -#include "adc.h"
  261. -#include "backlight.h"
  262. -#include "button.h"
  263. -#include "panic.h"
  264. -#include "power.h"
  265. -#include "file.h"
  266. -
  267. -/* Size of the buffer to store the loaded Rockbox/iriver image */
  268. -#define MAX_LOADSIZE (5*1024*1024)
  269. -
  270. -/* A buffer to load the iriver firmware or Rockbox into */
  271. -unsigned char loadbuffer[MAX_LOADSIZE];
  272. -
  273. -char version[] = APPSVERSION;
  274. -
  275. -#define DRAM_START              0x10000000
  276. -
  277. -int line=0;
  278. -
  279. -/* Load original iriver firmware. This function expects a file called
  280. -   "/System/Original.mi4" on the player. It should be decrypted
  281. -   and have the header stripped using mi4code. It reads the file in to a memory
  282. -   buffer called buf. The rest of the loading is done in main() and crt0.S
  283. -*/
  284. -int load_iriver(unsigned char* buf)
  285. -{
  286. -    int fd;
  287. -    int rc;
  288. -    int len;
  289. -   
  290. -    fd = open("/System/Original.mi4", O_RDONLY);
  291. -
  292. -    len = filesize(fd);
  293. -   
  294. -    if (len > MAX_LOADSIZE)
  295. -        return -6;
  296. -
  297. -    rc = read(fd, buf, len);
  298. -    if(rc < len)
  299. -        return -4;
  300. -
  301. -    close(fd);
  302. -    return len;
  303. -}
  304. -
  305. -/* Load Rockbox firmware (rockbox.h10) */
  306. -int load_rockbox(unsigned char* buf)
  307. -{
  308. -    int fd;
  309. -    int rc;
  310. -    int len;
  311. -    unsigned long chksum;
  312. -    char model[5];
  313. -    unsigned long sum;
  314. -    int i;
  315. -    char str[80];
  316. -   
  317. -    fd = open("/.rockbox/" BOOTFILE, O_RDONLY);
  318. -    if(fd < 0)
  319. -    {
  320. -        fd = open("/" BOOTFILE, O_RDONLY);
  321. -        if(fd < 0)
  322. -            return -1;
  323. -    }
  324. -
  325. -    len = filesize(fd) - 8;
  326. -
  327. -    snprintf(str, sizeof(str), "Length: %x", len);
  328. -    lcd_puts(0, line++ ,str);
  329. -    lcd_update();
  330. -   
  331. -    if (len > MAX_LOADSIZE)
  332. -        return -6;
  333. -
  334. -    lseek(fd, FIRMWARE_OFFSET_FILE_CRC, SEEK_SET);
  335. -   
  336. -    rc = read(fd, &chksum, 4);
  337. -    chksum=betoh32(chksum); /* Rockbox checksums are big-endian */
  338. -    if(rc < 4)
  339. -        return -2;
  340. -
  341. -    snprintf(str, sizeof(str), "Checksum: %x", chksum);
  342. -    lcd_puts(0, line++ ,str);
  343. -    lcd_update();
  344. -
  345. -    rc = read(fd, model, 4);
  346. -    if(rc < 4)
  347. -        return -3;
  348. -
  349. -    model[4] = 0;
  350. -   
  351. -    snprintf(str, sizeof(str), "Model name: %s", model);
  352. -    lcd_puts(0, line++ ,str);
  353. -    lcd_update();
  354. -
  355. -    lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET);
  356. -
  357. -    rc = read(fd, buf, len);
  358. -    if(rc < len)
  359. -        return -4;
  360. -
  361. -    close(fd);
  362. -
  363. -    sum = MODEL_NUMBER;
  364. -   
  365. -    for(i = 0;i < len;i++) {
  366. -        sum += buf[i];
  367. -    }
  368. -
  369. -    snprintf(str, sizeof(str), "Sum: %x", sum);
  370. -    lcd_puts(0, line++ ,str);
  371. -    lcd_update();
  372. -
  373. -    if(sum != chksum)
  374. -        return -5;
  375. -
  376. -    return len;
  377. -}
  378. -
  379. -void* main(void)
  380. -{
  381. -    char buf[256];
  382. -    int i;
  383. -    int rc;
  384. -    unsigned short* identify_info;
  385. -    struct partinfo* pinfo;
  386. -
  387. -    system_init();
  388. -    kernel_init();
  389. -    lcd_init();
  390. -    font_init();
  391. -
  392. -    line=0;
  393. -
  394. -    lcd_setfont(FONT_SYSFIXED);
  395. -
  396. -    lcd_puts(0, line++, "Rockbox boot loader");
  397. -    snprintf(buf, sizeof(buf), "Version: 20%s", version);
  398. -    lcd_puts(0, line++, buf);
  399. -    snprintf(buf, sizeof(buf), "iriver H10");
  400. -    lcd_puts(0, line++, buf);
  401. -    lcd_update();
  402. -
  403. -    i=ata_init();
  404. -    if (i==0) {
  405. -      identify_info=ata_get_identify();
  406. -      /* Show model */
  407. -      for (i=0; i < 20; i++) {
  408. -        ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
  409. -      }
  410. -      buf[40]=0;
  411. -      for (i=39; i && buf[i]==' '; i--) {
  412. -        buf[i]=0;
  413. -      }
  414. -      lcd_puts(0, line++, buf);
  415. -      lcd_update();
  416. -    } else {
  417. -      snprintf(buf, sizeof(buf), "ATA: %d", i);
  418. -      lcd_puts(0, line++, buf);
  419. -      lcd_update();
  420. -    }
  421. -
  422. -    disk_init();
  423. -    rc = disk_mount_all();
  424. -    if (rc<=0)
  425. -    {
  426. -        lcd_puts(0, line++, "No partition found");
  427. -        lcd_update();
  428. -    }
  429. -
  430. -    pinfo = disk_partinfo(0);
  431. -    snprintf(buf, sizeof(buf), "Partition 0: 0x%02x %ld MB",
  432. -                  pinfo->type, pinfo->size / 2048);
  433. -    lcd_puts(0, line++, buf);
  434. -    lcd_update();
  435. -
  436. -    i=button_read_device();
  437. -    if(i==BUTTON_LEFT)
  438. -    {
  439. -        lcd_puts(0, line, "Loading iriver firmware...");
  440. -        lcd_update();
  441. -        rc=load_iriver(loadbuffer);
  442. -    } else {
  443. -        lcd_puts(0, line, "Loading Rockbox...");
  444. -        lcd_update();
  445. -        rc=load_rockbox(loadbuffer);
  446. -    }
  447. -
  448. -    if (rc < 0) {
  449. -            snprintf(buf, sizeof(buf), "Rockbox error: %d",rc);
  450. -            lcd_puts(0, line++, buf);
  451. -            lcd_update();
  452. -    }
  453. -   
  454. -    memcpy((void*)DRAM_START,loadbuffer,rc);
  455. -   
  456. -    return (void*)DRAM_START;
  457. -}
  458. -
  459. -/* These functions are present in the firmware library, but we reimplement
  460. -   them here because the originals do a lot more than we want */
  461. -
  462. -void reset_poweroff_timer(void)
  463. -{
  464. -}
  465. -
  466. -int dbg_ports(void)
  467. -{
  468. -   return 0;
  469. -}
  470. -
  471. -void mpeg_stop(void)
  472. -{
  473. -}
  474. -
  475. -void usb_acknowledge(void)
  476. -{
  477. -}
  478. -
  479. -void usb_wait_for_disconnect(void)
  480. -{
  481. -}
  482. -
  483. -void sys_poweroff(void)
  484. -{
  485. -}
  486. Index: bootloader/main-pp.c
  487. ===================================================================
  488. RCS file: bootloader/main-pp.c
  489. diff -N bootloader/main-pp.c
  490. --- /dev/null   1 Jan 1970 00:00:00 -0000
  491. +++ bootloader/main-pp.c        13 Dec 2006 00:28:20 -0000
  492. @@ -0,0 +1,262 @@
  493. +/***************************************************************************
  494. + *             __________               __   ___.
  495. + *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
  496. + *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
  497. + *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
  498. + *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
  499. + *                     \/            \/     \/    \/            \/
  500. + * $Id: h10.c,v 1.4 2006-08-28 08:11:32 barrywardell Exp $
  501. + *
  502. + * Copyright (C) 2006 by Barry Wardell
  503. + *
  504. + * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
  505. + * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
  506. + *
  507. + * All files in this archive are subject to the GNU General Public License.
  508. + * See the file COPYING in the source tree root for full license agreement.
  509. + *
  510. + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  511. + * KIND, either express or implied.
  512. + *
  513. + ****************************************************************************/
  514. +#include "config.h"
  515. +
  516. +#include <stdlib.h>
  517. +#include <stdio.h>
  518. +#include <string.h>
  519. +#include "cpu.h"
  520. +#include "system.h"
  521. +#include "lcd.h"
  522. +#include "kernel.h"
  523. +#include "thread.h"
  524. +#include "ata.h"
  525. +#include "fat.h"
  526. +#include "disk.h"
  527. +#include "font.h"
  528. +#include "adc.h"
  529. +#include "backlight.h"
  530. +#include "button.h"
  531. +#include "panic.h"
  532. +#include "power.h"
  533. +#include "file.h"
  534. +
  535. +/* Size of the buffer to store the loaded firmware image */
  536. +#define MAX_LOADSIZE (10*1024*1024)
  537. +
  538. +/* A buffer to load the iriver firmware or Rockbox into */
  539. +unsigned char loadbuffer[MAX_LOADSIZE];
  540. +
  541. +char version[] = APPSVERSION;
  542. +
  543. +#define DRAM_START              0x10000000
  544. +
  545. +int line=0;
  546. +
  547. +/* Load original mi4 firmware. This function expects a file called
  548. +   "/System/OF.bin" on the player. It should be a mi4 firmware decrypted
  549. +   and header stripped using mi4code. It reads the file in to a memory
  550. +   buffer called buf. The rest of the loading is done in main() and crt0.S
  551. +*/
  552. +int load_original_firmware(unsigned char* buf)
  553. +{
  554. +    int fd;
  555. +    int rc;
  556. +    int len;
  557. +   
  558. +    fd = open("/System/OF.bin", O_RDONLY);
  559. +
  560. +    len = filesize(fd);
  561. +   
  562. +    if (len > MAX_LOADSIZE)
  563. +        return -6;
  564. +
  565. +    rc = read(fd, buf, len);
  566. +    if(rc < len)
  567. +        return -4;
  568. +
  569. +    close(fd);
  570. +    return len;
  571. +}
  572. +
  573. +/* Load Rockbox firmware (rockbox.*) */
  574. +int load_rockbox(unsigned char* buf)
  575. +{
  576. +    int fd;
  577. +    int rc;
  578. +    int len;
  579. +    unsigned long chksum;
  580. +    char model[5];
  581. +    unsigned long sum;
  582. +    int i;
  583. +    char str[80];
  584. +   
  585. +    fd = open("/.rockbox/" BOOTFILE, O_RDONLY);
  586. +    if(fd < 0)
  587. +    {
  588. +        fd = open("/" BOOTFILE, O_RDONLY);
  589. +        if(fd < 0)
  590. +            return -1;
  591. +    }
  592. +
  593. +    len = filesize(fd) - 8;
  594. +
  595. +    snprintf(str, sizeof(str), "Length: %x", len);
  596. +    lcd_puts(0, line++ ,str);
  597. +    lcd_update();
  598. +   
  599. +    if (len > MAX_LOADSIZE)
  600. +        return -6;
  601. +
  602. +    lseek(fd, FIRMWARE_OFFSET_FILE_CRC, SEEK_SET);
  603. +   
  604. +    rc = read(fd, &chksum, 4);
  605. +    chksum=betoh32(chksum); /* Rockbox checksums are big-endian */
  606. +    if(rc < 4)
  607. +        return -2;
  608. +
  609. +    snprintf(str, sizeof(str), "Checksum: %x", chksum);
  610. +    lcd_puts(0, line++ ,str);
  611. +    lcd_update();
  612. +
  613. +    rc = read(fd, model, 4);
  614. +    if(rc < 4)
  615. +        return -3;
  616. +
  617. +    model[4] = 0;
  618. +   
  619. +    snprintf(str, sizeof(str), "Model name: %s", model);
  620. +    lcd_puts(0, line++ ,str);
  621. +    lcd_update();
  622. +
  623. +    lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET);
  624. +
  625. +    rc = read(fd, buf, len);
  626. +    if(rc < len)
  627. +        return -4;
  628. +
  629. +    close(fd);
  630. +
  631. +    sum = MODEL_NUMBER;
  632. +   
  633. +    for(i = 0;i < len;i++) {
  634. +        sum += buf[i];
  635. +    }
  636. +
  637. +    snprintf(str, sizeof(str), "Sum: %x", sum);
  638. +    lcd_puts(0, line++ ,str);
  639. +    lcd_update();
  640. +
  641. +    if(sum != chksum)
  642. +        return -5;
  643. +
  644. +    return len;
  645. +}
  646. +
  647. +void* main(void)
  648. +{
  649. +    char buf[256];
  650. +    int i;
  651. +    int rc;
  652. +    unsigned short* identify_info;
  653. +    struct partinfo* pinfo;
  654. +
  655. +    system_init();
  656. +    kernel_init();
  657. +    lcd_init();
  658. +    font_init();
  659. +
  660. +    line=0;
  661. +
  662. +    lcd_setfont(FONT_SYSFIXED);
  663. +
  664. +    lcd_puts(0, line++, "Rockbox boot loader");
  665. +    snprintf(buf, sizeof(buf), "Version: 20%s", version);
  666. +    lcd_puts(0, line++, buf);
  667. +    snprintf(buf, sizeof(buf), MODEL_NAME);
  668. +    lcd_puts(0, line++, buf);
  669. +    lcd_update();
  670. +
  671. +    i=ata_init();
  672. +    if (i==0) {
  673. +      identify_info=ata_get_identify();
  674. +      /* Show model */
  675. +      for (i=0; i < 20; i++) {
  676. +        ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
  677. +      }
  678. +      buf[40]=0;
  679. +      for (i=39; i && buf[i]==' '; i--) {
  680. +        buf[i]=0;
  681. +      }
  682. +      lcd_puts(0, line++, buf);
  683. +      lcd_update();
  684. +    } else {
  685. +      snprintf(buf, sizeof(buf), "ATA: %d", i);
  686. +      lcd_puts(0, line++, buf);
  687. +      lcd_update();
  688. +    }
  689. +
  690. +    disk_init();
  691. +    rc = disk_mount_all();
  692. +    if (rc<=0)
  693. +    {
  694. +        lcd_puts(0, line++, "No partition found");
  695. +        lcd_update();
  696. +    }
  697. +
  698. +    pinfo = disk_partinfo(0);
  699. +    snprintf(buf, sizeof(buf), "Partition 0: 0x%02x %ld MB",
  700. +                  pinfo->type, pinfo->size / 2048);
  701. +    lcd_puts(0, line++, buf);
  702. +    lcd_update();
  703. +
  704. +    i=button_read_device();
  705. +    if(i==BUTTON_LEFT)
  706. +    {
  707. +        lcd_puts(0, line++, "Loading original firmware...");
  708. +        lcd_update();
  709. +        rc=load_original_firmware(loadbuffer);
  710. +    } else {
  711. +        lcd_puts(0, line++, "Loading Rockbox...");
  712. +        lcd_update();
  713. +        rc=load_rockbox(loadbuffer);
  714. +    }
  715. +
  716. +    if (rc < 0) {
  717. +            snprintf(buf, sizeof(buf), "Rockbox error: %d",rc);
  718. +            lcd_puts(0, line++, buf);
  719. +            lcd_update();
  720. +            while(1) {}
  721. +    }
  722. +   
  723. +    memcpy((void*)DRAM_START,loadbuffer,rc);
  724. +   
  725. +    return (void*)DRAM_START;
  726. +}
  727. +
  728. +/* These functions are present in the firmware library, but we reimplement
  729. +   them here because the originals do a lot more than we want */
  730. +
  731. +void reset_poweroff_timer(void)
  732. +{
  733. +}
  734. +
  735. +int dbg_ports(void)
  736. +{
  737. +   return 0;
  738. +}
  739. +
  740. +void mpeg_stop(void)
  741. +{
  742. +}
  743. +
  744. +void usb_acknowledge(void)
  745. +{
  746. +}
  747. +
  748. +void usb_wait_for_disconnect(void)
  749. +{
  750. +}
  751. +
  752. +void sys_poweroff(void)
  753. +{
  754. +}
  755. Index: firmware/SOURCES
  756. ===================================================================
  757. RCS file: /cvsroot/rockbox/firmware/SOURCES,v
  758. retrieving revision 1.146
  759. diff -u -r1.146 SOURCES
  760. --- firmware/SOURCES    9 Dec 2006 19:18:16 -0000   1.146
  761. +++ firmware/SOURCES    13 Dec 2006 00:28:21 -0000
  762. @@ -262,7 +262,11 @@
  763.  /* no i2c driver yet */
  764.  #endif
  765.  #if defined(CPU_PP)
  766. +#ifdef BOOTLOADER
  767. +target/arm/crt0-pp-bl.S
  768. +#else
  769.  target/arm/crt0-pp.S
  770. +#endif
  771.  #elif defined(CPU_ARM)
  772.  target/arm/crt0.S
  773.  #endif /* defined(CPU_*) */
  774. Index: firmware/boot.lds
  775. ===================================================================
  776. RCS file: /cvsroot/rockbox/firmware/boot.lds,v
  777. retrieving revision 1.26
  778. diff -u -r1.26 boot.lds
  779. --- firmware/boot.lds   10 Dec 2006 13:33:12 -0000 1.26
  780. +++ firmware/boot.lds   13 Dec 2006 00:28:21 -0000
  781. @@ -8,7 +8,7 @@
  782.  OUTPUT_FORMAT(elf32-littlearm)
  783.  OUTPUT_ARCH(arm)
  784.  #ifdef CPU_PP
  785. -INPUT(target/arm/crt0-pp.o)
  786. +INPUT(target/arm/crt0-pp-bl.o)
  787.  #else
  788.  INPUT(target/arm/crt0.o)
  789.  #endif
  790. Index: firmware/rolo.c
  791. ===================================================================
  792. RCS file: /cvsroot/rockbox/firmware/rolo.c,v
  793. retrieving revision 1.35
  794. diff -u -r1.35 rolo.c
  795. --- firmware/rolo.c     10 Dec 2006 15:53:26 -0000   1.35
  796. +++ firmware/rolo.c     13 Dec 2006 00:28:22 -0000
  797. @@ -31,9 +31,8 @@
  798.  #include "buffer.h"
  799.  
  800.  #if !defined(IRIVER_IFP7XX_SERIES) && \
  801. -    (CONFIG_CPU != PP5002) && !defined(IRIVER_H10) && \
  802. -    !defined(IRIVER_H10_5GB) && (CONFIG_CPU != S3C2440)
  803. -/* FIX: this doesn't work on iFP, 3rd Gen ipods, or H10 yet */
  804. +    (CONFIG_CPU != PP5002) && (CONFIG_CPU != S3C2440)
  805. +/* FIX: this doesn't work on iFP, 3rd Gen ipods */
  806.  
  807.  #define IRQ0_EDGE_TRIGGER 0x80
  808.  
  809. Index: firmware/system.c
  810. ===================================================================
  811. RCS file: /cvsroot/rockbox/firmware/system.c,v
  812. retrieving revision 1.131
  813. diff -u -r1.131 system.c
  814. --- firmware/system.c   5 Dec 2006 20:01:45 -0000  1.131
  815. +++ firmware/system.c   13 Dec 2006 00:28:22 -0000
  816. @@ -26,6 +26,7 @@
  817.  #include "timer.h"
  818.  #include "inttypes.h"
  819.  #include "string.h"
  820. +#include "logf.h"
  821.  
  822.  #ifndef SIMULATOR
  823.  long cpu_frequency = CPU_FREQ;
  824. @@ -574,12 +575,18 @@
  825.  /* TODO: this should really be in the target tree, but moving it there caused
  826.     crt0.S not to find it while linking */
  827.  /* TODO: Even if it isn't in the target tree, this should be the default case */
  828. +extern void e200_button_int(void);
  829. +
  830.  void irq(void)
  831.  {
  832.      if (CPU_INT_STAT & TIMER1_MASK)
  833.          TIMER1();
  834.      else if (CPU_INT_STAT & TIMER2_MASK)
  835.          TIMER2();
  836. +    else if (CPU_HI_INT_STAT & GPIO_MASK){
  837. +        e200_button_int();
  838. +        logf("button interrupt");
  839. +    }
  840.  }
  841.  #else
  842.  extern void ipod_4g_button_int(void);
  843. Index: firmware/export/config-e200.h
  844. ===================================================================
  845. RCS file: /cvsroot/rockbox/firmware/export/config-e200.h,v
  846. retrieving revision 1.6
  847. diff -u -r1.6 config-e200.h
  848. --- firmware/export/config-e200.h       10 Dec 2006 23:12:58 -0000     1.6
  849. +++ firmware/export/config-e200.h       13 Dec 2006 00:28:22 -0000
  850. @@ -5,6 +5,7 @@
  851.  
  852.  /* For Rolo and boot loader */
  853.  #define MODEL_NUMBER 16
  854. +#define MODEL_NAME   "Sandisk Sansa e200"
  855.  
  856.  /* define this if you have recording possibility */
  857.  /*#define HAVE_RECORDING 1*/ /* TODO: add support for this */
  858. Index: firmware/export/config-h10.h
  859. ===================================================================
  860. RCS file: /cvsroot/rockbox/firmware/export/config-h10.h,v
  861. retrieving revision 1.20
  862. diff -u -r1.20 config-h10.h
  863. --- firmware/export/config-h10.h        9 Nov 2006 22:33:24 -0000       1.20
  864. +++ firmware/export/config-h10.h        13 Dec 2006 00:28:23 -0000
  865. @@ -6,6 +6,7 @@
  866.  
  867.  /* For Rolo and boot loader */
  868.  #define MODEL_NUMBER 13
  869. +#define MODEL_NAME   "iriver H10 20GB"
  870.  
  871.  /* define this if you have recording possibility */
  872.  /*#define HAVE_RECORDING 1*/ /* TODO: add support for this */
  873. Index: firmware/export/config-h10_5gb.h
  874. ===================================================================
  875. RCS file: /cvsroot/rockbox/firmware/export/config-h10_5gb.h,v
  876. retrieving revision 1.14
  877. diff -u -r1.14 config-h10_5gb.h
  878. --- firmware/export/config-h10_5gb.h    9 Nov 2006 22:33:24 -0000   1.14
  879. +++ firmware/export/config-h10_5gb.h    13 Dec 2006 00:28:23 -0000
  880. @@ -6,6 +6,7 @@
  881.  
  882.  /* For Rolo and boot loader */
  883.  #define MODEL_NUMBER 14
  884. +#define MODEL_NAME   "iriver H10 5/6GB"
  885.  
  886.  /* define this if you have recording possibility */
  887.  /*#define HAVE_RECORDING 1*/ /* TODO: add support for this */
  888. Index: firmware/target/arm/crt0-pp-bl.S
  889. ===================================================================
  890. RCS file: firmware/target/arm/crt0-pp-bl.S
  891. diff -N firmware/target/arm/crt0-pp-bl.S
  892. --- /dev/null   1 Jan 1970 00:00:00 -0000
  893. +++ firmware/target/arm/crt0-pp-bl.S    13 Dec 2006 00:28:23 -0000
  894. @@ -0,0 +1,179 @@
  895. +/***************************************************************************
  896. + *             __________               __   ___.
  897. + *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
  898. + *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
  899. + *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
  900. + *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
  901. + *                     \/            \/     \/    \/            \/
  902. + * $Id: crt0-pp.S,v 1.2 2006/11/22 00:49:16 dan_a Exp $
  903. + *
  904. + * Copyright (C) 2002 by Linus Nielsen Feltzing
  905. + *
  906. + * All files in this archive are subject to the GNU General Public License.
  907. + * See the file COPYING in the source tree root for full license agreement.
  908. + *
  909. + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  910. + * KIND, either express or implied.
  911. + *
  912. + ****************************************************************************/
  913. +#include "config.h"
  914. +#include "cpu.h"
  915. +
  916. +    .section .init.text,"ax",%progbits
  917. +
  918. +    .global    start
  919. +start:
  920. +
  921. +/* PortalPlayer bootloader and startup code based on startup.s from the iPodLinux
  922. + * loader
  923. + *
  924. + * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org)
  925. + * Copyright (c) 2005, Bernard Leach <[email protected]>
  926. + *
  927. + */
  928. +#if CONFIG_CPU == PP5002
  929. +    .equ    PROC_ID,    0xc4000000
  930. +    .equ    COP_CTRL,   0xcf004058
  931. +    .equ    COP_STATUS, 0xcf004050
  932. +    .equ    IIS_CONFIG, 0xc0002500
  933. +    .equ    SLEEP,      0xca
  934. +    .equ    WAKE,       0xce
  935. +    .equ    SLEEPING,   0x4000
  936. +#else
  937. +    .equ    PROC_ID,    0x60000000
  938. +    .equ    COP_CTRL,   0x60007004
  939. +    .equ    COP_STATUS, 0x60007004
  940. +    .equ    IIS_CONFIG, 0x70002800
  941. +    .equ    SLEEP,      0x80000000
  942. +    .equ    WAKE,       0x0
  943. +    .equ    SLEEPING,   0x80000000
  944. +    .equ    CACHE_CTRL, 0x6000c000
  945. +#endif
  946. +
  947. +    msr    cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ */
  948. +
  949. +/* 1 - Copy the bootloader to IRAM */
  950. +    /* get the high part of our execute address */
  951. +    ldr    r7, =0xffffff00
  952. +    and    r4, pc, r7
  953. +
  954. +    /* Copy bootloader to safe area - 0x40000000 (IRAM) */
  955. +    mov    r5, #0x40000000
  956. +    ldr    r6, = _dataend
  957. +1:
  958. +    cmp    r5, r6
  959. +    ldrcc  r2, [r4], #4
  960. +    strcc  r2, [r5], #4
  961. +    bcc    1b
  962. +
  963. +#ifndef IPOD_ARCH
  964. +    /* For builds on targets with mi4 firmware, scramble writes data to
  965. +       0xe0-0xeb, so jump past that.*/
  966. +    b      pad_skip
  967. +
  968. +.space 60*4
  969. +
  970. +pad_skip:
  971. +#endif
  972. +
  973. +
  974. +/* 2 - Jump both CPU and COP there */
  975. +    ldr    pc, =start_loc    /* jump to the relocated start_loc:  */
  976. +
  977. +start_loc:
  978. +
  979. +    /* Find out which processor we are */
  980. +    ldr    r0, =PROC_ID
  981. +    ldr    r0, [r0]
  982. +    and    r0, r0, #0xff
  983. +    cmp    r0, #0x55
  984. +    beq    cpu
  985. +   
  986. +    /* put us (co-processor) to sleep */
  987. +    ldr    r4, =COP_CTRL
  988. +    mov    r3, #SLEEP
  989. +    str    r3, [r4]
  990. +    ldr    pc, =cop_wake_start
  991. +
  992. +cop_wake_start:
  993. +#if CONFIG_CPU != PP5002
  994. +     /* COP: Invalidate cache */
  995. +    ldr    r0, =0xf000f044
  996. +    ldr    r1, [r0]
  997. +    orr    r1, r1, #0x6
  998. +    str    r1, [r0]
  999. +
  1000. +    ldr    r0, =CACHE_CTRL
  1001. +1:
  1002. +    ldr    r1, [r0]
  1003. +    tst    r1, #0x8000
  1004. +    bne    1b
  1005. +#endif
  1006. +
  1007. +    ldr    r0, =startup_loc
  1008. +    ldr    pc, [r0]
  1009. +
  1010. +cpu:
  1011. +    /* Wait for COP to be sleeping */
  1012. +    ldr    r4, =COP_STATUS
  1013. +1:
  1014. +    ldr    r3, [r4]
  1015. +    ands   r3, r3, #SLEEPING
  1016. +    beq    1b
  1017. +   
  1018. +    /* Initialise bss section to zero */
  1019. +    ldr    r2, =_edata
  1020. +    ldr    r3, =_end
  1021. +    mov    r4, #0
  1022. +1:
  1023. +    cmp    r3, r2
  1024. +    strhi  r4, [r2], #4
  1025. +    bhi    1b
  1026. +       
  1027. +    /* Set up some stack and munge it with 0xdeadbeef */
  1028. +    ldr    sp, =stackend
  1029. +    mov    r3, sp
  1030. +    ldr    r2, =stackbegin
  1031. +    ldr    r4, =0xdeadbeef
  1032. +1:
  1033. +    cmp    r3, r2
  1034. +    strhi  r4, [r2], #4
  1035. +    bhi    1b
  1036. +
  1037. +    /* execute the loader - this will load an image to 0x10000000 */
  1038. +    bl     main
  1039. +
  1040. +    ldr    r1, =startup_loc
  1041. +    str    r0, [r1]
  1042. +
  1043. +#if CONFIG_CPU != PP5002
  1044. +    /* Flush cache */
  1045. +    ldr    r3, =0xf000f044
  1046. +    ldr    r4, [r3]
  1047. +    orr    r4, r4, #0x2
  1048. +    str    r4, [r3]
  1049. +
  1050. +    ldr    r3, =CACHE_CTRL
  1051. +1:
  1052. +    ldr    r4, [r3]
  1053. +    tst    r4, #0x8000
  1054. +    bne    1b
  1055. +#endif
  1056. +
  1057. +    /* Wake up the coprocessor before executing the firmware */
  1058. +    ldr    r4, =COP_CTRL
  1059. +    mov    r3, #WAKE
  1060. +    str    r3, [r4]
  1061. +
  1062. +    mov    pc, r0
  1063. +
  1064. +startup_loc:
  1065. +    .word    0x0
  1066. +   
  1067. +#ifdef IPOD_ARCH
  1068. +.align 8    /* starts at 0x100 */
  1069. +.global boot_table
  1070. +boot_table:
  1071. +    /* here comes the boot table, don't move its offset */
  1072. +    .space 400
  1073. +#endif
  1074. Index: firmware/target/arm/crt0-pp.S
  1075. ===================================================================
  1076. RCS file: /cvsroot/rockbox/firmware/target/arm/crt0-pp.S,v
  1077. retrieving revision 1.2
  1078. diff -u -r1.2 crt0-pp.S
  1079. --- firmware/target/arm/crt0-pp.S       22 Nov 2006 00:49:16 -0000     1.2
  1080. +++ firmware/target/arm/crt0-pp.S       13 Dec 2006 00:28:23 -0000
  1081. @@ -5,7 +5,7 @@
  1082.   *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
  1083.   *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
  1084.   *                     \/            \/     \/    \/            \/
  1085. - * $Id: crt0-pp.S,v 1.2 2006-11-22 00:49:16 dan_a Exp $
  1086. + * $Id: crt0-pp.S,v 1.2 2006/11/22 00:49:16 dan_a Exp $
  1087.   *
  1088.   * Copyright (C) 2002 by Linus Nielsen Feltzing
  1089.   *
  1090. @@ -52,15 +52,9 @@
  1091.  
  1092.      msr    cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ */
  1093.  
  1094. -#ifndef BOOTLOADER
  1095.      b      pad_skip
  1096.  
  1097. -#if defined(SANSA_E200)
  1098. -/* mi4tool writes junk between 0xe0 and 0xeb.  Avoid this. */
  1099. -.space 60*4 /* (more than enough) space for exception vectors */
  1100. -#else
  1101. -.space 50*4
  1102. -#endif
  1103. +.space 50*4 /* (more than enough) space for exception vectors */
  1104.  
  1105.  pad_skip:
  1106.  #ifdef SANSA_E200
  1107. @@ -108,11 +102,13 @@
  1108.  
  1109.      /* After doing the remapping, send the COP to sleep.
  1110.         On wakeup it will go to cop_init */
  1111. +
  1112. +    /* Find out which processor we are */
  1113.      ldr    r0, =PROC_ID
  1114.      ldr    r0, [r0]
  1115.      and    r0, r0, #0xff
  1116.      cmp    r0, #0x55
  1117. -    beq    1f
  1118. +    beq    cpu_init
  1119.      
  1120.      /* put us (co-processor) to sleep */
  1121.      ldr    r4, =COP_CTRL
  1122. @@ -121,9 +117,15 @@
  1123.  
  1124.      ldr    pc, =cop_init
  1125.  
  1126. -1:
  1127.  
  1128. -#ifndef DEBUG
  1129. +cpu_init:
  1130. +    /* Wait for COP to be sleeping */
  1131. +    ldr    r4, =COP_STATUS
  1132. +1:
  1133. +    ldr    r3, [r4]
  1134. +    ands   r3, r3, #SLEEPING
  1135. +    beq    1b
  1136. +   
  1137.      /* Copy exception handler code to address 0 */
  1138.      ldr    r2, =_vectorsstart
  1139.      ldr    r3, =_vectorsend
  1140. @@ -133,15 +135,7 @@
  1141.      ldrhi  r5, [r4], #4
  1142.      strhi  r5, [r2], #4
  1143.      bhi    1b
  1144. -#else
  1145. -    ldr    r1, =vectors
  1146. -    ldr    r0, =irq_handler
  1147. -    str    r0, [r1, #24]
  1148. -    ldr    r0, =fiq_handler
  1149. -    str    r0, [r1, #28]
  1150. -#endif
  1151.  
  1152. -#ifndef STUB
  1153.      /* Zero out IBSS */
  1154.      ldr    r2, =_iedata
  1155.      ldr    r3, =_iend
  1156. @@ -160,8 +154,6 @@
  1157.      ldrhi  r5, [r2], #4
  1158.      strhi  r5, [r3], #4
  1159.      bhi    1b
  1160. -#endif /* !STUB */
  1161. -#endif /* !BOOTLOADER */
  1162.  
  1163.      /* Initialise bss section to zero */
  1164.      ldr    r2, =_edata
  1165. @@ -181,90 +173,6 @@
  1166.      cmp    r3, r2
  1167.      strhi  r4, [r2], #4
  1168.      bhi    1b
  1169. -
  1170. -#ifdef BOOTLOADER
  1171. -    /* TODO: the high part of the address is probably dependent on CONFIG_CPU.
  1172. -       Since we tend to use ifdefs for each chipset target
  1173. -       anyway, we might as well just hardcode it here.
  1174. -     */
  1175. -       
  1176. -    /* get the high part of our execute address */
  1177. -    ldr    r0, =0xff000000
  1178. -    and    r8, pc, r0             @ r8 is used later
  1179. -
  1180. -    /* Find out which processor we are */
  1181. -    mov    r0, #PROC_ID
  1182. -    ldr    r0, [r0]
  1183. -    and    r0, r0, #0xff
  1184. -    cmp    r0, #0x55
  1185. -    beq    1f
  1186. -
  1187. -    /* put us (co-processor) to sleep */
  1188. -    ldr    r4, =COP_CTRL
  1189. -    mov    r3, #SLEEP
  1190. -    str    r3, [r4]
  1191. -    ldr    pc, =cop_wake_start
  1192. -
  1193. -cop_wake_start:
  1194. -    /* jump the COP to startup */
  1195. -    ldr    r0, =startup_loc
  1196. -    ldr    pc, [r0]
  1197. -
  1198. -1:
  1199. -   
  1200. -    /* get the high part of our execute address */
  1201. -    ldr    r2, =0xffffff00
  1202. -    and    r4, pc, r2
  1203. -
  1204. -    /* Copy bootloader to safe area - 0x40000000 */
  1205. -    mov    r5, #0x40000000
  1206. -    ldr    r6, = _dataend
  1207. -    sub    r0, r6, r5       /* length of loader */
  1208. -    add    r0, r4, r0     /* r0 points to start of loader */
  1209. -1:
  1210. -    cmp    r5, r6
  1211. -    ldrcc  r2, [r4], #4
  1212. -    strcc  r2, [r5], #4
  1213. -    bcc    1b
  1214. -
  1215. -    ldr    pc, =start_loc    /* jump to the relocated start_loc:  */
  1216. -   
  1217. -start_loc:
  1218. -
  1219. -    /* execute the loader - this will load an image to 0x10000000 */
  1220. -    bl     main
  1221. -
  1222. -    /* Wake up the coprocessor before executing the firmware */
  1223. -
  1224. -    /* save the startup address for the COP */
  1225. -    ldr    r1, =startup_loc
  1226. -    str    r0, [r1]
  1227. -
  1228. -    /* make sure COP is sleeping */
  1229. -    ldr    r4, =COP_STATUS
  1230. -1:
  1231. -    ldr    r3, [r4]
  1232. -    ands   r3, r3, #SLEEPING
  1233. -    beq    1b
  1234. -
  1235. -    /* wake up COP */
  1236. -    ldr    r4, =COP_CTRL
  1237. -    mov    r3, #WAKE
  1238. -    str    r3, [r4]
  1239. -
  1240. -    /* jump to start location */
  1241. -    mov    pc, r0
  1242. -
  1243. -startup_loc:
  1244. -    .word    0x0
  1245. -
  1246. -.align 8    /* starts at 0x100 */
  1247. -.global boot_table
  1248. -boot_table:
  1249. -    /* here comes the boot table, don't move its offset */
  1250. -    .space 400
  1251. -
  1252. -#else /* BOOTLOADER */
  1253.      
  1254.      /* Set up stack for IRQ mode */
  1255.      msr    cpsr_c, #0xd2
  1256. @@ -290,6 +198,21 @@
  1257.      /* main() should never return */
  1258.  
  1259.  cop_init:
  1260. +#if CONFIG_CPU != PP5002
  1261. +    /* COP: Invalidate cache */
  1262. +    ldr    r0, =0xf000f044
  1263. +    ldr    r1, [r0]
  1264. +    orr    r1, r1, #0x6
  1265. +    str    r1, [r0]
  1266. +
  1267. +    ldr    r0, =0x6000c000
  1268. +1:
  1269. +    ldr    r1, [r0]
  1270. +    tst    r1, #0x8000
  1271. +    bne    1b
  1272. +#endif
  1273. +
  1274. +    /* Setup stack for COP */
  1275.      ldr    sp, =cop_stackend
  1276.      mov    r3, sp
  1277.      ldr    r2, =cop_stackbegin
  1278. @@ -300,6 +223,8 @@
  1279.      bhi    2b
  1280.  
  1281.      ldr    sp, =cop_stackend
  1282. +   
  1283. +    /* Run cop_main() in apps/main.c */
  1284.      bl     cop_main
  1285.      
  1286.  /* Exception handlers. Will be copied to address 0 after memory remapping */
  1287. @@ -385,5 +310,3 @@
  1288.  /* 256 words of FIQ stack */
  1289.      .space 256*4
  1290.  fiq_stack:
  1291. -
  1292. -#endif /* BOOTLOADER */
  1293. Index: firmware/target/arm/sandisk/sansa-e200/button-e200.c
  1294. ===================================================================
  1295. RCS file: /cvsroot/rockbox/firmware/target/arm/sandisk/sansa-e200/button-e200.c,v
  1296. retrieving revision 1.2
  1297. diff -u -r1.2 button-e200.c
  1298. --- firmware/target/arm/sandisk/sansa-e200/button-e200.c        16 Oct 2006 00:18:49 -0000      1.2
  1299. +++ firmware/target/arm/sandisk/sansa-e200/button-e200.c        13 Dec 2006 00:28:24 -0000
  1300. @@ -28,16 +28,125 @@
  1301.  #include "backlight.h"
  1302.  #include "system.h"
  1303.  
  1304. +static unsigned int old_wheel_value = 0;
  1305. +int int_btn = BUTTON_NONE;
  1306. +static bool hold_button = false;
  1307.  
  1308. -void button_init_device(void)
  1309. +static int e200_button_read(void)
  1310.  {
  1311. -    /* Enable all buttons except the wheel */
  1312. -    GPIOF_ENABLE |= 0xff;
  1313. +    unsigned char source, wheel_source, state, wheel_state;
  1314. +    int btn = BUTTON_NONE;
  1315. +   
  1316. +    /* get source(s) of interupt */
  1317. +    source = GPIOA_INT_STAT & 0x3f;
  1318. +    wheel_source = GPIOB_INT_STAT & 0x30;
  1319. +
  1320. +    if (source == 0 && wheel_source == 0) {
  1321. +        return BUTTON_NONE; /* not for us */
  1322. +    }
  1323. +   
  1324. +    /* get current keypad & wheel status */
  1325. +    state = GPIOF_INPUT_VAL & 0xff;
  1326. +    wheel_state = GPIOH_INPUT_VAL & 0xc0;
  1327. +   
  1328. +    /* toggle interrupt level */
  1329. +    GPIOA_INT_LEV = ~state;
  1330. +    GPIOB_INT_LEV = ~wheel_state;
  1331. +   
  1332. +    /* device buttons */
  1333. +    //if (!hold_button)
  1334. +    {
  1335. +        /* Read normal buttons */
  1336. +        if ((state & 0x1) == 0) btn |= BUTTON_REC;
  1337. +        if ((state & 0x2) == 0) btn |= BUTTON_DOWN;
  1338. +        if ((state & 0x4) == 0) btn |= BUTTON_RIGHT;
  1339. +        if ((state & 0x8) == 0) btn |= BUTTON_LEFT;
  1340. +        if ((state & 0x10) == 0) btn |= BUTTON_SELECT; /* The centre button */
  1341. +        if ((state & 0x20) == 0) btn |= BUTTON_UP; /* The "play" button */
  1342. +        if ((state & 0x40) != 0) btn |= BUTTON_POWER;
  1343. +       
  1344. +        /* Read wheel
  1345. +         * Bits 6 and 7 of GPIOH change as follows:
  1346. +         * Clockwise rotation   01 -> 00 -> 10 -> 11
  1347. +         * Counter-clockwise    11 -> 10 -> 00 -> 01
  1348. +         *
  1349. +         * This is equivalent to wheel_value of:
  1350. +         * Clockwise rotation   0x40 -> 0x00 -> 0x80 -> 0xc0
  1351. +         * Counter-clockwise    0xc0 -> 0x80 -> 0x00 -> 0x40
  1352. +         */
  1353. +        wheel_state = GPIOH_INPUT_VAL & 0xc0;
  1354. +        switch(wheel_state){
  1355. +        case 0x00:
  1356. +            if(old_wheel_value==0x80)
  1357. +                btn |= BUTTON_SCROLL_UP;
  1358. +            else if (old_wheel_value==0x40)
  1359. +                btn |= BUTTON_SCROLL_DOWN;
  1360. +            break;
  1361. +        case 0x40:
  1362. +            if(old_wheel_value==0x00)
  1363. +                btn |= BUTTON_SCROLL_UP;
  1364. +            else if (old_wheel_value==0xc0)
  1365. +                btn |= BUTTON_SCROLL_DOWN;
  1366. +            break;
  1367. +        case 0x80:
  1368. +                    if(old_wheel_value==0xc0)
  1369. +                btn |= BUTTON_SCROLL_UP;
  1370. +            else if (old_wheel_value==0x00)
  1371. +                btn |= BUTTON_SCROLL_DOWN;
  1372. +            break;
  1373. +        case 0xc0:
  1374. +                    if(old_wheel_value==0x40)
  1375. +                btn |= BUTTON_SCROLL_UP;
  1376. +            else if (old_wheel_value==0x80)
  1377. +                btn |= BUTTON_SCROLL_DOWN;
  1378. +            break;
  1379. +        }
  1380. +        old_wheel_value = wheel_state;
  1381. +    }
  1382. +
  1383. +    /* ack any active interrupts */
  1384. +    if (source)
  1385. +        GPIOF_INT_CLR = source;
  1386. +    if (wheel_source)
  1387. +        GPIOH_INT_CLR = wheel_source;
  1388. +
  1389. +    return btn;
  1390.  }
  1391.  
  1392. -bool button_hold(void)
  1393. +void e200_button_int(void)
  1394.  {
  1395. -    return (GPIOF_INPUT_VAL & 0x80)?true:false;
  1396. +    CPU_HI_INT_CLR = GPIO_MASK;
  1397. +    int_btn = e200_button_read();
  1398. +    //CPU_INT_EN = 0x40000000;
  1399. +    CPU_HI_INT_EN = GPIO_MASK;
  1400. +}
  1401. +
  1402. +void button_init_device(void)
  1403. +{
  1404. +    /* Enable all buttons except the wheel */
  1405. +    GPIOF_ENABLE |= 0xff;
  1406. +   
  1407. +    /* Enable scroll wheel */
  1408. +    GPIOH_ENABLE |= 0xc0;
  1409. +   
  1410. +    /* buttons - set interrupt levels */
  1411. +    GPIOF_INT_LEV = ~(GPIOF_INPUT_VAL & 0xff);
  1412. +    GPIOF_INT_CLR = GPIOF_INT_STAT & 0xff;
  1413. +   
  1414. +    /* scroll wheel - set interrupt levels */
  1415. +    GPIOH_INT_LEV = ~(GPIOH_INPUT_VAL & 0xc0);
  1416. +    GPIOH_INT_CLR = GPIOH_INT_STAT & 0xc0;
  1417. +   
  1418. +    /* enable interrupts */
  1419. +    GPIOF_INT_EN = 0xff;
  1420. +    GPIOH_INT_EN = 0xc0;
  1421. +   
  1422. +    /* unmask interrupt */
  1423. +    CPU_INT_EN = 0x40000000;
  1424. +    CPU_HI_INT_EN = GPIO_MASK;
  1425. +   
  1426. +    /* Read initial wheel value (bit 6-7 of GPIOH) */
  1427. +    old_wheel_value = GPIOH_INPUT_VAL & 0xc0;
  1428.  }
  1429.  
  1430.  /*
  1431. @@ -45,9 +154,6 @@
  1432.   */
  1433.  int button_read_device(void)
  1434.  {
  1435. -    int btn = BUTTON_NONE;
  1436. -    unsigned char state;
  1437. -    static bool hold_button = false;
  1438.      bool hold_button_old;
  1439.  
  1440.      /* Hold */
  1441. @@ -64,19 +170,11 @@
  1442.  #endif
  1443.  #endif
  1444.  
  1445. -    /* device buttons */
  1446. -    if (!hold_button)
  1447. -    {
  1448. -        /* Read normal buttons */
  1449. -        state = GPIOF_INPUT_VAL & 0xff;
  1450. -        if ((state & 0x1) == 0) btn |= BUTTON_REC;
  1451. -        if ((state & 0x2) == 0) btn |= BUTTON_DOWN;
  1452. -        if ((state & 0x4) == 0) btn |= BUTTON_RIGHT;
  1453. -        if ((state & 0x8) == 0) btn |= BUTTON_LEFT;
  1454. -        if ((state & 0x10) == 0) btn |= BUTTON_SELECT; /* The centre button */
  1455. -        if ((state & 0x20) == 0) btn |= BUTTON_UP; /* The "play" button */
  1456. -        if ((state & 0x40) != 0) btn |= BUTTON_POWER;
  1457. -    }
  1458. +    /* The int_btn variable is set in the button interrupt handler */
  1459. +    return int_btn;
  1460. +}
  1461.  
  1462. -    return btn;
  1463. +bool button_hold(void)
  1464. +{
  1465. +    return (GPIOF_INPUT_VAL & 0x80)?true:false;
  1466.  }
  1467. Index: firmware/target/arm/sandisk/sansa-e200/button-target.h
  1468. ===================================================================
  1469. RCS file: /cvsroot/rockbox/firmware/target/arm/sandisk/sansa-e200/button-target.h,v
  1470. retrieving revision 1.3
  1471. diff -u -r1.3 button-target.h
  1472. --- firmware/target/arm/sandisk/sansa-e200/button-target.h      14 Oct 2006 12:16:29 -0000    1.3
  1473. +++ firmware/target/arm/sandisk/sansa-e200/button-target.h      13 Dec 2006 00:28:24 -0000
  1474. @@ -28,6 +28,7 @@
  1475.  bool button_hold(void);
  1476.  void button_init_device(void);
  1477.  int button_read_device(void);
  1478. +void e200_button_int(void);
  1479.  
  1480.  /* Sandisk Sansa E200 button codes */
  1481.  
  1482. Index: tools/configure
  1483. ===================================================================
  1484. RCS file: /cvsroot/rockbox/tools/configure,v
  1485. retrieving revision 1.245
  1486. diff -u -r1.245 configure
  1487. --- tools/configure     27 Nov 2006 02:15:39 -0000   1.245
  1488. +++ tools/configure     13 Dec 2006 00:28:28 -0000
  1489. @@ -1115,10 +1115,10 @@
  1490.      target="-DSANSA_E200"
  1491.      memory=32 # supposedly
  1492.      arm7tdmicc
  1493. -    tool="$rootdir/tools/scramble -mi4v3"
  1494. +    tool="$rootdir/tools/scramble -add=e200"
  1495.      bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
  1496.      bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
  1497. -    output="PP5022.mi4"
  1498. +    output="rockbox.e200"
  1499.      appextra="recorder:gui"
  1500.      archosrom=""
  1501.      flash=""
  1502. Index: tools/scramble.c
  1503. ===================================================================
  1504. RCS file: /cvsroot/rockbox/tools/scramble.c,v
  1505. retrieving revision 1.35
  1506. diff -u -r1.35 scramble.c
  1507. --- tools/scramble.c    31 Aug 2006 19:19:35 -0000  1.35
  1508. +++ tools/scramble.c    13 Dec 2006 00:28:29 -0000
  1509. @@ -89,7 +89,7 @@
  1510.             "\t-mi4v3  PortalPlayer .mi4 format (revision 010301)\n"
  1511.             "\t-add=X  Rockbox generic \"add-up\" checksum format\n"
  1512.             "\t        (X values: h100, h120, h140, h300, ipco, nano, ipvd\n"
  1513. -           "\t                   ip3g, ip4g, mini, x5, h10, h10_5gb)\n"
  1514. +           "\t                   ip3g, ip4g, mini, x5, h10, h10_5gb, tpj2, e200)\n"
  1515.             "\nNo option results in Archos standard player/recorder format.\n");
  1516.  
  1517.      exit(1);
  1518. @@ -207,6 +207,8 @@
  1519.              modelnum = 14;
  1520.          else if(!strcmp(&argv[1][5], "tpj2"))
  1521.              modelnum = 15;
  1522. +        else if(!strcmp(&argv[1][5], "e200"))
  1523. +            modelnum = 16;
  1524.          else {
  1525.              fprintf(stderr, "unsupported model: %s\n", &argv[1][5]);
  1526.              return 2;

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right