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