Jump to content

  •  

Photo

ENC28J60 Booster Pack


  • Please log in to reply
107 replies to this topic

#1 xpg

xpg

    Advanced Member

  • Members
  • PipPipPip
  • 101 posts


Posted 12 October 2012 - 09:36 PM

Hi,

After a couple of hours of work porting the enc26j80 driver from my own mini ipv6 stack to uip, I have my enc28j60 booster pack working with the Stellaris Launchpad.

Attached File  IMG_20121012_211109.jpg   106.9KB   191 downloads

The current example code is at https://github.com/xpgdk/stellaris-enc28j60-booster and does nothing more than acquiring an IPv4 address and serve a static web-page on port 80. The code is tested using GCC only.

http://www.youtube.com/watch?v=e7PsRniPZWo
(I apologize for the quality of the video)

I will be improving the driver and the example code in the coming weeks.

 

Schematics for revision 2:

Attached File  net430booster.png   311.48KB   70 downloads

 

Board:

Attached File  Board-rev2.png   48.62KB   60 downloads

 

 

Updated April 9th 2013: Added schematics and board-design of rev 2 board.


  • bluehash, Rickta59, oPossum and 5 others like this

#2 bluehash

bluehash

    Administrator

  • Administrators
  • 859 posts
  • LocationWaltham, MA

Posted 12 October 2012 - 10:26 PM

Hi,After a couple of hours of work porting the enc26j80 driver from my own mini ipv6 stack to uip, I have my enc28j60 booster pack working with the Stellaris Launchpad.The current example code is at https://github.com/xpgdk/stellaris-enc28j60-booster and does nothing more than acquiring an IPv4 address and serve a static web-page on port 80. The code is tested using GCC only. I will be improving the driver and the example code in the coming weeks.

This is awesome xpg! Thanks for sharing. You should add ability to turn GPIOs on/off through the web.
Promoting to Blog.
C2KCentral - C2000 News, Projects and Forums | 43oh - MSP430 Discussion, News and Projects. | Stellarisiti - Stellaris ARM Forums, Projects and News.

#3 xpg

xpg

    Advanced Member

  • Members
  • PipPipPip
  • 101 posts


Posted 12 October 2012 - 10:32 PM

This is awesome xpg! Thanks for sharing. You should add ability to turn GPIOs on/off through the web.


Good idea. Will do that tomorrow.

Oh, and a minor detail just to avoid confusion: The wires connected to the Launchpad are for programming via JTAG, the booster pack works fine without them :-)

#4 xpg

xpg

    Advanced Member

  • Members
  • PipPipPip
  • 101 posts


Posted 16 October 2012 - 11:35 PM

Ok, this took a bit longer than I had anticipated, and there is a lot of room for improvements.
I extended the example as suggested by BlueHash to be able to read and toggle the GPIO-pins via a web-browser.
The Launchpad will serve a small HTML-page with some Javascript on port 80. Three URLs are used to control and read the GPIO-pins.

"/read" returns a JSON array which contains four list: "J1", "J2", "J3", and "J4". Each of these lists represents a header on the Launchpad. The first item of J1 represents the first pin, second item second pin, etc. An example:
{
"J1": ["x","x",0,0,0,"x","x","x",0,1],
"J2": ["x",0,0,"x","x","x","x",0,0,0],
"J3": ["x","x",0,0,0,0,0,0,0,2],
"J4": [2,2,0,0,0,0,0,0,0,0]
}

"x" indicates that the pin can neither be read nor controlled as it is used by the program itself or is not a GPIO-pin. "0" means that the pin is configured for input and is low. "1" that it is configured for input and high. "2" means that the pin is configured for output and is low, while "3" means that it is low.

"/write/C.P/V" is used to set the pin number P of header C to value V. For instance, "/write/3.10/1" sets pin 10 on header 3 high, which turns on the red LED. Headers and pins are numbered from 1 and not 0, and the code parsing this is somewhat buggy.

Finally, "/config/C.P/D" is used to configure pin number P of header C according to D. Valid values of D are "o" for output, and "i" for input. The HTML-frontend to all this currently does not support configuring pins.

