FreeCalypso > hg > freecalypso-tools
comparison target-utils/loadagent/intelflash.c @ 659:761e8b0c65b0
loadagent: first step in implementation of binary flash programming
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 03 Mar 2020 17:55:20 +0000 |
parents | 0da2cf5a999c |
children | b34384991094 |
comparison
equal
deleted
inserted
replaced
658:0da2cf5a999c | 659:761e8b0c65b0 |
---|---|
78 return; | 78 return; |
79 } | 79 } |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 intelflash_binary_prog(offset, nwords, data) | |
84 u32 offset; | |
85 unsigned nwords; | |
86 u16 *data; | |
87 { | |
88 volatile u16 *flashptr; | |
89 u16 stat; | |
90 int i; | |
91 | |
92 flashptr = (volatile u16 *)(base_addr + offset); | |
93 while (nwords) { | |
94 *flashptr = 0x40; | |
95 *flashptr = *data; | |
96 for (i = 10000; i; i--) { | |
97 stat = *flashptr; | |
98 if (stat & 0x80) | |
99 break; | |
100 } | |
101 if (!i) { | |
102 serial_out(0x15); /* NAK */ | |
103 printf("ERROR: flash write timeout at %08X\n", | |
104 (u_long) flashptr); | |
105 return(-1); | |
106 } | |
107 if (stat & 0x10) { | |
108 serial_out(0x15); /* NAK */ | |
109 printf("ERROR: program operation failed at %08X\n", | |
110 (u_long) flashptr); | |
111 return(-1); | |
112 } | |
113 flashptr++; | |
114 data++; | |
115 nwords--; | |
116 } | |
117 return(0); | |
118 } | |
119 | |
83 void | 120 void |
84 cmd_intel_rewrite_sector(argbulk) | 121 cmd_intel_rewrite_sector(argbulk) |
85 char *argbulk; | 122 char *argbulk; |
86 { | 123 { |
87 char *argv[4]; | 124 char *argv[4]; |