-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathflash.mu4
36 lines (28 loc) · 1.09 KB
/
flash.mu4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| This file is part of muforth: https://muforth.dev/
|
| Copyright 2002-2025 David Frech. (Read the LICENSE for details.)
loading PIC18 flash programming
.ifdef 1xk50 64 .else ( Q series) 256 .then
constant /page ( erase page size)
ld target/common/flash.mu4
: prog-ee-chunk ( 'target len - 'target+len)
2dup + push
over image+ -rot ( buf a u) t.write-eeprom
pop ;
: prog-ee-region
cr ." Programming " .region
region
/chunk @ /mod ( r q) swap push for /chunk @ prog-ee-chunk next
pop =if ( rem) prog-ee-chunk drop ^ then 2drop ;
-: flash flash-region
user-id flash-region
config prog-ee-region
eeprom prog-ee-region ; is flash-regions
-: verify-2 flash verify-region report
boot verify-region report or ( just for fun)
user-id verify-region report or
verify-1 config verify-region report or
eeprom verify-region report or ; is verify-regions
-: 0= if ( everything verified)
cr ." Restarting application" t.app-start
then ; is after-flashing ( diff)