A short video showing the HTML/Javascript version in action:
http://www.youtube.com/watch?v=2bas_iznJDA&feature=youtu.be
The screen capture and the recording are not correctly synchronized, but it's close enough.
  • bluehash and Automate like this

#5 bluehash

bluehash

    Administrator

  • Administrators
  • 859 posts
  • LocationWaltham, MA

Posted 17 October 2012 - 01:38 AM

That is awesome! Whats next now? GW is working on a wifi boosterpack, so that makes two ethernet boosters.
C2KCentral - C2000 News, Projects and Forums | 43oh - MSP430 Discussion, News and Projects. | Stellarisiti - Stellaris ARM Forums, Projects and News.

#6 Nytblade

Nytblade

    Member

  • Members
  • PipPip
  • 20 posts
  • LocationChicago

Posted 17 October 2012 - 08:18 PM

This is really interesting since I have been working on something similar with the Wiznet Ethernet chip on the MSP430.

Why did you decide to switch from your own code to uIP?

Is there a particular reason you are using IPv6? Could it be easily switched to use IPv4?

Are you going to offer your boosterpack for sale anywhere?

#7 xpg

xpg

    Advanced Member

  • Members
  • PipPipPip
  • 101 posts


Posted 17 October 2012 - 09:36 PM

This is really interesting since I have been working on something similar with the Wiznet Ethernet chip on the MSP430.


I wanted to do it with the MSP430 as well, but with my IP-stack in there, I figured that there wasn't enough room to hold the HTML and javascript

Why did you decide to switch from your own code to uIP?


I only created my own IP-stack in the first place because the MSP430 G-series has too little RAM to run any of the existing ones. So, I'm keeping almost all stack-related data in external SRAM. The Stellaris Launchpad has plenty of RAM to run the uIP stack, so I'll go with that as it is far more mature than my little project.

Is there a particular reason you are using IPv6? Could it be easily switched to use IPv4?


Actually, it is using IPv4 right now. But I think uIP supports IPv6, so it should be fairly easy to switch to IPv6.

Are you going to offer your boosterpack for sale anywhere?


If there is interest for it, I will make a second revision of the PCB and put it up for sale somewhere.
However, I was under the impression that the Wiznet chips are cheaper and more capable than the ENC28J60. Therefore I would expect people to prefer the RobG's Ethernet Booster Pack.
But if you are interested in one, we can work something out.
  • bluehash likes this

#8 bluehash

bluehash

    Administrator

  • Administrators
  • 859 posts
  • LocationWaltham, MA

Posted 17 October 2012 - 10:35 PM

If there is interest for it, I will make a second revision of the PCB and put it up for sale somewhere.

If you are interested, we can work something out to put it on the Store.
C2KCentral - C2000 News, Projects and Forums | 43oh - MSP430 Discussion, News and Projects. | Stellarisiti - Stellaris ARM Forums, Projects and News.

#9 Nytblade

Nytblade

    Member

  • Members
  • PipPip
  • 20 posts
  • LocationChicago

Posted 18 October 2012 - 12:42 AM

xpg,

I have been doing a lot of work on the Wiznet chip you mention. The W5200 has 32 Kilobytes of RAM for packets (16 KB for TX, 16 KB for RX), and can support up to eight sockets at a time. You divide the memory into parts however you want, depending on your needs.

If you are just talking about the chip itself, the W5200 is slightly more expensive than the ENC28J60 (at least according to Mouser.com). There is one shortcoming in the Wiznet chip though -- it only does IPv4. However, the syn/ack/etc IP stuff is all handled by the Wiznet, which makes it easier to use. You just copy your data to and from its memory buffer via SPI and then execute single byte "commands" to make it send or receive data. It buffers any data it receives until you are ready for it, so you don't have to use interrupts (though they are available).

To send a packet you put an address/port in a register on the Wiznet then execute the send command. Receiving is similar. You don't have to handle the specifics of the TCP protocol in your code, though you do have to understand the handshake and close procedure. It is sort of like a 50% stack... it does require some driver, but enough of the TCP / UDP is on the Wiznet that it can't handle IPv6.

