嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
( |! C! [! k9 a+ X. U
核心板2:DDR2 256M Byte NAND FLASH 8G bit
% v, o( v5 e$ V: i
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
: ]& Z) j: }* Z3 b" _( L; ~$ Q
( T' h$ |& r4 w0 g! q0 L
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
# C% a; `; P; I$ R& ]. ~
' s8 p5 q) A: O6 C5 F; `
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
0 l! K* ~8 j' W9 c# T
/*
8 s- r+ T o" u' M# M5 ]) F2 k
* Check memory range for valid RAM. A simple memory test determines
9 M. G7 J- \5 G
* the actually available RAM size between addresses `base' and
. a! u" k# @4 ^7 \ d
* `base + maxsize'.
/ J4 N0 P/ ?3 d" L
*/
q- `( C8 }* V; _8 _
long get_ram_size(long *base, long maxsize)
5 P( O: r/ w" t: j
{
6 ^/ w% {' U: z3 g( M4 y" R
volatile long *addr;
. m- K' j1 Y+ U0 w$ |% u
long save[32];
3 ?" f1 o. i g5 k7 C
long cnt;
; [6 P& O; q' |; }8 G: [8 [8 T
long val;
( ^- m" F5 l7 Y( K' G, b
long size;
( c4 d4 T, Q9 T$ b: c* r; x
int i = 0;
2 \4 O" B5 a( F" u# A! F, ^
* j5 b. r8 F0 a' d
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
* \" b- V! S7 |. m5 V
addr = base + cnt; /* pointer arith! */
$ t* q& U" u" _+ G" f
sync ();
# W" l& h% j9 k+ c6 s: ^( Q
save[i++] = *addr;
* Q8 R i2 R1 m
sync ();
/ F3 b% ?% B$ T1 z
*addr = ~cnt;
, C, J1 p- K" F, q
}
G, N0 r0 |, E r# }5 G; {% l
! y+ G0 W8 Y1 J7 B0 B- K
addr = base;
( C. R; v. p0 J3 M/ S" V
sync ();
! v$ G8 `( c) Y5 |$ D+ n
save
= *addr;
: o7 I! y4 e0 K z& h* ^
sync ();
. S8 z' t4 ~# W/ o; ]: h
*addr = 0;
! y; a0 t6 a ?' Z8 K2 l! ?
Q5 C' k' K: A
sync ();
4 N7 }" u9 W0 L9 u, [
if ((val = *addr) != 0) {
, K& {, {+ U& o6 f8 ~/ `6 T
/* Restore the original data before leaving the function.
@" N8 l6 K) }+ K
*/
+ f% O) R. H8 K1 [* v
sync ();
# @, @& q2 l2 Y1 U
*addr = save
;
, m% L! o% G0 Z) a% e
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
, S8 }3 F: q0 Z
addr = base + cnt;
9 c2 J, }5 ], c; Y) E: s5 p
sync ();
7 s% p, u0 E; m% J' ^. M
*addr = save[--i];
9 R2 o/ I! D- b- R
}
5 \9 O* d4 M, [- O; g; p% Z+ h5 x2 S
return (0);
- i- |5 s' s6 y5 `
}
4 g# J2 p# K2 e6 |% ~
8 X8 h3 K* S9 g$ x$ V. o
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
& j; ]% H* v8 f- w* X8 m
addr = base + cnt; /* pointer arith! */
* N1 M. B" h3 b3 O& l+ s. h
val = *addr;
( h/ @: e% l0 ~ N4 l0 H$ P
*addr = save[--i];
! R8 H# n4 Q' h2 n7 C
if (val != ~cnt) {
5 Q' b; i1 ?! m5 m1 O/ v4 w
size = cnt * sizeof (long);
; [) W o9 q8 o k
/* Restore the original data before leaving the function.
$ l% s1 P. U) K4 M0 b& b- p3 ^
*/
& X9 I1 w" |4 F2 [1 h: b1 C
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
! A0 I' u3 E& Z4 u
addr = base + cnt;
7 L% h, U% K$ q, T( G9 B! g' e
*addr = save[--i];
; @1 d( f8 \* }- D' B, d* `
}
4 H( l! o8 m; i# U; X& {
return (size);
, O) G/ V; x& q9 |/ V* f
}
7 L8 g& P6 A) F2 J
}
; y8 j3 P$ H1 J
5 r: u5 n! Q, C2 h d" y
return (maxsize);
`9 e1 b7 |* _. ]# h4 c9 T
}
8 B, Y* [$ L V1 O9 b6 V5 }
int dram_init(void)
9 v) O' U+ w# l9 {, `
{
' \# A& O0 T0 z
/* dram_init must store complete ramsize in gd->ram_size */
9 ~/ Y7 Q( g$ W! ]
gd->ram_size = get_ram_size(
( M! L6 a& o( S8 o
(void *)CONFIG_SYS_SDRAM_BASE,
- A6 ?( p% Z4 Z
CONFIG_MAX_RAM_BANK_SIZE);
* n+ f8 B9 c8 U+ Q# V" m
return 0;
/ v* E/ H+ Y) ]+ g
}
) w9 M: O1 O, e0 z1 F: c
8 f* G) f6 q7 O2 j
2 M" U7 b+ b4 O; r) d
$ y: g1 w6 e" Z. s: w& z g
& s1 n* r; {9 J
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
! p# c3 o+ l0 O: `' Y3 d; ?( W
' E; {- ~% f4 o
: x9 ~& {! R* z
. l$ f- u! U) @9 X/ z
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4