annotate packages/redboot/current/src/flash_load.c @ 2863:7d8c61e6225c default tip

* Added execute permissions to files missed in conversion from CVS
author alexs
date Thu, 26 Mar 2009 20:39:18 +0000
parents 74dbf4c3f2e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2144
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
1 //==========================================================================
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
2 //
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
3 // flash_load.c
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
4 //
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
5 // RedBoot file/image loader into flash
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
6 //
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
7 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
8 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
9 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
11 // Copyright (C) 2006 Free Software Foundation, Inc.
2144
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
12 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
14 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
16 // version.
2144
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
17 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
21 // for more details.
2144
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
22 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
23 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
24 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2144
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
26 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
27 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
28 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
29 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
30 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
31 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
32 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
33 // General Public License v2.
2144
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
34 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
35 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
36 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
37 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2144
diff changeset
38 // ####ECOSGPLCOPYRIGHTEND####
2144
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
39 //==========================================================================
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
40 //#####DESCRIPTIONBEGIN####
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
41 //
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
42 // Author(s): Oliver Munz
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
43 // Contributors: om, asl
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
44 // Date: 2006-02-21
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
45 // Purpose:
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
46 // Description:
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
47 //
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
48 // This code is part of RedBoot (tm).
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
49 //
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
50 //####DESCRIPTIONEND####
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
51 //
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
52 //==========================================================================
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
53
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
54 #include <redboot.h>
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
55 #include <flash_load.h>
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
56
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
57 #include <cyg/io/flash.h>
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
58 #include <cyg/infra/cyg_ass.h>
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
59
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
60 static int flash_block_size;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
61
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
62 static cyg_uint8 * current_flash_page;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
63
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
64 /* Allocation of the flash-sector size RAM-buffer is done */
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
65 static bool init_done = false;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
66
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
67 /* We have initialized the current page ready for writing */
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
68 static bool flash_page_init = false;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
69
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
70 static cyg_uint8 *flash_buffer;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
71
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
72 // If the io flash code outputs when erasing/writing it will upset the
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
73 // download over the communications channel. So we install a dummy
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
74 // print function.
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
75 static int dummy_printf(const char *fmt, ...){
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
76 return 0;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
77 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
78
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
79 // Calculate the address of the first byte in a flash block
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
80 static cyg_uint8 * flash_block_begin(cyg_uint32 addr)
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
81 {
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
82 return (cyg_uint8 *)
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
83 ((addr / flash_block_size) * flash_block_size);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
84 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
85
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
86 // Initialize the loading process
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
87 void flash_load_start(void)
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
88 {
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
89 flash_init(dummy_printf);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
90
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
91 init_done = true;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
92 flash_page_init = false;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
93 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
94
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
95 // Write a byte into flash. We maintain a copy in RAM of the FLASH
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
96 // page we are currently "writing" into. This copy is loaded with the
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
97 // current contents of the FLASH page when the first byte is "written"
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
98 // to the page. The "writes" are then made into the RAM copy. We only
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
99 // write to FLASH when there is a "write" outside of the current page,
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
100 // or the flash_load_finish function is called.
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
101 void flash_load_write(cyg_uint8 *flash_addr, cyg_uint8 value)
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
102 {
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
103
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
104 cyg_uint32 retcode = FLASH_ERR_OK;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
105 void * err_addr;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
106 cyg_uint32 addr = (cyg_uint32)flash_addr;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
107 cyg_uint32 offset;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
108
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
109 if (!flash_page_init) {
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
110 /* First Byte for the current flash block. Read the current contents */
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
111 current_flash_page = flash_block_begin(addr);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
112 flash_read(flash_buffer, current_flash_page, flash_block_size, &err_addr);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
113 flash_page_init = true;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
114 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
115 if (flash_block_begin(addr) != current_flash_page) {
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
116 /* We have moved into the next flash page. Write the current
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
117 page so we can move on */
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
118 retcode = flash_erase(current_flash_page, flash_block_size, &err_addr);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
119 if (retcode != FLASH_ERR_OK){ /* Flash ERROR */
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
120 diag_printf("Error erase at %p: %s\n", err_addr, flash_errmsg(retcode));
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
121 return;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
122 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
123
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
124 retcode = flash_program(current_flash_page, flash_buffer,
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
125 flash_block_size, &err_addr);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
126 if (retcode != FLASH_ERR_OK){
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
127 diag_printf("Error writing at %p: %s\n",
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
128 err_addr, flash_errmsg(retcode));
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
129 return;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
130 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
131 current_flash_page = flash_block_begin(addr);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
132 flash_read(flash_buffer, current_flash_page, flash_block_size, &err_addr);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
133 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
134
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
135 offset = flash_addr - current_flash_page;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
136 CYG_ASSERT(offset < flash_block_size, "offset not inside flash block");
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
137
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
138 flash_buffer[offset] = value;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
139 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
140
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
141 // Program the current page into flash.
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
142 void flash_load_finish(void)
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
143 {
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
144 cyg_uint32 retcode = FLASH_ERR_OK;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
145 void * err_addr;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
146
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
147 if (init_done && flash_page_init) {
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
148 flash_page_init = false;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
149
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
150 retcode = flash_erase(current_flash_page, flash_block_size, &err_addr);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
151 if (retcode != FLASH_ERR_OK){
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
152 diag_printf("Error erase at %p: %s\n", err_addr, flash_errmsg(retcode));
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
153 } else {
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
154 retcode = flash_program(current_flash_page, flash_buffer,
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
155 flash_block_size, &err_addr);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
156 if (retcode != FLASH_ERR_OK){
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
157 diag_printf("Error writing at %p: %s\n",
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
158 err_addr, flash_errmsg(retcode));
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
159 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
160 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
161 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
162 flash_init(diag_printf);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
163 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
164
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
165 // This is called during redboot start up. We allocate a buffer the
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
166 // size of the flash page.
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
167 void
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
168 flash_load_init(void)
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
169 {
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
170 int flash_blocks;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
171
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
172 flash_get_block_info(&flash_block_size, &flash_blocks);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
173 workspace_end -= flash_block_size;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
174
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
175 flash_buffer = workspace_end;
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
176 }
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
177
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
178 // Register this initialization function in the table
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
179 RedBoot_init(flash_load_init, RedBoot_INIT_LAST);
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
180
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
181
36bfd6474600 * src/xyzModem.c (xyzModem_stream_open): Fix compiler warnings.
asl
parents:
diff changeset
182