Mercurial > flash_v2
annotate packages/devs/flash/synthv2/current/tests/flash3.c @ 1720:fcf5b538459b
* tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
and cyg_flash_get_limits() which have been removed.
| author | asl |
|---|---|
| date | Sat, 21 Aug 2004 13:45:53 +0000 |
| parents | 0673c75f3a08 |
| children | a24dbf2587a3 |
| rev | line source |
|---|---|
|
1702
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
1 /* Hay, the copyright is usefull for something! */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
2 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
3 static char copyright[] = |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
4 "//==========================================================================" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
5 "//" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
6 "// flash1.c" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
7 "//" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
8 "// Test flash operations for the synth target synth flash driver" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
9 "//" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
10 "//==========================================================================" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
11 "//####ECOSGPLCOPYRIGHTBEGIN####" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
12 "// -------------------------------------------" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
13 "// This file is part of eCos, the Embedded Configurable Operating System." |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
14 "// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc." |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
15 "//" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
16 "// eCos is free software; you can redistribute it and/or modify it under" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
17 "// the terms of the GNU General Public License as published by the Free" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
18 "// Software Foundation; either version 2 or (at your option) any later version." |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
19 "//" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
20 "// eCos is distributed in the hope that it will be useful, but WITHOUT ANY" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
21 "// WARRANTY; without even the implied warranty of MERCHANTABILITY or" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
22 "// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
23 "// for more details." |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
24 "//" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
25 "// You should have received a copy of the GNU General Public License along" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
26 "// with eCos; if not, write to the Free Software Foundation, Inc.," |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
27 "// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA." |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
28 "//" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
29 "// As a special exception, if other files instantiate templates or use macros" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
30 "// or inline functions from this file, or you compile this file and link it" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
31 "// with other works to produce a work based on this file, this file does not" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
32 "// by itself cause the resulting work to be covered by the GNU General Public" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
33 "// License. However the source code for this file must still be made available" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
34 "// in accordance with section (3) of the GNU General Public License." |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
35 "//" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
36 "// This exception does not invalidate any other reasons why a work based on" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
37 "// this file might be covered by the GNU General Public License." |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
38 "//" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
39 "// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc." |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
40 "// at http://sources.redhat.com/ecos/ecos-license/" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
41 "// -------------------------------------------" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
42 "//####ECOSGPLCOPYRIGHTEND####" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
43 "//==========================================================================" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
44 "//#####DESCRIPTIONBEGIN####" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
45 "//" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
46 "// Author(s): andrew.lunn@ascom.ch" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
47 "// Contributors: andrew.lunn" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
48 "// Date: 2000-10-31" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
49 "// Purpose: Test a flash driver" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
50 "// Description: Try out a number of flash operations and make sure" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
51 "// what is in the flash is what we expeect." |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
52 "// " |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
53 "//####DESCRIPTIONEND####" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
54 "//" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
55 "//==========================================================================&" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
56 ; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
57 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
58 #include <pkgconf/system.h> |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
59 #include <pkgconf/devs_flash_synth_v2.h> |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
60 #include <pkgconf/devs_flash_synth.h> |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
61 #include <cyg/io/flash.h> |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
62 #include <cyg/infra/testcase.h> |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
63 #include <cyg/infra/diag.h> |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
64 #include <cyg/flash/synth.h> |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
65 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
66 #include <string.h> |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
67 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
68 #ifndef CYGINT_ISO_STRING_STRFUNCS |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
69 # define NA_MSG "Need string functions for test" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
70 #endif |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
71 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
72 #ifdef NA_MSG |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
73 void cyg_user_start(void) |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
74 { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
75 CYG_TEST_INIT(); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
76 CYG_TEST_NA( NA_MSG ); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
77 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
78 #else |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
79 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
80 static struct cyg_flash_synth_config config = { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
81 CYGNUM_FLASH_SYNTH_V2_BLOCKSIZE, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
82 CYGNUM_FLASH_SYNTH_V2_NUMBLOCKS, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
83 CYGNUM_FLASH_SYNTH_V2_BOOT_BLOCKSIZE, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
84 CYGNUM_FLASH_SYNTH_V2_NUMBOOT_BLOCKS, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
85 CYGNUM_FLASH_SYNTH_V2_BOOT_BLOCK_BOTTOM, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
86 "synth.flash3" |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
87 }; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
88 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
89 CYG_FLASH_DRIVER(cyg_flash_synth_flashdev_flash3, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
90 &cyg_flash_synth_funs, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
91 &config, // Pointer to priv structure |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
92 0x40020000, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
93 sizeof(struct cyg_flash_synth_priv)); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
94 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
95 //========================================================================== |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
96 // main |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
97 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
98 void cyg_user_start(void) |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
99 { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
100 int ret; |
|
1720
fcf5b538459b
* tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents:
1702
diff
changeset
|
101 cyg_flashaddr_t flash_start=0, flash_end=0; |
|
1702
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
102 cyg_flash_info_t info; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
103 cyg_uint32 i=0; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
104 cyg_uint32 j; |
|
1720
fcf5b538459b
* tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents:
1702
diff
changeset
|
105 int block_size=0, blocks=0; |
|
1702
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
106 cyg_flashaddr_t prog_start; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
107 unsigned char * ptr; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
108 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
109 CYG_TEST_INIT(); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
110 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
111 // Reference the flash dev so the linker does not throw it away |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
112 CYG_REFERENCE_OBJECT(cyg_flash_synth_flashdev_flash3); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
113 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
114 ret=cyg_flash_init((cyg_flash_printf *)diag_printf); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
115 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
116 CYG_TEST_PASS_FAIL((ret == CYG_FLASH_ERR_OK),"flash_init"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
117 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
118 do { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
119 ret = cyg_flash_get_info(i, &info); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
120 if (ret == CYG_FLASH_ERR_OK) { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
121 diag_printf("INFO: Nth=%d, start=%p, end=%p\n", |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
122 i, info.start, info.end); |
|
1720
fcf5b538459b
* tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents:
1702
diff
changeset
|
123 if (i == 0) { |
|
fcf5b538459b
* tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents:
1702
diff
changeset
|
124 flash_start = info.start; |
|
fcf5b538459b
* tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents:
1702
diff
changeset
|
125 flash_end = info.end; |
|
fcf5b538459b
* tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents:
1702
diff
changeset
|
126 block_size = info.block_info[0].block_size; |
|
fcf5b538459b
* tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents:
1702
diff
changeset
|
127 blocks = info.block_info[0].blocks; |
|
fcf5b538459b
* tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents:
1702
diff
changeset
|
128 } |
|
fcf5b538459b
* tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents:
1702
diff
changeset
|
129 |
|
1702
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
130 for (j=0;j < info.num_block_infos; j++) { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
131 diag_printf("INFO:\t block_size %d, blocks %d\n", |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
132 info.block_info[j].block_size, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
133 info.block_info[j].blocks); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
134 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
135 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
136 i++; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
137 } while (ret != CYG_FLASH_ERR_INVALID); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
138 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
139 /* Erase the whole flash. Not recommended on real hardware since this |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
140 will probably erase the bootloader etc!!! */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
141 ret=cyg_flash_erase(flash_start,block_size * blocks,NULL); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
142 CYG_TEST_PASS_FAIL((ret == CYG_FLASH_ERR_OK),"flash_erase1"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
143 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
144 /* check that its actually been erased, and test the mmap area */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
145 for (ptr=(unsigned char *)flash_start,ret=0; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
146 ptr <= (unsigned char *)flash_end; ptr++) { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
147 if (*ptr != 0xff) { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
148 ret++; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
149 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
150 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
151 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
152 CYG_TEST_PASS_FAIL((ret == 0),"flash empty check"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
153 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
154 ret = cyg_flash_program(flash_start,©right,sizeof(copyright),NULL); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
155 CYG_TEST_PASS_FAIL((ret == CYG_FLASH_ERR_OK),"flash_program1"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
156 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
157 /* Check the contents made it into the flash */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
158 CYG_TEST_PASS_FAIL(!strncmp((void *)flash_start, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
159 copyright,sizeof(copyright)), |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
160 "flash program contents"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
161 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
162 /* .. and check nothing else changed */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
163 for (ptr=(unsigned char *)flash_start+sizeof(copyright),ret=0; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
164 ptr < (unsigned char *)flash_end; ptr++) { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
165 if (*ptr != 0xff) { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
166 ret++; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
167 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
168 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
169 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
170 CYG_TEST_PASS_FAIL((ret == 0),"flash program overrun check"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
171 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
172 /* Program over a block boundary */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
173 prog_start = flash_start + block_size - sizeof(copyright)/2; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
174 ret = cyg_flash_program(prog_start,©right,sizeof(copyright),NULL); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
175 CYG_TEST_PASS_FAIL((ret == CYG_FLASH_ERR_OK),"flash_program2"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
176 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
177 /* Check the first version is still OK */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
178 CYG_TEST_PASS_FAIL(!strncmp((void *)flash_start, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
179 copyright, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
180 sizeof(copyright)), |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
181 "Original contents"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
182 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
183 CYG_TEST_PASS_FAIL(!strncmp((void *)prog_start, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
184 copyright, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
185 sizeof(copyright)), |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
186 "New program contents"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
187 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
188 /* Check the bit in between is still erased */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
189 for (ptr=(unsigned char *)flash_start+sizeof(copyright),ret=0; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
190 ptr < (unsigned char *)prog_start; ptr++) { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
191 if (*ptr != 0xff) { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
192 ret++; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
193 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
194 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
195 CYG_TEST_PASS_FAIL((ret == 0),"flash erase check1"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
196 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
197 /* Erase the second block and make sure the first is not erased */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
198 ret=cyg_flash_erase(flash_start+block_size,block_size,NULL); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
199 CYG_TEST_PASS_FAIL((ret == CYG_FLASH_ERR_OK),"flash_erase2"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
200 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
201 /* Check the erase worked */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
202 for (ptr=(unsigned char *)flash_start+block_size,ret=0; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
203 ptr < (unsigned char *)flash_start+block_size*2; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
204 ptr++) { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
205 if (*ptr != 0xff) { |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
206 ret++; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
207 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
208 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
209 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
210 CYG_TEST_PASS_FAIL((ret == 0), "flash erase check2"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
211 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
212 /* Lastly check the first half of the copyright message is still there */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
213 CYG_TEST_PASS_FAIL(!strncmp((void *)prog_start, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
214 copyright, |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
215 sizeof(copyright)/2), |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
216 "Block 1 OK"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
217 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
218 #if 0 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
219 /* This test is be fatal! Its not run by default! |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
220 Check the flash is read only, by trying to write to it. We expect |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
221 to get an exception */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
222 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
223 *(char *)flash_start = 'a'; |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
224 #endif |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
225 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
226 CYG_TEST_PASS_FINISH("flash3"); |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
227 } |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
228 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
229 #endif /* ifndef NA_MSG */ |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
230 |
|
0673c75f3a08
Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff
changeset
|
231 /* EOF flash1.c */ |
