嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
' @- H/ a/ e L. w
核心板2:DDR2 256M Byte NAND FLASH 8G bit
. u, X! _5 i1 X P) O
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
- w8 I& M! D+ l/ F
- ^* o/ E+ j9 N! ]' z1 \# J% f' e
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
, U* X6 H! g* v1 J; H/ p _; u% ~& W
$ K( g' J: {- d& c1 l
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
& Z' t5 ~8 _8 l) R7 `6 A. d
/*
" P+ t- d1 _6 y* F
* Check memory range for valid RAM. A simple memory test determines
* w; M+ {8 i. H
* the actually available RAM size between addresses `base' and
9 }+ \* ~% w9 P# z6 s0 c0 `8 Q
* `base + maxsize'.
" P! E* x- T5 M0 Y) a
*/
2 D% y+ x n; h- a T
long get_ram_size(long *base, long maxsize)
6 Q5 O9 |3 o6 X* O: x6 Y
{
+ y+ g/ W* f) n8 u9 L7 G' m
volatile long *addr;
( l1 ^6 ?) ^& Z2 {
long save[32];
, O' @4 ^7 d: r5 U8 A6 W" ?
long cnt;
# y7 y6 q: y% p2 y4 ^0 c/ q6 k
long val;
( ` Y+ v6 S. W2 A( ?8 i$ q7 D
long size;
8 [3 |; ^6 v+ b. E- P
int i = 0;
9 ^7 O/ k8 I$ Z6 X2 k
$ D: Z; ]6 D+ z2 @
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
, m- [' g" z2 R; o
addr = base + cnt; /* pointer arith! */
1 B* W9 w8 d- [! J; E- x; {
sync ();
. R, {3 i I/ k0 o9 |3 p; \
save[i++] = *addr;
8 h* D! H) O2 b
sync ();
+ a# j% K% X( E, F
*addr = ~cnt;
8 k# c" [2 M2 t# D
}
) M' ?' M$ u N6 H' l
3 ~' L$ Y4 x; [) J9 h& z, ~
addr = base;
; K, q6 }9 z! ]
sync ();
# c7 Z+ D# Y' T4 o; x+ p
save
= *addr;
1 R8 a: r6 p V! T4 d
sync ();
6 C' c7 I4 g# S$ ]1 O9 r
*addr = 0;
6 N: R' v/ j6 s* S n0 T
& z" S- I6 r V7 B# l0 |
sync ();
m0 Z7 ~$ w3 C2 S% X
if ((val = *addr) != 0) {
2 M# L2 R7 o% p( u
/* Restore the original data before leaving the function.
. g4 U4 {( u5 u
*/
% h# S8 F9 @7 Q
sync ();
/ w2 P, `# p) k+ P. J
*addr = save
;
- W9 F: H+ v0 E) o2 [9 D
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
: h$ S& b8 i# I9 w, P3 n; i
addr = base + cnt;
; G: Y( y3 T1 R9 P8 ^! _8 x
sync ();
$ e3 T+ H; r/ z
*addr = save[--i];
# D o8 ^# c9 s; H* {
}
- \0 g/ U* j4 L% ~( k, s1 h: Z
return (0);
$ k9 I, Z% y. B) r% ]1 }
}
/ f2 B: h2 P. o P4 @' W( e
/ p( B, i/ ?+ K, ^# O
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
% E* P& M8 H; e$ x: C8 {
addr = base + cnt; /* pointer arith! */
0 `: |6 `9 W/ I2 N2 f8 l7 @
val = *addr;
+ {1 s5 M3 P2 \& k9 @1 y8 G& [7 b
*addr = save[--i];
* g0 h+ c7 V' Y4 E5 ~- `
if (val != ~cnt) {
! R8 c/ _9 ?2 V; s( j
size = cnt * sizeof (long);
& M$ [, U0 _ G5 R) G* ~0 w7 ]' P. E
/* Restore the original data before leaving the function.
- w+ G' |. L" A/ s$ S: t: Q. T% L: s
*/
; ~) z4 F" a5 y
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
H- z) r8 N) q9 b$ [ O# o$ O' E
addr = base + cnt;
7 ^, B5 P! `4 o: m0 |1 |6 ^, U
*addr = save[--i];
3 X f; J' f3 d
}
$ A: x* ~' C5 W& O% r
return (size);
; s/ Z# v6 l! p
}
7 m" M3 Y/ {; x8 [/ c, ^0 a
}
8 ^0 p# e0 D# ~9 i3 U% J/ T
8 h& ^* K5 y( R6 b% ]$ U: k
return (maxsize);
6 D, D* x5 [4 y4 {
}
" P2 {' v- { s' x1 I; [$ c
int dram_init(void)
. P# t ?6 s0 W3 p5 w* P2 c( ]( z
{
; k* D- h$ P8 G9 D: `
/* dram_init must store complete ramsize in gd->ram_size */
8 U6 R C7 s( q2 Z* I0 [
gd->ram_size = get_ram_size(
% l" d$ q! o# ^
(void *)CONFIG_SYS_SDRAM_BASE,
3 o0 g5 R- H2 G; s
CONFIG_MAX_RAM_BANK_SIZE);
4 n# ?" j. h7 f
return 0;
' a J* L0 @5 Q
}
1 Z" g m7 q5 R) A: r* ^
% ? ?0 A, q$ p
; p7 Y0 W9 n( s" f1 e
6 r- ]# h) U' G/ V, x! Q/ L
# V& ^! l* ^& I4 T% @" U R! A$ }
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
9 T, G# E J& j" q J
6 w/ `* h7 `3 i4 z( W) ?
! E$ G2 t2 z! q6 b0 _
6 O: `$ I$ X1 X* W# w% F! u5 N
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4