MCF52235 TCP/IP stack without RTOS

Update: The Interniche license agreement was breached. No example code is available here.

M52235EVBThe source code below contains makefile and everything needed to build a “network echo example” with a GNU toolchain for the MCF52235 microcontroller. The toolchain is available for free from CodeSourcery.

Simply connect to IP address 10.10.12.247 with TCP on port 4988 (or change IP, gateway and mask in ether.c) after building code and flashing the MCU:

user@pc:~$ telnet 10.10.12.247 4988
Trying 10.10.12.247...
Connected to 10.10.12.247.
Escape character is '^]'.
ping
ECHO: ping
^]

telnet> quit
Connection closed.
user@pc:~$ nc 10.10.12.247 4988
test
ECHO: test

user@pc:~$

Some debug information should be available on UART 0 at 115200 baud, 8N1:

Router version 0.0.2 (2007-06-27 09:10)

CPU and UART is up. Initialising.
ePHY enabled - Waiting..........
Start sw-semi-auto-negotiate
Try 100HD.
Link UP - 100HD
Heap size: 16384 bytes
MAC address: 00:CF:52:23:00:00
Starting interrupts
prep_evb: Preparing device for networking
IP address: 10.10.12.247
Start listening on TCP port 4988...
Enter main loop

The code is a mix of examples from Interniche Lite, CodeWarrior, CodeSourcery and the Freescale ColdFire forum. It does NOT use the niche-task-system (it’s a superloop thing with interrupts), to be able to use RAM and flash for other stuff. It was a major hassle to remove the task code and make it work from flash memory on the M52235EVB. This is where the initial versions of the files in the archive came from:

  • /cpu : codesourcery and codewarrior
  • /net : interniche
  • /std : interniche
  • /doc : relevant text based documents

ARP packets are transparent outside the Interniche files. To enable more debug information, define (by removing comment signs) NPDEBUG in /net/h/ipport.h or change the first “#if 0″ to “#if 1″ in /net/cf_specific/ifec.c. The Interniche mini-sockets TCP-api is partially documented in /doc/interniche. The file ether.c also contains the incomplete functions socket(), connect(), listen(), read() and write().

Fixes for interrupts, the TCP/IP stack, configuration of the coldfire flash module, 10/100 Mbps autonegotiation, address speculation, etc are included. In my opinion, all of them should have been made easily available from Freescale.

Free license

My changes are public domain, making all of this totally free of charge. If you use this code -please tell me here about improvements you make! Also, if anyone is able to compile a toolchain from source, I would be very interested.

If you download and use this software -you accept the terms specified in the text based license information included in the archive (specifically /net/h/license.h and the top of each applicable source code file).

Downloads

To make sure the CodeSourcery toolchain I used (version 4-1-32) is available, it can be downloaded here in [GNU/Linux], [Windows] and [Source code] versions. Extract and make the bin directory available in PATH to install it.

[Download MCF52235 example version 0.0.2], extract and cd to the directory before typing make, to compile.

Leave a comment

Here is a translation of the fields below, for those who do not understand Norwegian.

  • Navn : Name (required)
  • E-post : Email (required, will not be published)
  • Hjemmeside : Website
  • Varsle meg på e-post … : Send me an email on new comments here

Please use English in comments on this post.

