嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
! C7 s; W9 b Y" ~) G1 ~1 U
核心板2:DDR2 256M Byte NAND FLASH 8G bit
% j7 {% {, D, q- r
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
9 c8 t% V0 p0 N. ~' V
5 A% l z2 ], ^* E2 n( ~. m
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
0 {8 U+ J, ?8 h: J: {+ v8 S( x
, Z# j7 z6 s2 f* t
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
+ I5 K3 ?2 P/ |. w5 p
/*
T* O; N/ n( |2 ~6 T4 m' ~
* Check memory range for valid RAM. A simple memory test determines
: P" V U4 ?5 H9 _3 h# P& o+ H
* the actually available RAM size between addresses `base' and
0 O1 y3 o4 L, c+ I
* `base + maxsize'.
# d0 ?. |' [5 x+ N
*/
4 v6 h( @2 V4 |: P6 O( E# @# \
long get_ram_size(long *base, long maxsize)
6 N9 |6 w' f" X5 s
{
) z- S: u5 j3 {* V& t# ^
volatile long *addr;
. j0 ~/ }0 R& A
long save[32];
0 Q/ j" |$ u5 z7 @8 d8 u
long cnt;
7 {* D9 ]$ o# [# M S/ v4 V* p8 A
long val;
7 L/ a% F( o) Q
long size;
) ^. q' j1 ` d9 s& s
int i = 0;
; M p$ M/ \/ L s6 y: {3 e; I
: Y# O$ \1 E: y5 b L2 @# i5 k: \
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
* ~1 R/ b- k) C! |% J8 u
addr = base + cnt; /* pointer arith! */
' s+ R" y/ \/ P9 k$ D" @/ y
sync ();
, m# h) l @1 f( O, T1 F$ |
save[i++] = *addr;
( G0 T7 S# ?8 v
sync ();
7 y+ w$ m" ?" | {
*addr = ~cnt;
: c/ B, t8 J; h; T
}
' J7 U) z' ?7 l, U$ _/ a# Z2 Z+ Y
. V, o5 e: }% [- R$ F. t
addr = base;
( T: q. m8 s" a
sync ();
6 O8 F/ ?, o/ j6 ^/ D: c! u
save
= *addr;
/ a' C# O& n3 [$ d5 _4 B9 V
sync ();
[% P: F% K8 X7 H1 E( ~" P7 }) n$ p4 i
*addr = 0;
+ G" ]7 C1 ^0 [) A& ~
9 \; T, b0 o6 W) t' B, Q& Y/ R; f
sync ();
8 \9 K) O% t- Q# n
if ((val = *addr) != 0) {
. u S5 _% I( j5 Z9 }4 r
/* Restore the original data before leaving the function.
5 i( u! ?- d9 M, L; m8 F) W( K: V) u
*/
' U7 D! W+ d9 {% X
sync ();
- j( ? i6 h7 p' A; s& a
*addr = save
;
4 d* B( N, O! D* D8 W
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
0 z& C2 _: U0 I) l; H4 D
addr = base + cnt;
3 ~1 }! F! z. r, G9 J
sync ();
& Q; @4 M3 m* w0 q% E5 M& C
*addr = save[--i];
0 `, Z, |7 P1 s; Y# |7 R- K
}
3 a& b; l6 U; L( Q1 A* m% r S: p) t
return (0);
* E" K+ r5 T5 m9 A- `# Z8 _
}
3 \6 Z5 x, h6 Y+ _) E
/ S3 I' u- W& P ]: _. x& \
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
8 { P; I( M. E/ Z) c. {5 ~, s" ]2 t# x# V
addr = base + cnt; /* pointer arith! */
/ Y. Z# A7 p. v! }1 e
val = *addr;
9 @& _! B4 D) _& [
*addr = save[--i];
/ S$ N# u9 l, T+ d7 \# S
if (val != ~cnt) {
- A' i( p0 P" r1 Q, ]: H
size = cnt * sizeof (long);
/ z4 \2 v! F% ^+ _4 x
/* Restore the original data before leaving the function.
2 e' B4 \/ o' Y) |" O# b
*/
1 @: d# m2 H- w$ g! h
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
" f+ {$ t- K5 a, L
addr = base + cnt;
8 x. L+ P$ y% t2 X
*addr = save[--i];
& R g. t- n3 X7 ^6 O. U' E
}
. E, T% ]2 H0 H" b" y% d5 g# B
return (size);
% G! R0 G1 t* A4 \
}
# S+ f6 H6 h8 v: c Q2 }
}
* i4 Y" m/ D- N/ k2 J# R% ^6 }2 R: ~
, h' T/ h8 ~& A8 ^. ]
return (maxsize);
5 r6 m, l& _) T- h0 x: z9 O! c
}
M t( q0 `8 ^3 R6 y
int dram_init(void)
1 a3 A% ~# g2 Y' |
{
D( G* D/ r- u) V
/* dram_init must store complete ramsize in gd->ram_size */
! V7 L( ~4 ?5 e6 N* v- P
gd->ram_size = get_ram_size(
' o2 P, E {% z" I: D
(void *)CONFIG_SYS_SDRAM_BASE,
4 G E, u$ b7 d: k1 y# _" N" l
CONFIG_MAX_RAM_BANK_SIZE);
: w+ O! P0 A; q; \; L% c" u
return 0;
' \1 `$ J, R0 A
}
. A7 Y! @& W8 q5 n2 e
9 S# v' a7 n1 ~0 f
& Z1 t! u1 S- s
9 o0 c; x% f" B, V
6 y0 Z" p0 R# A$ _
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
' \# z" h* L; |. w# r9 i
, Z& M9 u8 t" N! T, J" I
4 h) P6 ?% K# w) w6 E
% u: k/ O! T C& I& k- Z
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4