嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
8 `* \* p" n! t. U" B
核心板2:DDR2 256M Byte NAND FLASH 8G bit
$ O2 b, \% r: d5 p2 S; o8 K
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
: P N/ g& a9 [9 ?
) s/ g' r) R$ m
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
5 U* [2 b6 ~. T$ j. G- O# M o
* E1 C2 I& W; }+ ~! g" C$ W
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
3 r+ L" h1 ]$ Y$ X" a! u" u
/*
3 I1 [8 `9 U! y1 \; p. h
* Check memory range for valid RAM. A simple memory test determines
! s! n' q3 F1 o& U! r1 M3 i
* the actually available RAM size between addresses `base' and
) I; o4 l2 A. J H
* `base + maxsize'.
8 g7 H( C D3 ]$ `
*/
3 f. Z3 I4 _+ H! _* c7 v
long get_ram_size(long *base, long maxsize)
0 g6 M6 |! f; D
{
0 {+ S. }+ q8 k. ^' b
volatile long *addr;
' F |( }8 [# y; P/ |7 ?( z/ T
long save[32];
9 z) M8 Z0 ^; ?' _! l
long cnt;
4 @5 ~ O) R" r! B& u
long val;
5 T' D2 }% e. M1 [
long size;
+ }8 h3 M) J+ F, E
int i = 0;
. L! n! {+ u) V9 q! e* R! m% H
8 d0 W/ U+ R8 r. t
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
! r) X- E1 X1 m
addr = base + cnt; /* pointer arith! */
+ i* ?' y' B+ A3 [
sync ();
8 X' g3 P- i% h* d1 u/ h+ m3 \
save[i++] = *addr;
2 r3 \: R9 w; E- z& s; l
sync ();
& u, |: l- d/ R+ Q; \ g1 S, Z6 z
*addr = ~cnt;
8 C& t4 d0 }4 Q' @
}
$ g; \' M; g5 b3 {: j
2 @4 z0 V, ]1 F
addr = base;
( m5 I6 d v$ O a6 \2 Q
sync ();
- e0 m* }2 [$ S6 z/ O9 ~1 [0 k
save
= *addr;
0 r o$ ] I4 f' V: g
sync ();
; _$ S7 Z | B/ ]6 W; O# k
*addr = 0;
5 w1 E; D6 i6 M* t7 Q- D
6 S0 r3 o$ O7 l Y) a$ a8 L A% r! U
sync ();
3 H2 K" J; j" Y3 S6 q" k
if ((val = *addr) != 0) {
& D2 w; @ M: T" z
/* Restore the original data before leaving the function.
0 U! V& ~' a4 O' Y$ P6 ?
*/
- p' M) h) j4 n4 Z* Z; |& m) C+ b5 u0 [
sync ();
$ ?0 \5 D0 L1 V# R+ H- L. h
*addr = save
;
7 S' H* k3 C) f+ a$ m( R" Z' y! @* H
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
/ L6 `4 r. [# ^: {8 Y
addr = base + cnt;
" O. K: t& \' z$ O) f
sync ();
+ i5 W. I: M5 f
*addr = save[--i];
7 y# }3 q t! i$ H' Y: |0 s
}
6 U( j" E Y) h6 Y5 D* i
return (0);
3 ?& G: ] [: q, }) ^. ^
}
+ \0 f9 z4 w/ G6 }$ q* Y i
+ }3 {' X, W& W) h4 ]
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
. j, n6 q. Z8 u: O4 S% x* l8 u
addr = base + cnt; /* pointer arith! */
. K) Y1 O$ B# G7 D/ G
val = *addr;
' _$ ^; N$ V8 r' h0 L0 D. Y1 N8 y
*addr = save[--i];
: X h/ |% v% ~8 o
if (val != ~cnt) {
* `6 B0 W4 i6 D5 c8 }8 t" z9 a% s! e& w
size = cnt * sizeof (long);
7 t4 N" {$ }; S4 V' a# t- q
/* Restore the original data before leaving the function.
* z; @% t# k& C
*/
) K$ }) o' T6 c* ~
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
) w5 a0 ]$ F7 ^1 e4 h% q ~, p; `
addr = base + cnt;
8 {0 F+ [8 [( `3 W; U# _
*addr = save[--i];
4 V4 Y" U/ q+ y5 B3 Q3 ?
}
; ?: a n: g# i0 Y3 e. l
return (size);
9 [; u2 j; `2 p& C2 K* r
}
; ~' n) ^; q8 D1 w- Y
}
2 M& C X% ]; {5 ?' @! h6 y
( ?' s" _) W0 I' S
return (maxsize);
3 o+ |( l' y5 `
}
- v4 a( x" c- U$ K
int dram_init(void)
; u& t f0 b# S" I2 m
{
/ B0 k4 V8 j+ w7 x1 o* v
/* dram_init must store complete ramsize in gd->ram_size */
, [& h& c8 x$ A- H4 v, c
gd->ram_size = get_ram_size(
! M% w8 O, [! w7 d% q
(void *)CONFIG_SYS_SDRAM_BASE,
. w$ H$ u1 @$ H" L, b/ S# a3 v
CONFIG_MAX_RAM_BANK_SIZE);
: F8 Y5 T9 Z0 k% U7 d# k+ `
return 0;
3 p( |* e _: @( v I6 q
}
" j% A( ^4 ~" g& I) |5 p. P8 m5 R( d
- h4 j# a4 g& ?$ K0 s L5 j
/ l2 I9 O! G3 }6 [1 L& g
0 |5 P% Q( G6 M9 v! u/ J, a* s
" p' A) v1 u. {6 b
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
6 K: P/ O) L: y! e
( ~/ U- F) \2 w; Z: x" Q: s
: w& i8 N+ q o. o/ F
! _' Q9 `5 n: \" a" J4 c' j- n, C
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4