15 kommentarer til “MCF52235 TCP/IP stack without RTOS”


  • Robin Gilham

    Thanks for the very useful example Peter. Can you perhaps please point me to where the source for the Linux Kernel is that will run on the M52233 device. I have begun to download the toolchain but it is unclear to me if the Linux kernel is included in this.

    Regards
    Robin

  • Hello Robin,

    The toolchain I used does not include the linux kernel. There is a linux version of the toolchain on the codesourcery web page.

    My example code contains all the stuff which fits into the internal flash memory in the MCF52235. There is no operating system, because I removed it to make room for more important stuff. The microcontroller jumps to an assembly initialisation sequence (from the reset vector) on reset, and enters the function called main after a short while. Some interrupts are configured for a few hardware events, before an infinite loop is entered. The infinite loop can be thought of as the only task in the system. It’s only temporarily stopped from executing when handling interrupts.

  • Robin Gilham

    Thanks for the prompt answer Petter, is it possible to compile a linux kernel for the 52233? If it is do you know if I need to your the uCKernel or the full 2.6 version kernel target for the coldfire. The uC site was last updated in 2005.

    Any pointers would be most helpful.

    Thanks
    Robin

  • You are most welcome. I have not compiled a kernel for the 52233. Sorry for not having all the answers.

    You could try searching or asking the same question in the CodeSourcery GNU discussion forum, or the Freescale ColdFire forum.

  • Hi Peter, you have done exactly what I am looking for. A TCP or UDP simple socket that will be able to send data to a pc. At this stage I dont even need to send data from the PC to the 52233.

    Is there any way that you can help me with a sample? I’m using codewarrior at the moment, but could switch to the gnu-tools if needs be.

    Thanks in advance.
    Michael

  • I’m waiting for Freescale to publish the URL for archive download with a “click-through” license. I will update my example code archive link here, when it’s available.

  • Peter, I would like to use your GNU build of the TCP/IP stack for a Stack configuration tool/GUI I am writeing.

    I also want to give you some credit during my next round of ColdFire TCP/IP training.

    Please contact me.

    What you have here is great!

  • Hello Eric. Thanks for a great comment. Feel free to use my build of the stack when it’s possible to download from Freescale. More usage should result in more and better feedback, and even better quality.

    If you give me credit: please use only my first name (and optionally a link to this web page).

    I wrote you an email also.

  • Michael and all: The archive will, based on my current knowledge, not become available from Freescale.

  • Richard Haldemann

    Hi Petter
    Is there a chance to get your Sourcecode for a TCP/IP Stack without an RTOS. Wanted to put the uClinux on the MCF52233 but uClinux must have 1MB Flash and the Coldfire has only got 256kB. So I believe it is not possible to port uClinux to our Coldfire.
    I would like to konw if somebody has ever tried to make something like a uPlinux with much less code?

    Regards
    Richard
    PS: http://www.frogmaster.ch
    A climat control unit for Terrariums with an 8 Bit Prozessor. Will replace it with the ColdFire

  • Hello, Richard.

    I do not want to violate any license agreement. I suggest you bump the forum thread in hope for a response.

    I guess you will be ignored or receive an unusable reply. You might want to use another MCU.

  • Hello,
    how did you write to flash in 52235 with codesourcery lite?
    My lastest version of codesourcery sg++ lite (freescale-coldfire-4.3-208-m68k-elf) don’t want flash:

    m68k-elf-gdb factorial
    >target remote| m68k-elf-sprite pe: m52235evb
    >load
    m68k-elf-sprite: Flash programming is unsupported in this release


    m68k-elf-gdb factorial
    GNU gdb (Sourcery G++ Lite 4.3-208) 6.8.50.20081022-cvs
    Copyright (C) 2008 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law. Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "--host=i686-pc-linux-gnu --target=m68k-elf".
    For bug reporting instructions, please see:
    ...
    (no debugging symbols found)
    (gdb) target remote|m68k-elf-sprite pe: m52235evb
    Remote debugging using |m68k-elf-sprite pe: m52235evb
    m68k-elf-sprite: Opening P&E USBMultilink port 1 (USB1 : USB-ML-CF Rev C (PE6015079))
    m68k-elf-sprite: Target reset
    0x00000000 in __cs3_interrupt_vector_coldfire ()
    (gdb) load
    m68k-elf-sprite: Flash programming is unsupported in this release
    Error erasing flash with vFlashErase packet
    (gdb)

  • Huh? I guess not many use this MCU. I used BDI2000. A bit expensive -but worth it.

    Hopefully someone at Freescale can help you with a cheaper solution. I suggest you try the forum.

  • Hi
    The link seams to be death… so I cant see you work at all
    http://neppe.no/wp-filez/m68k_standard_c_0-0-2.zip
    greetings Jan

  • jan: As i tried to explain in the update (first sentence after the post title): the software did not comply with the license. As a result the software is not available here anymore.

Skriv en kommentar