none
Modify eboot to run two OS on one SD-card RRS feed

  • Question

  • Hello!

    I have created a SD-card with two NK.nb0 and an eboot.nb0. The eboot boots the first OS as supposed to, but I want to modify the eboot to load the second OS instead. Does anyone know where to find location in the eboot code?

    I have tried to change IMAGE_BOOT_NKIMAGE_SD_PA_START and IMAGE_BOOT_NKIMAGE_SD_PA_END but it ended up booting the first OS.

    • Edited by icecold123 Friday, April 26, 2013 1:13 PM broken
    Friday, April 26, 2013 1:11 PM

Answers

  • Got i working now!


    * Download the CFImager source code.

    * Modify CStCFBootImager.h from CFImager.v1.7.3.001_bin_2bsrc.zip to able to add the second operating system right after the first one.

    From:

    // sector numbers for i.MX51 layout
    enum {
            kXLDRStart = 0x2,
            kEBOOTStart = 0x100,
            kNKStart = 0x500,
            kBootPartitionSize = 0x2FFFE,         // 94 MBs - 1024 bytes (sector 0 for MBR, sector 1 rsvd)
    };

    To:

    // sector numbers for i.MX51 layout
    enum {
            kXLDRStart = 0x2,
            kEBOOTStart = 0x100,
            kNKStart = 0x304FE,
            kBootPartitionSize = 0x5FFFC,         
    };

    Modify image_cfg.h and image_cfg.inc to boot from the second operating system.

    C:\WINCE700\platform\<platform>\SRC\INC\image_cfg.h

    C:\WINCE700\platform\<platform>\SRC\INC\image_cfg.inc

    From:
    #define IMAGE_BOOT_NKIMAGE_SD_OFFSET        (IMAGE_BOOT_BOOTIMAGE_SD_OFFSET+IMAGE_BOOT_BOOTIMAGE_SD_SIZE +IMAGE_BOOT_RESERVED_IMAGE_SD_SIZE)

    To:

    #define IMAGE_BOOT_NKIMAGE_SD_OFFSET        (101317632) //Offset of OS 2 on SD-card

    Use CFImager to create the layout of the SD-card:

    cfimager -f eboot.nb0 -d g -imx51
    
    cfimager -f nk.nb0 -d g -imx51 -a
    
    cfimager_mod -f nk.nb0 -d g -imx51 -a

    This will now boot OS 2, just flash a new eboot to boot OS 1. 


    • Marked as answer by icecold123 Friday, May 3, 2013 7:56 AM
    • Unmarked as answer by icecold123 Friday, May 3, 2013 7:56 AM
    • Edited by icecold123 Friday, May 3, 2013 8:00 AM fix.
    • Marked as answer by icecold123 Friday, May 3, 2013 10:47 AM
    Friday, May 3, 2013 7:48 AM

