annotate packages/devs/flash/synthv2/current/tests/flash3.c @ 1724:a24dbf2587a3

* src/flash_synth.c: Allow the use of arbitary sized block. * test/flash3.c: Allow the use of small blocks
author asl
date Thu, 09 Sep 2004 13:13:22 +0000
parents fcf5b538459b
children 2f4e31c45a45
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>
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;
1724
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
108 size_t copyright_len;
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
109
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
110 CYG_TEST_INIT();
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
111
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
112 // 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
113 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
114
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
115 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
116
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
117 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
118
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
119 do {
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
120 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
121 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
122 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
123 i, info.start, info.end);
1720
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
124 if (i == 0) {
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
125 flash_start = info.start;
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
126 flash_end = info.end;
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
127 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
128 blocks = info.block_info[0].blocks;
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
129 }
fcf5b538459b * tests/flash[23].c: Removed calls to cyg_flash_get_block_info()
asl
parents: 1702
diff changeset
130
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
131 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
132 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
133 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
134 info.block_info[j].blocks);
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 }
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
137 i++;
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
138 } 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
139
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
140 /* 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
141 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
142 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
143 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
144
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
145 /* 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
146 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
147 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
148 if (*ptr != 0xff) {
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
149 ret++;
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
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
153 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
154
1724
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
155 // With small blocks we have to use less of the copyright messages
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
156 // Since we make assumptions about fitting the message into a
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
157 // block.
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
158 if (block_size < sizeof(copyright)*2/3) {
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
159 copyright_len = block_size / 3;
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
160 } else {
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
161 copyright_len = sizeof(copyright);
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
162 }
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
163
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
164 ret = cyg_flash_program(flash_start,&copyright,copyright_len,NULL);
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
165 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
166
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
167 /* 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
168 CYG_TEST_PASS_FAIL(!strncmp((void *)flash_start,
1724
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
169 copyright,copyright_len),
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
170 "flash 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 /* .. and check nothing else changed */
1724
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
173 for (ptr=(unsigned char *)flash_start+copyright_len,ret=0;
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
174 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
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
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
180 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
181
1724
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
182 prog_start = flash_start + block_size - copyright_len/2;
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
183 ret = cyg_flash_program(prog_start,&copyright,copyright_len,NULL);
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
184 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
185
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
186 /* 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
187 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
188 copyright,
1724
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
189 copyright_len),
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
190 "Original contents");
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 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
193 copyright,
1724
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
194 copyright_len),
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
195 "New program contents");
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 /* Check the bit in between is still erased */
1724
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
198 for (ptr=(unsigned char *)flash_start+copyright_len,ret=0;
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
199 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
200 if (*ptr != 0xff) {
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
201 ret++;
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
202 }
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
203 }
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
204 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
205
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
206 /* 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
207 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
208 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
209
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
210 /* Check the erase worked */
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
211 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
212 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
213 ptr++) {
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
214 if (*ptr != 0xff) {
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
215 ret++;
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
216 }
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
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
219 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
220
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
221 /* 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
222 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
223 copyright,
1724
a24dbf2587a3 * src/flash_synth.c: Allow the use of arbitary sized block.
asl
parents: 1720
diff changeset
224 copyright_len/2),
1702
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
225 "Block 1 OK");
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
226
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
227 #if 0
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
228 /* 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
229 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
230 to get an exception */
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
231
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
232 *(char *)flash_start = 'a';
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
233 #endif
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
234
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
235 CYG_TEST_PASS_FINISH("flash3");
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
236 }
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
237
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
238 #endif /* ifndef NA_MSG */
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
239
0673c75f3a08 Import the first version of the synth flash driver which uses the V2 API.
asl
parents:
diff changeset
240 /* EOF flash1.c */