标题: TL138 uboot是怎么区分配置两款核心板的 [打印本页] 作者: Mr.Loser 时间: 2014-9-11 09:33 标题: TL138 uboot是怎么区分配置两款核心板的 核心板1:DDR2 128M Byte NAND FLASH 4G bit2 ?6 ^% z1 M5 q/ O
核心板2:DDR2 256M Byte NAND FLASH 8G bit2 Z( N$ x. C; i
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?% H. S! u. d: _( a
5 l$ e8 T( @! n, K: G是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?: z) \7 @1 W7 a2 i ~
7 j+ @& ^$ }- T 作者: 2532609929 时间: 2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下: ) a' @% @. ~! p" g1 U/* & p4 M( {3 H0 ^ C* Check memory range for valid RAM. A simple memory test determines+ T' {8 a% o. p' N' R3 k
* the actually available RAM size between addresses `base' and * X4 \ D# P: |, ~4 j, D* `base + maxsize'. $ F8 {# S1 t4 |# F: Z0 W*/' L1 N7 F+ K+ N3 L2 @
long get_ram_size(long *base, long maxsize)2 X3 _" h$ @7 |1 }: E
{ , O% X1 @4 O" N# n8 F volatile long *addr; 9 U; ~% ]( N8 r1 n$ p; D N% Z- u long save[32]; 3 ?; t4 m" b& o: F3 C, ?; h long cnt; . i/ \( _6 k( O% r long val; & h5 z$ E9 ~, D long size;; j B7 Y; q1 T* \
int i = 0;& [* j6 L+ W% b5 ~0 z+ w6 I5 E6 i
: g$ h0 d0 X B O: k7 n8 w
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {+ T" d; \5 Y; v/ p& U& N, ]
addr = base + cnt; /* pointer arith! */: _+ V8 t- K+ k' x% p, w
sync (); " ?3 R* U0 s. f save[i++] = *addr;5 o' J8 g- |! _5 D; H' J* P' m
sync ();- l- C; O5 S7 n
*addr = ~cnt; 6 q: C. |1 y- W- H4 L' Q2 P' C }# e- a ^! v: O- h# z
6 \: [2 W, M9 I1 W9 X
addr = base; 6 ]! Z4 Y1 J1 D6 M sync ();: x& D9 x( P# n1 l5 P2 N+ K
save = *addr; ; I& w+ ~4 \3 y0 K1 S. { sync (); : ^6 ]5 t4 J, ~( k. ] *addr = 0;* ?3 f+ B [- _) r- i8 @. Z2 G* N
, [0 P U" T- U* S* a
sync ();1 S' Z+ ^7 {) i; U* \. d
if ((val = *addr) != 0) {# H: Y4 f7 {% g- j
/* Restore the original data before leaving the function.9 I' P; H# q* L" D+ I
*/5 Q' x3 @$ D4 `& R
sync ();) r) f, c+ k8 l! s! l
*addr = save; # G3 R( F$ g: ]9 @# S for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {; Y! e4 H4 _8 y& V
addr = base + cnt; 9 y6 {. K3 U0 |( r4 h9 O- F' e" F sync ();# \+ d B( r5 V: D
*addr = save[--i];- z9 s! O* F3 c+ Z: n( E$ V$ x
} 8 t. L" c y# R0 q return (0); # D, v' X1 I C, [2 o } * O* P$ ^6 R7 g: _/ h0 ^& X, y# ^6 X: p5 R* R! w) ~3 d- ^& _
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {$ Q' z6 g( @( X2 Q: V+ t7 ]
addr = base + cnt; /* pointer arith! */* Y2 y7 J0 q5 g" G. t
val = *addr;. l0 L( J. n, O0 q+ g! t
*addr = save[--i];) i# a8 @% P5 i) i& `# R- y4 n
if (val != ~cnt) { 9 @8 a+ [* j- ^" r9 ~ size = cnt * sizeof (long); . i8 ~: k6 r8 U9 m2 {- {5 |: ^; d /* Restore the original data before leaving the function. ' ]8 \! }5 c6 e( }1 z */ 8 J3 C# z5 v0 X+ y" t for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {$ F/ R/ [2 }" f/ U* S
addr = base + cnt; ; |0 Q5 G/ S ^. w& t Z% ` *addr = save[--i];( q/ D1 X/ \, D2 p. [
}7 m9 V# k1 [( m5 h. t
return (size);+ ^" L- F4 N* P0 z
} 8 u8 y/ X$ [ G& Y }' e. |* _3 ]9 ?: m) a
4 w0 I1 z' U @# N: Z- H return (maxsize);, V3 ~( _9 ?; H+ j; e: {0 U& C; L( H
}$ ]* r+ F) F/ Q1 H% h7 b
int dram_init(void) ; {" y7 j, U `9 M{ : O( q9 [: C1 [1 A /* dram_init must store complete ramsize in gd->ram_size */ m. f h7 A8 I0 |9 P
gd->ram_size = get_ram_size( 8 O2 J! o+ f! y/ | (void *)CONFIG_SYS_SDRAM_BASE, 8 L8 K; P d. o' O CONFIG_MAX_RAM_BANK_SIZE); # D2 \5 Q; }$ w, D* k8 a return 0;6 O( n {. T! \+ P3 R3 S
}/ C4 Q; F0 g4 ]6 A
( T x* d: S9 e- x
/ v; u8 }/ q) G a7 z
* m, w! y/ z+ R4 A; k( ^) M1 J, f& B" {4 G* X5 }/ Z% a, _6 `
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!2 c! _+ l7 f5 ^, w, C# l$ z
% m7 X2 m. C7 y4 V x) G
2 h, g W6 [. \! ]/ f: ]& p o 2 O4 v' F4 O- x2 z+ A