This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem erasing sectors ( IAP_EraseSec )

Hi,

I need help. I'm using the IAP, secondary bootloader.
I'm having a problem erasing sectors.
When I try to erase a sector, it hangs at function "iap_entry(command, result)" in erase function.

It passes through Prepare function successfully.

The code:

#define IAP_LOCATION   0x7FFFFFF1
#define IAP_CLK        48000000
#define AP_ADDR        0x10000// where the user app located

typedef void (*FP)(void);/* run the user application from pre-specified address*/

#define iap_entry(a, b)     ((void (*)())(IAP_LOCATION))(a, b)

unsigned long  command[5];
unsigned long  result[3];

The ERASE FUNCTION:

unsigned long IAP_EraseSec (unsigned long StartSecNum,  unsigned long EndSecNum)
{
        if (EndSecNum < StartSecNum)
                return IAP_STA_INVALD_PARAM;
        command[0] = IAP_CMD_EraseSec;
        command[1] = StartSecNum;
        command[2] = EndSecNum;
        command[3] = IAP_CLK / 1000;
        _printf("\r\n*******ERASE3************");
        iap_entry(command, result);
        _printf("\r\n*******ERASE4************");

        return result[0];
}

The PREPARE FUNCTION:(that one works ok)

unsigned long IAP_PrepareSec (unsigned long StartSecNum, unsigned long EndSecNum)
{
        if (EndSecNum < StartSecNum)
                return IAP_STA_INVALD_PARAM;
        command[0] = IAP_CMD_EraseSec;
        command[1] = StartSecNum;
        command[2] = EndSecNum;
        command[3] = IAP_CLK / 1000;
        _printf("\r\n*******ERASE3************");
        iap_entry(command, result);
        _printf("\r\n*******ERASE4************");

        return result[0];
}


Can anyone help me?

thanks

Parents
  • Yeah..I don't think so..

    Because the user code begins at sector 9 (0x10000)..
    And I send the command to erase exactly this sector.

    An important thing I forgot to say is the sector is erased correctly!
    In Flash Magic we have a tool that displays the Memory and I´ve compared before and after and the sector 9 really is erased!

    I put some debugs in the code an I've found exactly where it stops.
    In Erase function:

    unsigned long IAP_EraseSec (unsigned long StartSecNum,  unsigned long EndSecNum)
    {
    ...
    iap_entry(command, result); // THE PROBLEM IS RIGHT HERE!
    // nothing after that is executed
    }
    

    Thanks!

Reply
  • Yeah..I don't think so..

    Because the user code begins at sector 9 (0x10000)..
    And I send the command to erase exactly this sector.

    An important thing I forgot to say is the sector is erased correctly!
    In Flash Magic we have a tool that displays the Memory and I´ve compared before and after and the sector 9 really is erased!

    I put some debugs in the code an I've found exactly where it stops.
    In Erase function:

    unsigned long IAP_EraseSec (unsigned long StartSecNum,  unsigned long EndSecNum)
    {
    ...
    iap_entry(command, result); // THE PROBLEM IS RIGHT HERE!
    // nothing after that is executed
    }
    

    Thanks!

Children