CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC24FJ256GB110 and TCP/IP problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PG_Program



Joined: 17 Jul 2020
Posts: 6

View user's profile Send private message

PIC24FJ256GB110 and TCP/IP problem
PostPosted: Fri Jul 17, 2020 3:58 am     Reply with quote

Hi everybody,
I run a simple project with PIC24FJ256GB110 and ENC28J60. We use a
simple webserver for showing online values and some setting pages. The
problem is when the webserver page sizes (mpfsimg.bin) are higher than
around 12k, CPU goes into reset !!
I also disabled the watchdog timer but result is the same.
The CPU goes into reset exactly when we call the page from browser !
When we use pages with lower size (mpfsimg.bin < ~12k) the system
works normally and we can see pages in web browser.
Is there any idea for this problem ?
Your notes highly appreciated.
thanks
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sun Jul 19, 2020 12:27 am     Reply with quote

Hey there PG.

I haven't played with the CCS TCP stack in a LONG time...

but it's based on the Microchip v3.75 (IIRC) TCPIP stack.

Granted, my project uses a PIC18F97J60... but I'm definitely using MPFS and the web pages are being stored out on a 2MB FLASH.

There are definitely files > 12KB (like 30KB PNGs and 72K of Javascript and a collection of sound files that are all > 12KB) that work OK.

I realize that's possibly not helpful yes other than to say, "I know MPFS works with the web server for files > 12K".

And are you saying the MPFSimg.bin is > 12K or the files within the image are < or > 12K?
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Sun Jul 19, 2020 10:04 am     Reply with quote

Tell us more.
How is the data actually stored?. Obviously you can use data from a
number of locations, is it possible that the method you are using to actually
store the data is giving issues when the size is larger?.
Any chance you can debug what the restart_cause is when this happens?.
Thoughts are that you may be triggering something like an address error,
or a maths error.
kmp84



Joined: 02 Feb 2010
Posts: 345

View user's profile Send private message

PostPosted: Mon Jul 20, 2020 1:01 am     Reply with quote

To tell my experience:

I also had problems with mpfs file inside controller's memory. With PCD devices it doesn't work because it has not function for writing program memory. My last target was dsPic33EP512. I have added external memory AT45DB011 and everything works correct.

Best Regard!
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Mon Jul 20, 2020 1:36 am     Reply with quote

It's wrong to say that the PCD devices does not have functions to write
program memory. They do, _but_ there are very major issues with
using the program memory:
1) First thing is the program memory has three bytes per four available.
So if you want to store something it has to be 'reformatted' to fit this
layout. Then when reading the data has to be read as 3bytes at a time.
2) Then the second thing is that memory erases are in relatively large
pages. Typically perhaps 512 instructions at a time.
3) Then third big 'caveat'. Remember on most of these PIC's the
configuration data occupies the top few bytes of the top page of ROM. So
you have to ensure that your data does not use this page.
I have DsPIC's running here using several tens of KB of program memory
to contain data. However it has to be loaded into the program memory
using the #IMPORT command, like:

#IMPORT(FILE=.\page.bin, RAW, LOCATION=where_stored, BPI=3)

The 'BPI' here is what reformats the data to 3 bytes per instruction.

This is then read using:
Code:

union access {
    unsigned int32 whole;
    unsigned int8 bytes[4];
};


//routine to give access to ROM stored data - used for bin data
BYTE getval(unsigned int32 locn, unsigned int32 index)
{
    unsigned int32 calc;
    union access rdg;
    unsigned int8 bval;
    //Now I need to calculate the actual cell I need to read, fetch this
    //then extract the byte
    calc=(index/3)*2;
    //This gives the actual cell offset from locn.
    read_program_memory(locn+calc, &rdg, 4);
    //Gives the 32bit value containing the byte required.
    bval=index % 3;
    //Now gives the byte number required
    return rdg.bytes[bval];
    //return the physical byte
}

With 'locn' being 'where_stored', and 'index' the address the byte is to come
from.

If you want to write on a running chip, a reciprocal code to this is needed
to repack the data into this format.

Using the program memory on these PIC's is quite complex, and fraught
with difficulties.... Sad
PG_Program



Joined: 17 Jul 2020
Posts: 6

View user's profile Send private message

PostPosted: Mon Jul 20, 2020 7:29 am     Reply with quote

Dear Friends,
Thanks for attention.
The problem is when MPFSimg.bin size is higher than around 12k, I check this issue with PIC18F26k80 and write a simple project and there was not any problem, but in 24F I think there is a point ? and I don’t know .
The problem happen when MPFSimg.bin goes higher than around 12 k !
For example when i add and image or some simple text that size goes higher then CPU goes reset.
The cpu reset cause exactly when we call page on browser, it means the problem is on addressing of MFPSimg.bin, i check the location and .. but no result.
Thanks again
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Mon Jul 20, 2020 7:49 am     Reply with quote

So you need to add some diagnostics, and find what the processor
restart_cause actually is on this reset.
I'd suspect you are going to either see RESTART_ILLEGAL_OP or
RESTART_TRAP_CONFLICT.

One obvious thought. How big is your stack?. It might be as simple as
a stack overflow. Remember the PIC18, does not use the stack for
data storage,. while the PIC24/30/33 all do. It is amazingly easy to
overflow the stack on these processors, with the compiler seeming to
not report some things that do use the stack, so it is better to always
err towards having quite a lot of spare stack space. primtf in particular
uses more stack than the compiler thinks it does...
PG_Program



Joined: 17 Jul 2020
Posts: 6

View user's profile Send private message

PostPosted: Mon Jul 20, 2020 7:51 am     Reply with quote

