Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Commit Details
Date: | 2011-11-20 21:02:40 (12 years 4 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 6dc6174b2ca232bfe2d765dbdfabf20c69f4924f |
Message: | m1/tools/m1nor: flash a file to M1 NOR partition selected by the
file name |
Files: |
m1/tools/m1nor (1 diff) |
Change Details
m1/tools/m1nor | ||
---|---|---|
1 | #!/bin/sh | |
2 | # | |
3 | # m1nor - Flash a file to M1 NOR partition selected by the file name | |
4 | # | |
5 | # Written 2011 by Werner Almesberger | |
6 | # Copyright 2011 by Werner Almesberger | |
7 | # | |
8 | # This program is free software; you can redistribute it and/or modify | |
9 | # it under the terms of the GNU General Public License as published by | |
10 | # the Free Software Foundation; either version 2 of the License, or | |
11 | # (at your option) any later version. | |
12 | # | |
13 | ||
14 | # | |
15 | # According to | |
16 | # http://www.milkymist.org/wiki/index.php?title=Flashing_the_Milkymist_One#Flash_Memory_Distribution | |
17 | # | |
18 | # standby.fpg 0x0000 0000 640k | |
19 | # soc-rescue.fpg 0x000A 0000 1536k | |
20 | # bios-rescue.bin 0x0022 0000 128k | |
21 | # splash-rescue.raw 0x0024 0000 640k | |
22 | # flickernoise.fbi(res) 0x002E 0000 4096k | |
23 | # soc.fpg 0x006E 0000 1536k | |
24 | # bios.bin 0x0086 0000 128k | |
25 | # splash.raw 0x0088 0000 640k | |
26 | # flickernoise.fbi 0x0092 0000 4096k | |
27 | # (data) 0x00D2 0000 19328k | |
28 | # | |
29 | ||
30 | if [ -z "$1" ]; then | |
31 | echo "usage: $0 filename" 1>&2 | |
32 | exit 1 | |
33 | fi | |
34 | ||
35 | if [ ! -r "$1" ]; then | |
36 | echo "cannot read $1" 1>&2 | |
37 | exit 1 | |
38 | fi | |
39 | ||
40 | n=${1##*/} | |
41 | if [ "${n#standby}" != "$n" ]; then off=0x0; ext=.fpg | |
42 | elif [ "${n#soc-rescue}" != "$n" ]; then off=0xa0000; ext=.fpg | |
43 | elif [ "${n#bios-rescue}" != "$n" ]; then off=0x220000; ext=.bin | |
44 | elif [ "${n#splash-rescue}" != "$n" ]; then off=0x240000; ext=.raw | |
45 | elif [ "${n#flickernoise-rescue}" != "$n" ]; then off=0x2e0000; ext=.fbi | |
46 | elif [ "${n#soc}" != "$n" ]; then off=0x6e0000; ext=.fpg | |
47 | elif [ "${n#bios}" != "$n" ]; then off=0x860000; ext=.bin | |
48 | elif [ "${n#splash}" != "$n" ]; then off=0x880000; ext=.raw | |
49 | elif [ "${n#flickernoise}" != "$n" ]; then off=0x920000; ext=.fbi | |
50 | elif [ "${n#data}" != "$n" ]; then off=0xd20000; ext= | |
51 | else | |
52 | echo "unrecognized file name" 1>&2 | |
53 | exit 1 | |
54 | fi | |
55 | ||
56 | if [ "$ext" -a "${1%$ext}" = "$1" ]; then | |
57 | echo "extension mismatch (expected $ext)" 1>&2 | |
58 | exit 1 | |
59 | fi | |
60 | ||
61 | if [ "$FJMEM_BIT" ]; then | |
62 | fjmem=$FJMEM_BIT | |
63 | else | |
64 | fjmem= | |
65 | for n in $HOME/.qi/milkymist/*/fjmem.bit \ | |
66 | $HOME/.qi/milkymist/*/*/fjmem.bit; do | |
67 | if [ -r "$n" ]; then | |
68 | fjmem="$n" | |
69 | break | |
70 | fi | |
71 | done | |
72 | if [ -z "$fjmem" ]; then | |
73 | echo "cannot find fjmem.bit (consider setting FJMEM_BIT)" 1>&2 | |
74 | exit 1 | |
75 | fi | |
76 | fi | |
77 | ||
78 | jtag <<EOF | |
79 | cable milkymist | |
80 | detect | |
81 | instruction CFG_OUT 000100 BYPASS | |
82 | instruction CFG_IN 000101 BYPASS | |
83 | pld load "$fjmem" | |
84 | initbus fjmem opcode=000010 | |
85 | frequency 6000000 | |
86 | detectflash 0 | |
87 | endian big | |
88 | flashmem "$off" "$1" noverify | |
89 | EOF | |
90 | ||
91 | echo "Flashed $1 at offset $off using $fjmem" 1>&2 |
Branches:
master