Main Site Documentation

TinyCLR in external flash


#1

First I must say that I am new to NETMF Porting Kit.

I am implementing OpenSSL on my device (M4-MCU). For this reason TinyCLR becomes larger than 1MB after building. This is too much for the on-chip Flash. So I want to moveTinyCLR into external flash. Is it possible to run TinyCLR in external flash?

I have tried to do this but without success. First, I adjusted the block configuration of the processor and the external flash. Secondly, I adjusted the ScatterFiles. Then I built and load the firmware (Tinybooter and TinyCLR) successfully to the device. But it doesn’t work. The device is no longer detected in MFDeploy after loading the firmware. What am I doing wrong?

Does anyone have experience running TinyCLR in an external flash?

Thanks for your help, mbr


#2

Yes it is possible. You need to adjust the scatter file properly and pay attention to your interrupt vectors.

Welcome to the community.


#3

There’s a whole lot of code going on just to get the device to show up in MFDeploy. You’re going to need to use a hardware debugger attached to your target processor and step through the code. We can help you get things going, but you’ll need to tell us exactly where things are getting screwed up. Does the processor get screwy once it jumps to that memory location? Is the firmware getting deployed properly to that memory? Or is it sitting in a while loop waiting for an initialization function to return true? All things to look out for!


#4

I found the problem. The TinyCLR configure the external flash once again. So it is clear, that the program abort, when the program code is executed on the external flash during the reconfiguration of the external flash.

The solution is to move only the desired libraries of TinyCLR to the external flash. These must be defined in a new execution and load region in TinyCLR scatterfile. The desired libraries are now referenced there. This looks like this:


<If Name="TARGETLOCATION" In="FLASH">
        <Set Name="Config_BaseAddress"  Value="0x0800C000"/>    
        <Set Name="Config_Size"         Value="0x00004000"/>
        <Set Name="Code_BaseAddress"    Value="0x08010000"/>
        <Set Name="Code_Size"           Value="0x00070000"/>
        <Set Name="Code_ExtAddress"     Value="0x60000000"/>
        <Set Name="Code_ExtSize"        Value="0x00200000"/>
        <Set Name="Valid"               Value="true"/>
</If>

And the new load region:


<LoadRegion Name="LR_EXTERNAL" Base="%Code_ExtAddress%" Options="ABSOLUTE" Size="%Code_ExtSize%">
        <ExecRegion Name="ER_EXTERNAL" Base="%Code_ExtAddress%" Options="FIXED" Size="">
                <FileMapping Name="*FS_FAT.lib*" Options="(+RO)" />
                <FileMapping Name="*COM_pal.lib*" Options="(+RO)" />
                <FileMapping Name="*usart_pal.lib*" Options="(+RO)" />
                <FileMapping Name="*usb_pal.lib*" Options="(+RO)" />
                <FileMapping Name="*usbHost_pal.lib*" Options="(+RO)" />
                <FileMapping Name="*usbHost.lib*" Options="(+RO)" />
                <FileMapping Name="*i2c_pal.lib*" Options="(+RO)" />
                <FileMapping Name="*sockets_pal_lwip.lib*" Options="(+RO)" />
                <FileMapping Name="*sockets_hal_sockets_lwIP.lib*" Options="(+RO)" />
                <FileMapping Name="*sockets_lwIP_pal.lib*" Options="(+RO)" />
                <FileMapping Name="*sockets_hal_async_lwIP.lib*" Options="(+RO)" />
                <FileMapping Name="*sockets_hal_tcp_lwIP.lib*" Options="(+RO)" />
                <FileMapping Name="*sockets_hal_DHCP_LWIP*" Options="(+RO)" />
                <FileMapping Name="*sockets_hal_udp_lwIP.lib*" Options="(+RO)" />                 
        </ExecRegion>
</LoadRegion>

Because I am new to the NETMF world, I would be pleased for any suggestions or comments.