Ttelmah wrote:
It's wrong to say that the PCD devices does not have functions to write
program memory. They do, _but_ there are very major issues with
using the program memory:
1) First thing is the program memory has three bytes per four available.
So if you want to store something it has to be 'reformatted' to fit this
layout. Then when reading the data has to be read as 3bytes at a time.
2) Then the second thing is that memory erases are in relatively large
pages. Typically perhaps 512 instructions at a time.
3) Then third big 'caveat'. Remember on most of these PIC's the
configuration data occupies the top few bytes of the top page of ROM. So
you have to ensure that your data does not use this page.
I have DsPIC's running here using several tens of KB of program memory
to contain data. However it has to be loaded into the program memory
using the #IMPORT command, like:

#IMPORT(FILE=.\page.bin, RAW, LOCATION=where_stored, BPI=3)

The 'BPI' here is what reformats the data to 3 bytes per instruction.

This is then read using:
Code:

union access {
    unsigned int32 whole;
    unsigned int8 bytes[4];
};


//routine to give access to ROM stored data - used for bin data
BYTE getval(unsigned int32 locn, unsigned int32 index)
{
    unsigned int32 calc;
    union access rdg;
    unsigned int8 bval;
    //Now I need to calculate the actual cell I need to read, fetch this
    //then extract the byte
    calc=(index/3)*2;
    //This gives the actual cell offset from locn.
    read_program_memory(locn+calc, &rdg, 4);
    //Gives the 32bit value containing the byte required.
    bval=index % 3;
    //Now gives the byte number required
    return rdg.bytes[bval];
    //return the physical byte
}

With 'locn' being 'where_stored', and 'index' the address the byte is to come
from.

If you want to write on a running chip, a reciprocal code to this is needed
to repack the data into this format.

Using the program memory on these PIC's is quite complex, and fraught
with difficulties.... Sad



Dear Ttelmah,
When i change the BPI to 3, I see this message on MPFimg.bin lower than 12k: "Error 500 internal server error ".
In case of bigger MPFSimg the result same as before.
Thanks and best regards.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Mon Jul 20, 2020 8:09 am     Reply with quote

You need to tell us more about how your project is actually built.
What hardware are you using to hold the data?. Are you using the
PIC's program memory for this?.

If you look, CCS defaults to packing 2 bytes per instruction. Wastes
a significant space, but avoids this problem. They use PSV, which
requires the data to be stored this way but limits you to 16K max.
If you are storing in the program memory, I suspect you are just
hitting the maximum that can be stored without re-writing the access
routines yourself....
PG_Program



Joined: 17 Jul 2020
Posts: 6

View user's profile Send private message

PostPosted: Mon Jul 20, 2020 8:23 am     Reply with quote

Ttelmah wrote:
You need to tell us more about how your project is actually built.
What hardware are you using to hold the data?. Are you using the
PIC's program memory for this?.


Dear Ttelmah,

I use the ccs wizard for making a simple project, and when the MPFSimg size is small everything is okay.
My hardware is simple and use ENC28J60 board and connect to spi bus on my board and use internal memory of PIC for storing data.
If you give me your email i can forward whole project for you if you have time.
Thanks and best regards.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Mon Jul 20, 2020 8:41 am     Reply with quote

If you want to use that much data add an external memory for it.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Jul 23, 2020 3:55 pm     Reply with quote

Yea - I'd also chime in to say that after a couple of embedded web projects using PIC CPUs, external FLASH is the way to go for holding web pages.

It's surprising how fast you can use lots of memory for decent looking web pages.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
PG_Program



Joined: 17 Jul 2020
Posts: 6

View user's profile Send private message

adding SPI flash
PostPosted: Mon Aug 03, 2020 9:32 am     Reply with quote

Dear friends ,
I try a lot but I can’t find any way to solve problem , then I change hardware and add external SPI flash (SST25VF016B) for webserver files .
I edited my HardwareProfile.h and added SPI flash defines to it ,but I have two question that
where I should enable MPFS_USE_SPI_FLASH that compiler read from SPI flash ?
How I can transfer my web pages to SPI flash ? (is there any documents or example for it)
Thanks for help .
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Aug 03, 2020 10:01 am     Reply with quote

In my old project files:

There are two #defines which I'm sure you have one already.

IIRC, both are located in TCPIPconfig.h (although in my project, I commented out near everything and redirected TCPIPconfig.h to include another file that has all my project specific edits in it)

One is the STACK_USE_MPFS2 and the other is the one you also mentioned which is
MPFS_USE_SPI_FLASH

I also have MPFS_RESERVE_BLOCK set to (4096ul)
and MAX_MPFS_HANDLES set to (13ul)

As for uploading them,

once you have the TCPIP web app working, there's a URL /mpfsupload that allows you to push the web pages into the SPI FLASH from the web browser.


One example talks about this:
https://documentation.help/Microchip-TCP.IP-Stack/GS-MPFSUpload.html

for my PIC web server it's indeed http://hostname/mpfsupload

and there's a utility (I'm sure you have used already) to convert the web page file structure into an MPFS.bin file which you still use.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
PG_Program



Joined: 17 Jul 2020
Posts: 6

View user's profile Send private message

adding SPI flash
PostPosted: Wed Aug 05, 2020 10:29 am     Reply with quote

Dear bkamen,
Thanks for useful information. After long try i can compile without any errors,
but there are some points that its not clear for me. I added these define to my header file for using SPIFlash

#define MPFS_USE_SPI_FLASH
#undef MPFS_USE_EEPROM

#define MPFS_RESERVE_BLOCK (4096ul)


1. I didn't find any page inside the programs for uploading the MPFS files inside the spi flash ! Did you do uploading with ccs compiler ?

Because when i call mpfsupload page, i see error 500 (internal server error).
Thanks
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group