Recompiling Cerberus firmware with ethernet

The cerberus firmware come out in two different versions: “ethernet” and "no ethernet"
Playing around with the compilation toolchain I obtain the “no ethernet” version (I suppose this because the output hex file size is around the same of the official version and my tested code throw a socketexception…).
How can I enable the ethernet part? I suppose that exists a flag in a header file but where?

You need to remove stub lib and add the real lib in the main project file.

Check inside TinyCLR.proj

I’ve removed the stub lib and added the real lib but the compilation fails:

"C:\MicroFrameworkPK_v4_2\Solutions\FEZCerberus\dotnetmf.proj" (default target)
(1) -> "C:\MicroFrameworkPK_v4_2\Solutions\FEZCerberus\TinyCLR\TinyCLR.proj" (Build target) (75) ->
(BuildAXF target) ->  EXEC : error : L6220E: Execution region ER_RAM_RW size (69536 bytes) exceeds limit (65536 bytes). Region contains 47 bytes of padding and 0 bytes of veneers (total 47 bytes of linker generated content). [C:\MicroFrameworkPK_v4_2\Solutions\FEZCerberus\TinyCLR\TinyCLR.proj] C:\MicroFrameworkPK_v4_2\tools\targets\Microsoft.SPOT.System.MDK.targets(297,5): error MSB3073: The command ""c:\Keil\Arm\bin40\armlink.exe"  --keep *(.init_array) --no_keep_init_arrays --feedback C:\MicroFrameworkPK_v4_2\BuildOutput\THUMB2\MDK4.54\le\FLASH\debug\FEZCerberus\bin\tinyclr_FEZCerberus_FLASH_Debug_MDK4.54.feedback  --debug --remove --unmangled --info sizes,totals,veneers,unused,libraries --map  --xref --symbols --callgraph --userlibpath C:\MicroFrameworkP...

Changing the ER_RAM_RW region size (in the scatter file) from 0x10000 to 0x12000 leads to a compile without errors but when the image is deployed the board is not recognized.
I suppose that I can not simply modify this number in the scatter file.

Any Idea?

Is it recognized if you recompile it as is - without replacing the stub lib?

I think GHI uses RDsomethingsomething(or RVDS?) compiler. I think the MDK scatter file is messed up as it was never updated. Look at the RD**(or RVDS?) scatter file…

Yes! The recompiled firmware (without ethernet lib) works as expected.

The scatter file that I’ve used in both builds is the RVDS vesion renamed in “scatterfile_tinyclr_mdk.xml”

Anyone has succesfully rebuilt cerberus firmware with ethernet support?
How?

Build it in Release mode, not debug mode. The debug mode is too big to fit into the scatter file regions.

Build in release mode helps but not resolve. I’ve just found the problem: my modified firmware uses 4 UART instead of 3, When I compile without ethernet the RAM is enough but 1 additional uart plus ethernet consume too much ram.

Hi Cybernox.
Can you please point me out, how to enable ethernet adapter?

Thank you.

Hi.
Can please somebody help me how to enable ethernet at Cerberus firmware?
Still can’t found out how to disable stub and enable library.

Thanks in advance for any help.

Hi slawek.
Excuse me for the delay, but I was out of office last week.
Disabling stuff and enabling the real library is very simple (if you know where to puts hands ;-P)

  1. Download the cerberus source code and merge the folder with the porting kit.
  2. Open the file located in <PK4.2 folder>Solutions\FEZCerberus\TinyCLR\TinyCLR.proj
  3. On line 457 you found a tag containing the element
<DriverLibs Include="sockets_pal_stubs.$(LIB_EXT)" />

This is the stub
4) Comment out this ItemGroup
5) Uncomment the ItemGroup that follows


  <ItemGroup>
    <DriverLibs Include="sockets_pal_lwip.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\DeviceCode\PAL\COM\Sockets_lwip\dotNetMF.proj" />
  </ItemGroup>

This is the real lib
6) Recompile your firmware in release mode

I think you’ll need more than that. You need lwIP, but also the .NET interop, as well as an actual sockets hardware driver (right now, the enc28j60 is the only driver tested with Cerberus, methinks).

If you pull up Solution Wizard, open the Cerberus solution, you should be able to add networking by ticking the appropriate feature. It will resolve any required dependencies so you don’t have to mess around with XML files.

For what it’s worth, though, here’s what the official Cerberus firmware adds to enable ethernet:


<ItemGroup>
    <DriverLibs Include="sockets_hal_sockets_lwIP.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\DeviceCode\pal\lwip\lwip\src\dotnetmf_sockets.proj" />
  </ItemGroup>
  <ItemGroup>
    <DriverLibs Include="sockets_hal_DHCP_LWIP.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\DeviceCode\pal\lwip\lwip\src\dotnetmf_dhcp.proj" />
  </ItemGroup>
  <ItemGroup>
    <DriverLibs Include="sockets_lwIP_pal.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\DeviceCode\pal\lwip\SocketsDriver\dotnetmf.proj" />
  </ItemGroup>
  <ItemGroup>
    <DriverLibs Include="sockets_hal_async_lwIP.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\DeviceCode\pal\lwip\tinyclr\dotnetmf.proj" />
  </ItemGroup>
  <ItemGroup>
    <DriverLibs Include="sockets_hal_tcp_lwIP.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\DeviceCode\pal\lwip\lwip\src\dotnetmf_tcp.proj" />
  </ItemGroup>
  <ItemGroup>
    <DriverLibs Include="sockets_hal_udp_lwIP.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\DeviceCode\pal\lwip\lwip\src\dotnetmf_udp.proj" />
  </ItemGroup>
  <ItemGroup>
    <DriverLibs Include="ETHERNET_enc28j60_lwip.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\DeviceCode\GHI\Drivers\Ethernet\enc28J60_lwip\dotNetMF.proj" />
  </ItemGroup>
  <ItemGroup>
    <DriverLibs Include="ETHERNET_loopback_lwip.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\DeviceCode\Drivers\Ethernet\Loopback_lwip\dotNetMF.proj" />
  </ItemGroup>
  <ItemGroup>
    <DriverLibs Include="Network_Config_HAL_FEZ_Hydra.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\Solutions\FEZCerberus\DeviceCode\Network_Config_HAL\dotNetMF.proj" />
  </ItemGroup>
  <ItemGroup>
    <DriverLibs Include="ENC28J60_Config_LWIP_HAL_FEZ_Hydra.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\Solutions\FEZCerberus\DeviceCode\ENC28J60_Config_LWIP_HAL\dotNetMF.proj" />
  </ItemGroup>
  <ItemGroup>
    <PlatformIndependentLibs Include="SPOT_Net.$(LIB_EXT)" />
    <RequiredProjects Include="$(SPOCLIENT)\CLR\libraries\spot_net\dotNetMF.proj" />
  </ItemGroup>

what jay says is correct, but these item groups are already active in the project file.

Bye