I initially started with Rob's boosterpack, but ran out of memory as well. However, I am betting his Boosterpack would work on the Stellaris. I would port my own code to the Stellaris but I don't know if I am going to have enough time for it or if enough people are interested in it to make it worth the trouble. I don't know anything about the ENC28J60. I am just giving people an overview of what I learned so they can compare for themselves here. I never did any research about other ethernet chips -- I just used the Wiznet because it was on the Boosterpack when I bought it.

Having looked at the uIP code you mentioned, I am thinking I may have actually taken wrong approach in what I've done and probably should have just used uIP instead along with the ENC chip instead. That Contiki OS that uses uIP is interesting too. It apparently runs on the MSP430 according to their website. Perhaps it would be a more useful effort to port Contiki to Stellaris.

I assume there will be some some Ethernet Boosterpack for the Stellaris... it is just a matter of choosing the right code and chip. At this point I think that uIP might be a better choice because it is better known. What do you think about lwip? It looks like it might be a more active codebase than uip?

BTW here is a blog post I did with my latest code (wrote earlier today): http://www.cashdollar.org/2012/10/17/dhcp-client-for-wiznet-w5200-and-msp430-completed/
  • bluehash and xpg like this

#10 xpg

xpg

    Advanced Member

  • Members
  • PipPipPip
  • 101 posts


Posted 18 October 2012 - 12:25 PM

I have been doing a lot of work on the Wiznet chip you mention. The W5200 has 32 Kilobytes of RAM for packets (16 KB for TX, 16 KB for RX), and can support up to eight sockets at a time. You divide the memory into parts however you want, depending on your needs.

If you are just talking about the chip itself, the W5200 is slightly more expensive than the ENC28J60 (at least according to Mouser.com). There is one shortcoming in the Wiznet chip though -- it only does IPv4.
[...]
It is sort of like a 50% stack... it does require some driver, but enough of the TCP / UDP is on the Wiznet that it can't handle IPv6.



For use on a small micro like the 43oh, I would say that the extra costs are quite ok with the Wiznet. Having the entire IP-stack in the micro controller simply takes up too much flash and requires more RAM than available (thus the external SRAM on the ENC28j60 booster).
Especially TCP handling takes up large amounts of both flash and RAM.
While I personally prefer IPv6, I havde to admit that IPv6 is not well adopted, and for many (most?) scenarios IPv4 will do just fine. One of the cool things
about IPv6 is that I would be able to address all units globally via the Internet. With IPv4 that is just not possible.

I initially started with Rob's boosterpack, but ran out of memory as well. However, I am betting his Boosterpack would work on the Stellaris. I would port my own code to the Stellaris but I don't know if I am going to have enough time for it or if enough people are interested in it to make it worth the trouble. I don't know anything about the ENC28J60. I am just giving people an overview of what I learned so they can compare for themselves here. I never did any research about other ethernet chips -- I just used the Wiznet because it was on the Boosterpack when I bought it.



I really appreciate your information. I chose the ENC28J60-chip as it was the cheapest I could find that did SPI. I found out about the Wiznet chips later when I had started working with the ENC28J60. I might still prefer the ENC28J60 today, mainly due to the fact that I can use IPv6 with it. But as mentioned above, that might not really be a requirement for everyone. The ENC-chip driver that I wrote for my own stack was ported to uIP in an hour or so, and I guess it wouldn't take longer to port it to other IP-stacks as it behaves as a regular MAC/PHY-device. I'm not quite sure how a hybrid devices, such as the Wiznet chips should be driven by uIP.

Having looked at the uIP code you mentioned, I am thinking I may have actually taken wrong approach in what I've done and probably should have just used uIP instead along with the ENC chip instead. That Contiki OS that uses uIP is interesting too. It apparently runs on the MSP430 according to their website. Perhaps it would be a more useful effort to port Contiki to Stellaris.



