ESP32 S3 ee.vld.128.ip instruction crashes

aaronw
Posts: 14
Joined: Fri Apr 17, 2020 4:33 am

ESP32 S3 ee.vld.128.ip instruction crashes

Postby aaronw » Mon Oct 17, 2022 8:27 pm

When I insert the instruction ee.vld.128.ip instruction into my code I get a trap. The address I am passing is correct, it is 16 byte aligned (actually 64 byte aligned) and readable using l32i. This is on an ESP32 S3.

aaronw
Posts: 14
Joined: Fri Apr 17, 2020 4:33 am

Re: ESP32 S3 ee.vld.128.ip instruction crashes

Postby aaronw » Mon Oct 17, 2022 8:28 pm

Note that the almost identical code that doesn't use the ee.vld.128.ip instruction works fine.

Here is my code:
  1.     volatile register uint32_t *pItem = (uint32_t *)mRMT_mem_ptr;
  2.     for (register int i = 0; i < PULSES_PER_FILL/8; i++) {
  3.         if (mCur < mSize) {
  4.             register uint32_t tmp1, tmp2, tmp3, tmp4;
  5. #if 1
  6.             register uint8_t pData = mPixelData[mCur];
  7.             register rmt_item32_t *bitTablePtr = &bitTable[0][0];
  8. #if 1
  9.             // This is a slight speedup by not waiting for the load stall
  10.             // cycles.  By the time the load is finished, the store should
  11.             // be ready.  Stores aren't as critical due to a write buffer,
  12.             // but you can't immediately store after loading without losing
  13.             // a couple of cycles due to pipeline stalls.
  14.             __asm__ __volatile__(
  15.                 // Get upper nibble of color and multiply it by 16 to
  16.                 // get the address in the table
  17.                 "   srli            %[tmp], %[p], 4             \n"
  18.                 "   slli            %[tmp], %[tmp], 4           \n"
  19.                 // Add color nibble as offset to table
  20.                 "   add.n           %[tmp], %[tmp], %[bitTable] \n"
  21.                 // Load 4 words from table
  22.                 "   l32i            %[tmp1], %[tmp],0           \n"
  23.                 "   l32i            %[tmp2], %[tmp],4           \n"
  24.                 "   l32i            %[tmp3], %[tmp],8           \n"
  25.                 "   l32i            %[tmp4], %[tmp],12          \n"
  26.                 // Store 4 words to RMT memory
  27.                 "   s32i            %[tmp1], %[pRmtMem], 0x0     \n"
  28.                 "   s32i            %[tmp2], %[pRmtMem], 0x4     \n"
  29.                 "   s32i            %[tmp3], %[pRmtMem], 0x8     \n"
  30.                 "   s32i            %[tmp4], %[pRmtMem], 0xc     \n"
  31.                 // Take the lower nibble and multiply it by 16 to
  32.                 // get the address in the table
  33.                 "   extui           %[tmp], %[p], 0, 4          \n"
  34.                 "   slli            %[tmp], %[tmp], 4           \n"
  35.                 // Add color nibble as offset to table
  36.                 "   add.n           %[tmp], %[tmp], %[bitTable] \n"
  37.                 // Load 4 words from table
  38.                 "   l32i            %[tmp1], %[tmp],0           \n"
  39.                 "   l32i            %[tmp2], %[tmp],4           \n"
  40.                 "   l32i            %[tmp3], %[tmp],8           \n"
  41.                 "   l32i            %[tmp4], %[tmp],12          \n"
  42.                 // Store 4 words to RMT memory
  43.                 "   s32i            %[tmp1], %[pRmtMem], 0x10   \n"
  44.                 "   s32i            %[tmp2], %[pRmtMem], 0x14   \n"
  45.                 "   s32i            %[tmp3], %[pRmtMem], 0x18   \n"
  46.                 "   s32i            %[tmp4], %[pRmtMem], 0x1c   \n"
  47.                 // Update RMT memory pointer
  48.                 "   addi.n          %[pRmtMem], %[pRmtMem], 0x20\n"
  49.                 // Flush the writes
  50.                 "   memw                                        \n"
  51.                 : [tmp] "=&r"(tmp), [pRmtMem] "+r"(pItem),
  52.                   [tmp1] "=&r"(tmp1),[tmp2] "=&r"(tmp2),
  53.                   [tmp3] "=&r"(tmp3), [tmp4] "=&r"(tmp4)
  54.                 : [bitTable] "r"(bitTablePtr), [p] "r"(pData)
  55.                 : );
  56. #else
  57.             // This attempts to do the same thing but with the vector load
  58.             // instructions.  This crashes for some unknown reason when the
  59.             // ee.vld.128.ip instruction hits.  It's not due to alignment
  60.             // but for some reason the ee instruction is barfing on the address.
  61.             __asm__ __volatile__(
  62.                 "   srli            %[tmp], %[p], 4             \n"
  63.                 "   slli            %[tmp], %[tmp], 4           \n"
  64.                 "   add.n           %[tmp], %[tmp], %[bitTable] \n"
  65.                 "   mov.n           a15, %[tmp]                 \n"
  66.                 "   l32i            a14, %[tmp], 0              \n"
  67.                 "   ee.vld.128.ip   q0,%[tmp],0                 \n"
  68.                 "   extui           %[tmp], %[p], 0, 4          \n"
  69.                 "   slli            %[tmp], %[tmp], 4           \n"
  70.                 "   add.n           %[tmp], %[tmp], %[bitTable] \n"
  71.                 "   ee.vld.128.ip   q1,%[tmp],0                 \n"
  72.                 "   ee.movi.32.a    q0, %[tmp], 3               \n"
  73.                 "   s32i            %[tmp], %[pRmtMem], 0x0     \n"
  74.                 "   ee.movi.32.a    q0, %[tmp], 2               \n"
  75.                 "   s32i            %[tmp], %[pRmtMem], 0x4     \n"
  76.                 "   ee.movi.32.a    q0, %[tmp], 1               \n"
  77.                 "   s32i            %[tmp], %[pRmtMem], 0x8     \n"
  78.                 "   ee.movi.32.a    q0, %[tmp], 0               \n"
  79.                 "   s32i            %[tmp], %[pRmtMem], 0xc     \n"
  80.                 "   ee.movi.32.a    q1, %[tmp], 3               \n"
  81.                 "   s32i            %[tmp], %[pRmtMem], 0x10    \n"
  82.                 "   ee.movi.32.a    q1, %[tmp], 2               \n"
  83.                 "   s32i            %[tmp], %[pRmtMem], 0x14    \n"
  84.                 "   ee.movi.32.a    q1, %[tmp], 1               \n"
  85.                 "   s32i            %[tmp], %[pRmtMem], 0x18    \n"
  86.                 "   ee.movi.32.a    q1, %[tmp], 0               \n"
  87.                 "   s32i            %[tmp], %[pRmtMem], 0x1c    \n"
  88.                 "   addi            %[pRmtMem],%[pRmtMem], 0x20 \n"
  89.                 "   memw                                        \n"
  90.                 : [tmp] "=&r"(tmp), [pRmtMem] "+r"(pItem)
  91.                 : [bitTable] "r"(bitTablePtr), [p] "r"(pData)
  92.                 : "a14", "a15");
  93. #endif
  94.             mCur++;

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: ESP32 S3 ee.vld.128.ip instruction crashes

Postby ESP_igrr » Mon Oct 17, 2022 9:17 pm

Is this the same issue you have described in https://esp32.com/viewtopic.php?f=2&t=30121? If yes, please avoid creating duplicate topics. If no, could you please point out the difference?

Who is online

Users browsing this forum: No registered users and 106 guests