嵌入式开发者社区

标题: TL138 uboot是怎么区分配置两款核心板的 [打印本页]

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
: W- c8 a2 e/ s4 G0 |核心板2:DDR2 256M Byte   NAND FLASH 8G bit9 n" t1 |  l- Q
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?2 S6 T$ J9 o- N# T4 I( `

( ?4 Q9 ?2 G& l) i% s是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?  V" s1 l/ m+ S3 a) h" I6 f% t# |

. @" _. x( Z; i7 Q
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:3 V4 ^9 n$ @, V0 e; H3 j
/*
2 H0 ?+ F* V1 B$ |* Check memory range for valid RAM. A simple memory test determines2 [1 C' ]3 h7 _! G/ z
* the actually available RAM size between addresses `base' and$ J+ l' v5 Z7 K* u
* `base + maxsize'.+ z6 U+ \& K- M% |- d
*/
- K0 A* C6 |, W" i! O9 F/ Zlong get_ram_size(long *base, long maxsize)7 Z( [$ O$ ~% y/ v
{
/ m0 P- W. h: k' Q8 y; C6 C: N        volatile long *addr;
& H0 t8 Y0 L: I# z4 c" s: N- |6 j        long           save[32];2 @+ O1 Z; w0 S5 F; m
        long           cnt;
: p1 l: n+ P- f7 R        long           val;2 T) ^2 Z7 h% M
        long           size;
  [9 r/ _; g! z        int            i = 0;
. g* Q% [* l! t9 ]4 A+ ^$ F( s4 u
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
3 Z1 [! V. E9 U# V8 t# _4 _& s" p1 V" a                addr = base + cnt;        /* pointer arith! */
+ v1 @' L" ^4 n% q! ]3 k. K                sync ();
2 E$ n' \( n- u4 J- @* b                save[i++] = *addr;
" O+ i/ }6 n% L$ `4 b7 a2 S                sync ();
" m2 x& ~* d, D                *addr = ~cnt;( ]3 c6 V* o% ?( O; ?
        }
, W4 m* u" @, h
! Z- x8 h5 Z; _$ k8 K        addr = base;
9 S, I3 d! t, T; i( i3 O        sync ();
6 |/ e/ k: |$ c        save = *addr;
( M' ^* S- C/ W& Q, H        sync ();+ c* R7 e9 j; s1 J- l. Q- G
        *addr = 0;
) D" K: M& D/ A- p' U  n& F% k+ U
        sync ();
- Y9 j& {8 t# s# @# H        if ((val = *addr) != 0) {
8 C5 O1 Q' C8 k0 a0 }                /* Restore the original data before leaving the function.9 w' u6 S/ u% L4 c
                 */. l7 ?/ u2 Q' m  H  ?- h3 \4 W
                sync ();5 ^& P: x9 M# y5 l
                *addr = save;! `: Q( C" _& K+ @( e  I9 ^2 }
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
. }' E$ o3 ]9 z; W8 U- u                        addr  = base + cnt;# G4 f' w% R% x3 [
                        sync ();
2 R% ?% b5 C$ d% A2 `                        *addr = save[--i];
* r2 _% k5 \) d6 A                }3 x: F4 |' x% ?! A
                return (0);
9 B2 _) |5 B: m        }
  c% c5 [( u4 C# r! K& N% q/ d" X
# k* h( M- S" D        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {; _6 T& C; c; H  }: x/ r7 U
                addr = base + cnt;        /* pointer arith! */
, u6 ~! _. i5 y8 H8 {; [! B                val = *addr;9 L* \; s7 {6 z' r* D- G( Y; k# p- y
                *addr = save[--i];  N& L& u# n1 A9 N* q9 h  b
                if (val != ~cnt) {8 [' I* L! p2 e( E/ ?' U- `
                        size = cnt * sizeof (long);' t2 l% K9 n" |4 _
                        /* Restore the original data before leaving the function.
2 q3 ^$ B7 h  e! p9 o+ I9 u7 m                         */$ k' n) a2 h7 L; I
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, E9 O4 ]% q7 o3 A$ b. z( Z                                addr  = base + cnt;9 _9 G- a: l- N/ u
                                *addr = save[--i];9 c3 C9 O6 U8 x4 A  K+ l
                        }2 z! I+ F+ Q9 x4 G
                        return (size);( I2 o& k, B3 I4 Y
                }+ }: x' r, E8 Y6 ^" B4 ]
        }2 }8 c, q4 a$ w7 ?1 C9 w2 p
# d% R% t( x  j( r+ ]
        return (maxsize);
# t- T/ Z. Y0 \$ k7 j) q}0 Q! @3 A* C8 d4 p$ U
int dram_init(void)/ {- F3 R9 H' p! S9 e# k
{" F5 r' W/ C* T3 Z
        /* dram_init must store complete ramsize in gd->ram_size */  [' [& F" C. Z0 I. [6 U. M' @
        gd->ram_size = get_ram_size(' z+ o9 C: E! [5 N8 n
                        (void *)CONFIG_SYS_SDRAM_BASE,
' p  t+ Z7 w( {0 z' }                        CONFIG_MAX_RAM_BANK_SIZE);
3 l  i9 M8 C3 w' B        return 0;
9 M* ?# T& y. F. p) K$ v( O}: P7 F' p/ P* {) w& t! I4 [
" \8 y' L! _2 p- |( A* v$ n* v3 K

$ g' X- W! @% s2 B' f& I/ a5 p' U2 }( S- b7 `& Z% Z7 V) M% U0 ~0 t

4 v, p1 z' e# X, L6 jFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
2 F1 V% r( Y+ g6 Q, E1 [
( r, |8 D6 V1 S+ g8 a' R9 ^& |+ \1 P& O
; h$ y1 M3 B9 g! e* u5 @5 u: _' \' y





欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) Powered by Discuz! X3.4