• AVR Freaks

Hot!AN1388 bootloader

Author
cjchiragcool90
Starting Member
  • Total Posts : 45
  • Reward points : 0
  • Joined: 2018/12/28 16:50:33
  • Location: 0
  • Status: offline
2019/01/31 15:42:36 (permalink)
0

AN1388 bootloader

I just started work with AN1388 bootloader.
Could anyone explain me how given two function works?
 
1>As in order to move control from bootloader mode to application mode we have to jump to application code starting address right? How it transferring control from bootloader to application mode using JumpToApp function?What fptr() will do in JumpToApp function?
2> In ValidApp function it is just checking data present on application reset address and if data present it is validates its right?
 

#define USER_APP_RESET_ADDRESS (0x9D006000 + 0x1000)
/********************************************************************
* Function: JumpToApp()
* Overview: Jumps to application.
************************/
void JumpToApp(void)
{
 void (*fptr)(void);
 fptr = (void (*)(void))USER_APP_RESET_ADDRESS;
 fptr();
}

/********************************************************************
* Function: ValidAppPresent()
* Output: TRUE: If application is valid.
* Overview: Logic: Check application vector has
    some value other than "0xFFFFFFFF"
********************************************************************/
BOOL ValidAppPresent(void)
{
 DWORD *AppPtr;
 AppPtr = (DWORD *)USER_APP_RESET_ADDRESS;
 if(*AppPtr == 0xFFFFFFFF)
 {
  return FALSE;
 }
 else
 {
  return TRUE;
 }
}

 
Thanks 
post edited by cjchiragcool90 - 2019/01/31 16:01:48
#1

4 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 17246
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: AN1388 bootloader 2019/01/31 16:25:00 (permalink)
    0
    fptr is a function pointer.
    since it is a pointer to a void function.  And it is pointing at USER_APP_RESET_ADDRESS
    when called it will goto the memory location.
    An ASM Jump would also be a possibility.
    #2
    cjchiragcool90
    Starting Member
    • Total Posts : 45
    • Reward points : 0
    • Joined: 2018/12/28 16:50:33
    • Location: 0
    • Status: offline
    Re: AN1388 bootloader 2019/01/31 16:39:46 (permalink)
    0
    So why they type casting 
    USER_APP_RESET_ADDRESS into  (void(*)(void))USER_APP_RESET_ADDRESS
    Cant we directly assign address of USER_APP_RESET_ADDRESS to fptr?
    ex. fptr= &USER_APP_RESET_ADDRESS
     
    @NKurzman
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 17246
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: AN1388 bootloader 2019/01/31 16:46:33 (permalink)
    0
    Yes and No  USER_APP_RESET_ADDRESS in an integer that is the value of the address.
    A function pointer wants the address of a function.  so it would work , but the compiler would complain about the mismatch.
    The cast stops the compiler warning.
     
    and it would be  fptr = USER_APP_RESET_ADDRESS
    #4
    cjchiragcool90
    Starting Member
    • Total Posts : 45
    • Reward points : 0
    • Joined: 2018/12/28 16:50:33
    • Location: 0
    • Status: offline
    Re: AN1388 bootloader 2019/01/31 16:49:59 (permalink)
    0
    Ok .
    because this scenario is different than what I used before with function pointer.
    I used function pointer for pointing to functions.
    Here we are using function pointer with address.
    So as we want to execute instruction from this address we are type casting this address and passing into fptr so it will start executing instruction from that address right.
     
     
    @NKurzman
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5