色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > Uboot對(duì)非Linux kernel的引導(dǎo)

          Uboot對(duì)非Linux kernel的引導(dǎo)

          作者: 時(shí)間:2016-09-12 來源:網(wǎng)絡(luò) 收藏

          實(shí)現(xiàn)了uboot對(duì)非linux kernel的引導(dǎo)。雖然有一個(gè)IH_TYPE_STANDALONE,但是沒有實(shí)現(xiàn)。nnd。只能自己想辦法。實(shí)現(xiàn)詳細(xì)見下面。

          本文引用地址:http://cafeforensic.com/article/201609/305147.htm

          1、兩個(gè)命令

          set bootcmd tftp 84000000 uImage;bootm 84000000

          set bootdelay 1

          2、非linux kernel的引導(dǎo)實(shí)現(xiàn)方法:

          一共三個(gè)函數(shù): jump,selectboot 和 system_boot

          把jump放在需要跳轉(zhuǎn)的地方,參數(shù)就是要跳轉(zhuǎn)的地址。然后返回,重啟系統(tǒng)。select放在main的開頭。通過判斷ram的特定地址的特定信息實(shí)現(xiàn)跳轉(zhuǎn)。

          system_boot實(shí)現(xiàn)系統(tǒng)的重新啟動(dòng)

          #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);

          }



          關(guān)鍵詞:

          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