This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

make a common ubl for ipcam and dvr

Hello:

My target is ipcam and dvr use one common UBL.

i.e. ubl_ipcam_dvr.bin can be loaded in ipcam and dvr without rebuild or modify  and it can boot ipcam and dvr .

the differences of ubl between ipcan and dvr are “pll1,pll2,and ddr2..” in device.c of separate UBL.pjt.

 

according to a narration in device.c of dm368 dvr:

#ifdef DM368_DVR

        DEVICE_pinmuxControl(0,0xFFFFFFFF,0x00FC0000); 

      DEVICE_pinmuxControl(1,0xFFFFFFFF,0x00040000); 

      ………..

 

#else

      DEVICE_pinmuxControl(0,0xFFFFFFFF,0x00FD0000);        

DEVICE_pinmuxControl(1,0xFFFFFFFF,0x00145555); 

      ………..

endif

=========================================================

I want to modify as below:

#ifdef DM368_DVR  //if device is dvr

        DEVICE_pinmuxControl(0,0xFFFFFFFF,0x00FC0000); 

      DEVICE_pinmuxControl(1,0xFFFFFFFF,0x00040000); 

      ………..

#ifdef IPNC_DM368  //if device is ipcam

      DEVICE_pinmuxControl(0,0xFFFFFFFF,0x00FD0000);        

DEVICE_pinmuxControl(1,0xFFFFFFFF,0x00145555); 

      ………..

endif

But, I search all sources and headers in UBL.pjt, I can’t find where the keyword, “DM368_DVR” define in.

I right click the UBL.pjt and select “Open for Editing” and there is a sentence as below:

["Compiler" Settings: "BOOT_NAND"]

Options=-o3 -fr"$(Proj_dir)\NAND" -fs"$(Proj_dir)\NAND" -i"$(Proj_dir)\include" -i"$(Proj_dir)\..\..\..\Common\arch\arm926ejs\include" -i"$(Proj_dir)\..\..\..\Common\ubl\include" -i"$(Proj_dir)\..\..\..\Common\gnu\include" -i"$(Proj_dir)\..\..\Common\include" -i"$(Proj_dir)\..\..\..\Common\include" -i"$(Proj_dir)\..\..\..\Common\drivers\include" -d"UBL_NAND" -d"DM368_DVR" -me -mv5e --abi=eabi --symdebug:none

The word “DM368_DVR” only appears in this sentence…

 

Do you know what place I can define the keywords, “DM368_DVR” and “IPNC_DM368” let  the two device identify their own word and execute their relevant act.

Or is there any other way ??

Thank you very much~~~

  • Hi,

    Pei Wei-Dyi said:
    Do you know what place I can define the keywords, “DM368_DVR” and “IPNC_DM368” let  the two device identify their own word and execute their relevant act.

    As you noticed, the definition of DM368_DVR is done in the project specific settings of UBL. That is one place where you can set the definitions using -d. This means the configuration selection for DVR or IPCAM will be specific to compile time and in turn means you would have two UBLs, one for IPCAM and other for DVR.

    Now, to make it generic, you would need to decide runtime whether the system is IPCAM or DVR. There are few options that can be used:

    1. Use one of the GPIOs - Tie it high on IPCAM hardware and low on DVR hardware. In the UBL read the status of this GPIO and use corresponding code for IPCAM or DVR

    2. Use some magic number programmed on the NAND - Program some magic number specific to IPCAM or DVR. Read that block of NAND and parse the magic number. Based on the magic number, you can select whether the product is IPCAM or DVR.

    Hope this helps.

    Regards,

    Anshuman

    PS: Please mark this post as verified if you think it has answered your question. Thanks.

     

  • hello Anshuman:

    thank you very much for telling me about these 2 methods,

    but,i still have no idea...

    can you tell me more details ,e.g. where i can program to ??

    set gpio registers or magic numbers in device.c ??...

    thank you very much~~

  • Hi,

    Firstly pick a GPIO on DM365 that is not used in any other peripheral connection. There are 104 odd GPIOs available on DM365. Please ensure that the GPIO comes up as a GPIO during reset.

    You would have to modify device.c to read the GPIO value first. Based on your hardware connection, your GPIO might be tied high or low. Once you read GPIO, you can go into IPNC or DVR mode. APIs to readd GPIO are shown in UBL itself (device.h and device.c). You have to use GPIO->INDATA0x registers to read the corresponding GPIO.

    Hope this helps.

    Regards,

    Anshuman

    PS: Please mark this post as verified, if you think it has answered your question. Thanks.

  • hello Anshuman:

    thank you very much for telling me about gpio method, and now i know how does it work~~

    and i am more intrested in how to setting magic number to nand.

    how could i program magic number on nand before ubl runs and let ubl reads them from nand??

    can you teach me more detials about this ~~

    thank you very much~~

  • Hi,

    The magic number implementation that is proposed is complete software implementation. In your NAND programming, you need to reserve a block on NAND. This block of NAND has to be written with some magic number that you decide. When UBL starts, it reads this block first and then goes on reading uBoot etc.

    Based on the magic number, you would have to do the selection of pinmux for IPCamera or DVR.

    Again, i would recommend you to go through the boot process in the datasheet and the PSP package to understand how UBL reads uBoot and then you can try implementing your own magic number framework.

    Regards,

    Anshuman

  • hello Anshuman:

    i tried setting pinumx1:: DEVICE_pinmuxControl(1,0xFFFFFFFF,0x00430000);,and

    set GIO[83] as input::GPIO->DIR45|=0x00080000;then

    read the status of GPIO[83]::if((GPIO->INDTATA45 & 0x00080000)==0x00080000)

                                              ipcam.....

                                              else

                                              dvr.........

    i write above code in device_init() in device.c

    but it can't boot my ipcam board...??

    do i miss something??

    can i set gpio at preprocess phase...??

    can you give a tip!

    thank you very much!!

  • Hi,

    Are you able to jump to dvr board mode?

    Did you change the GPIO value on the hardware board to switch it high or low?

    Regards,

    Anshuman

  • hello Anshuman:

    yes,

    there is a switch on my board ,

    it's gpio[83] ,if it is high to ipcam and low to dvr

    the difference between ipcam and dvr are pll1,pll2,and ddr initialize...as below:

    if(gpio->indata45==1)

      ipcam_ddr_init...

    else

     dvr_ddr_init...

  • So you are saying irrespective of what you do on the switch on our board, you are always ending up in dvr_ddr_init?

    regards,

    Anshuman

  • hello Anshuman:

    thank for teching me ~

    now i can use gpio to make a common ubl between ipcam and dvr.

    but i still remain some questions:

    1.i set gpio before device initial~~why can gpio work before device initial??

    2.about magic number~~ i still not understand...that magic number is stored in nand flash~

       and is readed by ubl ~ how can i program magic number on nand before ubl...??

    i still want to try magic number~~

    thank you very much~~~~~~!!!!