System.NotSupportedException

Hello,

I have been working on transferring our current HMI to a Toradex T20 and have run into a problem. All the functions I have tested so far have worked great, except for one. One part of our code reads in a sometimes quite large (600KB or more) XML file, and puts all the data into assorted arrays. Small files are loaded without a problem (<2KB), but medium sized ones (2-50KB) files have caused one of the serial ports to stop recognizing when serial data has been received. That is to say, the data_received trigger no longer automatically functions. I have solved this error by instituting a one-time forced read after loading the file. This resets the serial port and solves that portion of the problem. I include this as extended explanation of the actual problem.

The actual problem I am having is that large (>~50KB) files are crashing the program. The system gives a “System.NotSupportedException”. Where it gives the error changes depending on the particular file size and sometimes how long I wait to cause other inputs after loading the file. I am absolutely sure that the functions that it says are having the problems are supported code, as they have functioned in our previous implementation for years and work fine on the Toradex unit as long as I don’t load a large function before them. Often it crashes on function calls that have no inputs like button presses. To be clear, it crashes on the function call - not in the function.
Another clue to this problem is that the system can take larger files (~120KB) if the system is running in a full release and not debugging via the USB.

I have talked with Samuel, and he suggested turning off the l2cache and multiprocessor support separately, see if either of those fixed our problem. They did not, unfortunately.

I’m assuming this has something to do with memory management somewhere, since size of the files seems to be the only thing changing, but I’m at a loss as to what the problem could be.

Any solutions to this problem are appreciated.

Could you check which image version you are using? Please give it a try with the latest 2.0 final release. You get that from here and can update it with the update tool.

I am using version 2.0

@SamCarey: Thanks for the description of the issue. I first assumed an issue with UART in general but as you say you are using the image 2.0 this should be solved.

Could you also check once log the debug output to see, if there is anything that should not be there when the issue happens? (See also: How to enable debug output)

Currently there is know issue known that behaves as the you describe it. I think we have to further investigate this. Do you think it would be possible to share some code with us that reproduces the issue somehow?

Here is the output of the debugger if I power up the system from scratch with the debugger enabled:

Toradex Bootloader 2.0 for Tegra Built Mar 6 2017

Press [SPACE] to enter Bootloader Menu

Colibri T20 512MB IT V1.2A SerialNo: 4755477
RAM: 512 MB, CarveOut: 64 MB
Locating kernel image in flash…Ecc.Corrected(1) Blk 110 PgOffset 0, status: 0x100100
Done(1356)
Decompressing IMAGE(25895437, 50612212) from FLASH(0) to RAM(16000)…Done(569ms)
Jumping to image at 0x80016000…

Toradex Windows CE 7.0 IMAGE 2.0 for Tegra Built Feb 6 2017
INFO:OALLogSetZones: dpCurSettings.ulZoneMask: 0xb
L2 cache enabled
MainMemoryEndAddress adjusted from 0x86000000 to 0x9C000000
Main Phys Mem: 0x00000000:0x1BFFFFFF
Carveout Phys: 0x1C000000:0x1FFFFFFF
Cold boot selected
Chip Id: 0x20 (Handheld SOC) Major: 0x1 Minor: 0x4 SKU: 0x8
NVRM Initialized shmoo database
PllClocks(Mhz): X=1000, M=666, C=581, P=216, A=24.576
SysClocks(Mhz): CPU=1000, AVP=232, SysBus=232, Mem=333, EMem=666
GraphicClocks(Mhz): Host=108, 3D=111, 2D=111, Epp=111, Mpe=111, Vde=232
Loading FlashFileSystem(NAND)…
Micron M71M PS:4KB BS:256KB DS:1024MB BCH16 ECC
INFO: TotalBlocks = 4096, FreeBlocks = 179
BBs: 0
No TAT bad block found.
No TT bad block found.
Done FlashFileSystem(NAND)(106)
Loading Audio…Done
Loading Serial2(UART_B)…Done Serial2(0)
Loading Serial3(UART_C)…Done Serial3(0)
Loading SDIO(SDIO4)…Done(4)
Loading USBFunction(Port1)…Done
Loading USBHost(Port2)…NvDdkSdioSetClockFrequency: Requested: 100 KHz, Actual: 101 KHz
Done
Loading USBHost(Port3)…Done
NvDdkSdioSetClockFrequency: Requested: 25000 KHz, Actual: 25411 KHz
NvDdkSdioSetClockFrequency: Requested: 50000 KHz, Actual: 48000 KHz
Loading DisplayDriver…Done(73)
Set LCD to 800x600 (60Hz)
Loading Keyboard/MouseDriver…Done
Loading TouchDriver…Maximum Allowed Error 5:
RTC Time restored (23.05.2017 17:01:04)
AX88772B: instantiate [AX88772B1]
Loading NETUI…
Done NETUI
Done
Ecc.Corrected(1) Blk 689 PgOffset 46, status: 0x800108
Ecc.Corrected(1) Blk 694 PgOffset 41, status: 0x20010f
Ecc.Corrected(1) Blk 695 PgOffset 10, status: 0x20108
Ecc.Corrected(1) Blk 701 PgOffset 24, status: 0x1010b
Ecc.Corrected(1) Blk 713 PgOffset 49, status: 0x800103
Ecc.Corrected(1) Blk 714 PgOffset 48, status: 0x4010d
Ecc.Corrected(1) Blk 714 PgOffset 60, status: 0x80106
Ecc.Corrected(1) Blk 719 PgOffset 10, status: 0x10100
Ecc.Corrected(1) Blk 721 PgOffset 36, status: 0x100106
Ecc.Corrected(1) Blk 722 PgOffset 60, status: 0x20109
Ecc.Corrected(1) Blk 729 PgOffset 36, status: 0x10106
Ecc.Corrected(1) Blk 730 PgOffset 41, status: 0x1010b
Ecc.Corrected(1) Blk 731 PgOffset 3, status: 0x80103
Ecc.Corrected(1) Blk 731 PgOffset 13, status: 0x80103
Ecc.Corrected(1) Blk 667 PgOffset 60, status: 0x40101
Ecc.Corrected(1) Blk 742 PgOffset 2, status: 0x800102
Ecc.Corrected(1) Blk 742 PgOffset 5, status: 0x20105
Ecc.Corrected(1) Blk 764 PgOffset 2, status: 0x40100
Ecc.Corrected(1) Blk 763 PgOffset 59, status: 0x400100
Warning: you are requesting IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMTYPE, which has been deprecated. Use IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMNAME instead.
Warning: you are requesting IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMTYPE, which has been deprecated. Use IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMNAME instead.
Loading NETUI…
Done NETUI
Ecc.Corrected(1) Blk 761 PgOffset 39, status: 0x400100
Ecc.Corrected(1) Blk 761 PgOffset 48, status: 0x800100
Ecc.Corrected(1) Blk 754 PgOffset 10, status: 0x400100
Ecc.Corrected(1) Blk 754 PgOffset 56, status: 0x80100
Ecc.Corrected(1) Blk 759 PgOffset 46, status: 0x10100
Warning: you are requesting IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMTYPE, which has been deprecated. Use IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMNAME instead.
Warning: you are requesting IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMTYPE, which has been deprecated. Use IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMNAME instead.
Loading NETUI…
Done NETUI
Ecc.Corrected(1) Blk 754 PgOffset 10, status: 0x400100
Ecc.Corrected(1) Blk 754 PgOffset 56, status: 0x80100
Ecc.Corrected(1) Blk 759 PgOffset 46, status: 0x10100
Ecc.Corrected(1) Blk 752 PgOffset 60, status: 0x100100
Ecc.Corrected(1) Blk 750 PgOffset 55, status: 0x20100
Ecc.Corrected(1) Blk 751 PgOffset 3, status: 0x10100
Ecc.Corrected(1) Blk 756 PgOffset 55, status: 0x20100
ramstc.exeErrorAn unexpected error has occurred in ramstc.exe.
Select Quit and then restart this program, or select Details for more information.

