G120 using NetMF v4.3 - access to RAM and ROM shown on the data sheet?

Using the G120 with NetMF v4.3, I am not sure if I am able to make use of the amounts of RAM and ROM shown on the data sheet, which mentions 16MB RAM and 4MB FLASH.

On the GC debug output in VS2013, I see around 6MB RAM available in the managed heap, before creating any large data structures.

I made some applications that used a lot of ROM, to make sure my implementation of the In-Field Update feature would operate properly.

Enumerating the size of all of the assemblies in the largest successful application gave a total of less than 600KB.

However…

I did not successfully reach my target of an application using about 1MB of ROM, which is only 1/4 of the ROM on the data sheet. When the larger applications failed, they corrupted the firmware, and I had to reload it.

And, it seems like there is a large amount of RAM that I can’t use, since I see about 6MB available to the managed heap, which is 10MB less than the 16MB on the data sheet.

It’s important for planning purposes to know if more ROM and RAM can be accessed, or if I need to look elsewhere when planning larger projects.

Has the Forum had different results than this? If so, are there any examples I can look at?

You should have no issue addressing more memory. Create a new project, and check memory availability without adding your own code. A GC print is allowed. :smile: You should see the maximum memory available.

Add a GC print at the start of your program. How much memory is avaialble?

I suspect there are thing in your program gobbling up the memory. somewhere Static variables?

Can’t comment on flash question.

The Heap is used for many things, like 1MB reserved for display VRAM and 2MB for custom heap for large objects and 1MB for RLP…etc. It is sad how memory was fragmented in NETMF. We have changed some of that in TinyCLR OS.

When you check the RAM size, make sure you run the GC first.

Thanks to Gus and Mike for answers and suggestions regarding RAM.

That leaves my question about ROM.

To be specific, when I write this code to enumerate the RAM and ROM used by the assemblies that are loaded to run my application:

        System.Reflection.Assembly[] arrAssembly;
        System.Reflection.AssemblyName assemblyName;
        arrAssembly = Reflection.GetAssemblies();
        int arrAssemblyLength;
        arrAssemblyLength = arrAssembly.Length;
        int arrNumAssembly = 0;
        while (arrNumAssembly < arrAssemblyLength)
        {
            assemblyName = arrAssembly[arrNumAssembly].GetName();
            Debug.Print(assemblyName.FullName.ToString());
            Reflection.AssemblyMemoryInfo ami = new Reflection.AssemblyMemoryInfo();
            Reflection.GetAssemblyMemoryInfo(arrAssembly[arrNumAssembly], ami);
            uint RamSize = ami.RamSize;
            uint RomSize = ami.RomSize;
            Debug.Print("Ram: " + RamSize.ToString() + " " +
                        "Rom: " + RomSize.ToString());
            arrNumAssembly++;
        }

on the G120 SOM, and I add up the RomSize of every assembly, how large can that number get before attempting to load the application overwrites the firmware?

raises hand When you say ROM do you actually mean Read Only Memory or FLASH memory?

You will never over write the firmware. Deploy will fail instead.

Add all your pe files sizes to get the flash size. Subtract that from the deployment region size, Wich you can see through mfdeploy using the senior map.

If you are not adding several large resources like images, you will probably never fill the flash with just code!

1 Like

I have had this challenge out for about 10 years! And no one has even come close.

Yes, show me a project that uses all flash in just code and FEZ will come to your doorstep :nerd:

1 Like

If you are not using a display does it still allocate VRAM? Or is that heap memory cleared for program use?

Will we (end users) have any direct control over memory allocation in TinyCLR?

most users will need a display support and it is a 1MB out of 16MB so it is not a concern.

TinyCLR is portable. Change everything to whatever you like. But out-of-the-box it is already much better than NETMF at managing RAM and FLASH.

I assume I am making a different mistake somewhere, so until properly educated will set personal limit at 0x80000, which seems to work fine for the way I write code.

If there is ever a break in the delivery schedule, I will write a generic app that runs on generic hardware so I can submit for others to run and analyze.

So it is as easy as flip a bit to free that display ram?

It is as easy as making a small change and recompiling the firmware. You can even remove the display support altogether and save more flash/ram.