All replies

  • *** SD-card:

    [ OS 1 |  OS 2 | EMPTY PARTITION | EBOOT ]

    This is how my SD card looks right now, it boots straight to OS 1 (0x500) from eboot, but I want to modify eboot to boot from (0x2FFFE) instead where my OS 2 is located. If I get this working i will create a safe update mechanism for wec7 for an exam project

    Friday, April 26, 2013 1:43 PM
  • Anon, there are more architectures then x86... Most ARM boards use some form of bootloader to get the image from NAND. In x86 world "loadcepc" is the "bootloader", and eboot is just a network transport driver. In CE ARM world, eboot is "loadcepc" + "eboot". It's a bit confusing; just wanted to clear that up for you.

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Friday, April 26, 2013 11:42 PM
    Moderator
  • Icecold,

    For you some questions:

    What OS version?
    What CPU?
    What BSP?
    etc.

    Read this: http://guruce.com/blogpost/how-to-ask-questions-on-forums


    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Friday, April 26, 2013 11:50 PM
    Moderator
  • Thanks for you reply.

    This is my setup:

    OS: Windows Embedded Compact 7
    CPU: Freescale i.mx515 (ARMv7)
    BSP: PRJMX51 (Modified version of Freescale iMX51_EVK?)
    Board: Seco Cross Platform Kit

    The system seems to have a boot loader (eboot?) located on the SD-card since it doesn’t start without a card inserted. The SD-card also contains the operating system and that’s where it boots from.

    Its currently layout: [ OS 1 |  OS 2 | EMPTY PARTITION | EBOOT ]

    The first operating system is booting on start, but I want to change the boot up sequence to boot the second operating system. My guess is that I just need to change an address and compile a new eboot and put on the SD-card.

    I found this file:
    WINCE700\platform\PRJMX51\SRC\INC\image_cfg.h 

    Which contains:

    #define IMAGE_BOOT_NKIMAGE_SD_PA_START      (IMAGE_BOOT_SDHCDEV_SD_PA_START+IMAGE_BOOT_NKIMAGE_SD_OFFSET)
    #define IMAGE_BOOT_NKIMAGE_SD_SIZE          IMAGE_BOOT_NKIMAGE_SIZE
    #define IMAGE_BOOT_NKIMAGE_SD_PA_END        (IMAGE_BOOT_NKIMAGE_SD_PA_START+IMAGE_BOOT_NKIMAGE_SD_SIZE-1)

    I tried to switch that to another adress but it still booted the first operating system.

    Also i haven't used the nand on the board so i'm unaware of it contains.
    • Edited by icecold123 Saturday, April 27, 2013 9:29 AM
    Saturday, April 27, 2013 9:27 AM
  • How did you get that 2nd OS flashed in that partition? Is this something you did or was this already configured by the manufacturer of the board? I'm guessing the latter and in that case I very much doubt you'll have to change any code to load the 2nd OS. There's probably an option in the bootloader menu that allows you to select the OS to boot. Best ask the board manufacturer.

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Saturday, April 27, 2013 10:03 AM
    Moderator
  • I created it using a modified version of the Freescale CFImager, this is a software that creates the correct layout of the SD-card to boot the device.

    This is what the layout utility normaly creates on the SD-card: [ OS | EMPTY PARTITION | EBOOT ] 

    I changed it so it creates two different OS partitions, now i just need to figure out how to make it boot from the second OS, I don’t need any menu, just a hard code it to boot the second OS 2.





    • Edited by icecold123 Saturday, April 27, 2013 10:47 AM
    Saturday, April 27, 2013 10:42 AM
  • Hi,

    How did you change it to create two partitions?

    Even I want to test this feature in my i.MX6 platform. 

    Could you please share your ideas?

    Regards,

    Seetharam


    Seeth

    Saturday, April 27, 2013 10:58 AM
  • There can be another way of doing the same in the bootloader as ... Modify the bootloader to check if OS2 is present and boot with it or else boot with OS1 ...

    Checking the existence of OS2 and download if present or download OS1.bin This can be implemented as :

    You can simply copy the two OS's to the SD card ...

                if(!SDFileInit())
                {
                    OALLog(L"SD file io init failed\r\n");
                }
                OALLog(L"Checking for OS2 \r\n");
                 memset(file, 0, 20);
                wcscpy(file, L"OS2.bin");

                len = BLSDImageDownload(file);
                if((!len) || (len == BL_ERROR))
                {
                    OALLog(L" OS2.bin file not found..\r\n");

                     memset(file, 0, 20);
                wcscpy(file, L"OS1.bin");           

                len = BLSDImageDownload(file);               
                }

    ---- Misbah        


    Senior Design Engineer T.E.S Electroni Solutions (Bangalore-India) www.tes-dst.com email-misbah.khan@tes-dst.com

    Monday, April 29, 2013 12:05 PM
  • Got i working now!


    * Download the CFImager source code.

    * Modify CStCFBootImager.h from CFImager.v1.7.3.001_bin_2bsrc.zip to able to add the second operating system right after the first one.

    From:

    // sector numbers for i.MX51 layout
    enum {
            kXLDRStart = 0x2,
            kEBOOTStart = 0x100,
            kNKStart = 0x500,
            kBootPartitionSize = 0x2FFFE,         // 94 MBs - 1024 bytes (sector 0 for MBR, sector 1 rsvd)
    };

    To:

    // sector numbers for i.MX51 layout
    enum {
            kXLDRStart = 0x2,
            kEBOOTStart = 0x100,
            kNKStart = 0x304FE,
            kBootPartitionSize = 0x5FFFC,         
    };

    Modify image_cfg.h and image_cfg.inc to boot from the second operating system.

    C:\WINCE700\platform\<platform>\SRC\INC\image_cfg.h

    C:\WINCE700\platform\<platform>\SRC\INC\image_cfg.inc

    From:
    #define IMAGE_BOOT_NKIMAGE_SD_OFFSET        (IMAGE_BOOT_BOOTIMAGE_SD_OFFSET+IMAGE_BOOT_BOOTIMAGE_SD_SIZE +IMAGE_BOOT_RESERVED_IMAGE_SD_SIZE)

    To:

    #define IMAGE_BOOT_NKIMAGE_SD_OFFSET        (101317632) //Offset of OS 2 on SD-card

    Use CFImager to create the layout of the SD-card:

    cfimager -f eboot.nb0 -d g -imx51
    
    cfimager -f nk.nb0 -d g -imx51 -a
    
    cfimager_mod -f nk.nb0 -d g -imx51 -a

    This will now boot OS 2, just flash a new eboot to boot OS 1. 


    • Marked as answer by icecold123 Friday, May 3, 2013 7:56 AM
    • Unmarked as answer by icecold123 Friday, May 3, 2013 7:56 AM
    • Edited by icecold123 Friday, May 3, 2013 8:00 AM fix.
    • Marked as answer by icecold123 Friday, May 3, 2013 10:47 AM
    Friday, May 3, 2013 7:48 AM