AnsweredAssumed Answered

BF527, otp_write, error 9

Question asked by vboman on Oct 7, 2009
Latest reply on Oct 12, 2009 by vboman

Hello,

 

I am trying to write otp memory, but otp_write-function returns always error code 9 (Attempt to access invalid OTP space). I have tried to write public key pages (0x10 - 0x12) and also inside Unsecured general purpose space (pages 0x01C  to  0x0DF). I have tried to write lockbox public key to my own hardware for testing purposes (otp_read works, I was able to read public key area from BF527 evaluation board). In my HW BF527 rev. is 0.2. I cannot test lockbox with my BF527 evaluation board, because it has processor rev. 0.0 (0.2 is required for lockbox).

 

I have used modified lockbox demo (lockbox_example.c):

 

u8 au8_public_key[  ] =

{

    0xA6,0xC0,0x9B,0x8A,0xA0,0x5D,0x1D,0xBB,0x76,0xCE,0x39,0x1E,0x00,0x3D,0x19,0x43,

    0xF2,0x8A,0x36,0x69,0x03,0x00,0x00,0x00,0x1B,0x25,0x2E,0xCD,0xF7,0x6E,0x7F,0x16,

    0x0F,0xE7,0x05,0xB0,0xE1,0xF1,0xD4,0x41,0xC8,0x90,0x7A,0x5F,0x01,0x00,0x00,0x00

};

 

s32 main( s32 argc, s8 *argv[] )

{

    unsigned long ul_error = 0;

    u64  data;

    u32  page;

    int   byte;

    u32  (*otp_read)(u32 page, u32 half, u64 *page_content) = ( void* )0xEF00001A;

    u32  (*otp_write)(u32 page, u32 half, u64 *page_content) = ( void* )0xEF00001C;

    u8   *pu8_p;

    int  index = 0;

 

    pu8_p = ( u8* )&data;

 

 

    /* Initialize system services. */

    InitSystemServices();

 

       // Test write to page 0x50

        data = 0x12345678;

        ul_error = otp_write( 0x50, 0, &data );

        if( 0 != ul_error )

        {

            printf( "OTP write error: 0x%X\n", ul_error );

        }

 

    // Write public key

    for( page = 0x10; page <= 0x12; page++ )

    {     

        // Lower half

        for( byte = 0; byte < 8; byte++ )

        {

            *( pu8_p + byte ) = au8_public_key[ index++ ];

            printf( "0x%02X,", *( pu8_p + byte ) );

        }

        ul_error = otp_write( page, 0, &data );

        if( 0 != ul_error )

        {

            printf( "OTP write error: 0x%X\n", ul_error );

        }

 

        // Higher half

        for( byte = 0; byte < 8; byte++ )

        {

            *( pu8_p + byte ) = au8_public_key[ index++ ];

            printf( "0x%02X,", *( pu8_p + byte ) );

        }

        ul_error = otp_write( page, 1, &data );

        if( 0 != ul_error )

        {

            printf( "OTP write error: 0x%X\n", ul_error );

        }

 

        printf( "\n" );

    }

 

Outcomes