How smallest can TinyCLR Os be, 128KB?

One of the features in TinyCLR Os is, the user can rebuild their custom builds, only include what they need to reduce firmware’s size and ram.

By disabling some flags in Device.h, users can easily exclude the features they don’t need. But it is around few KB for each peripheral. Meaning even excluding all of what we have in Device.h, you may only get more 20~30KB space.

There is another way though, you can remove some features in core library file. Of course: “What you pay is what you get, what you add is what you use” and “what you remove is what you don’t use”:)))

The core library file is just a zip of all object files, unzip this file by using 7zip, you will get a list of objects that will be included when build the firmware.

Coming back your project, do you need Reflection? Do you need Random class? String, DateTime… Mostly we need, of course. But not always.

The name of object files will let you image about theirs function. Go ahead and delete them:))). So simple!

Of course, you can’t build your firmware any more. Open build.bat file, replace the option:

-Wl,--gc-sections,--no-wchar-size-warning

by

-Wl,--gc-sections,--no-wchar-size-warning,--unresolved-symbols=ignore-in-object-files

A lot of you know what this change does, so I don’t need to say.

That is it. You can copy all these objects into the folder where you compile your firmware, or just pack all of them back into one file with original name.

Although you used 7zip to unzip them, but you can’t use 7zip to zip them back:)). You can use small script below as GHI guys did.

@echo off

set AR=C:\gcc\bin\arm-none-eabi-ar -rcs

set TARGETPLATFORM=.\Core\TinyCLR_CortexM4.lib

for %%i in (.\Core\*.obj) do %AR% %TARGETPLATFORM% %%i

Of course there are a tan of files you can’t delete, but I got from 220KB down to 127KB and being scared, because it will be down more if I seat here more. Of course I can’t do anything with this firmware, but debug by usb/deploy application and playing with GPIO just fine.

You also get more heap for your application, of course.

I wish I can lose weight by this way.

4 Likes

Brilliant! I tried to run NETMF on Lego mindstorm years ago but it was 128k so I couldn’t. Looks like now I can with TinyCLR.

But my goal now it’s 64k. Maybe we can remove float or threading? Not sure but there are $2 boards on eBay using STM32F103C8T6. I want to see these running .NET :slight_smile:

6 Likes

That’s really useful!
Is this info up on GitHub? Sure it would be of interest to a lot of folks!

Thanks!

2 Likes