您的位置:首页 > 其它

U-boot2016.05移植TQ2440之串口输出实现

2017-07-20 21:31 411 查看
uboot下载:ftp://ftp.denx.de/pub/u-boot/

之前习惯性的使用串口烧录u-boot,可是,在调试这个的时候输出一直是



因此,改用TFTP烧录。

之前玩过的u-boot是没有带menuconfig这个功能,感觉变了许多。从根目录的README得知

$ CROSS_COMPILE=ppc_4xx-
$ export CROSS_COMPILE

make NAME_defconfig

If the system board that you have is not listed, then you will need
to port U-Boot to your hardware platform. To do this, follow these
steps:

1.  Create a new directory to hold your board specific code. Add any
files you need. In your board directory, you will need at least
the "Makefile" and a "<board>.c".
2.  Create a new configuration file "include/configs/<board>.h" for
your board.
3.  If you're porting U-Boot to a new CPU, then also create a new
directory to hold your CPU specific code. Add any files you need.
4.  Run "make <board>_defconfig" with your new name.
5.  Type "make", and you should get a working "u-boot.srec" file
to be installed on your target system.
6.  Debug and solve any problems that might arise.
[Of course, this last step is much harder than it sounds.]


由于sc32440是Samsung公司出产的arm920t系列,这个可以从s3c2440的数据手册得知。搜索了一下这个目录并没有s3c2440的相关配置,使用2410代替。

1.  复制2410配置,并修改相关信息

[root@Double u-boot-2016.05]# \cp -rf board/samsung/smdk2410 board/samsung/smdk2440/
需要修改文件 Kconfig lowlevel_init.S MAINTAINERS Makefile smdk2440.c 使用vim打开文件后,全部修改变量。
:%s/2410/2440/g
从MAINTAINERS文件中看出相关联文件,
1 SMDK2440 BOARD
2 M:  David Müller <d.mueller@elsoft.ch>
3 S:  Maintained
4 F:  board/samsung/smdk2440/
5 F:  include/configs/smdk2440.h
6 F:  configs/smdk2440_defconfig
方法就是在相对应的目录下以2410为模版备份一份,并修改文件内的2410为2440。

文件的运行开始为u-boot.lds中的_start
#include <config.h>

OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
#ifndef CONFIG_CMDLINE
/DISCARD/ : { *(.u_boot_list_2_cmd_*) }
#endif
...
}
而后跳转到version.S,由“breset”
_start:

#ifdef CONFIG_SYS_DV_NOR_BOOT_CFG
.word	CONFIG_SYS_DV_NOR_BOOT_CFG
#endif

b	reset
ldr	pc, _undefined_instruction
ldr	pc, _software_interrupt
ldr	pc, _prefetch_abort
ldr	pc, _data_abort
ldr	pc, _not_used
ldr	pc, _irq
ldr	pc, _fiq
在rebet中配置关门狗的寄存器,关闭看门狗。
reset:
.......
#if defined(CONFIG_S3C2440)
#define pWTCON	0x15300000
#define INTMSK	0x14400008	/* Interrupt-Controller base addresses */
#define INTSUBMSK	0x4A00001C
#define CLKDIVN	0x14800014	/* clock divisor register */
#else
#define pWTCON	0x53000000
#define INTMSK	0x4A000008	/* Interrupt-Controller base addresses */
#define CLKDIVN	0x4C000014	/* clock divisor register */
#endif

ldr	r0, =pWTCON
mov	r1, #0x0
str	r1, [r0]
......
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
bl	cpu_init_crit
#endif

bl	_main
由于等下使用TFTP将u-boot下载到内存中运行,如果还执行cpu_init_crit函数配置底层的初始化,会造成代码的丢失,这个观看卫东山的学习视频有很清晰的讲解。因为在开头就 #include <config.h> 因此,在config.h中定义,还有方便调试定义DEBUG变量。
#define CONFIG_SKIP_LOWLEVEL_INIT
#define DEBUG
使用TFTP烧录。。。
U-Boot 2016.05 (Jul 20 2017 - 21:13:16 +0800)

