201-flashsize.patch 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. --- a/arch/cris/arch-v10/lib/hw_settings.S
  2. +++ b/arch/cris/arch-v10/lib/hw_settings.S
  3. @@ -60,3 +60,5 @@
  4. .dword R_PORT_PB_SET
  5. .dword PB_SET_VALUE
  6. .dword 0 ; No more register values
  7. + .ascii "ACME_PART_MAGIC"
  8. + .dword 0xdeadc0de
  9. --- a/arch/cris/arch-v10/drivers/axisflashmap.c
  10. +++ b/arch/cris/arch-v10/drivers/axisflashmap.c
  11. @@ -113,7 +113,7 @@
  12. /* If no partition-table was found, we use this default-set. */
  13. #define MAX_PARTITIONS 7
  14. -#define NUM_DEFAULT_PARTITIONS 3
  15. +#define NUM_DEFAULT_PARTITIONS 2
  16. /*
  17. * Default flash size is 2MB. CONFIG_ETRAX_PTABLE_SECTOR is most likely the
  18. @@ -122,19 +122,14 @@
  19. */
  20. static struct mtd_partition axis_default_partitions[NUM_DEFAULT_PARTITIONS] = {
  21. {
  22. - .name = "boot firmware",
  23. - .size = CONFIG_ETRAX_PTABLE_SECTOR,
  24. - .offset = 0
  25. - },
  26. - {
  27. .name = "kernel",
  28. - .size = 0x200000 - (6 * CONFIG_ETRAX_PTABLE_SECTOR),
  29. - .offset = CONFIG_ETRAX_PTABLE_SECTOR
  30. + .size = 0x00,
  31. + .offset = 0
  32. },
  33. {
  34. - .name = "filesystem",
  35. - .size = 5 * CONFIG_ETRAX_PTABLE_SECTOR,
  36. - .offset = 0x200000 - (5 * CONFIG_ETRAX_PTABLE_SECTOR)
  37. + .name = "rootfs",
  38. + .size = 0x200000 ,
  39. + .offset = 0x200000
  40. }
  41. };
  42. @@ -281,6 +276,11 @@
  43. struct partitiontable_entry *ptable;
  44. int use_default_ptable = 1; /* Until proven otherwise. */
  45. const char pmsg[] = " /dev/flash%d at 0x%08x, size 0x%08x\n";
  46. + unsigned int kernel_part_size = 0;
  47. + unsigned char *flash_mem = (unsigned char*)(FLASH_CACHED_ADDR);
  48. + unsigned int flash_scan_count = 0;
  49. + const char *part_magic = "ACME_PART_MAGIC";
  50. + unsigned int magic_len = strlen(part_magic);
  51. if (!(mymtd = flash_probe())) {
  52. /* There's no reason to use this module if no flash chip can
  53. @@ -292,6 +292,31 @@
  54. mymtd->name, mymtd->size);
  55. axisflash_mtd = mymtd;
  56. }
  57. + /* scan flash to findout where out partition starts */
  58. +
  59. + printk(KERN_INFO "Scanning flash for end of kernel magic\n");
  60. + for(flash_scan_count = 0; flash_scan_count < 100000; flash_scan_count++){
  61. + if(strncmp(&flash_mem[flash_scan_count], part_magic, magic_len - 1) == 0)
  62. + {
  63. + kernel_part_size = flash_mem[flash_scan_count + magic_len ];
  64. + kernel_part_size <<= 8;
  65. + kernel_part_size += flash_mem[flash_scan_count + magic_len + 2];
  66. + kernel_part_size <<= 8;
  67. + kernel_part_size += flash_mem[flash_scan_count + magic_len + 1];
  68. + kernel_part_size <<= 8;
  69. + kernel_part_size += flash_mem[flash_scan_count + magic_len + 3];
  70. + printk(KERN_INFO "Kernel ends at 0x%.08X\n", kernel_part_size);
  71. + flash_scan_count = 1100000;
  72. + }
  73. + }
  74. +
  75. +
  76. + if(kernel_part_size){
  77. + kernel_part_size = (kernel_part_size & 0xffff0000);
  78. + axis_default_partitions[0].size = kernel_part_size;
  79. + axis_default_partitions[1].size = mymtd->size - axis_default_partitions[0].size;
  80. + axis_default_partitions[1].offset = axis_default_partitions[0].size;
  81. + }
  82. if (mymtd) {
  83. mymtd->owner = THIS_MODULE;