chipKIT® Development Platform

Inspired by Arduino™

Cerebot mx7ck and Ethernet

Created Fri, 08 Jun 2012 19:21:00 +0000 by vitobot


vitobot

Fri, 08 Jun 2012 19:21:00 +0000

Dear friends, I need some help to start up with Cerebot mx7ck.

I want to use the embedded ethernet port to set up a DHCP connection, call a remote script URL and manage the answer of the script.

Anyone can tell me how can I set it up?


nik999389

Fri, 08 Jun 2012 20:39:30 +0000

Well, you could get an Ethernet shield for it and program it yourself. Except I'm not too sure if there are any working libraries for any good shields.

Umm, do you think you could give us a little more than that? What do you expect the script to do? and what is your processor going to be used for? As a web server? as a script compiler? What are you trying to accomplish?


vitobot

Sat, 09 Jun 2012 17:02:33 +0000

Hi Nick. The microcontroller must work as client that call an URL and get the answer. Digilent give two libraries for MPIDE: DNetcK and chipKITEthernet. Has anyone had experience of this type?


Jacob Christ

Tue, 26 Jun 2012 13:50:04 +0000

call a remote script URL

Can you elaborate on this? I don't quite understand what you are trying to do.

Jacob


vitobot

Tue, 26 Jun 2012 22:45:19 +0000

Dear Jacob,

I need only to read the output of a remote script: http://46.105.19.18/cgi-bin/test.cgi

In this example I need to read the string "ko".

How can I do it with DNETcK library?


Jacob Christ

Wed, 27 Jun 2012 08:01:01 +0000

Dear Jacob, I need only to read the output of a remote script: http://46.105.19.18/cgi-bin/test.cgi In this example I need to read the string "ko". How can I do it with DNETcK library?

I've never used DNETcK, but the chipKIT WebClient may do the trick.

Jacob


vitobot

Wed, 27 Jun 2012 21:18:49 +0000

My Cerebot mx7ck have a strange behavior with DNETck library.

Methods begin and connect seems to work.

But other main methods (like isInitialized and isConnected) seems to freeze the system. Any line of code after that isn't executed.

I try to change the standard waiting time with the following: DNETcK::setDefaultBlockTime(DNETcK::msImmediate);

But the main problem is that I experience this behavior also with examples provided. RemoteWOL stop with this last alert: "Dynamic begin"

Can it be an hardware issue? Can I try to reset the board in some way?


GeneApperson

Thu, 28 Jun 2012 20:58:43 +0000

I have run a TCP client app, a TCP server app and an HTTP server app on a Cerebot MX7cK without any problems using the DNETcK library that is currently on the Digilent web site. In fact, there is an HTTP server running on an MX7cK sitting on my desk right now. So, I know it works.

I'll see if I can get Keith (the guy who wrote the library) to get on here and see if he can help you out.

Gene Apperson Digilent


vitobot

Sun, 01 Jul 2012 09:27:33 +0000

Thank you Gene. I want to notify that I do one step foreward.

Trying to set up an ethernet connection with DNETCK library, the first instruction that freeze the system is: if(DNETcK::isStatusAnError(status))

Removing this condition I finally get the error from the status answer of the isInitialized(&status)) method:

"Hard Error status #53 occurred." (RemoteWOL example)

I test it with more then one network and router with DHCP or with static parameters. Near the ethernet port, LD5, LD6, L7 are orange. On the ethernet port, the left led is orange and the right led is yellow.

Do you think that my microcontroller is fault? Can I try some kind of reset?

The serial number on the back side is: d414760


Jacob Christ

Mon, 02 Jul 2012 05:46:40 +0000

Which bootloader are you using on your board? I've been trying to use the USB bootloader and it's missing some pragma's that prevent the chipKITEthernet lib from working. I just added the following to the bootloader code main.c to get Ethernet to work on my board (Basicly a Max32 and Network Shield).

#pragma config	FETHIO = ON	// Standard/alternate ETH pin select (OFF=Alt)
#pragma config	FMIIEN = OFF	// MII/RMII select (OFF=RMII)

Jacob


vitobot

Mon, 02 Jul 2012 09:22:28 +0000

