嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit3 m. ?$ E) O/ C3 T
核心板2:DDR2 256M Byte   NAND FLASH 8G bit/ N1 t* X( n9 F9 h4 ]  a/ P. T/ i
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?" ]2 i' p* o% R& R
7 P+ R- s, Y( N( |* k; Y
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
- e, q2 i0 y9 `) w) h
' B# g. l; A3 N
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
% y1 H" t1 M: S" j  n- H/*" ]% c0 k% x8 ?6 R
* Check memory range for valid RAM. A simple memory test determines
$ M/ w  f- w3 c& m/ h* the actually available RAM size between addresses `base' and4 Y( l) T6 T# T' S
* `base + maxsize'.. K( ?# U, y6 |2 Q' s6 }
*/
! z' y% r+ q  C/ Tlong get_ram_size(long *base, long maxsize)5 v3 ]  p5 h5 ~( K" L1 j
{
, L* c8 b5 S0 `/ N4 h, j6 q! d  O        volatile long *addr;
0 b" u" |7 V5 C* H. p' e5 j' ], I        long           save[32];
; y' x1 E+ ~; g  u        long           cnt;0 Y! f% |6 S6 H3 G' O- m9 P3 [+ i
        long           val;/ v- f& {& C# [! ?/ ~5 o3 _+ s
        long           size;
' r! I+ P) Q0 n; o- b; r9 R- S        int            i = 0;
. l9 Z& {/ P3 U) ?: _- l* ]0 i; ]7 C% _- W, j' F7 w
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {& ]* ^& M* l  C, i) g! c
                addr = base + cnt;        /* pointer arith! */, k# V/ H& p4 Q' |3 ^6 W8 W
                sync ();
3 A) ^1 Q- X' k7 r' u$ u                save[i++] = *addr;6 ?& L+ C3 v3 T# J( Y0 B9 \
                sync ();
. Q1 M, d1 i9 g- g                *addr = ~cnt;" \2 M. j6 A. o- e; g0 |
        }
1 w/ H( w0 a; G; j+ h# ?+ d. L
0 S/ {7 b# K. N        addr = base;; j# G$ X7 a& F) S! X- p- [
        sync ();. o4 r: F& \: F0 ]
        save = *addr;
# x# c; [' b; w        sync ();- M# ?. E* d% _; Q6 Y9 I' N
        *addr = 0;
8 C4 i0 T; s/ r* x5 v1 d( j" _& U% a1 K' r9 t
        sync ();% z- r/ D" X) D  N' N
        if ((val = *addr) != 0) {5 `3 K% E; N' `, |) ]
                /* Restore the original data before leaving the function.0 _8 e, C, p# g8 R7 V" ~! ^1 n& Y
                 */
6 J! o- P* D; }2 J- j( y, S6 o                sync ();4 Z5 k6 z: L7 l+ Q% z: v4 P' ]
                *addr = save;
* l* }. V& n9 Y, v5 d                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
# q+ r2 X9 d' c8 \- z, F                        addr  = base + cnt;* F1 Q. P1 o3 x/ X2 i* c
                        sync ();
/ y/ t2 [9 ^7 @                        *addr = save[--i];
9 z& S$ ~8 r# W; }" o8 @9 v                }/ t% k- @, ^2 R+ P9 a% a, t% z
                return (0);
8 G8 f* S! l, y/ ?- r! \5 K        }: ?% j7 ]6 f- g" c

4 d) z/ z+ X4 W1 S        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
9 L- B) R) B: Z; p. L) U+ `                addr = base + cnt;        /* pointer arith! *// z5 h$ P- t: z3 t; c0 T
                val = *addr;! K# I; O8 X+ k4 c& R6 L
                *addr = save[--i];/ g5 ^; f( C# J2 J, A6 i1 h
                if (val != ~cnt) {
! X( A1 `/ \7 M                        size = cnt * sizeof (long);0 ?9 h8 a) z0 A/ s  s* p
                        /* Restore the original data before leaving the function.
7 L3 V+ |4 O; H; b$ U/ ~                         */
) Q1 F. U6 f, S# R                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
, L4 k" L8 M% }( C+ f                                addr  = base + cnt;* D. G. P- t) v0 g
                                *addr = save[--i];. G0 q( o2 s3 ?/ t1 t4 d
                        }; Z; ~8 T. m0 J5 o
                        return (size);; x5 Z7 y8 F% |8 C- C: r9 n
                }
2 F  h- Z0 @0 G. ~% T! O  {, J        }2 z: q9 n, N9 o! a$ c* A# c9 H
6 M/ I/ X$ P2 i. g5 L
        return (maxsize);2 v8 y( F* l3 h$ n6 V! p
}5 t0 l+ h+ Q$ V* H2 ~2 n
int dram_init(void)! k/ |' F, k. r: W2 E% p
{
  d& N1 k3 ]- ^; ?% Q2 a        /* dram_init must store complete ramsize in gd->ram_size */: ~$ m; s1 r, s9 B0 {) }- f
        gd->ram_size = get_ram_size(
0 O/ Q$ V8 Q! d4 h8 I% }. w                        (void *)CONFIG_SYS_SDRAM_BASE,1 w: u% z6 v2 Y* t6 \2 ?9 W8 N8 u* m( i
                        CONFIG_MAX_RAM_BANK_SIZE);, }# K- y* O5 U7 ~* x; U! q
        return 0;
+ u7 k# b+ X+ O' C* q}- W0 O2 x2 P0 i3 ]( \0 b

1 O, G/ X  W3 X0 m9 F
$ F( `% [- k4 ?9 j: j# A& `
5 i% Y! Y7 [' C9 w6 t) ~
" n; Y4 M  @  U  QFLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!3 K6 ]3 i( ~' J) h) f
. x  _- x1 X3 i* i1 r
4 u( r- M9 _1 M7 }' x; E& \
- X( K, \- P2 j: |





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