I have considered trying out both Contiki and NuttX on both MSP430F5510 and the Stellaris Launchpad. However, I haven't had the time to take a serious look at them. NuttX seems to support Stellaris LM3s, so it might be the easiest to get working on the Stellaris Launchpad. I even think NuttX has an ENC28J60-driver, so it might be an easy task.
Anyways, porting any of those OS'es to any of the platforms would be great fun. If anyone is up to it, I will be happy to help. I just don't have the time to do it on my own, currently (I have one of those todo-lists that doesn't know how to shrink).

I assume there will be some some Ethernet Boosterpack for the Stellaris... it is just a matter of choosing the right code and chip. At this point I think that uIP might be a better choice because it is better known. What do you think about lwip? It looks like it might be a more active codebase than uip?


Indeed. I had a quick look at lwip when I started working with the booster on Stellaris, but for some reason decided uIP was easiest to get working. Can't remember why, though. Probably it was a (un)lucky pick. To be honest, I just wanted the thing working as quick as possible :D
But I'm curious, so maybe I should try getting the booster working with lwip as well

BTW here is a blog post I did with my latest code (wrote earlier today): http://www.cashdolla...p430-completed/


Interesting. I will be following your progress closely. It's cool that your doing your own OS, you will learn plenty from doing that.
Do you have any design goals for your OS?
  • Nytblade likes this

#11 _txf_

_txf_

    Member

  • Members
  • PipPip
  • 19 posts


Posted 18 October 2012 - 09:26 PM

Indeed. I had a quick look at lwip when I started working with the booster on Stellaris, but for some reason decided uIP was easiest to get working. Can't remember why, though. Probably it was a (un)lucky pick. To be honest, I just wanted the thing working as quick as possible :D
But I'm curious, so maybe I should try getting the booster working with lwip as well


uIP is indeed the easier of the two to get working, primarily because it is much more simple than lwip. Unfortunately these days more recent versions of uIP are coupled to Contiki.

lwIP is, however, much more flexible and powerful. If a uC has sufficient flash and ram then there is no reason not to go with lwIP, for technical reasons. You'll note that the majority of ethernet examples in StellarisWare use lwIP (one or two use uIP).

Porting speed and simplicity however favour uIP.

#12 xpg

xpg

    Advanced Member

  • Members
  • PipPipPip
  • 101 posts


Posted 18 October 2012 - 09:29 PM

uIP is indeed the easier of the two to get working, primarily because it is much more simple than lwip. Unfortunately these days more recent versions of uIP are coupled to Contiki.

lwIP is, however, much more flexible and powerful. If a uC has sufficient flash and ram then there is no reason not to go with lwIP, for technical reasons. You'll note that the majority of ethernet examples in StellarisWare use lwIP (one or two use uIP).

Porting speed and simplicity however favour uIP.


Thankl you very much for that information. Sounds like I'll need to get working on lwIP. Do you have any experience with Contiki?

#13 _txf_

_txf_

    Member

  • Members
  • PipPip
  • 19 posts


Posted 18 October 2012 - 09:33 PM

Do you have any experience with Contiki?


I wish. I keep meaning to have a look at it, maybe even port it to the stellaris (there are already stm32 ports). First I want to see if I can get some 802.15.4 modules working , so that I can get some sweet 6lowPan mesh networks going (with contiki).

(though tbh, contiki is more designed for lower power uCs like MSP430, and maybe M0).

#14 xpg

xpg

    Advanced Member

  • Members
  • PipPipPip
  • 101 posts


Posted 18 October 2012 - 09:41 PM

I wish. I keep meaning to have a look at it, maybe even port it to the stellaris (there are already stm32 ports). First I want to see if I can get some 802.15.4 modules working , so that I can get some sweet 6lowPan mesh networks going (with contiki).


That sounds very interesting. Please keep us up to date.

#15 Nytblade

Nytblade

    Member

  • Members
  • PipPip
  • 20 posts
  • LocationChicago

Posted 20 October 2012 - 11:28 AM

Interesting. I will be following your progress closely. It's cool that your doing your own OS, you will learn plenty from doing that.
Do you have any design goals for your OS?


Actually my goal was a kind of "internet of things" operating system, basically the same as what Contiki appears to be aiming for. I want to try some experiments with distributed operating system / collective sensor intelligence design as well.

I agree that IPv6 appears to be the future, but I am not sure if it will be able to beat proprietary standards like Bluetooth and Zigbee. For that reason my next step after Ethernet was going to be to add Bluetooth Low Energy support. Now I am undecided on that.

#16 xpg

xpg

    Advanced Member

  • Members
  • PipPipPip
  • 101 posts


Posted 20 October 2012 - 12:25 PM

Actually my goal was a kind of "internet of things" operating system, basically the same as what Contiki appears to be aiming for. I want to try some experiments with distributed operating system / collective sensor intelligence design as well.


I am currently playing with something similar. Not as ambitious as your project sounds, just a simple way of collecting information from various sensors that I can place around the house. I have been mainly focusing on the sensor side, which I envision being MSP430-based due to the very low power usage.

I agree that IPv6 appears to be the future, but I am not sure if it will be able to beat proprietary standards like Bluetooth and Zigbee. For that reason my next step after Ethernet was going to be to add Bluetooth Low Energy support. Now I am undecided on that.


IPv6 by itself does not really help sensors communicate, and for very low power things I think it is quite overkill. Most sensors won't hardly receive any data besides what is needed for configuration.
While I haven't looked into Zigbee or Bluetooth Low Energy, my first guess is that they are quite expensive to get started with. Currently I'm playing with some cheap CC2500 modules where my goal is to achieve extreme power efficiency by allowing the sensor only to power up the radio circuitry once every 5 minutes or even less frequent.
Having briefly read the IEEE 802.15.4 standard, I think it might make sense to implement parts of it on MSP430 chips using CC2500 modules. But for now I'm just playing around with some custom stuff to gain a bit of experience.

Oh, and maybe we should move any further wireless/sensor discussion to a new thread :-)

