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

Something
Tuesday, November 27th, 2007 at 1:19:48am UTC 

  1. diff --git a/bootloader/gigabeat-s.c b/bootloader/gigabeat-s.c
  2. index 25b9ab5..190dca5 100644
  3. --- a/bootloader/gigabeat-s.c
  4. +++ b/bootloader/gigabeat-s.c
  5. @@ -28,6 +28,7 @@
  6.  #include "kernel.h"
  7.  #include "thread.h"
  8.  #include "ata.h"
  9. +#include "dir.h"
  10.  #include "fat.h"
  11.  #include "disk.h"
  12.  #include "font.h"
  13. @@ -47,13 +48,38 @@
  14.  #include <stdarg.h>
  15.  
  16.  char version[] = APPSVERSION;
  17. +char buf[5][MAX_PATH];
  18. +
  19. +void ls_dir(const char *path, int level)
  20. +{
  21. +    struct dirent_uncached* entry;
  22. +    DIR_UNCACHED* dir;
  23. +    dir = opendir_uncached(path);
  24. +
  25. +    printf("listing %s:", path);
  26. +
  27. +    while ((entry = readdir_uncached(dir)))
  28. +    {
  29. +        if (*entry->d_name != '.')
  30. +            printf("%s: %d, %ld", entry->d_name, entry->attribute, entry->size);
  31. +
  32. +        if (level < 5 && entry->attribute == ATTR_DIRECTORY && *entry->d_name != '.')
  33. +        {
  34. +            snprintf(buf[level], sizeof(buf[level]), "%s%s/", path, entry->d_name);
  35. +            ls_dir(buf[level], level+1);
  36. +        }
  37. +    }
  38. +
  39. +    printf("end");
  40. +}
  41.  
  42.  void main(void)
  43.  {
  44.      lcd_clear_display();
  45.      printf("Hello world!");
  46. -    printf("Gigabeat S Rockbox Bootloader v.00000001");         
  47. +    printf("Gigabeat S Rockbox Bootloader v.00000001");
  48.      kernel_init();
  49. +    printf("kernel init done");
  50.      int rc;
  51.  
  52.      rc = ata_init();
  53. @@ -62,8 +88,10 @@ void main(void)
  54.          reset_screen();
  55.          error(EATA, rc);
  56.      }
  57. +    printf("ata init done");
  58.  
  59.      disk_init();
  60. +    printf("disk init done");
  61.  
  62.      rc = disk_mount_all();
  63.      if (rc<=0)
  64. @@ -71,6 +99,10 @@ void main(void)
  65.          error(EDISK,rc);
  66.      }
  67.  
  68. +    /* Directory listing */
  69. +
  70. +    ls_dir("/", 0);
  71. +
  72.      printf("Congratulations!");
  73.      while(1);
  74.  
  75. diff --git a/firmware/boot.lds b/firmware/boot.lds
  76. index d4c72b5..7e20cf0 100644
  77. --- a/firmware/boot.lds
  78. +++ b/firmware/boot.lds
  79. @@ -292,7 +292,7 @@ SECTIONS
  80.  }
  81.  #elif (CONFIG_CPU==IMX31L)
  82.  {
  83. -  . = 0x88201000;
  84. +  . = 0x89000000;
  85.    .vectors :
  86.    { 
  87.      KEEP(*(.vectors*));
  88. diff --git a/firmware/common/disk.c b/firmware/common/disk.c
  89. index 563bb05..5d00379 100644
  90. --- a/firmware/common/disk.c
  91. +++ b/firmware/common/disk.c
  92. @@ -150,7 +150,7 @@ int disk_mount(int drive)
  93.      /* The Elio's hard drive has no partition table and probing for partitions causes
  94.         Rockbox to crash - so we temporarily disable the probing until we fix the
  95.         real problem. */
  96. -    for (i=0; volume != -1 && i<4; i++)
  97. +    for (i=1; volume != -1 && i<4; i++)
  98.      {
  99.  #ifdef MAX_LOG_SECTOR_SIZE
  100.          int j;
  101. diff --git a/firmware/debug.c b/firmware/debug.c
  102. index 6b638c1..8f62f0b 100644
  103. --- a/firmware/debug.c
  104. +++ b/firmware/debug.c
  105. @@ -25,6 +25,7 @@
  106.  #ifdef HAVE_GDB_API
  107.  #include "gdb_api.h"
  108.  #endif
  109. +#include "../bootloader/common.h"
  110.  
  111.  #ifdef DEBUG
  112.  static char debugmembuf[200];
  113. @@ -241,7 +242,8 @@ void debugf(const char *fmt, ...)
  114.      va_start(ap, fmt);
  115.      vsnprintf(debugmembuf, sizeof(debugmembuf), fmt, ap);
  116.      va_end(ap);
  117. -    debug(debugmembuf);
  118. +    //debug(debugmembuf);
  119. +    printf(debugmembuf);
  120.  #else
  121.      (void)fmt;
  122.  #endif
  123. diff --git a/firmware/export/config-gigabeat-s.h b/firmware/export/config-gigabeat-s.h
  124. index 285b381..67b2ee8 100644
  125. --- a/firmware/export/config-gigabeat-s.h
  126. +++ b/firmware/export/config-gigabeat-s.h
  127. @@ -5,6 +5,8 @@
  128.  
  129.  #define TOSHIBA_GIGABEAT_S 1
  130.  
  131. +// #define DEBUG
  132. +
  133.  /* For Rolo and boot loader */
  134.  #define MODEL_NUMBER 19
  135.  
  136. diff --git a/firmware/kernel.c b/firmware/kernel.c
  137. index 803c224..de66556 100644
  138. --- a/firmware/kernel.c
  139. +++ b/firmware/kernel.c
  140. @@ -27,6 +27,7 @@
  141.  #if CONFIG_CPU == IMX31L
  142.  #include "avic-imx31.h"
  143.  #endif
  144. +#include "debug.h"
  145.  
  146.  /* Make this nonzero to enable more elaborate checks on objects */
  147.  #ifdef DEBUG
  148. @@ -65,6 +66,7 @@ static struct
  149.   ****************************************************************************/
  150.  void kernel_init(void)
  151.  {
  152. +    DEBUGF("Testing, testing, 123");
  153.      /* Init the threading API */
  154.      init_threads();
  155.  
  156. diff --git a/firmware/thread.c b/firmware/thread.c
  157. index 126cc41..3b68cf6 100644
  158. --- a/firmware/thread.c
  159. +++ b/firmware/thread.c
  160. @@ -28,6 +28,7 @@
  161.  #ifdef RB_PROFILE
  162.  #include <profile.h>
  163.  #endif
  164. +#include "debug.h"
  165.  
  166.  /* Define THREAD_EXTRA_CHECKS as 1 to enable additional state checks */
  167.  #ifdef DEBUG
  168. @@ -2555,6 +2556,8 @@ void init_threads(void)
  169.          remove_thread(NULL);
  170.  #endif /* NUM_CORES */
  171.      }
  172. +
  173. +    DEBUGF("init_threads done");
  174.  }
  175.  
  176.  /*---------------------------------------------------------------------------
  177. diff --git a/tools/mknkboot.c b/tools/mknkboot.c
  178. index c5e89f6..ad49704 100644
  179. --- a/tools/mknkboot.c
  180. +++ b/tools/mknkboot.c
  181. @@ -27,6 +27,12 @@
  182.  #include <unistd.h>
  183.  #include <inttypes.h>
  184.  
  185. +/* New entry point for nk.bin - where our dualboot code is inserted */
  186. +#define NK_ENTRY_POINT 0x88200000
  187. +
  188. +/* Entry point (and load address) for the main Rockbox bootloader */
  189. +#define BL_ENTRY_POINT 0x89000000
  190. +
  191.  /*
  192.  
  193.  Description of nk.bin from
  194. @@ -65,11 +71,35 @@ mknkboot.c appends two images:
  195.  #define O_BINARY 0
  196.  #endif
  197.  
  198. -
  199.  #define DISABLE_ADDR    0x88065A10 /* in EBoot */
  200.  #define DISABLE_INSN    0xe3a00001
  201.  #define DISABLE_SUM     (0xe3+0xa0+0x00+0x01) 
  202.  
  203. +/* Code to dual-boot - this is inserted at NK_ENTRY_POINT */
  204. +
  205. +/* Define the following to load Rockbox on hold switch, otherwise
  206. +   Rockbox is loaded by default, and the OF if hold is on */
  207. +//#define ROCKBOX_ON_HOLD
  208. +
  209. +static uint32_t dualboot[] =
  210. +{
  211. +    0xe59f900c,      /* ldr     r9, [pc, #12] -> 0x53fa4000 */
  212. +    0xe5999000,      /* ldr     r9, [r9] */
  213. +    0xe3190010,      /* tst     r9, #16 ; 0x10 */
  214. +#if 1
  215. +    /* Branch to Rockbox if hold is on */
  216. +    0x159ff004,      /* ldrne   pc, [pc, #4]  -> 0x89000000 */
  217. +#else
  218. +    /* Branch to Rockbox if hold is off */
  219. +    0x059ff004,      /* ldreq   pc, [pc, #4]  -> 0x89000000 */
  220. +#endif
  221. +    /* Branch to original firmware */
  222. +    0xea0003fa,      /* b 0x1000 */
  223. +
  224. +    0x53fa4000,      /* GPIO3_DR */
  225. +    BL_ENTRY_POINT   /* RB bootloader load address/entry point */
  226. +};
  227. +
  228.  static void put_uint32le(uint32_t x, unsigned char* p)
  229.  {
  230.      p[0] = x & 0xff;
  231. @@ -105,6 +135,7 @@ int main(int argc, char *argv[])
  232.      int inlength,bootlength,newlength;
  233.      unsigned char* buf;
  234.      unsigned char* boot;
  235. +    unsigned char* boot2;
  236.      unsigned char* disable;
  237.      uint32_t sum;
  238.      
  239. @@ -133,9 +164,9 @@ int main(int argc, char *argv[])
  240.      bootlength = filesize(fdboot);
  241.  
  242.      /* Create buffer for original nk.bin, plus our bootloader (with 12
  243. -       byte header), plus the 16-byte "disable record" */
  244. +       byte header), plus the 16-byte "disable record", plus our dual-boot code */
  245.  
  246. -    newlength = inlength + (bootlength + 12) + 16;
  247. +    newlength = inlength + (bootlength + 12) + 16 + (12 + 28);
  248.      buf = malloc(newlength);
  249.  
  250.      if (buf==NULL)
  251. @@ -156,6 +187,8 @@ int main(int argc, char *argv[])
  252.      /****** STEP 2 - Move EOF record to the new EOF */
  253.      memcpy(buf + newlength - 12, buf + inlength - 12, 12);
  254.  
  255. +    /* Overwrite default entry point with NK_ENTRY_POINT */
  256. +    put_uint32le(NK_ENTRY_POINT, buf + newlength - 8);
  257.  
  258.      /****** STEP 3 - Create a record to disable the firmware signature
  259.                  check in EBoot */
  260. @@ -177,17 +210,35 @@ int main(int argc, char *argv[])
  261.  
  262.      /****** STEP 5 - Create header for bootloader record */
  263.  
  264. -    /* Calculate simple checksum */
  265. +    /* Calculate checksum */
  266.      sum = 0;
  267.      for (i = 0; i < bootlength; i++) {
  268.          sum += boot[12 + i];
  269.      }
  270.      
  271. -    put_uint32le(0x88201000, boot); /* nk.exe start address */
  272. +    put_uint32le(BL_ENTRY_POINT, boot); /* Our entry point */
  273.      put_uint32le(bootlength, boot + 4);
  274.      put_uint32le(sum, boot + 8);
  275.  
  276. -    /****** STEP 6 -  Now write the output file */
  277. +    /****** STEP 6 -  Insert our dual-boot code */
  278. +    boot2 = boot + bootlength + 12;
  279. +
  280. +    /* Copy dual-boot code in an endian-safe way */
  281. +    for (i = 0; i < sizeof(dualboot) / 4; i++) {
  282. +        put_uint32le(dualboot[i], boot2 + 12 + i*4);
  283. +    }
  284. +
  285. +    /* Calculate checksum */
  286. +    sum = 0;
  287. +    for (i = 0; i < sizeof(dualboot); i++) {
  288. +        sum += boot2[i+12];
  289. +    }
  290. +   
  291. +    put_uint32le(NK_ENTRY_POINT, boot2); /* New entry point for our nk.bin */
  292. +    put_uint32le(sizeof(dualboot), boot2 + 4);
  293. +    put_uint32le(sum, boot2 + 8);
  294. +
  295. +    /****** STEP 7 -  Now write the output file */
  296.  
  297.      fdout = open(outfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644);
  298.      if (fdout < 0)

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