嵌入式开发者社区

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

作者: Mr.Loser    时间: 2014-9-11 09:33
标题: TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte   NAND FLASH 4G bit
& n" _! m1 E0 r) Q4 C3 L! J( N核心板2:DDR2 256M Byte   NAND FLASH 8G bit3 ~7 \; N4 a4 T8 {) ]
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
& S) Z, `& B( G1 P! w
" V* r# q& ~6 X9 D8 C是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?$ K$ T$ F: `+ h/ \+ P6 G

% x/ G3 ?: k& B. d# A, k
作者: 2532609929    时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:0 w, [3 n4 p& X
/*
. V' F  M( p- _* s" B7 x* Check memory range for valid RAM. A simple memory test determines& R) M! t* g; `; K3 j$ B
* the actually available RAM size between addresses `base' and
" `* e  w0 U2 e& a7 f  [; O4 z) U* `base + maxsize'.
2 z2 Y) I' x3 P*/# u- }0 s2 s( r* [
long get_ram_size(long *base, long maxsize)
( X# [. H4 K9 r) O, y/ @9 L{
! Q# P, u, g* Y' t0 F        volatile long *addr;7 D1 n# {$ r* e2 U4 k7 m* |
        long           save[32];* ?2 |+ V* x4 S; ^( M" U
        long           cnt;
3 f' A) I- C* F3 Q4 ?        long           val;
4 a2 Y+ e- S  v) e7 K! X) z, E        long           size;, U3 q& C7 _( k1 Q; v" X, x9 A
        int            i = 0;5 ?* i# O1 Q  O, b* z8 C9 ^& A
+ f; u1 p# ?' |+ Q
        for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {. }* J' k9 L9 q- e  K
                addr = base + cnt;        /* pointer arith! */# j7 R% {4 M2 v; D% o$ F
                sync ();
4 X3 C7 f! J/ q$ c% S/ ~                save[i++] = *addr;
2 Z' }- E2 `" H: L' E' v5 s; A                sync ();
5 R4 _9 @. a% a  L/ z                *addr = ~cnt;
: i! `- n4 O/ @; m$ m( I1 q        }
" S+ U$ y; e* r) M) Y' L
3 i) s6 ?. U, Z# z' }5 U# Z        addr = base;& [3 k. b* e, @
        sync ();! q  Q' e9 J3 s, b7 y+ @
        save = *addr;$ B6 w1 D$ ^5 V5 D
        sync ();
* [  k2 q7 D7 |2 v3 @' z/ h* k4 [6 H        *addr = 0;
: D" I7 ^2 s# v" D- e) d/ a( X# |! o: H/ y) n% @1 w$ z) {* N+ ]! S
        sync ();
$ g5 \: ~% ?. y7 f# {. j! p* n        if ((val = *addr) != 0) {
* f: I8 m0 ]3 H& y" [3 f; o" w                /* Restore the original data before leaving the function.# B% c1 I7 X! ~7 K/ u8 x
                 */
% G$ N7 J7 D+ l6 S3 _" V+ y, |                sync ();
$ Q6 L; l% ~  |4 P) b                *addr = save;
* l3 O: l8 b9 M. c( C0 L                for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {6 i7 ?0 y* ~& q
                        addr  = base + cnt;. b7 e' U% D5 b0 k4 v
                        sync ();
" S! z  g/ Q3 _! M1 X* L7 U                        *addr = save[--i];
8 V+ _7 ~: u% Z" U0 k                }6 N3 B: i6 W, Q7 O9 g
                return (0);
: @  ?' K1 d+ u        }5 R1 x, Z$ _. F( W

; y5 }, D3 J  P        for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
8 t0 y5 y- R9 w4 T. Z0 H                addr = base + cnt;        /* pointer arith! */( O2 T! R* u7 L% C# T0 i
                val = *addr;
3 ^' K( i) {. r/ N! Q                *addr = save[--i];$ ^5 X' y# j* U) X( ^
                if (val != ~cnt) {
7 m" B# z9 C6 R- d* c" L                        size = cnt * sizeof (long);7 g/ m. t5 G! j1 d4 P  r
                        /* Restore the original data before leaving the function.
6 z) U# `) y3 D& R2 p! Z4 x                         */
. t4 M0 Y" T5 _: f9 A* w" W                        for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
: t) s) ~0 q* x  Q/ L                                addr  = base + cnt;3 x, \2 W, ]4 M: R
                                *addr = save[--i];
- R0 x5 D8 \! w* Y                        }
2 L0 U, K: Q4 B                        return (size);& n: U; \9 V0 x' w% _" R& S
                }
3 h( H, R5 |7 k! O2 P% O( M. i        }' d2 V/ E" \. E+ d' m3 a

% V& c* u9 T8 G  W: {        return (maxsize);* J, R% K% h$ ]# I  T
}; F( \9 w8 g4 ^. d) ~2 l
int dram_init(void): ]0 W$ N6 t! L
{
; g" y( a, Z- B0 l        /* dram_init must store complete ramsize in gd->ram_size */
1 @. b7 S% j2 Q# ^/ r        gd->ram_size = get_ram_size(
9 ^& v9 D7 M% F# ]* l" ~5 S& z                        (void *)CONFIG_SYS_SDRAM_BASE,
1 i# x& t# K+ v* n  i( E                        CONFIG_MAX_RAM_BANK_SIZE);
, r( W8 p1 t5 u- |        return 0;9 v6 C7 `7 W. S; j, p
}5 G1 x$ J/ E0 m% Z- X+ u

) r* }4 c  }( Y3 M3 z$ h$ Z  ^+ G: q8 f  `6 M0 e2 B  }

; H2 @7 |+ I2 v; }7 m8 \2 a  p" y2 H% s( E3 F1 O5 \
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!) k+ @' z! F6 `& s3 u

+ Y$ m' d) @/ X$ d% E, }* [; {2 o' W( e4 o/ Q8 t% ?; N
; }" r# n7 d) D3 _" Q& j  I+ ~





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