An error message cannot be displayed because an optional resource assembly containing it cannot be found
ramstc.exeErrorramstc.exe
InvalidOperationException
An error message cannot be displayed because an optional resource assembly containing it cannot be found


The crash is caused because the system wants to use the debug serial port.

So I created a debug version of the code and ran the system from the USB debugger with modified code so it wouldn’t crash trying to use Serialport1. This is the output I got:

Warning: you are requesting IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMTYPE, which has been deprecated. Use IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMNAME instead.
Warning: you are requesting IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMTYPE, which has been deprecated. Use IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMNAME instead.
Warning: you are requesting IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMTYPE, which has been deprecated. Use IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMNAME instead.
Loading NETUI…
Done NETUI
Warning: you are requesting IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMTYPE, which has been deprecated. Use IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMNAME instead.
Warning: you are requesting IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMTYPE, which has been deprecated. Use IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMNAME instead.
Loading NETUI…
Done NETUI
Ecc.Corrected(1) Blk 754 PgOffset 10, status: 0x400100
Ecc.Corrected(1) Blk 754 PgOffset 56, status: 0x80100
Ecc.Corrected(1) Blk 759 PgOffset 46, status: 0x10100
Ecc.Corrected(1) Blk 750 PgOffset 55, status: 0x20100
Ecc.Corrected(1) Blk 751 PgOffset 3, status: 0x10100
Ecc.Corrected(1) Blk 756 PgOffset 55, status: 0x20100


The system then displayed the previously described NotSupportedException.

I am running the request to show you guys the code up the chain of command here - but even if it is approved I don’t know what portion of the code is causing this error (I know the generic function, but it is over a thousand of lines of code). As I said before, the particular line that the system crashes on moves and each one I have seen so far is a valid line of code.

I am loading a fair amount of information into relatively large arrays (1-84 by 1-360) but even the largest ones shouldn’t be more than half a MB. Yet the problem seems very linked to the size of the files so I’m not sure where the problem could be caused…

I will try calling today to work out next steps, but would welcome any suggestions you might have.

As a piece of added information, we have found that the system can give a very similar error to the one it gives if we do our function if I simply dimension an byte array that is bigger than 3500 x 3000 but less than 3333 x 3333.

That is to say a 3500 x 3000 does NOT cause the crash, but the 3333 x 3333 does.

I do not assign values to the array.

@SamCarry: The debug output looks good so far, nothing special.

I tried to reproduce the issue you reported with the arrays but was not able to reproduce the exception. I further extended the example and started increasing the two dimensional array size. Depending on the GC, the application crashed with a System.OutOfMemoryException which I actually also expected. What array type are you using?

Could it be, you get a System.NotSupportedException because some resource can not be loaded properly because of low memory? As you working with some bigger arrays, your issue could be related to a memory issue as well?

You wrote earlier, you had that software running on an other device: Was this an ARM based device as well? Was it running with .NET Compact Framework 3.5 as well?

After a couple more phone calls with Toradex support and further testing I have found (at Toradex’s suggestion) that the only solution I could find was to upgrade the build to .NET CF 3.5 using Visual Studio 2008 instead of 2005. This solved the problem.

The only other possible solution that came up was that when a small file was loaded it allowed the system to load larger files. These larger files would sit in memory for ~100 seconds before being cleared. Then the system could work. This did not work in our application, but might work in some others.