initcall: 3200f110
U-Boot code: 32000000 -> 3207E780  BSS: -> 320CDD70
initcall: 3200038c
CPUID: 32440001
FCLK:  405.600 MHz
HCLK:  101.400 MHz
PCLK:   50.700 MHz
initcall: 3200f368
DRAM:  initcall: 3200116c
initcall: 3200f2b8
Monitor len: 000CDD70
Ram size: 04000000
Ram top: 34000000
initcall: 3200eeec
initcall: 3200f0b8
TLB table from 33ff0000 to 33ff4000
initcall: 3200ef04
initcall: 3200f06c
Reserving 823k for U-Boot at: 33f22000
initcall: 3200f040
Reserving 4160k for malloc() at: 33b12000
initcall: 3200f26c
memset_count:-1Reserving 80 Bytes for Board Info at: 33b11fb0
initcall: 3200ef0c
initcall: 3200f00c
Reserving 168 Bytes for Global Data at: 33b11f08
initcall: 3200ef94
initcall: 3200ef40
initcall: 3200ef14
initcall: 3200f358
initcall: 3200f1e4

RAM Configuration:
Bank #0: 30000000 64 MiB

DRAM:  64 MiB
initcall: 3200ef78
New Stack Pointer is: 33b11ee0
initcall: 3200f1a8
initcall: 3200f13c
Relocation Offset is: 01f22000
Relocating to 33f22000, new gd
b0a8
at 33b11f08, sp at 33b11ee0
initcall: 33f313e4
initcall: 33f313ec
initcall: 3200f5d0 (relocated to 33f315d0)
WARNING: Caches not enabled
initcall: 3200f404 (relocated to 33f31404)
initcall: 3200f42c (relocated to 33f3142c)
initcall: 3200f5b4 (relocated to 33f315b4)
using memory 0x33b12000-0x33f22000 for malloc()
搜索关键字“using memory”定位到dlmalloc.c文件,查看源码
void mem_malloc_init(ulong start, ulong size)
{
mem_malloc_start = start;
mem_malloc_end = start + size;
mem_malloc_brk = start;

debug("using memory %#lx-%#lx for malloc()\n", mem_malloc_start,   //using memory 0x33b12000-0x33f22000 for malloc()
mem_malloc_end);
#ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT
memset((void *)mem_malloc_start, 0x0, size);
#endif
debug("malloc_bin_reloc()   before;\n");
malloc_bin_reloc();
debug("malloc_bin_reloc()   after;\n");
}
debug("malloc_bin_reloc() before;\n");和debug("malloc_bin_reloc() after;\n");是我添加上去定位BUG所在位置,结果控制台的输出结果依旧没变。锁定了错误在

memset((void *)mem_malloc_start, 0x0, size); 经计算的出(0x33f22000-0x33b12000=4M)在追到memset源码
void * memset(void * s,int c,size_t count)
{
unsigned long *sl = (unsigned long *) s;
unsigned long cl = 0;
char *s8;
int i;
printf("memset_begin",(int)count);
/* do it one word at a time (32 bits or 64 bits) while possible */
if ( ((ulong)s & (sizeof(*sl) - 1)) == 0) {
for (i = 0; i < sizeof(*sl); i++) {
cl <<= 8;
cl |= c & 0xff;
}
while (count >= sizeof(*sl)) {
*sl++ = cl;
count -= sizeof(*sl);
}
}
/* fill 8 bits at a time */
s8 = (char *)sl;
while (count--)
*s8++ = c;
return s;
}
具体原因有待深究。

解决方法是:

mem_malloc_init中memset((void *)mem_malloc_start, 0x0, size/2);此处将size的范围缩小一半可以解决这个BUG。

之后使用TFTP烧录
EmbedSky> tftp 0x32000000 u-boot.bin;go 0x32000000
dm9000 i/o: 0x20000300, id: 0x90000a46
MAC: 0a:1b:2c:3d:4e:5f
TFTP from server 192.168.1.135; our IP address is 192.168.1.3
Filename 'u-boot.bin'.
Load address: 0x32000000
Loading: #######################################
done
Bytes transferred = 561056 (88fa0 hex)
## Starting application at 0x32000000 ...
initcall: 3205d30c

U-Boot 2016.05 (Jul 20 2017 - 22:58:10 +0800)

initcall: 3200f110
U-Boot code: 32000000 -> 3207E760 BSS: -> 320CDD70
initcall: 3200038c
CPUID: 32440001
FCLK: 405.600 MHz
HCLK: 101.400 MHz
PCLK: 50.700 MHz
initcall: 3200f368
DRAM: initcall: 3200116c
initcall: 3200f2b8
Monitor len: 000CDD70
Ram size: 04000000
Ram top: 34000000
initcall: 3200eeec
initcall: 3200f0b8
TLB table from 33ff0000 to 33ff4000
initcall: 3200ef04
initcall: 3200f06c
Reserving 823k for U-Boot at: 33f22000
initcall: 3200f040
Reserving 4160k for malloc() at: 33b12000
initcall: 3200f26c
Reserving 80 Bytes for Board Info at: 33b11fb0
initcall: 3200ef0c
initcall: 3200f00c
Reserving 168 Bytes for Global Data at: 33b11f08
initcall: 3200ef94
initcall: 3200ef40
initcall: 3200ef14
initcall: 3200f358
initcall: 3200f1e4

