嵌入式开发者社区
标题:
TL138 uboot是怎么区分配置两款核心板的
[打印本页]
作者:
Mr.Loser
时间:
2014-9-11 09:33
标题:
TL138 uboot是怎么区分配置两款核心板的
核心板1:DDR2 128M Byte NAND FLASH 4G bit
# \5 [0 j; T3 ~: I0 J3 o% q
核心板2:DDR2 256M Byte NAND FLASH 8G bit
- U: K7 a1 x& C7 ?
这两个核心板公共一个uboot,DDR2的配置肯定是不同的,uboot怎么检查到是哪个核心板,然后去执行相应的配置呢?
! K$ N1 K+ F; x- a) q1 f9 g3 ?
* G- v/ N5 H: u" D. l
是不是通过读NAND FLASH的ID,两款核心板NAND FLASH不同,ID也不同,这样读到了ID就知道是哪个核心板了?
/ I5 p6 R' F C
7 f6 D a8 b6 M0 E; d+ a
作者:
2532609929
时间:
2014-9-11 18:55
DDR通过检查最大有效地址来识别容量,具体请看uboot的common/memsize.c文件中的检查代码,也可以看如下:
# R3 N: V' W" A C( Q
/*
# K5 V9 [2 y1 c4 ]7 [! K) Z( M
* Check memory range for valid RAM. A simple memory test determines
' I3 @& b! }8 z* q- W+ o
* the actually available RAM size between addresses `base' and
, \: X3 y* R* G: k% T
* `base + maxsize'.
4 Q1 b5 U9 y3 c: |0 _4 t) U8 a
*/
- ~! e z6 g0 |
long get_ram_size(long *base, long maxsize)
( e+ D& e& h U" a" p+ d
{
9 _2 W( s9 y( ?" \* `
volatile long *addr;
7 ?, B ~% E' j1 p% ^- j
long save[32];
. j; Z" K2 W8 V3 I$ L# M
long cnt;
. j; O* _5 Y" _$ t. C- k
long val;
! w8 N* Q4 i5 X3 z
long size;
. V0 O, F8 a( b0 d W
int i = 0;
, G+ p6 r* M% F, |) b1 C& y) B8 }
: t% g! |2 w6 k6 y7 `
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
% R' b W$ g5 ~; n
addr = base + cnt; /* pointer arith! */
$ v! J% i1 M* x0 W; c; m
sync ();
' ? i" J' q$ G- r- J) A& _
save[i++] = *addr;
! o) p! b A! |% e" R
sync ();
* @ M! D& n, Q
*addr = ~cnt;
4 g6 ^& |5 p5 n3 Z8 D5 C
}
. o, C; |( l1 b% {0 d6 w( |9 R
: L3 S5 v- p$ C: @5 C
addr = base;
0 A' y# C) a x+ W4 D' O# h
sync ();
$ u4 c2 V0 ~; b8 x0 i) h
save
= *addr;
+ c3 K8 {% ^1 p- b6 P7 j
sync ();
Y: ^0 z+ x# E: r- S
*addr = 0;
3 W$ ~. ]( Q0 A: B; T
! o3 I: d# w+ Z9 n2 `
sync ();
) |$ r. I% W# b5 @( a) Y
if ((val = *addr) != 0) {
. L+ p! y. a, f( E
/* Restore the original data before leaving the function.
8 j+ {9 N* T9 l2 U$ v E7 v
*/
2 { S$ j/ o* {. U# W9 K, x- x( n
sync ();
: ^& e7 g% Y; w- g
*addr = save
;
: h9 F @/ t' m: H5 k
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
; c, P0 P/ z7 e
addr = base + cnt;
* p' f) N1 I2 d2 w* s! B
sync ();
& ?; |( b3 i& \* _9 j* |3 S( a
*addr = save[--i];
% S0 q- V5 B3 s9 l5 v( W
}
% i; A2 T+ \3 n# Q2 d+ e
return (0);
& {7 w# W# X6 }& o& f5 _4 \0 H8 G
}
' B7 C+ ^! E' {
8 n% L8 T9 r( d- Z* s0 z
for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ d& u) o$ R* ^: P0 C1 }; t c4 D
addr = base + cnt; /* pointer arith! */
* p8 @ @$ b1 W) L. K
val = *addr;
* H8 e' A3 M( U
*addr = save[--i];
1 y1 s8 c8 H: X: o' {) _" H; D
if (val != ~cnt) {
; _7 U8 W& ^5 R
size = cnt * sizeof (long);
* P& p$ f4 B# f8 y" P. A1 }
/* Restore the original data before leaving the function.
3 z8 U5 v3 V, R; u
*/
6 i* Z& k- x5 @9 N: w0 D
for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
$ q/ j3 S7 V) C, G; a* M% S/ J$ s
addr = base + cnt;
S" u# I; |! F& u& v
*addr = save[--i];
+ U+ t9 h A \8 c6 W* o
}
x6 {6 a! f+ m8 U8 Z
return (size);
7 K3 [3 K. s: S+ Z' |
}
9 ^( V' p& Z* f9 S) r. F7 W; Q
}
# I' ^. Y0 M3 I3 [- b* R/ K& S
- B) s% r$ _+ q: ?! o' ~
return (maxsize);
# @4 t1 h8 g* @+ m$ z' r% L
}
, Y2 p3 M, x0 {4 A; ~
int dram_init(void)
7 c$ s+ z4 F$ i f+ M
{
4 P" @9 E7 M/ q( b/ z# I) w
/* dram_init must store complete ramsize in gd->ram_size */
8 G# [8 z a+ L& R1 V' g
gd->ram_size = get_ram_size(
- p) \0 D- g; Q. e% w
(void *)CONFIG_SYS_SDRAM_BASE,
1 @, j: w- W9 _/ W6 e& c! @
CONFIG_MAX_RAM_BANK_SIZE);
! Y6 a2 u, h5 L" N3 X# x# {
return 0;
$ T6 c9 @0 }0 w( M j
}
`% O+ G5 |( V$ V' ?* m$ J( W
' U/ Q. J0 G% S$ O8 V' Y+ C$ P
2 [, j3 u \6 v2 v# q [
4 Y0 h/ z; l9 y8 `: D( Y
9 J2 [* t/ T8 f: P% t1 X3 K9 O
FLASH是通过检查FLASH内部的ID识别容量,希望对您有帮助!
3 X7 \/ P8 ], w
# o7 }/ r( Z" g% l0 s- l
" ?9 B' n8 b( b2 m
# G7 `9 [0 A1 v! S# y
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4