Mercurial > ecos
annotate packages/io/flash/current/tests/flashdev.c @ 2888:d5bbba5243dc
* tests/flashdev.c: Compiler warning cleanup. [ Bugzilla 1000643 ]
| author | jld |
|---|---|
| date | Wed, 01 Jul 2009 18:52:09 +0000 |
| parents | 74dbf4c3f2e1 |
| children |
| rev | line source |
|---|---|
|
2626
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
1 //================================================================= |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
2 // |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
3 // flashdev.c |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
4 // |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
5 // Simple tests for FLASHdev driver |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
6 // |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
7 //================================================================= |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
8 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
9 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. |
|
2626
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
12 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
16 // version. |
|
2626
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
17 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
18 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
21 // for more details. |
|
2626
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
22 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
23 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
24 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
2626
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
26 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
27 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
28 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
29 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
30 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
31 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
32 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
33 // General Public License v2. |
|
2626
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
34 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
35 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
36 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
37 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2626
diff
changeset
|
38 // ####ECOSGPLCOPYRIGHTEND#### |
|
2626
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
39 //================================================================= |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
40 //#####DESCRIPTIONBEGIN#### |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
41 // |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
42 // Author(s): nickg, gthomas |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
43 // Contributors: |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
44 // Date: 2005-10-25 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
45 // Description: Simple test of FLASH I/O device. This is really |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
46 // just a copy of the flash1 test, but using the |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
47 // /dev/flash interface instead of the flash library. |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
48 // |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
49 // Options: |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
50 //####DESCRIPTIONEND#### |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
51 //================================================================= |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
52 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
53 // #define DEBUG_PRINTFS |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
54 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
55 #include <pkgconf/hal.h> |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
56 #include <pkgconf/io_flash.h> |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
57 #include CYGHWR_MEMORY_LAYOUT_H |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
58 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
59 #include <cyg/infra/diag.h> |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
60 #include <cyg/infra/testcase.h> |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
61 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
62 #include <cyg/io/io.h> |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
63 #include <cyg/io/config_keys.h> |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
64 #include <cyg/io/flash.h> |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
65 #include <errno.h> |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
66 #include <string.h> |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
67 #include <cyg/hal/hal_if.h> |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
68 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
69 //================================================================= |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
70 // Config options. |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
71 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
72 #define FLASH_TEST_OFFSET 0 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
73 #define FLASH_TEST_LENGTH 0x40000 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
74 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
75 //================================================================= |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
76 // A FIS entry named "flashtest" of at least FLASH_TEST_LENGTH bytes |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
77 // must exist for this test to work. It can be created with the |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
78 // following command: |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
79 // |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
80 // RedBoot> fis cre -b %{freememlo} -l 0x100000 flashtest |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
81 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
82 #define FLASH_TEST_DEVICE "/dev/flash/fis/flashtest" |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
83 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
84 // If it does not exist, a FIS entry named "jffs2test" will be used |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
85 // if present, as this may have been set up for jffs2 testing. |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
86 #define FLASH_TEST_DEVICE2 "/dev/flash/fis/jffs2test" |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
87 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
88 //================================================================= |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
89 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
90 #if !defined(CYGPKG_IO_FLASH_BLOCK_DEVICE) |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
91 externC void |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
92 cyg_start( void ) |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
93 { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
94 CYG_TEST_INIT(); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
95 CYG_TEST_NA("Only usable with flash block device driver"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
96 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
97 #else |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
98 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
99 //================================================================= |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
100 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
101 externC void |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
102 cyg_start( void ) |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
103 { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
104 Cyg_ErrNo stat; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
105 cyg_io_handle_t flash_handle; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
106 cyg_io_flash_getconfig_erase_t e; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
107 cyg_io_flash_getconfig_devsize_t d; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
108 cyg_io_flash_getconfig_blocksize_t b; |
|
2888
d5bbba5243dc
* tests/flashdev.c: Compiler warning cleanup. [ Bugzilla 1000643 ]
jld
parents:
2729
diff
changeset
|
109 #ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING |
|
2626
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
110 cyg_io_flash_getconfig_lock_t l; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
111 cyg_io_flash_getconfig_unlock_t u; |
|
2888
d5bbba5243dc
* tests/flashdev.c: Compiler warning cleanup. [ Bugzilla 1000643 ]
jld
parents:
2729
diff
changeset
|
112 #endif |
|
2626
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
113 CYG_ADDRWORD flash_start, flash_end; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
114 CYG_ADDRWORD flash_test_start, flash_addr; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
115 cyg_uint32 flash_block_size, flash_num_blocks; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
116 CYG_ADDRWORD test_buf1, test_buf2; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
117 cyg_uint32 *lp1, *lp2; |
|
2888
d5bbba5243dc
* tests/flashdev.c: Compiler warning cleanup. [ Bugzilla 1000643 ]
jld
parents:
2729
diff
changeset
|
118 int i; |
|
d5bbba5243dc
* tests/flashdev.c: Compiler warning cleanup. [ Bugzilla 1000643 ]
jld
parents:
2729
diff
changeset
|
119 unsigned len; |
|
2626
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
120 cyg_bool passed, ok; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
121 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
122 CYG_TEST_INIT(); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
123 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
124 passed = true; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
125 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
126 if ((stat = cyg_io_lookup(FLASH_TEST_DEVICE, &flash_handle)) == -ENOENT) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
127 stat = cyg_io_lookup(FLASH_TEST_DEVICE2, &flash_handle); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
128 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
129 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
130 if (stat != 0) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
131 diag_printf("FLASH: driver init failed: %s\n", strerror(-stat)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
132 CYG_TEST_FAIL_FINISH("FLASH driver init failed"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
133 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
134 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
135 len = sizeof(d); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
136 stat = cyg_io_get_config( flash_handle, CYG_IO_GET_CONFIG_FLASH_DEVSIZE, &d, &len ); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
137 flash_start = 0; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
138 // Keep 'end' address as last valid location, to avoid wrap around problems |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
139 flash_end = d.dev_size - 1; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
140 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
141 len = sizeof(b); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
142 b.offset = 0; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
143 stat = cyg_io_get_config( flash_handle, CYG_IO_GET_CONFIG_FLASH_BLOCKSIZE, &b, &len ); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
144 flash_block_size = b.block_size; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
145 flash_num_blocks = d.dev_size/flash_block_size; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
146 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
147 diag_printf("FLASH: %p - %p, %d blocks of 0x%x bytes each.\n", |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
148 (void*)flash_start, (void*)(flash_end + 1), flash_num_blocks, flash_block_size); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
149 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
150 // Verify that the testing limits are within the bounds of the |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
151 // physical device. Also verify that the size matches with |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
152 // the erase block size on the device |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
153 if ((FLASH_TEST_OFFSET > (flash_end - flash_start)) || |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
154 ((FLASH_TEST_OFFSET + FLASH_TEST_LENGTH) > (flash_end - flash_start))) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
155 CYG_TEST_FAIL_FINISH("FLASH test region outside physical limits"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
156 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
157 if ((FLASH_TEST_LENGTH % flash_block_size) != 0) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
158 CYG_TEST_FAIL_FINISH("FLASH test region must be integral multiple of erase block size"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
159 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
160 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
161 // Allocate two buffers large enough for the test |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
162 test_buf1 = (CYG_ADDRWORD)CYGMEM_SECTION_heap1; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
163 test_buf2 = test_buf1 + FLASH_TEST_LENGTH; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
164 if (CYGMEM_SECTION_heap1_SIZE < (FLASH_TEST_LENGTH * 2)) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
165 CYG_TEST_FAIL_FINISH("FLASH not enough heap space - reduce size of test region"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
166 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
167 diag_printf("... Using test buffers at %p and %p\n", (void *)test_buf1, (void *)test_buf2); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
168 flash_test_start = flash_start + FLASH_TEST_OFFSET; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
169 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
170 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
171 #ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
172 // Unlock test |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
173 diag_printf("... Unlock test\n"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
174 ok = true; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
175 u.offset = flash_test_start; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
176 u.len = FLASH_TEST_LENGTH; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
177 len = sizeof(u); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
178 if ((stat = cyg_io_get_config(flash_handle, CYG_IO_GET_CONFIG_FLASH_UNLOCK, &u, &len ) ) != 0 || u.flasherr != 0) |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
179 { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
180 diag_printf("FLASH: unlock failed: %s %s\n", strerror(stat), cyg_flash_errmsg(u.flasherr)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
181 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
182 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
183 #endif |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
184 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
185 // Erase test |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
186 diag_printf("... Erase test\n"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
187 ok = true; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
188 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
189 e.offset = flash_test_start; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
190 e.len = FLASH_TEST_LENGTH; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
191 len = sizeof(e); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
192 if ((stat = cyg_io_get_config(flash_handle, CYG_IO_GET_CONFIG_FLASH_ERASE, &e, &len ) ) != 0 || e.flasherr != 0) |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
193 { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
194 diag_printf("FLASH: erase failed: %s %s\n", cyg_flash_errmsg(stat),cyg_flash_errmsg(e.flasherr)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
195 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
196 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
197 len = FLASH_TEST_LENGTH; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
198 if (ok && (stat = cyg_io_bread(flash_handle, (void *)test_buf1, &len, flash_test_start)) != 0) |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
199 { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
200 diag_printf("FLASH: read/verify after erase failed: %s\n", cyg_flash_errmsg(stat)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
201 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
202 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
203 lp1 = (cyg_uint32 *)test_buf1; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
204 for (i = 0; i < FLASH_TEST_LENGTH; i += sizeof(cyg_uint32)) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
205 if (*lp1++ != 0xFFFFFFFF) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
206 diag_printf("FLASH: non-erased data found at offset %p\n", (void*)((CYG_ADDRWORD)(lp1-1) - test_buf1)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
207 diag_dump_buf((void *)(lp1-1), 32); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
208 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
209 break; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
210 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
211 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
212 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
213 // Try reading in little pieces |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
214 len = FLASH_TEST_LENGTH; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
215 flash_addr = flash_test_start; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
216 while (len > 0) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
217 cyg_uint32 l = 0x200; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
218 if ((stat = cyg_io_bread(flash_handle, (void *)test_buf1, &l, flash_addr)) != CYG_FLASH_ERR_OK) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
219 diag_printf("FLASH: read[short]/verify after erase failed: %s\n", strerror(stat)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
220 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
221 break; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
222 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
223 flash_addr = flash_addr + l; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
224 len -= l; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
225 lp1 = (cyg_uint32 *)test_buf1; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
226 for (i = 0; i < 0x200; i += sizeof(cyg_uint32)) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
227 if (*lp1++ != 0xFFFFFFFF) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
228 diag_printf("FLASH: non-erased data found at offset %p\n", |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
229 (cyg_uint8 *)flash_addr + (CYG_ADDRWORD)((lp1-1) - test_buf1)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
230 diag_dump_buf((void *)(lp1-1), 32); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
231 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
232 len = 0; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
233 break; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
234 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
235 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
236 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
237 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
238 if (!ok) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
239 CYG_TEST_INFO("FLASH erase failed"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
240 passed = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
241 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
242 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
243 // Simple write/verify test |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
244 diag_printf("... Write/verify test\n"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
245 lp1 = (cyg_uint32 *)test_buf1; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
246 for (i = 0; i < FLASH_TEST_LENGTH; i += sizeof(cyg_uint32)) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
247 *lp1 = (cyg_uint32)lp1; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
248 lp1++; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
249 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
250 ok = true; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
251 len = FLASH_TEST_LENGTH; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
252 if (ok && (stat = cyg_io_bwrite(flash_handle, (void *)test_buf1, |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
253 &len, flash_test_start)) != 0) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
254 diag_printf("FLASH: write failed: %s\n", strerror(stat)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
255 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
256 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
257 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
258 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
259 len = FLASH_TEST_LENGTH; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
260 if (ok && (stat = cyg_io_bread(flash_handle, (void *)test_buf2, &len, flash_test_start)) != CYG_FLASH_ERR_OK) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
261 diag_printf("FLASH: read/verify after write failed: %s\n", strerror(stat)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
262 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
263 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
264 lp1 = (cyg_uint32 *)test_buf1; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
265 lp2 = (cyg_uint32 *)test_buf2; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
266 for (i = 0; i < FLASH_TEST_LENGTH; i += sizeof(cyg_uint32)) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
267 if (*lp2++ != *lp1++) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
268 diag_printf("FLASH: incorrect data found at offset %p\n", (void *)((CYG_ADDRWORD)(lp2-1) - test_buf2)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
269 diag_dump_buf((void *)(lp2-1), 32); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
270 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
271 break; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
272 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
273 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
274 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
275 // Try reading in little pieces |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
276 len = FLASH_TEST_LENGTH; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
277 flash_addr = flash_test_start; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
278 lp1 = (cyg_uint32 *)test_buf1; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
279 lp2 = (cyg_uint32 *)test_buf2; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
280 while (len > 0) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
281 cyg_uint32 l = 0x200; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
282 if ((stat = cyg_io_bread(flash_handle, (void *)lp2, &l, flash_addr)) != 0) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
283 diag_printf("FLASH: read[short]/verify after erase failed: %s\n", strerror(stat)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
284 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
285 break; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
286 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
287 flash_addr = flash_addr + l; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
288 len -= l; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
289 for (i = 0; i < l; i += sizeof(cyg_uint32)) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
290 if (*lp2++ != *lp1++) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
291 diag_printf("FLASH: incorrect data found at offset %p\n", |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
292 (cyg_uint8 *)flash_addr + (CYG_ADDRWORD)((lp2-1) - test_buf2)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
293 diag_dump_buf((void *)(lp2-1), 32); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
294 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
295 len = 0; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
296 break; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
297 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
298 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
299 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
300 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
301 #ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
302 // Lock test |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
303 diag_printf("... Lock test\n"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
304 ok = true; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
305 l.offset = flash_test_start; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
306 l.len = FLASH_TEST_LENGTH; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
307 len = sizeof(l); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
308 if ((stat = cyg_io_get_config(flash_handle, CYG_IO_GET_CONFIG_FLASH_LOCK, &l, &len ) ) != 0 || l.flasherr != 0 ) |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
309 { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
310 diag_printf("FLASH: unlock failed: %s %s\n", strerror(stat), cyg_flash_errmsg(l.flasherr)); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
311 ok = false; |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
312 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
313 #endif |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
314 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
315 if (!ok) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
316 CYG_TEST_INFO("FLASH write/verify failed"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
317 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
318 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
319 if (passed) { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
320 CYG_TEST_PASS_FINISH("FLASH test1"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
321 } else { |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
322 CYG_TEST_FAIL_FINISH("FLASH test1"); |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
323 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
324 } |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
325 #endif |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
326 |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
327 //================================================================= |
|
a2f5434df2cb
Merge flashv2 branch to trunk, with eCosCentric additions
jlarmour
parents:
diff
changeset
|
328 // EOF flashdev.c |