#17 bluehash

bluehash

    Administrator

  • Administrators
  • 859 posts
  • LocationWaltham, MA

Posted 20 October 2012 - 12:40 PM

Oh, and maybe we should move any further wireless/sensor discussion to a new thread :-)

I would agree. This will help the booster to be on topic.
Good discussion BTW.
C2KCentral - C2000 News, Projects and Forums | 43oh - MSP430 Discussion, News and Projects. | Stellarisiti - Stellaris ARM Forums, Projects and News.

#18 soccou

soccou

    Member

  • Members
  • PipPip
  • 15 posts

Posted 31 October 2012 - 09:18 PM

Wow this looks great, and exactly what I was looking for :)

I have been successfully using the ENC28J60 chip with an AVR for a while, but wanted to try to get my new stellaris launchpad working.

It looks like the source code attached is setup to be compiled with a linux GCC toolchain, is that correct?

Right now I only have the CCSv5 toolchain on windows working. Can this source code be imported into a CCS project easily? Anyone have any hints or links to tutorials on that type of import / compile process?

Thanks in advance,

Sokkou

#19 xpg

xpg

    Advanced Member

  • Members
  • PipPipPip
  • 101 posts


Posted 01 November 2012 - 11:35 AM

It looks like the source code attached is setup to be compiled with a linux GCC toolchain, is that correct?


That is correct. I ought to make it toolchain independent, as that shouldn't be too difficult. The general structure of the code is not too good at this point, as it was just a proof of concept. But I'll try to fire up CCSv5 and see what I can do about it.

#20 soccou

soccou

    Member

  • Members
  • PipPip
  • 15 posts

Posted 01 November 2012 - 12:56 PM

Hi xpg,
Thanks. I would appreciate any info or conversion you have time for.

Also, I am interested to learn as well. If anyone can suggest documentation or steps for that type of toolchain switch process.






Recent blog entries on this topic

Photo

Stellaris Launchpad ENC28J60 Ethernet BoosterPack

By Stellarisiti in The Stellarisiti Blog, on 12 October 2012 - 10:27 PM


Xpg has completed porting his msp430 ethernet boosterpack to the Stellaris Launchpad....

Read Full Entry →

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users