Dear Jacob, can you tell me steps required to change the bootloader? I remember your that I need to program with MPIDE. Thank you


Jacob Christ

Mon, 02 Jul 2012 20:31:11 +0000

Dear Jacob, can you tell me steps required to change the bootloader? I remember your that I need to program with MPIDE. Thank you

You only need to do this if your using the USB-Bootloader. The bootloader for the Max32 SHOULD work fine.

You need to download the bootloader code from here (you may need git):

https://github.com/chipKIT32/pic32-Arduino-USB-Bootloader

You need to download MPLAB X from here:

http://www.microchip.com/pagehandler/en-us/family/mplabx/

Open the code in MPLAB X and select your board. If you board doesn't exist you will need to make a custom build for it.

Once built, you will need a tool like and ICD or PicKit to re-flash the bootloader for you board.

Jacob


vitobot

Mon, 02 Jul 2012 20:55:30 +0000

Dear Jacob,

I just solved following the direction of your help.

The problems with ethernet depends on the bootloader pre-installed on my mx5ck.

With MPLAB I uploaded the latest firmware found at bottom of the page dedicated to mx5ck on Diligent website.

Now all works great. Near the ethernet port, only LED7 is orange, LED5 and LED6 are off, but I don't know what it means.

Thanks a lot


Jacob Christ

Mon, 02 Jul 2012 22:55:11 +0000

Awsome! You must have an old board that had an old bootloader.

Jacob


GeneApperson

Mon, 02 Jul 2012 23:12:03 +0000

I am glad to hear that you have solved the problem, but am concerned that reprogramming the boot loader did it. This would seem to indicate a problem with the boot loader originally programmed on your board. They should all be programmed with the same boot loader image. I haven't heard of any other cases where this kind of problem has come up. I know that I have taken boards directly from stock and run network sketches on them without any problems.

LED5, LED6, and LED7 on the Cerebot MX7cK are part of the licensed debugger circuit and don't have anything to do with the Ethernet circuit. They just happen to be next to the RJ45 connector. Those LEDs have the same function as the three LEDs on a PICkit3.

Although I designed the board, I don't have a clue what they actually mean :), as that part of the design came from Microchip.

Gene Apperson Digilent


vitobot

Tue, 03 Jul 2012 00:02:32 +0000

Dear Gene, I suspected that it was a strange solution since the latest chipKIT is dated 1/25/12. I could be wrong but that update seems to have solved the main problems.

But when the ethernet cable is unplugged the problem still exist. This depends on the same methods that I mentioned at the beginning of the post: isInitialized(), isConnected(), available() (the last one used to get the answer of the server)

These methods block the function loop() and not allow to perform actions in this situation.

I need to constantly get the state of pins on a PMod connector.

For this, I need to modify these methods to maintain control while these methods await the retrieval of the connection.

Can you help me in some way?


KeithV

Tue, 03 Jul 2012 01:00:08 +0000

vitobot,

Sorry but I've been letting Jacob handle this sense he does such a good job, but I think I can offer some insite.

We need to be clear on which versions of DNETcK that we are running as there have been significant changes over the last 6 months.

As to your first problem, Gene and I have been scratching our memories and it is possible that if you have one of the very first MX7cKs that you did in fact have an older bootloader with the config bit wrong. I just checked, and the bootloader that have been on the Digilent site since at least last August set the config bits properly; which is probably why it worked. If your board is fairly new, then I am with Gene and have no idea why what you did worked.

As to your second problem. The default delay for connect is 15 seconds, this allows for DHCP and stuff to finish. I realize that this is way too long for an embedded system but we decided to pick this "default" because of the way the Arduino Ethernet Classes worked. However, if you are going to do serious programming, you want to change the default to immediate. As in the RemoteWOL example, you will see in the setup code a line like:

DNETcK::setDefaultBlockTime(DNETcK::msImmediate);  

This will then cause all calls to return as quickly as possible, but you WILL need to check the status to see when you are done! But you will be able to service the rest of your loop while waiting for the connection.

Now, it can take a long time to connect, and clearly you won't connect if you unplug the cable because the PHY is not linked. Now this is one of the differences with our latest release! I now check the status of the link and report the error correctly. In my last release I DID NOT, I erroneously reported you were connected when clearly that would be impossible! You now get a waiting connection non-fatal status. Plug the cable in, and you will be connected. If you unplug it later, you will get a fatal error of lost connection; because you did. But this change is only in the most current drop on the library.

