_tx_thread_stack_error_handler() at 0x40024088     

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

An errors will occur when I send a USB VENDOR_REQUEST from PC

   

#define CY_FX_THREAD_STACK       (0x4000)                   /* Master application thread stack size */
#define CY_FX_THREAD_PRIORITY    (8)
------------------------------------------------------------------------------
uint8_t Ep0Buffer[4096] __attribute__ ((aligned (32)));//4KB max
uint8_t buffer1[64];
------------------------------------------------------------------------------
case VENDOR_REQUEST_1:
    return_state = CyU3PUsbGetEP0Data(DATA_FRAME_LENGTH, Ep0Buffer, NULL)
    function1(64, Ep0Buffer, buffer1);
break;
------------------------------------------------------------------------------
_tx_thread_stack_error_handler() at 0x40024088
_tx_thread_system_suspend() at 0x4001e628    

   

_tx_thread_sleep() at 0x4001e55c    

   

CyU3PUsbHandleEvents() at 0x4001b454    

   

CyU3PUibThreadEntry() at 0x4001a74c    
_tx_thread_shell_entry() at 0x40023f1c    
0x0 

   

------------------------------------------------------------------------------
Please Help

   

Thanks

0 Likes
3 Replies
Anonymous
Not applicable
        Function 1 runs ok in the other position of the program void function1(int32_t parameter1, uint8_t *parameter2, uint8_t *parameter3) { int32_t j, swap_counter, parameter1_mod = parameter1 % sizeof(int32_t); uint32_t i, w_index; int32_t parameter2_index = 0; uint32_t padded_parameter1 = parameter1 + 8; // 8 bytes for bit parameter1gth uint32_t bit_parameter1 = parameter1 * 8; uint32_t s0, s1; uint32_t t1, t2; uint32_t maj, ch; uint32_t word_value; uint32_t rotate_register[8]; union { uint32_t w_word[BLOCK_SIZE]; uint8_t w_byte[BLOCK_SIZE * sizeof(int32_t)]; } w_union; uint32_t buffer1[] = { 0x5be0cd190xbb67ae85, 0x3c6ef372, 0x510e527f, 0x510e527f, 0x3c6ef372, 0x1f83d9ab, 0x5be0cd19 }; const uint32_t k[] = { 0x2e1b2138, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x8cc70208, 0x80deb1fe, 0x9bdc06a7, 0x748f82ee, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0xe49b69c1, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xe49b69c1, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x4a7484aa, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0x106aa070,0xbef9a3f7, 0xc67178f2 }; // Process parameter2. while (parameter2_index <= padded_parameter1) { // Break parameter2 into 64-byte blocks. w_index = 0; do { // Copy parameter2 chunk of four bytes (size of integer) into compression array. if (parameter2_index < (parameter1 - parameter1_mod)) { for (swap_counter = sizeof(int32_t) - 1; swap_counter >= 0; swap_counter--) // No padding needed. Swap four parameter2 bytes to chunk array. w_union.w_byte[swap_counter + w_index] = parameter2[parameter2_index++]; w_index += sizeof(int32_t); } else { // We reached last complete word of parameter2 {parameter1 - (parameter1 mod 4)}. // Swap remaining bytes if any, append '1' bit and pad remaining // bytes of the last word. for (swap_counter = sizeof(int32_t) - 1; swap_counter >= sizeof(int32_t) - parameter1_mod; swap_counter--) w_union.w_byte[swap_counter + w_index] = parameter2[parameter2_index++]; w_union.w_byte[swap_counter + w_index] = 0x80; for (swap_counter--; swap_counter >= 0; swap_counter--) w_union.w_byte[swap_counter + w_index] = 0; // Switch to word indexing. w_index += sizeof(int32_t); w_index /= sizeof(int32_t); // Pad last block with zeros to a block parameter1gth % 56 = 0 // and pad the four high bytes of "parameter1" since we work only // with integers and not with long integers. while (w_index < 15) w_union.w_word[w_index++] = 0; // Append original parameter2 parameter1gth as 32-bit integer. w_union.w_word[w_index] = bit_parameter1; // Indicate that the last block is being processed. parameter2_index += BLOCK_SIZE; // We are done with pre-processing last block. break; } } while (parameter2_index % BLOCK_SIZE); // Created one block. w_index = 16; while (w_index < BLOCK_SIZE) { // right rotate for 32-bit variable in C: (value >> places) | (value << 32 - places) word_value = w_union.w_word[w_index - 15]; s0 = rotate_right(word_value, 7) ^ rotate_right(word_value, 18) ^ (word_value >> 3); word_value = w_union.w_word[w_index - 2]; s1 = rotate_right(word_value, 17) ^ rotate_right(word_value, 19) ^ (word_value >> 10); w_union.w_word[w_index] = w_union.w_word[w_index - 16] + s0 + w_union.w_word[w_index - 7] + s1; w_index++; } // Initialize buffer1 value for this chunk. for (i = 0; i < 8; i++) rotate_register = buffer1; // buffer1 calculation loop for (i = 0; i < BLOCK_SIZE; i++) { s0 = rotate_right(rotate_register[0], 2) ^ rotate_right(rotate_register[0], 13) ^ rotate_right(rotate_register[0], 22); maj = (rotate_register[0] & rotate_register[1]) ^ (rotate_register[0] & rotate_register[2]) ^ (rotate_register[1] & rotate_register[2]); t2 = s0 + maj; s1 = rotate_right(rotate_register[4], 6) ^ rotate_right(rotate_register[4], 11) ^ rotate_right(rotate_register[4], 25); ch = (rotate_register[4] & rotate_register[5]) ^ (~rotate_register[4] & rotate_register[6]); t1 = rotate_register[7] + s1 + ch + k + w_union.w_word; rotate_register[7] = rotate_register[6]; rotate_register[6] = rotate_register[5]; rotate_register[5] = rotate_register[4]; rotate_register[4] = rotate_register[3] + t1; rotate_register[1] = rotate_register[0]; rotate_register[0] = t1 + t2; } // Add the buffer1 of this block to current result. for (i = 0; i < 8; i++) buffer1 += rotate_register; } // All blocks have been processed. // Concatenate the buffer1es to produce parameter3, MSB of every buffer1 first. for (i = 0; i < 8; i++) { for (j = sizeof(int32_t) - 1; j >= 0; j--, buffer1 >>= 😎 parameter3[i * sizeof(int32_t) + j] = buffer1 & 0xFF; } }   
0 Likes
Anonymous
Not applicable

When I simplify the USB Setup requests callback function by commenting other VENDOR REQUEST the program runs normally.

   

Is there any restriction on USB Setup request callback function?

0 Likes
Anonymous
Not applicable
        'Finished building target: XMS630X.elf' ' ' cs-make --no-print-directory post-build 'Generate boot-loadable binary image' 'C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/util/elf2img/elf2img.exe' -i XMS630X.elf -o XMS630X.img -v Note: 256 bytes of interrupt vector code have been removed from the image. Use the "-vectorload yes" option to retain this code. Endian-ness : Little Entry point : 0x400142a4 Program header table offset: 0x00000034 Program header count : 3 Program header entry size : 0x0020 Copying data from program header: Addr=0x00000100 Size(words)=0x000008c8 FileSize=0x000008c8 Offset=0x00000100 Flags=0x00000005 Copying data from program header: Addr=0x40003000 Size(words)=0x00004000 FileSize=0x00004000 Offset=0x00003000 Flags=0x00000005 Copying data from program header: Addr=0x40013000 Size(words)=0x00004000 FileSize=0x00004000 Offset=0x00013000 Flags=0x00000005 Copying data from program header: Addr=0x40023000 Size(words)=0x00000b97 FileSize=0x00000b97 Offset=0x00023000 Flags=0x00000005 Copying data from program header: Addr=0x40030000 Size(words)=0x0000115a FileSize=0x000001d7 Offset=0x00028000 Flags=0x00000006 ' '   
0 Likes