3 # Copyright (c) 2005 Poul-Henning Kamp.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 # Convenience function for commonly used Flash devices.
30 # There is a hook over in nanobsd.sh which allows you to call into
31 # this function simply with a line like:
33 # FlashDevice Sandisk 256
35 # This file will then set NANO_MEDIASIZE, NANO_HEADS and NANO_SECTS for you.
40 a1=`echo $1 | tr '[:upper:]' '[:lower:]'`
41 a2=`echo $2 | tr '[:upper:]' '[:lower:]'`
46 NANO_MEDIASIZE=`expr 256204800 / 512`
51 echo "Unknown Hitachi Flash capacity"
57 # Source: mich@FreeBSD.org
60 NANO_MEDIASIZE=`expr 259596288 / 512`
65 echo "Unknown Integral i-Pro Flash capacity"
71 # Source: mwlucas@FreeBSD.org
74 NANO_MEDIASIZE=`expr 64487424 / 512`
79 echo "Unknown Kodak Flash capacity"
85 # Source: simon@FreeBSD.org
89 NANO_MEDIASIZE=`expr 519192576 / 512`
94 echo "Unknown Memory Corp Flash capacity"
101 # SanDisk CompactFlash Memory Card
104 # Document No. 20-10-00038
107 # NB: notice math error in SDCFJ-4096-388 line.
111 NANO_MEDIASIZE=`expr 32112640 / 512`
116 NANO_MEDIASIZE=`expr 64225280 / 512`
121 NANO_MEDIASIZE=`expr 128450560 / 512`
126 NANO_MEDIASIZE=`expr 256901120 / 512`
131 NANO_MEDIASIZE=`expr 512483328 / 512`
136 NANO_MEDIASIZE=`expr 1024966656 / 512`
141 NANO_MEDIASIZE=`expr 2048901120 / 512`
146 NANO_MEDIASIZE=`expr -e 4097802240 / 512`
151 echo "Unknown Sandisk Flash capacity"
159 NANO_MEDIASIZE=`expr 260571136 / 512`
164 NANO_MEDIASIZE=`expr -e 4224761856 / 512`
169 echo "Unknown SiliconSystems Flash capacity"
176 net4526 | 4526 | net4826 | 4826 | 64 | 64mb)
177 NANO_MEDIASIZE=125056
182 echo "Unknown Soekris Flash capacity"
190 NANO_MEDIASIZE=125184
195 NANO_MEDIASIZE=4061232
200 echo "Unknown Transcend Flash capacity"
205 # Generic flash media. It assumes that we're booting using packet
206 # mode so the HEADS and SECTS don't matter. The truncation of the
207 # size to a slightly lower number is intentional to be conservative
208 # (eg, 1 sector smaller than N GB is always smaller than any flash
209 # claiming to be N GB, but wastes a little space sometimes when 1GB
210 # really means 1GiB). This is intended to be used when producing
211 # generic images for anybody to boot. Media sizes are specified 'Xg'
212 # for X GB (10^9 bytes) flash or Xm for X MB (10^6 bytes) flash.
213 # Power of 2 variants can be specified with gi or mi for GiB and MiB
214 # sizeed flash and don't try to be conservative (use with caution).
217 *.*) # Catch unsupported 1.5g case, since expr can't
219 echo "Unsupported generic size $a2"
225 NANO_MEDIASIZE=`expr -e ${a2%m} \* 1000000 / 512`
230 NANO_MEDIASIZE=`expr -e ${a2%g} \* 1000000000 / 512`
235 NANO_MEDIASIZE=`expr -e ${a2%mi} \* 1024 \* 1024 / 512`
240 NANO_MEDIASIZE=`expr -e ${a2%gi} \* 1024 \* 1024 \* 1024 / 512`
243 echo "Unsupported generic size $a2"
249 echo "Unknown Flash manufacturer"