c - U-Boot: Unexpected problems porting code -


i want extend u-boot spl code fuzzy extractor logic adding code {u-boot_sources}/arch/arm/cpu/armv7/omap-common/hwinit-common.c. u-boot shall used on pandaboard es (omap4460 soc).

thus, first implemented code on x86 pc , porting arm-based pandaboard. complete code can found here (as side note "main" function s_init()):

http://pastebin.com/iaz13yn9

however, expecting dozens of unexptected effects, results in either stopping during execution of code, stopping u-boot after reading u-boot.img or not sending output (and not booting) @ all.

for example, want call 2 functions (computesyndrome, decodeerrors) inside for-loop, part of function golaydecode.

for first problem please ignore code below multiline comment starting /* >>>> these lines of code below totally break u-boot. function computesyndrome in conjunction calling function golaydecode important.

the issue: if comment out both functions computesyndrome , decodeerrors works fine , os (android) booting. however, if computesyndrome not commented out , gets processed, u-boot stucks after displaying reading u-boot.img. funny thing it: if replace computesyndrome bogus function not iterating values or displaying stuff, u-boot stucks well.

furthermore, if remove multiline comment furhter below include residual code, u-boot doesn't display ony character. (1*)

i beginner regarding microprocessor programming can not figure out possible error in these 12 lines of computesyndrome function or general behaviour of u-boot @ all. (2*)

does have clue missing?

thanks, p.

1* using minicom display output of u-boot, receive on serial-usb-converter.
2* using following compiler flags make sure there no errors @ compile time: -wall -wstrict-prototypes -wdisabled-optimization -w -pedantic

void golaydecode(volatile int x[12], volatile int y[12], volatile unsigned int golayencodedsecret[30], volatile unsigned int s, volatile unsigned char repetitiondecodedsecretbits[360]){  printf("\n[i] - performing golay decoding\r\n"); volatile unsigned char secret[22] = {0}; volatile unsigned char currentbyte = 0, tmpbyte = 0; volatile unsigned int golaydecodedsecret[30] ={0}; volatile int twelvebitcounter = 0;//, j = 0, k = 0, q = 0, aux = 0, found = 0, bitcounter = 0, i_2 = 7, currentsecretencbyte = 0x00; volatile int c_hat[2] = {0}, e[2] = {0}; e[0] = s; e[1] = 0;  for(twelvebitcounter = 0; twelvebitcounter < 30; twelvebitcounter+=2){     printf("computing syndrome , decoding errors bytes %03x & %03x\n", golayencodedsecret[twelvebitcounter], golayencodedsecret[twelvebitcounter+1]);       computesyndrome(golayencodedsecret[twelvebitcounter], golayencodedsecret[twelvebitcounter+1], x, y, s);       decodeerrors(golayencodedsecret[i], golayencodedsecret[i+1], x, y, s); }  printf("\n[d] - reconstructing secret bytes\r\n");   /*        >>>> these lines of code below totally break u-boot for(i = 0; < 30; i+=2){     currentsecretencbyte = golaydecodedsecret[i];     volatile int j = 11;      // access each source bit            for(; 0<=j; j--){                    volatile int currentsourcebit = (currentsecretencbyte >> j) & 0x01;           repetitiondecodedsecretbits[bitcounter] = currentsourcebit;         bitcounter++;     } }  k = 0; for(i = 0; i<176; i++){     tmpbyte =  repetitiondecodedsecretbits[i] << i_2;     currentbyte = currentbyte | tmpbyte;     i_2--;     if(i_2==0){ // collected 8 bits , created byte         secret[k] = currentbyte;         i_2 = 7;         tmpbyte = 0x00;         currentbyte = 0x00;         k++;     }        }  sha256_ctx ctx; unsigned char hash[32];  printf("\n[i] - generating secret key k\n"); sha256_init(&ctx); sha256_update(&ctx,secret,strlen((const char*)secret)); sha256_final(&ctx,hash);  printf("\n[i] - our secret key k\n\t==================================\n\t"); print_hash(hash); printf("\t==================================\n"); */ }   /* function syndrome computation */ void computesyndrome(int r0, int r1, volatile int x[12], volatile int y[12], volatile unsigned int s){ unsigned int syndromebitcounter, syndromematrixcounter, syndromeaux;  s = 0; for(syndromematrixcounter=0; syndromematrixcounter<12; syndromematrixcounter++){     syndromeaux = 0;      for(syndromebitcounter=0; syndromebitcounter<12; syndromebitcounter++){         syndromeaux = syndromeaux^((x[syndromematrixcounter]&r0)>>syndromebitcounter &0x01);     }     for(syndromebitcounter=0; syndromebitcounter<12; syndromebitcounter++){         syndromeaux = syndromeaux^((y[syndromematrixcounter]&r1)>>syndromebitcounter &0x01);     }     s = (s<<1)^syndromeaux;  } }    /* funcion recover original byte */ void decodeerrors(int r0, int r1, volatile int x[12], volatile int y[12], volatile unsigned int s){ //printf("\n[d] - starting decode errors %3x | %3x\n", r0, r1); volatile unsigned int c_hat[2] = {0xaa}, e[2] = {0xaa}; volatile unsigned int q; unsigned int i, j, aux, found;  //printf("step 2\n"); if(weight(s)<=3){     e[0] = s;     e[1] = 0; }else{     /******* step 3 */     //printf("step 3\n");     = 0;     found = 0;     do{         if (weight(s^y[i]) <=2){                 e[0] = s^y[i];                 e[1] = x[i];                 found = 1;             printf("\ntest 2\n");         }         i++;         }while ((i<12) && (!found));          if (( i==12 ) && (!found)){          /******* step 4 */         //printf("step 4\n");         q = 0;         (j=0; j<12; j++){                 aux = 0;                 (i=0; i<12; i++)                 aux = aux ^ ( (y[j]&s)>>i & 0x01 );                  q = (q<<1) ^ aux;             }          /******* step 5 */         //printf("step 5\n");         if (weight(q) <=3){                 e[0] = 0;                 e[1] = q;             }else{                 /******* step 6 */                 //printf("step 6\n");                 = 0;                 found = 0;                 do{                 if (weight(q^y[i]) <=2){                         e[0] = x[i];                         e[1] = q^y[i];                         found = 1;                 }                 i++;             }while((i<12) && (!found));                  if ((i==12) && (!found)){                 /******* step 7 */                 printf("\n[e] - uncorrectable error pattern! (%3x | %3x)\n", r0, r1);                 /* can raise flag here, or output vector */                 //exit(1);             }         }     } }  c_hat[0] = r0^e[0]; c_hat[1] = r1^e[1]; //printf("\t\testimated codeword = %x%x\n", c_hat[0], c_hat[1]); } 

indeed, code little bit complex executed @ point of boot time. @ time there ne real crt , have minimal stack.
thus, moved code board_init_f() still part of spl. gave more stable results , algorithm works expected.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -