STM32F103 ucLinux内核没有完全启动
从BOOT跳转到内核后,执行一长段的汇编语言,然后来到startkernel函数,开启C语言之旅。
但是内核输出不正常,如下所示:
Linux version 2.6.26-uc0 (stm32@localhost.localdomain) (gcc version 4.3.3
(Sourcery G++ Lite 2009q1-163) ) #2 Wed Sep 2 10:09:23 UTC 2009
CPU: ARMv7-M
Processor [411fc231] revision 1 (ARMv?(11)M)
Machine:
STM3210E-EVAL
Warning: bad configuration page, trying to continue
SRAM
Config: bank[0] @ 0x68000000 (size: 1024KB) - bank[1] @ 0x20000000 (size:
64KB).
Ignoring unrecognised tag 0x00000000
Built 1 zonelists in Zone
order, mobility grouping off. Total pages: 254
Kernel command line:
PID
hash table entries: 16 (order: 4, 64 bytes)
console [ttyS0] enabled
Dentry
cache hash table entries: 1024 (order: 0, 4096 bytes)
Inode-cache hash table
entries: 1024 (order: 0, 4096 bytes)
Bad
page state in process ‘swapper‘
page:68901180
flags:0x2f55030e mapping:00000000 mapcount:0 count:0
Trying
to fix it up, but a reboot is needed
Backtrace:
Bad page
state in process ‘swapper‘
page:689011c0
flags:0x08a8420a mapping:00000000 mapcount:0 count:134218033
Trying to
fix it up, but a reboot is needed
Backtrace:
Bad page
state in process ‘swapper‘
page:689011c0
flags:0x08a8420a mapping:00000000 mapcount:0 count:134218033
Trying to
fix it up, but a reboot is needed
Backtrace:
Bad page
state in process ‘swapper‘
page:689011e0
flags:0x2eb8430e mapping:00000000 mapcount:0 count:134218033
Trying to
fix it up, but a reboot is needed
Backtrace:
Bad page
state in process ‘swapper‘
page:689011e0
flags:0x2eb8430e mapping:00000000 mapcount:0 count:134218033
Trying to
fix it up, but a reboot is needed
Backtrace:
Bad page
state in process ‘swapper‘
page:68901200
flags:0x0185000c mapping:00000000 mapcount:0 count:0
Trying
to fix it up, but a reboot is needed
Backtrace:
CPU: 0
Tainted: G B (2.6.26-uc0 #2)
pc
: [<08039bc2>] lr : [<08039cb1>] psr: 0100000b
sp :
20001f50 ip : 00000000 fp : 68901000
r10:
2000c28c r9 : 00000006 r8 : 00900000
r7
: 00000000 r6 : 00020000 r5 : 0c955a82 r4 : 68901220
r3
: 2984a715 r2 : ffffffff r1 : 9e375c8e r0 : 689
01220
跟踪调试内核,发现在mem_init→ free_all_bootmem_node→ free_all_bootmem_core→ __free_pages_bootmem→ __free_page→ __free_pages
→free_hot_page→ free_hot_cold_page→ free_pages_check→ bad_page
在bad_pages函数最终输出了下面的信息
Bad page state in process ‘swapper‘
page:68901180
flags:0x2f55030e mapping:00000000 mapcount:0 count:0
Trying to
fix it up, but a reboot is needed
Backtrace:
而导致上面的原因是在free_all_bootmem_core函数中
pfn_to_page→ __pfn_to_page(根据推断是它,但看编译又不是)
#define __pfn_to_page(pfn) (mem_map + ((pfn) - ARCH_PFN_OFFSET))
#define
ARCH_PFN_OFFSET PHYS_PFN_OFFSET
#define PHYS_PFN_OFFSET (PHYS_OFFSET
>> PAGE_SHIFT)
#define PHYS_OFFSET (CONFIG_DRAM_BASE)
#define
CONFIG_DRAM_BASE 0x20000000
struct page *mem_map,page结构体占用32个字节,mem_map的地址是0x6800 0000,ARCH_PFN_OFFSET根据上面的推算为2000 0
若pfn是6800 0,则内存0x6800 0000对应的页管理地址是
0x6800 0000 +(6800 0-2000 0)*32 = 6890 0000
而6890 0000这个地址实际是不存在的。
综上所述,很奇怪ST官网上的开发板可以正常运行。
我做了如下尝试:
1、将官网上的BOOT、内核下载到自己的设备上,串口输出乱码。原因是官网上是无源的8M晶振,而我们使用的是有源的11.0592M,
这样根据BOOT配置,系统主频变成了99M,但是串口的波特率应该不会改变啊,输出却是乱码,试了几个波特率都不对。
2、内核中,在调用控制台初始化时,我对串口1重新配置,修改它的波特率,仍然不起作用,输出乱码。
3、更换晶振,但是手边没有8M有源的,无源又需要电容搭接电路等,现在暂时没有试验出来。