diff options
author | Michael Sparmann <theseven@rockbox.org> | 2010-10-25 12:36:57 +0000 |
---|---|---|
committer | Michael Sparmann <theseven@rockbox.org> | 2010-10-25 12:36:57 +0000 |
commit | 01cdb6a21f0a7737bc51c4997d66bd152db694a8 (patch) | |
tree | cc98be9a47e120f62c3b946d2589f00831b7d178 | |
parent | 0952848368e403f81541e222f941ec46b0e583a4 (diff) | |
download | rockbox-01cdb6a21f0a7737bc51c4997d66bd152db694a8.tar.gz rockbox-01cdb6a21f0a7737bc51c4997d66bd152db694a8.zip |
Fix screendump on iPod Nano 2G by increasing the usb thread stack size and reducing the stack usage of FAT and storage functions
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28356 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/common/file.c | 5 | ||||
-rw-r--r-- | firmware/export/screendump.h | 14 | ||||
-rw-r--r-- | firmware/screendump.c | 16 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c | 40 | ||||
-rw-r--r-- | firmware/usb.c | 5 |
5 files changed, 33 insertions, 47 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index 53a1a35b31..da85846a34 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c | |||
@@ -65,7 +65,8 @@ static int open_internal(const char* pathname, int flags, bool use_cache) | |||
65 | DIR_UNCACHED* dir; | 65 | DIR_UNCACHED* dir; |
66 | struct dirent_uncached* entry; | 66 | struct dirent_uncached* entry; |
67 | int fd; | 67 | int fd; |
68 | char pathnamecopy[MAX_PATH]; | 68 | int pathnamesize = strlen(pathname) + 1; |
69 | char pathnamecopy[pathnamesize]; | ||
69 | char* name; | 70 | char* name; |
70 | struct filedesc* file = NULL; | 71 | struct filedesc* file = NULL; |
71 | int rc; | 72 | int rc; |
@@ -133,7 +134,7 @@ static int open_internal(const char* pathname, int flags, bool use_cache) | |||
133 | } | 134 | } |
134 | #endif | 135 | #endif |
135 | 136 | ||
136 | strlcpy(pathnamecopy, pathname, sizeof(pathnamecopy)); | 137 | strlcpy(pathnamecopy, pathname, pathnamesize); |
137 | 138 | ||
138 | /* locate filename */ | 139 | /* locate filename */ |
139 | name=strrchr(pathnamecopy+1,'/'); | 140 | name=strrchr(pathnamecopy+1,'/'); |
diff --git a/firmware/export/screendump.h b/firmware/export/screendump.h index 87b32c6bee..9be1f5d3f2 100644 --- a/firmware/export/screendump.h +++ b/firmware/export/screendump.h | |||
@@ -39,6 +39,20 @@ | |||
39 | #define LE16_CONST(x) (x)&0xff, ((x)>>8)&0xff | 39 | #define LE16_CONST(x) (x)&0xff, ((x)>>8)&0xff |
40 | #define LE32_CONST(x) (x)&0xff, ((x)>>8)&0xff, ((x)>>16)&0xff, ((x)>>24)&0xff | 40 | #define LE32_CONST(x) (x)&0xff, ((x)>>8)&0xff, ((x)>>16)&0xff, ((x)>>24)&0xff |
41 | 41 | ||
42 | #if LCD_DEPTH <= 4 | ||
43 | #define BMP_BPP 4 | ||
44 | #define BMP_LINESIZE ((LCD_WIDTH/2 + 3) & ~3) | ||
45 | #elif LCD_DEPTH <= 8 | ||
46 | #define BMP_BPP 8 | ||
47 | #define BMP_LINESIZE ((LCD_WIDTH + 3) & ~3) | ||
48 | #elif LCD_DEPTH <= 16 | ||
49 | #define BMP_BPP 16 | ||
50 | #define BMP_LINESIZE ((LCD_WIDTH*2 + 3) & ~3) | ||
51 | #else | ||
52 | #define BMP_BPP 24 | ||
53 | #define BMP_LINESIZE ((LCD_WIDTH*3 + 3) & ~3) | ||
54 | #endif | ||
55 | |||
42 | 56 | ||
43 | #ifdef BOOTLOADER | 57 | #ifdef BOOTLOADER |
44 | 58 | ||
diff --git a/firmware/screendump.c b/firmware/screendump.c index 1876df8ac0..cd9d6a5bd6 100644 --- a/firmware/screendump.c +++ b/firmware/screendump.c | |||
@@ -49,20 +49,6 @@ | |||
49 | #endif /* LCD_DEPTH > 8 */ | 49 | #endif /* LCD_DEPTH > 8 */ |
50 | #endif /* LCD_DEPTH != 16 */ | 50 | #endif /* LCD_DEPTH != 16 */ |
51 | 51 | ||
52 | #if LCD_DEPTH <= 4 | ||
53 | #define BMP_BPP 4 | ||
54 | #define BMP_LINESIZE ((LCD_WIDTH/2 + 3) & ~3) | ||
55 | #elif LCD_DEPTH <= 8 | ||
56 | #define BMP_BPP 8 | ||
57 | #define BMP_LINESIZE ((LCD_WIDTH + 3) & ~3) | ||
58 | #elif LCD_DEPTH <= 16 | ||
59 | #define BMP_BPP 16 | ||
60 | #define BMP_LINESIZE ((LCD_WIDTH*2 + 3) & ~3) | ||
61 | #else | ||
62 | #define BMP_BPP 24 | ||
63 | #define BMP_LINESIZE ((LCD_WIDTH*3 + 3) & ~3) | ||
64 | #endif | ||
65 | |||
66 | #define BMP_HEADERSIZE (54 + 4 * BMP_NUMCOLORS) | 52 | #define BMP_HEADERSIZE (54 + 4 * BMP_NUMCOLORS) |
67 | #define BMP_DATASIZE (BMP_LINESIZE * (LCD_HEIGHT+LCD_SPLIT_LINES)) | 53 | #define BMP_DATASIZE (BMP_LINESIZE * (LCD_HEIGHT+LCD_SPLIT_LINES)) |
68 | #define BMP_TOTALSIZE (BMP_HEADERSIZE + BMP_DATASIZE) | 54 | #define BMP_TOTALSIZE (BMP_HEADERSIZE + BMP_DATASIZE) |
@@ -115,7 +101,7 @@ static void (*screen_dump_hook)(int fh) = NULL; | |||
115 | void screen_dump(void) | 101 | void screen_dump(void) |
116 | { | 102 | { |
117 | int fd, y; | 103 | int fd, y; |
118 | char filename[MAX_PATH]; | 104 | char filename[32]; |
119 | 105 | ||
120 | fb_data *src; | 106 | fb_data *src; |
121 | #if LCD_DEPTH == 1 | 107 | #if LCD_DEPTH == 1 |
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c index 0cada3162a..90217363cc 100644 --- a/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c +++ b/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c | |||
@@ -418,6 +418,13 @@ static uint16_t ftl_offsets_backup[0x200] STORAGE_ALIGN_ATTR; | |||
418 | 418 | ||
419 | static struct mutex ftl_mtx; | 419 | static struct mutex ftl_mtx; |
420 | 420 | ||
421 | /* Pages per hyperblock (ftl_nand_type->pagesperblock * ftl_banks) */ | ||
422 | static uint32_t ppb; | ||
423 | |||
424 | /* Reserved hyperblocks (ftl_nand_type->blocks | ||
425 | - ftl_nand_type->userblocks - 0x17) */ | ||
426 | static uint32_t syshyperblocks; | ||
427 | |||
421 | 428 | ||
422 | 429 | ||
423 | /* Finds a device info page for the specified bank and returns its number. | 430 | /* Finds a device info page for the specified bank and returns its number. |
@@ -826,9 +833,6 @@ static uint32_t ftl_vfl_read(uint32_t vpage, void* buffer, void* sparebuffer, | |||
826 | DEBUGF("FTL: VFL: Reading page %d\n", vpage); | 833 | DEBUGF("FTL: VFL: Reading page %d\n", vpage); |
827 | #endif | 834 | #endif |
828 | 835 | ||
829 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
830 | uint32_t syshyperblocks = ftl_nand_type->blocks | ||
831 | - ftl_nand_type->userblocks - 0x17; | ||
832 | uint32_t abspage = vpage + ppb * syshyperblocks; | 836 | uint32_t abspage = vpage + ppb * syshyperblocks; |
833 | if (abspage >= ftl_nand_type->blocks * ppb || abspage < ppb) | 837 | if (abspage >= ftl_nand_type->blocks * ppb || abspage < ppb) |
834 | { | 838 | { |
@@ -875,9 +879,6 @@ static uint32_t ftl_vfl_read_fast(uint32_t vpage, void* buffer, void* sparebuffe | |||
875 | #endif | 879 | #endif |
876 | 880 | ||
877 | uint32_t i, rc = 0; | 881 | uint32_t i, rc = 0; |
878 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
879 | uint32_t syshyperblocks = ftl_nand_type->blocks | ||
880 | - ftl_nand_type->userblocks - 0x17; | ||
881 | uint32_t abspage = vpage + ppb * syshyperblocks; | 882 | uint32_t abspage = vpage + ppb * syshyperblocks; |
882 | if (abspage + ftl_banks - 1 >= ftl_nand_type->blocks * ppb || abspage < ppb) | 883 | if (abspage + ftl_banks - 1 >= ftl_nand_type->blocks * ppb || abspage < ppb) |
883 | { | 884 | { |
@@ -951,9 +952,6 @@ static uint32_t ftl_vfl_write(uint32_t vpage, uint32_t count, | |||
951 | DEBUGF("FTL: VFL: Writing page %d\n", vpage); | 952 | DEBUGF("FTL: VFL: Writing page %d\n", vpage); |
952 | #endif | 953 | #endif |
953 | 954 | ||
954 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
955 | uint32_t syshyperblocks = ftl_nand_type->blocks | ||
956 | - ftl_nand_type->userblocks - 0x17; | ||
957 | uint32_t abspage = vpage + ppb * syshyperblocks; | 955 | uint32_t abspage = vpage + ppb * syshyperblocks; |
958 | if (abspage + count > ftl_nand_type->blocks * ppb || abspage < ppb) | 956 | if (abspage + count > ftl_nand_type->blocks * ppb || abspage < ppb) |
959 | { | 957 | { |
@@ -962,9 +960,9 @@ static uint32_t ftl_vfl_write(uint32_t vpage, uint32_t count, | |||
962 | return 4; | 960 | return 4; |
963 | } | 961 | } |
964 | 962 | ||
965 | uint32_t bank[5]; | 963 | static uint32_t bank[5]; |
966 | uint32_t block[5]; | 964 | static uint32_t block[5]; |
967 | uint32_t physpage[5]; | 965 | static uint32_t physpage[5]; |
968 | 966 | ||
969 | for (i = 0; i < count; i++, abspage++) | 967 | for (i = 0; i < count; i++, abspage++) |
970 | { | 968 | { |
@@ -1034,9 +1032,6 @@ static uint32_t ftl_vfl_open(void) | |||
1034 | uint8_t bbt[0x410]; | 1032 | uint8_t bbt[0x410]; |
1035 | #endif | 1033 | #endif |
1036 | 1034 | ||
1037 | uint32_t syshyperblocks = ftl_nand_type->blocks | ||
1038 | - ftl_nand_type->userblocks - 0x18; | ||
1039 | |||
1040 | for (i = 0; i < ftl_banks; i++) | 1035 | for (i = 0; i < ftl_banks; i++) |
1041 | #ifndef FTL_READONLY | 1036 | #ifndef FTL_READONLY |
1042 | if (ftl_load_bbt(i, ftl_bbt[i]) == 0) | 1037 | if (ftl_load_bbt(i, ftl_bbt[i]) == 0) |
@@ -1117,7 +1112,6 @@ static uint32_t ftl_open(void) | |||
1117 | { | 1112 | { |
1118 | uint32_t i; | 1113 | uint32_t i; |
1119 | uint32_t ret; | 1114 | uint32_t ret; |
1120 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
1121 | struct ftl_vfl_cxt_type* cxt = ftl_vfl_get_newest_cxt(); | 1115 | struct ftl_vfl_cxt_type* cxt = ftl_vfl_get_newest_cxt(); |
1122 | 1116 | ||
1123 | uint32_t ftlcxtblock = 0xffffffff; | 1117 | uint32_t ftlcxtblock = 0xffffffff; |
@@ -1281,7 +1275,6 @@ static struct ftl_log_type* ftl_get_log_entry(uint32_t block) | |||
1281 | uint32_t ftl_read(uint32_t sector, uint32_t count, void* buffer) | 1275 | uint32_t ftl_read(uint32_t sector, uint32_t count, void* buffer) |
1282 | { | 1276 | { |
1283 | uint32_t i, j; | 1277 | uint32_t i, j; |
1284 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
1285 | uint32_t error = 0; | 1278 | uint32_t error = 0; |
1286 | 1279 | ||
1287 | #ifdef FTL_TRACE | 1280 | #ifdef FTL_TRACE |
@@ -1513,7 +1506,6 @@ static uint32_t ftl_save_erasectr_page(uint32_t index) | |||
1513 | static uint32_t ftl_next_ctrl_pool_page(void) | 1506 | static uint32_t ftl_next_ctrl_pool_page(void) |
1514 | { | 1507 | { |
1515 | uint32_t i; | 1508 | uint32_t i; |
1516 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
1517 | if (++ftl_cxt.ftlctrlpage % ppb != 0) return 0; | 1509 | if (++ftl_cxt.ftlctrlpage % ppb != 0) return 0; |
1518 | for (i = 0; i < 3; i++) | 1510 | for (i = 0; i < 3; i++) |
1519 | if ((ftl_cxt.ftlctrlblocks[i] + 1) * ppb == ftl_cxt.ftlctrlpage) | 1511 | if ((ftl_cxt.ftlctrlblocks[i] + 1) * ppb == ftl_cxt.ftlctrlpage) |
@@ -1552,7 +1544,6 @@ static uint32_t ftl_next_ctrl_pool_page(void) | |||
1552 | static uint32_t ftl_copy_page(uint32_t source, uint32_t destination, | 1544 | static uint32_t ftl_copy_page(uint32_t source, uint32_t destination, |
1553 | uint32_t lpn, uint32_t type) | 1545 | uint32_t lpn, uint32_t type) |
1554 | { | 1546 | { |
1555 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
1556 | uint32_t rc = ftl_vfl_read(source, ftl_copybuffer[0], | 1547 | uint32_t rc = ftl_vfl_read(source, ftl_copybuffer[0], |
1557 | &ftl_copyspare[0], 1, 1) & 0x11F; | 1548 | &ftl_copyspare[0], 1, 1) & 0x11F; |
1558 | memset(&ftl_copyspare[0], 0xFF, 0x40); | 1549 | memset(&ftl_copyspare[0], 0xFF, 0x40); |
@@ -1573,7 +1564,6 @@ static uint32_t ftl_copy_page(uint32_t source, uint32_t destination, | |||
1573 | static uint32_t ftl_copy_block(uint32_t source, uint32_t destination) | 1564 | static uint32_t ftl_copy_block(uint32_t source, uint32_t destination) |
1574 | { | 1565 | { |
1575 | uint32_t i, j; | 1566 | uint32_t i, j; |
1576 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
1577 | uint32_t error = 0; | 1567 | uint32_t error = 0; |
1578 | ftl_cxt.nextblockusn++; | 1568 | ftl_cxt.nextblockusn++; |
1579 | for (i = 0; i < ppb; i += FTL_COPYBUF_SIZE) | 1569 | for (i = 0; i < ppb; i += FTL_COPYBUF_SIZE) |
@@ -1632,7 +1622,6 @@ static void ftl_check_still_sequential(struct ftl_log_type* entry, uint32_t page | |||
1632 | static uint32_t ftl_compact_scattered(struct ftl_log_type* entry) | 1622 | static uint32_t ftl_compact_scattered(struct ftl_log_type* entry) |
1633 | { | 1623 | { |
1634 | uint32_t i, j; | 1624 | uint32_t i, j; |
1635 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
1636 | uint32_t error; | 1625 | uint32_t error; |
1637 | struct ftl_log_type backup; | 1626 | struct ftl_log_type backup; |
1638 | if (entry->pagescurrent == 0) | 1627 | if (entry->pagescurrent == 0) |
@@ -1716,7 +1705,6 @@ static uint32_t ftl_commit_scattered(struct ftl_log_type* entry) | |||
1716 | static uint32_t ftl_commit_sequential(struct ftl_log_type* entry) | 1705 | static uint32_t ftl_commit_sequential(struct ftl_log_type* entry) |
1717 | { | 1706 | { |
1718 | uint32_t i; | 1707 | uint32_t i; |
1719 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
1720 | 1708 | ||
1721 | if (entry->issequential != 1 | 1709 | if (entry->issequential != 1 |
1722 | || entry->pagescurrent != entry->pagesused) | 1710 | || entry->pagescurrent != entry->pagesused) |
@@ -1762,7 +1750,6 @@ static uint32_t ftl_commit_sequential(struct ftl_log_type* entry) | |||
1762 | static uint32_t ftl_remove_scattered_block(struct ftl_log_type* entry) | 1750 | static uint32_t ftl_remove_scattered_block(struct ftl_log_type* entry) |
1763 | { | 1751 | { |
1764 | uint32_t i; | 1752 | uint32_t i; |
1765 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
1766 | uint32_t age = 0xFFFFFFFF, used = 0; | 1753 | uint32_t age = 0xFFFFFFFF, used = 0; |
1767 | if (entry == NULL) | 1754 | if (entry == NULL) |
1768 | { | 1755 | { |
@@ -1855,7 +1842,6 @@ static struct ftl_log_type* ftl_allocate_log_entry(uint32_t block) | |||
1855 | static uint32_t ftl_commit_cxt(void) | 1842 | static uint32_t ftl_commit_cxt(void) |
1856 | { | 1843 | { |
1857 | uint32_t i; | 1844 | uint32_t i; |
1858 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
1859 | uint32_t mappages = (ftl_nand_type->userblocks + 0x3ff) >> 10; | 1845 | uint32_t mappages = (ftl_nand_type->userblocks + 0x3ff) >> 10; |
1860 | uint32_t ctrpages = (ftl_nand_type->userblocks + 23 + 0x3ff) >> 10; | 1846 | uint32_t ctrpages = (ftl_nand_type->userblocks + 23 + 0x3ff) >> 10; |
1861 | uint32_t endpage = ftl_cxt.ftlctrlpage + mappages + ctrpages + 1; | 1847 | uint32_t endpage = ftl_cxt.ftlctrlpage + mappages + ctrpages + 1; |
@@ -1894,7 +1880,7 @@ static uint32_t ftl_commit_cxt(void) | |||
1894 | 1880 | ||
1895 | #ifndef FTL_READONLY | 1881 | #ifndef FTL_READONLY |
1896 | /* Swaps the most and least worn block on the flash, | 1882 | /* Swaps the most and least worn block on the flash, |
1897 | to better distribute wear. It will refuse to do anything | 1883 | to better distribute wear. It will not do anything |
1898 | if the wear spread is lower than 5 erases. */ | 1884 | if the wear spread is lower than 5 erases. */ |
1899 | static uint32_t ftl_swap_blocks(void) | 1885 | static uint32_t ftl_swap_blocks(void) |
1900 | { | 1886 | { |
@@ -1940,7 +1926,6 @@ static uint32_t ftl_swap_blocks(void) | |||
1940 | uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer) | 1926 | uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer) |
1941 | { | 1927 | { |
1942 | uint32_t i, j, k; | 1928 | uint32_t i, j, k; |
1943 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
1944 | 1929 | ||
1945 | #ifdef FTL_TRACE | 1930 | #ifdef FTL_TRACE |
1946 | DEBUGF("FTL: Writing %d sectors starting at %d\n", count, sector); | 1931 | DEBUGF("FTL: Writing %d sectors starting at %d\n", count, sector); |
@@ -2119,7 +2104,6 @@ uint32_t ftl_sync(void) | |||
2119 | { | 2104 | { |
2120 | uint32_t i; | 2105 | uint32_t i; |
2121 | uint32_t rc = 0; | 2106 | uint32_t rc = 0; |
2122 | uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
2123 | if (ftl_cxt.clean_flag == 1) return 0; | 2107 | if (ftl_cxt.clean_flag == 1) return 0; |
2124 | 2108 | ||
2125 | mutex_lock(&ftl_mtx); | 2109 | mutex_lock(&ftl_mtx); |
@@ -2177,6 +2161,8 @@ uint32_t ftl_init(void) | |||
2177 | for (i = 0; i < 4; i++) | 2161 | for (i = 0; i < 4; i++) |
2178 | if (nand_get_device_type(i) != 0) ftl_banks = i + 1; | 2162 | if (nand_get_device_type(i) != 0) ftl_banks = i + 1; |
2179 | ftl_nand_type = nand_get_device_type(0); | 2163 | ftl_nand_type = nand_get_device_type(0); |
2164 | ppb = ftl_nand_type->pagesperblock * ftl_banks; | ||
2165 | syshyperblocks = ftl_nand_type->blocks - ftl_nand_type->userblocks - 0x17; | ||
2180 | foundsignature = 0; | 2166 | foundsignature = 0; |
2181 | blockwiped = 1; | 2167 | blockwiped = 1; |
2182 | for (i = 0; i < ftl_nand_type->pagesperblock; i++) | 2168 | for (i = 0; i < ftl_nand_type->pagesperblock; i++) |
diff --git a/firmware/usb.c b/firmware/usb.c index af16b7d4bd..a76eb66fef 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -69,10 +69,9 @@ static int usb_state; | |||
69 | static int usb_mmc_countdown = 0; | 69 | static int usb_mmc_countdown = 0; |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | /* FIXME: The extra 0x800 is consumed by fat_mount() when the fsinfo | 72 | /* Make sure there's enough stack space for screendump */ |
73 | needs updating */ | ||
74 | #ifdef USB_FULL_INIT | 73 | #ifdef USB_FULL_INIT |
75 | static long usb_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; | 74 | static long usb_stack[(DEFAULT_STACK_SIZE + SECTOR_SIZE + BMP_LINESIZE)/sizeof(long)]; |
76 | static const char usb_thread_name[] = "usb"; | 75 | static const char usb_thread_name[] = "usb"; |
77 | static unsigned int usb_thread_entry = 0; | 76 | static unsigned int usb_thread_entry = 0; |
78 | #ifndef USB_STATUS_BY_EVENT | 77 | #ifndef USB_STATUS_BY_EVENT |