嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
& |) n1 m' j9 @& U
核心板2:DDR2 256M Byte NAND FLASH 8G bit
6 o: e* T. `3 n9 c- P1 S
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
6 ]3 o' t/ ?9 e2 F. {# V
/ p V( Q7 N3 i: z5 y- Q. f& h
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
; u! O9 F% U2 n: T2 E
' D# p4 `, o0 E$ u7 j
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
z$ I x. |% s$ L5 r
/*
5 @; q1 w8 Y" k( x, }' W5 B
* Check memory range for valid RAM. A simple memory test determines
+ b$ R6 Z3 A. {& S
* the actually available RAM size between addresses `base' and
, }& m4 Z8 O; E) b7 z8 X
* `base + maxsize'.
X$ G; b' d2 e+ `8 {
*/
6 G& Z' m# b0 q$ Q( F+ ]8 Y3 D" c+ F
long get_ram_size(long *base, long maxsize)
/ r+ w* v5 r6 e0 c8 T5 Z' ?
{
; _! ?" \; n: ^' [ C7 P$ ~. o
volatile long *addr;
2 o: O: ]' u4 O7 V) V7 y
long save[32];
k/ m4 ?) F; B# i
long cnt;
% ]9 T2 D5 B* p- K
long val;
6 D' E) A. V0 N5 X+ b
long size;
$ U: X( m! j' l
int i = 0;
0 Q5 W* h" a9 k4 J2 l$ Q* f
. Z9 T3 b9 P+ w F/ G5 _$ |
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
( v& X. D% |! v3 f0 x- Q+ D* u
addr = base + cnt; /* pointer arith! */
$ [6 J T/ p# D$ v- x
sync ();
1 ^$ ^; I+ E/ u2 a+ q
save[i++] = *addr;
$ h( E. R9 ]. D2 n5 S1 P, C5 l
sync ();
% O! H: u! n) X8 t. i
*addr = ~cnt;
$ f& V/ {- `. |' A
}
. m7 U: p! s7 S
' s. d4 s: s0 i. v6 S* T: B& n
addr = base;
' V& S. O9 ~ F! V4 }2 Y5 m D3 _
sync ();
' i3 U4 p8 _0 Y' O. t
save
= *addr;
4 H* k/ j5 S7 i* [0 ~ `* P9 N2 E
sync ();
$ {1 @$ ]. G" g
*addr = 0;
, j& G( g; Y& Y3 S4 q1 D! ?- t
4 f$ b5 g \2 m* W, w
sync ();
. z% ~+ s6 U5 U6 j
if ((val = *addr) != 0) {
( M% u% T3 ?% I& ^0 q$ O3 e
/* Restore the original data before leaving the function.
5 U! m7 W8 q3 S3 U9 |
*/
" a$ _$ @- ]6 x$ K3 }& M H
sync ();
$ X4 [" o. N5 C. v* V
*addr = save
;
0 e7 z$ _ S) o& \( A0 K
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
, ?/ y+ b2 W7 ?2 d
addr = base + cnt;
% z5 S) C; u! v% X
sync ();
" m( n# a! L5 d5 p+ y3 L: h! i8 R3 M, s
*addr = save[--i];
2 b" O: l8 P) D1 A7 B# m( a+ ]/ Q
}
7 T0 k9 n* ?' `- C* t; m6 q6 U
return (0);
& E6 q! D) a |
}
S' @+ K; y# ?) f+ f* e1 G6 D. G
) u$ m# ? t6 Y1 b. R4 p" y3 [
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
* y$ ^2 s8 d+ k2 r$ q E
addr = base + cnt; /* pointer arith! */
7 _4 V2 m- I/ e+ Y* @
val = *addr;
4 ^ _; I6 N, H$ D, Q
*addr = save[--i];
; x( J6 ?% A' e9 B d6 @0 A% @
if (val != ~cnt) {
8 w7 s5 N8 M4 |/ ^( M
size = cnt * sizeof (long);
! z8 b5 Q7 {* v2 {; b; T) Y
/* Restore the original data before leaving the function.
' F- a7 m# q! @; ]$ r" ^) G
*/
, ^3 d+ Q, i }8 _7 S* [
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
; x$ Q+ e$ P5 Z2 b
addr = base + cnt;
5 H4 S" U3 h9 y g
*addr = save[--i];
+ k8 M+ p# D6 B; @
}
/ P% M* O& n: S: c
return (size);
: x4 P+ l3 S" w Z, A5 p2 b! [( [
}
5 t$ [+ `" N7 E
}
7 h7 g: `' A, R M9 r9 i5 L2 ~
% R) J7 g0 N; ^- R+ R0 V: ] o
return (maxsize);
5 F* a" K; n, r8 C
}
2 N1 ^1 }7 Z3 h5 t
int dram_init(void)
. b& Q. W# F' ~7 g) o; O# M' ]+ N
{
4 }5 R6 M# q; {3 W
/* dram_init must store complete ramsize in gd->ram_size */
) t, {" C: m) a) Q) |: @
gd->ram_size = get_ram_size(
# U. ?9 r! a# l$ K0 K% M: [
(void *)CONFIG_SYS_SDRAM_BASE,
. `! {8 y3 I/ j- g) p
CONFIG_MAX_RAM_BANK_SIZE);
; L0 L% z6 P Z
return 0;
9 i b0 T" Y' B& I/ u
}
* f$ v4 _ w+ p( T- N
1 X" ]! i5 ]' a8 e" Y
% C W0 R/ S! V; R! G1 H
) }5 W+ R$ C5 s. F2 s
4 u u0 t( K8 Y: n
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
/ V$ [; `& i( Z y6 ^ j4 J
) j- C2 `4 j( J7 C0 A# r8 r
5 ]% V/ f. A, Y* ? S( @& R2 k
3 X" Y) f( H( ^
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4