RAM Configuration:
Bank #0: 30000000 64 MiB

DRAM: 64 MiB
initcall: 3200ef78
New Stack Pointer is: 33b11ee0
initcall: 3200f1a8
initcall: 3200f13c
Relocation Offset is: 01f22000
Relocating to 33f22000, new gd at 33b11f08, sp at 33b11ee0
initcall: 33f313e4
initcall: 33f313ec
initcall: 3200f5d0 (relocated to 33f315d0)
WARNING: Caches not enabled
initcall: 3200f404 (relocated to 33f31404)
initcall: 3200f42c (relocated to 33f3142c)
initcall: 3200f5b4 (relocated to 33f315b4)
using memory 0x33b12000-0x33f22000 for malloc()
malloc_bin_reloc() before;
malloc_bin_reloc() after;
initcall: 3200f434 (relocated to 33f31434)
initcall: 3200f3c0 (relocated to 33f313c0)
initcall: 3200f5a0 (relocated to 33f315a0)
initcall: 320011a4 (relocated to 33f231a4)
initcall: 32018164 (relocated to 33f3a164)
initcall: 3200f590 (relocated to 33f31590)
initcall: 3200f4f8 (relocated to 33f314f8)
Now running in RAM - U-Boot at: 33f22000
initcall: 3200f43c (relocated to 33f3143c)
initcall: 3200f514 (relocated to 33f31514)
Flash: fwc addr 00000000 cmd f0 00f0 16bit x 16 bit
fwc addr 0000aaaa cmd aa 00aa 16bit x 16 bit
fwc addr 00005554 cmd 55 0055 16bit x 16 bit
fwc addr 0000aaaa cmd 90 0090 16bit x 16 bit
fwc addr 00000000 cmd f0 00f0 16bit x 16 bit
JEDEC PROBE: ID 1c 2249 0
fwc addr 00000000 cmd ff 00ff 16bit x 16 bit
fwc addr 00000000 cmd 90 0090 16bit x 16 bit
fwc addr 00000000 cmd ff 00ff 16bit x 16 bit
JEDEC PROBE: ID 16 ea00 0
0 Bytes
initcall: 3200f4dc (relocated to 33f314dc)
NAND: board_nand_init()
end of nand_init
hwcontrol(): 0xff 0x83
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0x90 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0x90 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0x90 0x83
hwcontrol(): 0x40 0x85
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0xffffffff 0x80
0 MiB
initcall: 3200f4ac (relocated to 33f314ac)
*** Warning - bad CRC, using default environment

Destroy Hash Table: 33f9af74 table = 00000000
Create Hash Table: N=75
INSERT: table 33f9af74, filled 1/79 rv 33b12238 ==> name="bootdelay" value="5"
INSERT: table 33f9af74, filled 2/79 rv 33b120f8 ==> name="baudrate" value="115200"
INSERT: table 33f9af74, filled 3/79 rv 33b120a8 ==> name="ipaddr" value="10.0.0.110"
INSERT: table 33f9af74, filled 4/79 rv 33b12260 ==> name="serverip" value="10.0.0.1"
INSERT: table 33f9af74, filled 5/79 rv 33b124f4 ==> name="netmask" value="255.255.255.0"
INSERT: free(data = 33b12008)
INSERT: done
initcall: 3200f3d4 (relocated to 33f313d4)
initcall: 32018224 (relocated to 33f3a224)
initcall: 3200f49c (relocated to 33f3149c)
initcall: 32015d00 (relocated to 33f37d00)
Initial value for argc=3
Final value for argc=3
Initial value for argc=3
Final value for argc=3
Initial value for argc=3
Final value for argc=3
initcall: 32000bb0 (relocated to 33f22bb0)
initcall: 3200f48c (relocated to 33f3148c)
initcall: 3200f46c (relocated to 33f3146c)
initcall: 3200f450 (relocated to 33f31450)
Net: Initial value for argc=3
Final value for argc=3
CS8900-0
Error: CS8900-0 address not set.

initcall: 3200f444 (relocated to 33f31444)
### main_loop entered: bootdelay=5

### main_loop: bootcmd="<UNDEFINED>"
SMDK2440 #



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: