嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
3 ~" }8 C# C: W5 o
核心板2:DDR2 256M Byte NAND FLASH 8G bit
u( _+ [: P7 r+ y! B
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
9 ?! K5 Y- z3 A {$ m+ } D q' ^
- e- ]: J5 c9 s& g8 J* x! B
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
/ g$ o' U) V/ \( O) _
: m# _9 a( x! [3 j
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
# O/ \" Z% A- E E- Y% ?
/*
' d$ i c6 r& f# ^& G. Y# x5 |
* Check memory range for valid RAM. A simple memory test determines
& p8 E( \# @ ]
* the actually available RAM size between addresses `base' and
, H: D G4 j- ]
* `base + maxsize'.
9 M' p4 Q7 O- R' h
*/
+ _) Z* x: [% \! S- }; U
long get_ram_size(long *base, long maxsize)
# |+ M6 d3 i8 ?9 O
{
: ]" I' [" {8 F% F+ a8 [5 R
volatile long *addr;
* e' h5 I/ b; O7 Q
long save[32];
& B# q S: I6 b% E8 u1 P' @: O
long cnt;
6 i Q6 y& j# b) y
long val;
J: m+ `3 h" U
long size;
4 w1 i* g1 u# l! ~: r0 Z1 D
int i = 0;
# ]3 C x' e2 r! {; ]! U
8 s9 {0 I+ j9 ~7 W6 c8 e- E' G
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
t& N' D3 H& W. S5 e) X$ _. r
addr = base + cnt; /* pointer arith! */
3 I% e" _" h9 d8 Z
sync ();
/ ?0 G, d' k3 n6 P
save[i++] = *addr;
) f& U5 @8 }# c' } _7 f
sync ();
3 V) r- h$ Z4 C' Y6 H9 ^8 `) [
*addr = ~cnt;
V5 N' N" K, m( b# P9 k
}
2 { n, \ `/ o" X$ Y
3 N& H! v& o; u2 [4 j
addr = base;
9 E0 p: {% R# l" P& H9 l
sync ();
6 O) _) k" @. u8 Y, j$ `
save
= *addr;
6 N: t, Z7 L1 ^; A0 D9 o
sync ();
: X8 A" b( {2 U+ I
*addr = 0;
! Y& H/ _. _+ N( l9 Q6 Y+ x4 q
! K* C3 R/ R" A4 X' q4 s
sync ();
1 j8 V3 V- b p' A
if ((val = *addr) != 0) {
8 g2 e9 j( k. Y! e$ _, ?9 V6 [
/* Restore the original data before leaving the function.
: B$ Y* y8 h0 G1 ^3 L* d' X" Q- Y, j
*/
% [% `+ l* g8 ?6 V% s+ ~$ X6 f
sync ();
& o: _+ @6 g2 s3 |
*addr = save
;
2 B; {4 f' @+ p( Q t: b" q8 x4 M
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
; I1 N* K: @' O# V1 A8 O
addr = base + cnt;
, M- o+ _; q0 e! i* l8 O9 Q0 Z
sync ();
$ f$ B. `4 T: b. I2 V4 t
*addr = save[--i];
/ x# e6 y9 [3 F1 u- F
}
7 Q" |$ j% w7 s, j0 j$ Q
return (0);
+ O0 r2 \6 I& L
}
d5 S8 a0 c0 m5 x' S& d- z; R4 s
! n/ O- @* J+ r* o
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
1 C- {, U S* \6 H2 O
addr = base + cnt; /* pointer arith! */
+ b& r( \5 ^5 i
val = *addr;
/ y- E" Y0 \- X3 g$ J/ B% R/ f
*addr = save[--i];
' w! [7 \! o2 R) k; K/ ?9 s
if (val != ~cnt) {
" V0 U2 \4 b$ W7 `. {
size = cnt * sizeof (long);
: P" Y+ Y0 }( |; [7 J0 a
/* Restore the original data before leaving the function.
' E" Y4 y" u8 i0 e1 W
*/
6 c& j/ o* A/ h* p
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
" \# Y2 K7 g: d+ t* @) k: r# N$ j' [
addr = base + cnt;
- c; A3 S4 z" s: @# r
*addr = save[--i];
& Q9 n7 I9 l! k+ E. n
}
' Q" X2 |2 O* K6 U& \, x4 j- l
return (size);
5 C6 z" v# ~* D' }& j
}
, B, x8 V! x) Z# T) {
}
1 l6 N6 \& I' l, N# A
/ ?, U+ q& h- @0 ?( H3 S# O
return (maxsize);
* t8 Y Z: }& p* m/ i! ^
}
; \2 l5 n" J5 |; ^
int dram_init(void)
2 J3 N! r. S4 N! a6 T9 Z3 b( ?! P
{
& ?- h1 C! i6 B4 d6 |+ _
/* dram_init must store complete ramsize in gd->ram_size */
, f6 f6 [# }3 E+ g% }# T# I
gd->ram_size = get_ram_size(
4 A$ N7 ]6 u3 m
(void *)CONFIG_SYS_SDRAM_BASE,
9 U" u9 @8 Z5 q# c$ H
CONFIG_MAX_RAM_BANK_SIZE);
. T' O+ K2 r, E2 }- ]7 a
return 0;
9 P( f+ u' E c: `
}
% T, S7 k4 e$ b1 ]7 |9 ~) l; Y6 S/ u* D
3 |4 R! G0 L1 |) X
C7 v( ?1 [/ F2 S. j9 t- A
+ B7 h0 c2 o, F- v1 l0 E, A
- s4 E, \- A8 o1 U% {# I# E1 w+ U
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
* x2 x+ Z/ \* K: X
( ]. |% Z* o* f& U
! W# r8 Z' W, L- q7 o
6 K' w1 V( m" z& g
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4