A lot of this fell out with the multple hardware support we now have, including WiFi. More strict connection status is needed to keep the model consistent (and thus you code) across all hardware. In general, if you lose the link, you need to end() and then do a begin() and then hold in isInitialized or isConnected() until you get the connection; this insures that hardware/software is cleaned up when the link is broken. While the internal MAC (MX7cK) is really very good at not getting hosed and will often just automatically reconnect, using other hardware like the WiFi module is way less friendly!

In any case your code should check the status. Setting msImmediate as your default timeout you will always return immediately; but check the status. Stay in your state until either there is a hard failure, or you succeed. To know if you have a hard failure call isStatusAnError on the status.

The document is pretty clear on the msImmediate option, and that is what I always use. Maybe in the future we should make that the default, but that will break a lot of sketches. Use RemoteWOL as your model example, as the other examples are just to illistrate how quickly you can get something running; but they are not robust in design. In particular, take a look at the WiFiRemoteWOL, and you will see how to restart on failure. I have been running the WiFi server for over month with power failures and router reboots, and that server just keeps on recovering and working.

Hope this helps.

KeithV


penguinman

Mon, 23 Dec 2013 06:33:58 +0000

The Github repository contains an MPLAB X project.

The Project supports bootloaders for many different boards.

These are all defined and setup in a header file BoardConfig.h

I have no idea what to define or change in this header file in order to compile for a MAX32 board, and I have been an embedded C programmer for 20 years.

A simple explanation at the top of the file would be nice, instead of all the Licence agreement crap that no one reads or cares about.


Jacob Christ

Mon, 06 Jan 2014 19:11:51 +0000

penguinman,

Be the nature of the open source project, it would be great if you could implement and do a pull request for the changes you need.

A couple of warnings.

  1. I think the link I provided above is for the old bootloader project and there may be a new better bootloader project. I have not worked on bootloaders in quite sometime but I think this is the latest and greatest:

https://github.com/chipKIT32/PIC32-avrdude-bootloader

  1. The Max32 bootloader is not named so in the project, I think its called a the Mega bootloader (since the Max32 is kinda like a Mega). Anyway the one to look for is the one for the PIC32MX795F512L (which is the chip on the Max32).

Jacob


GPeti

Mon, 22 Sep 2014 07:50:18 +0000

Hi everybody, I new in this forum.

I made a web server with Cerebot MX7CK board, MPIDE-0023-windows-20120903, modified date of chipKITServer.cpp is 2011-10-10. Local netwowk work well, but via inernet across router or NAS the web page always froze, succesfully repair the defect, see code example:

//client.println("HTTP/1.1 200 OK"); client.print("H"); delay(1); client.print("T"); delay(1); client.print("T"); delay(1); client.print("P"); delay(1); client.print("/"); delay(1); client.print("1"); delay(1); client.print("."); delay(1); client.print("1"); delay(1); client.print(" "); delay(1); client.print("2"); delay(1); client.print("0"); delay(1); client.print("0"); delay(1); client.print(" "); delay(1); client.print("O"); delay(1); client.println("K");delay(1);

//client.println("Content-Type: text/html"); client.print("C"); delay(1); client.print("o"); delay(1); client.print("n"); delay(1); client.print("t"); delay(1); client.print("e"); delay(1); client.print("n"); delay(1); client.print("t"); delay(1); client.print("-"); delay(1); client.print("T"); delay(1); client.print("y"); delay(1); client.print("p"); delay(1); client.print("e"); delay(1); client.print(":"); delay(1); client.print(" "); delay(1); client.print("t"); delay(1); client.print("e"); delay(1); client.print("x"); delay(1); client.print("t"); delay(1); client.print("/"); delay(1); client.print("h"); delay(1); client.print("t"); delay(1); client.print("m"); delay(1); client.println("l");delay(1);

So between bytes needs 1ms delay, now the web server with this "correction" working very well, but slow and not too correct, the MX7CK in cliens mode work well no need delay. We can not change and don't know what is the rear problem please help and modify.