xmos / xscope_fileio

FileIO interface over xscope
Other
2 stars 10 forks source link

xscope_fread() fails with Windows host #30

Closed mbanth closed 2 years ago

mbanth commented 2 years ago

Calling xscope_fread() in xscope_io_device.c causes an Illegal Resource exception as shown below:

C:\Users\michaelb\sandboxes\sln_hark\build>nmake run_application_hark

Microsoft (R) Program Maintenance Utility Version 14.25.28610.4
Copyright (C) Microsoft Corporation.  All rights reserved.

Run application
xrun: Program received signal ET_ILLEGAL_RESOURCE, Resource exception.
      [Switching to tile[0] core[5]]
      0x00084174 in xscope_data_from_host (c=2147614722, buf=@0x8a5bc, n=@0x8a58c) at xscope_shared_xc.xc:44

      44        xscope_shared_xc.xc: No such file or directory.
        in xscope_shared_xc.xc
NMAKE : fatal error U1077: '"C:\Program Files (x86)\XMOS\XTC\15.1.4\bin\xrun.EXE"' : return code '0x7d'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x86\nmake.exe"' : return code '0x2'
Stop.

This failure was seen when running the non-premeptive FreeRTOS Hark application from the sln_hark repository. The dump state after the execption appears below:

C:\Users\michaelb\sandboxes\sln_hark\build>xrun --dump-state application_hark.xe
xrun: Program received signal ET_KCALL, KCALL instruction executed.
      vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
      94            asm volatile("waiteu");
      Current language:  auto; currently minimal

      ***** Active Cores *****
        11 tile[1] core[4]  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
        10 tile[1] core[3]  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
        9  tile[1] core[2]  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
        8  tile[1] core[1]  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
        7  tile[1] core[0]  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
        6  tile[0] core[5]  0x00084174 in xscope_data_from_host (c=2147614722, buf=@0x8a5bc, n=@0x8a58c) at xscope_shared_xc.xc:44
        5  tile[0] core[4]  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
        4  tile[0] core[3]  __xcore_lock_acquire (__l=773) at C:\Program Files (x86)\XMOS\XTC\15.1.4\target/include\xcore/_support\xcore_lock_impl.h:19
        3  tile[0] core[2]  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
        2  tile[0] core[1] (dual issue)  xscope_connect_data_from_host (from_host=<value optimized out>) at xscope_shared_xc.xc:69
      * 1  tile[0] core[0]  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94

      Thread 11 (tile[1] core[4]):

      ***** Call Stack *****
      #0  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
      #1  0x00082afa in prvMinimalIdleTask (pvParameters=0x1b) at C:\Users\michaelb\sandboxes\sln_hark\xcore_sdk\modules\rtos\modules\FreeRTOS\FreeRTOS-SMP-Kernel\tasks.c:4274
      #2  0x00000000 in ?? ()

      ***** Disassembly *****
      0x802b4 <vApplicationMinimalIdleHook+20>: waiteu (0r)      *
      0x802b6 <vApplicationMinimalIdleHook+22>: retsp (u6)      0x2
      0x802b8 <main_tile1>:     entsp (lu6)     0x6
      0x802bc <main_tile1+4>:   stw (ru6)       r4, sp[0x4]
      0x802be <main_tile1+6>:   add (2rus)      r4, r0, 0x0

      ***** Registers *****
      r0             0x1b       27
      r1             0x1        1
      r2             0x80030002 -2147287038
      r3             0x87914    555284
      r4             0x6        6
      r5             0x5050505  84215045
      r6             0x6060606  101058054
      r7             0x7070707  117901063
      r8             0x8080808  134744072
      r9             0x9090909  151587081
      r10            0x10101010 269488144
      r11            0x0        0
      cp             0x84388    541576
      dp             0x84fc8    544712
      sp             0x879c0    555456
      lr             0x802b4    524980   vApplicationMinimalIdleHook + 20
      pc             0x802b4    524980   vApplicationMinimalIdleHook + 20
      sr             0x243      579
      spc            0x802b4    524980   vApplicationMinimalIdleHook + 20
      ssr            0x243      579
      et             0xf        15
      ed             0x0        0
      sed            0x0        0
      kep            0x83380    537472
      ksp            0x802b4    524980
      vec_vsr        0x0        0
      vec_c          {v8_int32 = {0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101}, v16_int16 = {0x101 <repeats 16 times>}, v32_int8 = {0x1 <repeats 32 times>}}
      vec_d          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}
      vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}

      Thread 10 (tile[1] core[3]):

      ***** Call Stack *****
      #0  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
      #1  0x00082afa in prvMinimalIdleTask (pvParameters=0x1b) at C:\Users\michaelb\sandboxes\sln_hark\xcore_sdk\modules\rtos\modules\FreeRTOS\FreeRTOS-SMP-Kernel\tasks.c:4274
      #2  0x00000000 in ?? ()

      ***** Disassembly *****
      0x802b4 <vApplicationMinimalIdleHook+20>: waiteu (0r)      *
      0x802b6 <vApplicationMinimalIdleHook+22>: retsp (u6)      0x2
      0x802b8 <main_tile1>:     entsp (lu6)     0x6
      0x802bc <main_tile1+4>:   stw (ru6)       r4, sp[0x4]
      0x802be <main_tile1+6>:   add (2rus)      r4, r0, 0x0

      ***** Registers *****
      r0             0x1b       27
      r1             0x1        1
      r2             0x80030002 -2147287038
      r3             0x87d9c    556444
      r4             0x6        6
      r5             0x5050505  84215045
      r6             0x6060606  101058054
      r7             0x7070707  117901063
      r8             0x8080808  134744072
      r9             0x9090909  151587081
      r10            0x10101010 269488144
      r11            0x0        0
      cp             0x84388    541576
      dp             0x84fc8    544712
      sp             0x87e48    556616
      lr             0x802b4    524980   vApplicationMinimalIdleHook + 20
      pc             0x802b4    524980   vApplicationMinimalIdleHook + 20
      sr             0x243      579
      spc            0x802b4    524980   vApplicationMinimalIdleHook + 20
      ssr            0x243      579
      et             0xf        15
      ed             0x0        0
      sed            0x0        0
      kep            0x83380    537472
      ksp            0x802b4    524980
      vec_vsr        0x0        0
      vec_c          {v8_int32 = {0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101}, v16_int16 = {0x101 <repeats 16 times>}, v32_int8 = {0x1 <repeats 32 times>}}
      vec_d          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}
      vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}

      Thread 9 (tile[1] core[2]):

      ***** Call Stack *****
      #0  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
      #1  0x00082afa in prvMinimalIdleTask (pvParameters=0x1b) at C:\Users\michaelb\sandboxes\sln_hark\xcore_sdk\modules\rtos\modules\FreeRTOS\FreeRTOS-SMP-Kernel\tasks.c:4274
      #2  0x00000000 in ?? ()

      ***** Disassembly *****
      0x802b4 <vApplicationMinimalIdleHook+20>: waiteu (0r)      *
      0x802b6 <vApplicationMinimalIdleHook+22>: retsp (u6)      0x2
      0x802b8 <main_tile1>:     entsp (lu6)     0x6
      0x802bc <main_tile1+4>:   stw (ru6)       r4, sp[0x4]
      0x802be <main_tile1+6>:   add (2rus)      r4, r0, 0x0

      ***** Registers *****
      r0             0x1b       27
      r1             0x1        1
      r2             0x80030002 -2147287038
      r3             0x88224    557604
      r4             0x6        6
      r5             0x5050505  84215045
      r6             0x6060606  101058054
      r7             0x7070707  117901063
      r8             0x8080808  134744072
      r9             0x9090909  151587081
      r10            0x10101010 269488144
      r11            0x0        0
      cp             0x84388    541576
      dp             0x84fc8    544712
      sp             0x882d0    557776
      lr             0x802b4    524980   vApplicationMinimalIdleHook + 20
      pc             0x802b4    524980   vApplicationMinimalIdleHook + 20
      sr             0x243      579
      spc            0x82af2    535282   prvMinimalIdleTask + 10
      ssr            0x202      514
      et             0xf        15
      ed             0x0        0
      sed            0x0        0
      kep            0x83380    537472
      ksp            0x802b4    524980
      vec_vsr        0x0        0
      vec_c          {v8_int32 = {0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101}, v16_int16 = {0x101 <repeats 16 times>}, v32_int8 = {0x1 <repeats 32 times>}}
      vec_d          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}
      vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}

      Thread 8 (tile[1] core[1]):

      ***** Call Stack *****
      #0  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
      #1  0x00082afa in prvMinimalIdleTask (pvParameters=0x1b) at C:\Users\michaelb\sandboxes\sln_hark\xcore_sdk\modules\rtos\modules\FreeRTOS\FreeRTOS-SMP-Kernel\tasks.c:4274
      #2  0x00000000 in ?? ()

      ***** Disassembly *****
      0x802b4 <vApplicationMinimalIdleHook+20>: waiteu (0r)      *
      0x802b6 <vApplicationMinimalIdleHook+22>: retsp (u6)      0x2
      0x802b8 <main_tile1>:     entsp (lu6)     0x6
      0x802bc <main_tile1+4>:   stw (ru6)       r4, sp[0x4]
      0x802be <main_tile1+6>:   add (2rus)      r4, r0, 0x0

      ***** Registers *****
      r0             0x1b       27
      r1             0x1        1
      r2             0x80030002 -2147287038
      r3             0x8748c    554124
      r4             0x6        6
      r5             0x5050505  84215045
      r6             0x6060606  101058054
      r7             0x7070707  117901063
      r8             0x8080808  134744072
      r9             0x9090909  151587081
      r10            0x10101010 269488144
      r11            0x0        0
      cp             0x84388    541576
      dp             0x84fc8    544712
      sp             0x87538    554296
      lr             0x802b4    524980   vApplicationMinimalIdleHook + 20
      pc             0x802b4    524980   vApplicationMinimalIdleHook + 20
      sr             0x243      579
      spc            0x82af2    535282   prvMinimalIdleTask + 10
      ssr            0x202      514
      et             0xf        15
      ed             0x0        0
      sed            0x0        0
      kep            0x83380    537472
      ksp            0x802b4    524980
      vec_vsr        0x0        0
      vec_c          {v8_int32 = {0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101}, v16_int16 = {0x101 <repeats 16 times>}, v32_int8 = {0x1 <repeats 32 times>}}
      vec_d          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}
      vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}

      Thread 7 (tile[1] core[0]):

      ***** Call Stack *****
      #0  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
      #1  0x00082ae4 in prvIdleTask (pvParameters=0x1b) at C:\Users\michaelb\sandboxes\sln_hark\xcore_sdk\modules\rtos\modules\FreeRTOS\FreeRTOS-SMP-Kernel\tasks.c:4420
      #2  0x00000000 in ?? ()

      ***** Disassembly *****
      0x802b4 <vApplicationMinimalIdleHook+20>: waiteu (0r)      *
      0x802b6 <vApplicationMinimalIdleHook+22>: retsp (u6)      0x2
      0x802b8 <main_tile1>:     entsp (lu6)     0x6
      0x802bc <main_tile1+4>:   stw (ru6)       r4, sp[0x4]
      0x802be <main_tile1+6>:   add (2rus)      r4, r0, 0x0

      ***** Registers *****
      r0             0x1b       27
      r1             0x1        1
      r2             0x80030002 -2147287038
      r3             0x86ffc    552956
      r4             0x4040404  67372036
      r5             0x6        6
      r6             0x34       52
      r7             0xffffffff -1
      r8             0x8080808  134744072
      r9             0x9090909  151587081
      r10            0x10101010 269488144
      r11            0x0        0
      cp             0x84388    541576
      dp             0x84fc8    544712
      sp             0x870a8    553128
      lr             0x802b4    524980   vApplicationMinimalIdleHook + 20
      pc             0x802b4    524980   vApplicationMinimalIdleHook + 20
      sr             0x243      579
      spc            0x802b4    524980   vApplicationMinimalIdleHook + 20
      ssr            0x243      579
      et             0xf        15
      ed             0x0        0
      sed            0x0        0
      kep            0x83380    537472
      ksp            0x802b4    524980
      vec_vsr        0x0        0
      vec_c          {v8_int32 = {0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101}, v16_int16 = {0x101 <repeats 16 times>}, v32_int8 = {0x1 <repeats 32 times>}}
      vec_d          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}
      vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}

      Thread 6 (tile[0] core[5]):

      ***** Call Stack *****
      #0  0x00084174 in xscope_data_from_host (c=2147614722, buf=@0x8a5bc, n=@0x8a58c) at xscope_shared_xc.xc:44
      #1  0x00080624 in xscope_fread (xscope_file=<value optimized out>, buffer=<value optimized out>, n_bytes_to_read=1) at C:\Users\michaelb\sandboxes\sln_hark\applications\hark\xscope_fileio\xscope_fileio\xscope_fileio\src\xscope_io_device.c:103
      #2  0x00080402 in xscope_fileio (arg=<value optimized out>) at C:\Users\michaelb\sandboxes\sln_hark\applications\hark\src\xscope_io\xscope_io_task.c:89
      #3  0x00000000 in ?? ()
      Current language:  auto; currently c

      ***** Disassembly *****
      0x84174 <xscope_data_from_host+12>:       chkct (rus)     res[r0], 0x1 *
      0x84176 <xscope_data_from_host+14>:       stw (ru6)       r6, sp[0x2]
      0x84178 <xscope_data_from_host+16>:       outct (rus)     res[r0], 0x1 *
      0x8417a <xscope_data_from_host+18>:       nop (0r)
      0x8417c <xscope_data_from_host+20>:       in (2r)         r3, res[r0] *

      ***** Registers *****
      r0             0x80020002 -2147352574
      r1             0x8a5bc    566716
      r2             0x8a58c    566668
      r3             0x1        1
      r4             0x1        1
      r5             0x8a5bc    566716
      r6             0x0        0
      r7             0x2        2
      r8             0x0        0
      r9             0x80       128
      r10            0x0        0
      r11            0x80080    524416
      cp             0x85ee8    548584
      dp             0x86df0    552432
      sp             0x8a578    566648
      lr             0x80624    525860   xscope_fread + 152
      pc             0x84174    541044   xscope_data_from_host + 12
      sr             0x210      528
      spc            0x84174    541044   xscope_data_from_host + 12
      ssr            0x300      768
      et             0x14       20
      ed             0x80020002 -2147352574
      sed            0x10000    65536
      kep            0x83800    538624
      ksp            0x800a4    524452
      vec_vsr        0x0        0
      vec_c          {v8_int32 = {0x2020202, 0x2020202, 0x2020202, 0x2020202, 0x2020202, 0x2020202, 0x2020202, 0x2020202}, v16_int16 = {0x202 <repeats 16 times>}, v32_int8 = {0x2 <repeats 32 times>}}
      vec_d          {v8_int32 = {0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101}, v16_int16 = {0x101 <repeats 16 times>}, v32_int8 = {0x1 <repeats 32 times>}}
      vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}

      Thread 5 (tile[0] core[4]):

      ***** Call Stack *****
      #0  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
      #1  0x0008938c in ucHeap ()
      Backtrace stopped: frame did not save the PC
      Current language:  auto; currently minimal

      ***** Disassembly *****
      0x802ac <vApplicationMinimalIdleHook+20>: waiteu (0r)      *
      0x802ae <vApplicationMinimalIdleHook+22>: retsp (u6)      0x2
      0x802b0 <main_tile0>:     entsp (lu6)     0x6
      0x802b4 <main_tile0+4>:   stw (ru6)       r4, sp[0x4]
      0x802b6 <main_tile0+6>:   add (2rus)      r4, r1, 0x0

      ***** Registers *****
      r0             0x305      773
      r1             0x0        0
      r2             0x86f38    552760
      r3             0x0        0
      r4             0x3        3
      r5             0x1        1
      r6             0xffffffff -1
      r7             0x7070707  117901063
      r8             0x8080808  134744072
      r9             0x9090909  151587081
      r10            0x10101010 269488144
      r11            0x82a04    535044
      cp             0x85ee8    548584
      dp             0x86df0    552432
      sp             0xff568    1045864
      lr             0x838fc    538876   _freertos_restore_ctx + 0
      pc             0x802ac    524972   vApplicationMinimalIdleHook + 20
      sr             0x258      600
      spc            0x802ac    524972   vApplicationMinimalIdleHook + 20
      ssr            0x243      579
      et             0xf        15
      ed             0x0        0
      sed            0x0        0
      kep            0x83800    538624
      ksp            0x82a20    535072
      vec_vsr        0x19       25
      vec_c          {v8_int32 = {0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101}, v16_int16 = {0x101 <repeats 16 times>}, v32_int8 = {0x1 <repeats 32 times>}}
      vec_d          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}
      vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}

      Thread 4 (tile[0] core[3]):

      ***** Call Stack *****
      #0  __xcore_lock_acquire (__l=773) at C:\Program Files (x86)\XMOS\XTC\15.1.4\target/include\xcore/_support\xcore_lock_impl.h:19
      #1  lock_acquire (__l=773) at C:\Program Files (x86)\XMOS\XTC\15.1.4\target/include\xcore\lock.h:62
      #2  rtos_lock_acquire (lock_id=1) at C:/Users/michaelb/sandboxes/sln_hark/xcore_sdk/modules/rtos/modules/rtos_support/api\rtos_locks.h:38
      #3  vTaskSuspendAll () at C:\Users\michaelb\sandboxes\sln_hark\xcore_sdk\modules\rtos\modules\FreeRTOS\FreeRTOS-SMP-Kernel\tasks.c:2869
      #4  0x000823da in vTaskDelay (xTicksToDelay=5000) at C:\Users\michaelb\sandboxes\sln_hark\xcore_sdk\modules\rtos\modules\FreeRTOS\FreeRTOS-SMP-Kernel\tasks.c:1862
      #5  0x00080296 in mem_analysis () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:70
      #6  startup_task (arg=<value optimized out>) at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:85
      #7  0x00000000 in ?? ()

      ***** Disassembly *****
      0x821d8 <vTaskSuspendAll+44>:     in (2r)         r2, res[r2] *
      0x821da <vTaskSuspendAll+46>:     ldw (lru6)      r2, cp[0x167]
      0x821de <vTaskSuspendAll+50>:     ldw (2rus)      r3, r2[0x0]
      0x821e0 <vTaskSuspendAll+52>:     add (2rus)      r3, r3, 0x1
      0x821e2 <vTaskSuspendAll+54>:     stw (2rus)      r3, r2[0x0]

      ***** Registers *****
      r0             0x1        1
      r1             0xffffffff -1
      r2             0x305      773
      r3             0x0        0
      r4             0x2        2
      r5             0x1388     5000
      r6             0x1c3e8    115688
      r7             0x7070707  117901063
      r8             0x8080808  134744072
      r9             0x9090909  151587081
      r10            0x10101010 269488144
      r11            0x2        2
      cp             0x85ee8    548584
      dp             0x86df0    552432
      sp             0x87998    555416
      lr             0x823da    533466   vTaskDelay + 14
      pc             0x821d8    532952   vTaskSuspendAll + 44
      sr             0x240      576
      spc            0x80244    524868   startup_task + 0
      ssr            0x202      514
      et             0x0        0
      ed             0x0        0
      sed            0x0        0
      kep            0x83800    538624
      ksp            0x821d8    532952
      vec_vsr        0x0        0
      vec_c          {v8_int32 = {0x2020202, 0x2020202, 0x2020202, 0x2020202, 0x2020202, 0x2020202, 0x2020202, 0x2020202}, v16_int16 = {0x202 <repeats 16 times>}, v32_int8 = {0x2 <repeats 32 times>}}
      vec_d          {v8_int32 = {0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101}, v16_int16 = {0x101 <repeats 16 times>}, v32_int8 = {0x1 <repeats 32 times>}}
      vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}

      Thread 3 (tile[0] core[2]):

      ***** Call Stack *****
      #0  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
      #1  0x00082f9a in prvMinimalIdleTask (pvParameters=0x1b) at C:\Users\michaelb\sandboxes\sln_hark\xcore_sdk\modules\rtos\modules\FreeRTOS\FreeRTOS-SMP-Kernel\tasks.c:4274
      #2  0x00000000 in ?? ()

      ***** Disassembly *****
      0x802ac <vApplicationMinimalIdleHook+20>: waiteu (0r)      *
      0x802ae <vApplicationMinimalIdleHook+22>: retsp (u6)      0x2
      0x802b0 <main_tile0>:     entsp (lu6)     0x6
      0x802b4 <main_tile0+4>:   stw (ru6)       r4, sp[0x4]
      0x802b6 <main_tile0+6>:   add (2rus)      r4, r1, 0x0

      ***** Registers *****
      r0             0x1b       27
      r1             0x1        1
      r2             0x80020302 -2147351806
      r3             0x89ca4    564388
      r4             0x6        6
      r5             0x5050505  84215045
      r6             0x6060606  101058054
      r7             0x7070707  117901063
      r8             0x8080808  134744072
      r9             0x9090909  151587081
      r10            0x10101010 269488144
      r11            0x0        0
      cp             0x85ee8    548584
      dp             0x86df0    552432
      sp             0x89d50    564560
      lr             0x802ac    524972   vApplicationMinimalIdleHook + 20
      pc             0x802ac    524972   vApplicationMinimalIdleHook + 20
      sr             0x243      579
      spc            0x82f92    536466   prvMinimalIdleTask + 10
      ssr            0x202      514
      et             0xf        15
      ed             0x0        0
      sed            0x0        0
      kep            0x83800    538624
      ksp            0x802ac    524972
      vec_vsr        0x0        0
      vec_c          {v8_int32 = {0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101}, v16_int16 = {0x101 <repeats 16 times>}, v32_int8 = {0x1 <repeats 32 times>}}
      vec_d          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}
      vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}

      Thread 2 (tile[0] core[1] (dual issue)):

      ***** Call Stack *****
      #0  xscope_connect_data_from_host (from_host=<value optimized out>) at xscope_shared_xc.xc:69
      #1  0x0008048c in xscope_io_init (xscope_end=2147614722) at C:\Users\michaelb\sandboxes\sln_hark\applications\hark\xscope_fileio\xscope_fileio\xscope_fileio\src\xscope_io_device.c:40
      #2  0x00080334 in init_xscope_host_data_user_cb (c_host=4) at C:\Users\michaelb\sandboxes\sln_hark\applications\hark\src\xscope_io\xscope_io_task.c:41
      #3  0x00083c6e in __main__main_tile_0_task_init_xscope_host_data_user_cb_1 (frame=<value optimized out>) at C:\Users\michaelb\sandboxes\sln_hark\xcore_sdk\modules\core\modules\multitile_support\src\tile_map.xc:51
      #4  0x000852bc in __start_core ()
      Current language:  auto; currently c

      ***** Disassembly *****
      0x84220 <xscope_connect_data_from_host+20>:       in (2r)         r0, res[r4] *
      0x84222 <xscope_connect_data_from_host+22>:       nop (0r)
      0x84224 <xscope_connect_data_from_host+24>:       setd (r2r)      res[r4], r0
      0x84226 <xscope_connect_data_from_host+26>:       nop (0r)
      0x84228 <xscope_connect_data_from_host+28>:       chkct (rus)     res[r4], 0x1 *

      ***** Registers *****
      r0             0x4        4
      r1             0x80020002 -2147352574
      r2             0x105      261
      r3             0x105      261
      r4             0x80020002 -2147352574
      r5             0x0        0
      r6             0x10000c00 268438528
      r7             0x0        0
      r8             0x0        0
      r9             0x0        0
      r10            0x0        0
      r11            0x70052e0  117461728
      cp             0x85ee8    548584
      dp             0x86df0    552432
      sp             0xfef60    1044320
      lr             0x84220    541216   xscope_connect_data_from_host + 20
      pc             0x84220    541216   xscope_connect_data_from_host + 20
      sr             0x140      320
      spc            0x0        0
      ssr            0x0        0
      et             0x0        0
      ed             0x0        0
      sed            0x0        0
      kep            0x80080    524416
      ksp            0x84220    541216
      vec_vsr        0x0        0
      vec_c          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}
      vec_d          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}
      vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}

      Thread 1 (tile[0] core[0]):

      ***** Call Stack *****
      #0  vApplicationMinimalIdleHook () at C:/Users/michaelb/sandboxes/sln_hark/applications/hark/src\main.c:94
      #1  0x00082f84 in prvIdleTask (pvParameters=0x1b) at C:\Users\michaelb\sandboxes\sln_hark\xcore_sdk\modules\rtos\modules\FreeRTOS\FreeRTOS-SMP-Kernel\tasks.c:4420
      #2  0x00000000 in ?? ()
      Current language:  auto; currently minimal

      ***** Disassembly *****
      0x802ac <vApplicationMinimalIdleHook+20>: waiteu (0r)      *
      0x802ae <vApplicationMinimalIdleHook+22>: retsp (u6)      0x2
      0x802b0 <main_tile0>:     entsp (lu6)     0x6
      0x802b4 <main_tile0+4>:   stw (ru6)       r4, sp[0x4]
      0x802b6 <main_tile0+6>:   add (2rus)      r4, r1, 0x0

      ***** Registers *****
      r0             0x1b       27
      r1             0x1        1
      r2             0x80020302 -2147351806
      r3             0x88f04    560900
      r4             0x4040404  67372036
      r5             0x6        6
      r6             0x34       52
      r7             0xffffffff -1
      r8             0x8080808  134744072
      r9             0x9090909  151587081
      r10            0x10101010 269488144
      r11            0x0        0
      cp             0x85ee8    548584
      dp             0x86df0    552432
      sp             0x88fb0    561072
      lr             0x802ac    524972   vApplicationMinimalIdleHook + 20
      pc             0x802ac    524972   vApplicationMinimalIdleHook + 20
      sr             0x243      579
      spc            0x82f1c    536348   prvIdleTask + 16
      ssr            0x202      514
      et             0xf        15
      ed             0x0        0
      sed            0x0        0
      kep            0x83800    538624
      ksp            0x802ac    524972
      vec_vsr        0x0        0
      vec_c          {v8_int32 = {0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101}, v16_int16 = {0x101 <repeats 16 times>}, v32_int8 = {0x1 <repeats 32 times>}}
      vec_d          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}
      vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}
vec_r          {v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v16_int16 = {0x0 <repeats 16 times>}, v32_int8 = {0x0 <repeats 32 times>}}

The problem disappears by adding a 1 ms delay in xscope_fread() after the call to xscope_bytes(XSCOPE_ID_READ_BYTES, sizeof(packet), packet); and before the call to xscope_data_from_host(c_xscope, (char *)buffer_ptr, &bytes_read); which suggests a race condition between xscope_fileio functionality on the device and the speed with which the host provides the requested data.

mbanth commented 2 years ago

@xmos-jmccarthy has discovered that this problem still exists, and that it appears on all platforms.

mbanth commented 2 years ago

Fixed with #41.