您的位置 首页 发布

Uboot对非Linux kernel的引导

实现了uboot对非linux kernel的引导。虽然有一个IH_TYPE_STANDALONE,但是没有实现。nnd。只能自己想办法。实现详细见下面。1、两个命令set bootcmd tftp

完成了uboot对非linux kernel的引导。虽然有一个IH_TYPE_STANDALONE,可是没有完成。nnd。只能自己想办法。完成具体见下面。

1、两个指令

set bootcmd tftp 84000000 uImage\;bootm 84000000

set bootdelay 1

2、非linux kernel的引导完成办法:

总共三个函数: jump,selectboot 和 system_boot

把jump放在需求跳转的当地,参数便是要跳转的地址。然后回来,重启体系。select放在main的最初。经过判别ram的特定地址的特定信息完成跳转。

system_boot完成体系的重新启动

#define FDMA_SRAM_TOP_ADDRESS 0xB9229800

#define MAGIC_NUM 0x71097100

#define DEAD_PATTERN 0xBAD0BADF

#define ST40_CPG_REGS_BASE 0xFFC00000#define

ST40_CPG_WTCNT (ST40_CPG_REGS_BASE + 0x08)

#define ST40_CPG_WTCSR (ST40_CPG_REGS_BASE + 0x0C)

#define ST40_CPG_WTCSR2 (ST40_CPG_REGS_BASE + 0x1C)

void Jump(unsigned int address)

{

STSYS_WriteRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*1, MAGIC_NUM);

STSYS_WriteRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*2, address);

STSYS_WriteRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*3, ~address);

STSYS_WriteRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*4, ~MAGIC_NUM);

STSYS_WriteRegDev16LE(ST40_CPG_WTCNT, 0x5AF0); /*Watchdog counter*/

STSYS_WriteRegDev16LE(ST40_CPG_WTCSR, 0xA547); /*Watchdog control*/

STSYS_WriteRegDev16LE(ST40_CPG_WTCSR2, 0xAA00); /*Watchdog control2*/

STSYS_WriteRegDev16LE(ST40_CPG_WTCSR, 0xA5C7); /*Start watchdog counter*/ for(;;);

}

void SelectBoot(void)

{

unsigned int MagicNum = 0;

unsigned int NotMagicNum = 0;

unsigned int JumpAddress = 0;

unsigned int NotJumpAddress = 0; void (*entry)(void);

/* entry=0xa0100000;

entry();*/ //if((STSYS_ReadRegDev16LE(ST40_CPG_WTCSR2) 0xFF) != 0x0)

{

MagicNum = STSYS_ReadRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*1);

JumpAddress = STSYS_ReadRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*2);

NotJumpAddress = STSYS_ReadRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*3);

NotMagicNum = STSYS_ReadRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*4);

if((MagicNum == MAGIC_NUM)

(MagicNum == (~NotMagicNum))

(JumpAddress == (~NotJumpAddress)))

{

entry = (void (*)(void))JumpAddress;

STSYS_WriteRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*1, DEAD_PATTERN);

STSYS_WriteRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*2, DEAD_PATTERN);

STSYS_WriteRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*3, DEAD_PATTERN);

STSYS_WriteRegDev32LE(FDMA_SRAM_TOP_ADDRESS – 4*4, DEAD_PATTERN);

#if 0/*Setup For watchdog in case jump failed.*/

STSYS_WriteRegDev16LE(ST40_CPG_WTCNT, 0x5AF0);

STSYS_WriteRegDev16LE(ST40_CPG_WTCSR, 0xA543);

STSYS_WriteRegDev16LE(ST40_CPG_WTCSR2, 0xAA01);

STSYS_WriteRegDev16LE(ST40_CPG_WTCSR, 0xA5C7);

#endif entry(); while(1);

}

}

}void system_reboot(void)

{

ulong sr;

asm (stc sr, %0:=r (sr));

sr  = (1 28); /* set block bit */

asm (ldc %0, sr: :r (sr));

asm volatile (trapa #0);

}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/changshang/fabu/299566.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部