嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
) C: r0 `; B* [2 J+ i% d, j核心板2:DDR2 256M Byte   NAND FLASH 8G bit
" C) N7 F$ K2 Q/ H: X; i这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
* `7 s+ \- w9 g% P# J2 Z& U" f) D+ ?. D8 T
" W$ Q% |* B% m是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?# W$ r9 g8 q" ~) H0 G& X3 _
) E2 }/ a8 d; B- ~& \/ h$ B

作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
: Z0 X( G6 X( U8 @, p, t7 n/*
- O7 f4 y7 K4 F# e% i* Check memory range for valid RAM. A simple memory test determines' r1 s. b! }1 Z* s" H0 Q
* the actually available RAM size between addresses `base' and
' o. a9 D, r# V( N4 N; f* ~1 e3 x* `base + maxsize'.
3 S  V8 a& E+ U, a*/
5 b+ b5 n5 ?) ]! D. u2 [9 ?long get_ram_size(long *base, long maxsize)
6 k" g# q  h: i. V; U# u3 B1 Q{0 Q" c2 f: P, l( O
        volatile long *addr;1 E3 c1 D" W$ }  g( I; k. P
        long           save[32];! _5 I/ P: S  M& s
        long           cnt;: d' J9 F) {  o# x
        long           val;
  E& Z8 R8 s9 U        long           size;7 ]/ q1 }/ J9 M# v1 `
        int            i = 0;0 S( T  P; X9 f3 ~1 d0 j

2 m! Y  s( U2 Z4 G9 C5 S        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {5 @! H+ f2 G( C$ _7 ?
                addr = base + cnt;        /* pointer arith! */
3 q& V9 D) m1 y- O+ P8 M! w* x                sync ();
4 {; w6 ~. X& w( q& S6 c& E5 ~4 D                save[i++] = *addr;
, @% }+ `- S2 N0 _! Y/ b% m/ X# g& E                sync ();) C# X% h# t5 i. G; |
                *addr = ~cnt;, p+ R5 A2 K2 {# \! Z
        }3 a& S! |7 i. A8 H

( P/ J" e; ^9 Y3 N        addr = base;
2 U% j' o/ U! \: _        sync ();5 M$ @" O: G) C/ v& a
        save = *addr;
! Y7 F' e( V+ K+ U$ a5 j: E  f" W& \        sync ();! k0 y- x# `0 ?6 X! O5 K& i: m
        *addr = 0;
! B! \8 I# O. }" ~! L; J0 i% q- y% H, m4 q; A* G7 N+ u
        sync ();
8 a5 l' d, f/ @        if ((val = *addr) != 0) {
" y& V+ B3 b8 F                /* Restore the original data before leaving the function.
/ R, J# i+ v4 p. \$ r( x                 */
3 m- O+ U' L$ _$ c; K' \8 J                sync ();7 z/ d8 ]7 m7 h. ~
                *addr = save;5 M/ I. c+ k$ c$ s0 e7 Z
                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
. o  r: ^8 A9 K/ e" b                        addr  = base + cnt;
5 Q/ R) u$ a5 }                        sync ();9 Q* ?2 _  w9 Y: T
                        *addr = save[--i];7 T5 w7 s% H* V. X" R
                }5 {) P: @6 d$ W2 `9 e$ v
                return (0);" `% f" i; W, A2 |0 f: ]
        }2 H' P* {2 L/ b

+ ?, Y% r) q4 b- f3 v$ H) ?, ~        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 x- v. d' k0 g, y  ]. X- c                addr = base + cnt;        /* pointer arith! */
/ [: k$ C2 E1 ]. O& b( U/ i                val = *addr;
8 g, X- K# S) h+ s                *addr = save[--i];
5 H7 Q% g" ?  q2 Y4 \4 n                if (val != ~cnt) {
' Y7 M9 ~/ D5 C0 N1 j4 f  Q. C% l                        size = cnt * sizeof (long);
) n* L! n+ N- ^! k1 [                        /* Restore the original data before leaving the function.( V9 \# q" `8 R2 e( b0 q! u, U
                         */6 i  J6 `7 d( {* r) B
                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {. ~) A* G: P* y2 B9 G
                                addr  = base + cnt;
1 A6 @2 @- I1 C3 Y                                *addr = save[--i];) A" Z; t: J6 s
                        }
- J/ |* f7 ^# F9 Q                        return (size);
: o. d; ^0 q4 M5 H( a4 R* A9 Z                }
/ f% f/ s. d% I: r. ]# `$ o        }( C' {8 ^: Z7 i# f) u1 n) T

) g9 \$ y6 `4 D) y# h# ^' h$ b7 ~        return (maxsize);- f5 W( T$ v* `( r/ Z, `
}; u5 O6 w+ q4 ?" Z/ m
int dram_init(void)
8 |0 J/ h! s: Q7 y{  O; I  k8 C% t5 K
        /* dram_init must store complete ramsize in gd->ram_size */
) p4 s6 z, i# F9 y# ]        gd->ram_size = get_ram_size(
' N$ I5 g3 A# K2 e% m, f; g                        (void *)CONFIG_SYS_SDRAM_BASE,& m2 K3 ~  _" L: `7 W# _
                        CONFIG_MAX_RAM_BANK_SIZE);- P9 F7 B$ S+ n% H, v
        return 0;# i2 I% ^, L* F9 r/ {/ }
}! G# o" G' L' J  |# |

+ m1 e- j! u' L, t% u
' x$ u0 D6 X* e7 \* G2 d
* m. J  b! o' i0 s. E! t; \( I8 v# A1 i3 r6 ]
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!- p6 I# T7 c- }) u* d3 _2 p

4 \, T, p: Z4 V; g" `! F' I; |( B0 y2 p# _
4 ^3 b  ]$ p( q: z/ u





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