annotate packages/devs/flash/synthv2/current/tests/flash2.c @ 1756:2f4e31c45a45

Update following changes to the flash device driver interface
author bartv
date Mon, 22 Nov 2004 20:54:04 +0000
parents fcf5b538459b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
1756
2f4e31c45a45 Update following changes to the flash device driver interface
bartv
parents: 1720
diff changeset
59 #ifdef CYGPKG_DEVS_FLASH_SYNTH_V2
1702
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_v2.h>
1756
2f4e31c45a45 Update following changes to the flash device driver interface
bartv
parents: 1720
diff changeset
61 #endif
2f4e31c45a45 Update following changes to the flash device driver interface
bartv
parents: 1720
diff changeset
62 #ifdef CYGPKG_DEVS_FLASH_SYNTH
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
63 #include <pkgconf/devs_flash_synth.h>
1756
2f4e31c45a45 Update following changes to the flash device driver interface
bartv
parents: 1720
diff changeset
64 #endif
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
65 #include <cyg/io/flash.h>
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
66 #include <cyg/infra/testcase.h>
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
67 #include <cyg/infra/diag.h>
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
68
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
69 #include <string.h>
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
70
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
71 #ifndef CYGINT_ISO_STRING_STRFUNCS
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
72 # 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
73 #endif
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 #ifdef NA_MSG
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
76 void cyg_user_start(void)
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 CYG_TEST_INIT();
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
79 CYG_TEST_NA( NA_MSG );
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
80 }
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
81 #else
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
82
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
83 //==========================================================================
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
84 // main
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
85
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
86 void cyg_user_start(void)
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 int ret;
1720
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
89 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
90 cyg_flash_info_t info;
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
91 cyg_uint32 i=0;
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
92 cyg_uint32 j;
1720
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
93 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
94 cyg_flashaddr_t prog_start;
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
95 unsigned char * ptr;
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
96
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
97 CYG_TEST_INIT();
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
98
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
99 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
100
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
101 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
102
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
103 do {
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
104 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
105 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
106 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
107 i, info.start, info.end);
1720
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
108 if (i == 0) {
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
109 flash_start = info.start;
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
110 flash_end = info.end;
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
111 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
112 blocks = info.block_info[0].blocks;
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
113 }
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
114 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
115 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
116 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
117 info.block_info[j].blocks);
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
118 }
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
119 }
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
120 i++;
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
121 } 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
122
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
123 /* 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
124 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
125 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
126 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
127
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
128 /* 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
129 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
130 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
131 if (*ptr != 0xff) {
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
132 ret++;
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
133 }
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 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
137
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
138 ret = cyg_flash_program(flash_start,&copyright,sizeof(copyright),NULL);
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
139 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
140
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
141 /* 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
142 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
143 copyright,sizeof(copyright)),
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
144 "flash program contents");
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
145
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
146 /* .. and check nothing else changed */
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
147 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
148 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
149 if (*ptr != 0xff) {
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
150 ret++;
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 }
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 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
155
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
156 /* Program over a block boundary */
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
157 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
158 ret = cyg_flash_program(prog_start,&copyright,sizeof(copyright),NULL);
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
159 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
160
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
161 /* 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
162 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
163 copyright,
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
164 sizeof(copyright)),
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
165 "Original contents");
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
166
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
167 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
168 copyright,
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
169 sizeof(copyright)),
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
170 "New program contents");
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 /* 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
173 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
174 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
175 if (*ptr != 0xff) {
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
176 ret++;
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
177 }
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
178 }
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
179 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
180
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
181 /* 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
182 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
183 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
184
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
185 /* Check the erase worked */
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
186 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
187 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
188 ptr++) {
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
189 if (*ptr != 0xff) {
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
190 ret++;
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
191 }
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
192 }
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 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
195
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
196 /* 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
197 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
198 copyright,
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
199 sizeof(copyright)/2),
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
200 "Block 1 OK");
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
201
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
202 #if 0
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
203 /* 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
204 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
205 to get an exception */
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
206
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
207 *(char *)flash_start = 'a';
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
208 #endif
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_FINISH("flash1");
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
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
213 #endif /* ifndef NA_MSG */
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
214
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
215 /* EOF flash1.c */