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 CCS Technical Support

TCPIP wizard problem

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



Joined: 08 Jan 2018
Posts: 59
Location: Finland

View user's profile Send private message

TCPIP wizard problem
PostPosted: Sun May 12, 2019 9:19 am     Reply with quote

Hello!

I have successfully working 18F67J60 webserver project and i want to change that to DSPIC33EP512MC202 + ENC28J60 combo.
DSPic running 140Mhz and led is blinking correctly, however if i use default webpage on that wizard i get "internal server error 500" but if i change file "mpfsimg.bin" to another project webpage shows up?? If i change something on that page i get same error again.

What is can be the problem? Is that some silly mistake?
Can it MPFS problem?

DSPIC33EP512MC202 + ENC28J60
WIN7 64bit
PCWHD 5.081
Compiling MPLAB IDE 8.92 + CCSC plugin

Hardwareprofile.h
Code:

//Port control:
#use standard_io(a)
#use standard_io(b)

//Output control:
#define low(X)   output_low(X)
#define high(X)  output_high(X)

//I/O- configuration:
#define STATUSLED1      PIN_A0
//#define   MODE         (!input(PIN_c0))

//ENC28J60 ethernet bridge setup:
#define ENC28J60_SPI_PORT SPI1
#define ENC_CS_IO        LATBbits.LATB15
#define ENC_CS_TRIS      TRISBbits.TRISB15
#define ENC_RST_IO       LATBbits.LATB7
#define ENC_RST_TRIS     TRISBbits.TRISB7

//UART:
#PIN_SELECT U1RX=PIN_B11
#PIN_SELECT U1TX=PIN_B10
#USE RS232 (UART1, BAUD=115200, ERRORS, STREAM=HW_CONSOLE)

//I2c:
/*
#pin_select SCL1OUT = PIN_C0
#pin_select SCL1IN  = PIN_C0
#pin_select SDA1OUT = PIN_C1
#pin_select SDA1IN  = PIN_C1
*/
#use i2c(MASTER, I2C1, FAST)


tcpipconfig.h
Code:

#define STACK_USE_ICMP_SERVER    1
#define STACK_USE_TCP            1
#define STACK_USE_DHCP_CLIENT    1

#define STACK_CCS_SMTP_TX_SIZE    0
#define STACK_CCS_SMTP_RX_SIZE    0

#define STACK_USE_CCS_HTTP2_SERVER
#define STACK_CCS_HTTP2_SERVER_TX_SIZE    1500
#define STACK_CCS_HTTP2_SERVER_RX_SIZE    500
#define HTTP_NUM_SOCKETS                  1
#define HTTP_PORT                         (80u)
#define HTTP_USE_DOUBLE_ESCAPE            1
#import(RAW, file="mpfs/mpfsimg.bin", location=MPFS_Start, bpi=2)

#define STACK_MY_HTTPC_RX_SIZE    0
#define STACK_MY_HTTPC_TX_SIZE    0

#define STACK_MY_TELNET_SERVER_TX_SIZE    0
#define STACK_MY_TELNET_SERVER_RX_SIZE    0

#define MY_DEFAULT_HOST_NAME      "DSPserver"

#define MY_DEFAULT_MAC_BYTE1      (0x3e)
#define MY_DEFAULT_MAC_BYTE2      (0x2f)
#define MY_DEFAULT_MAC_BYTE3      (0x3f)
#define MY_DEFAULT_MAC_BYTE4      (0x23)
#define MY_DEFAULT_MAC_BYTE5      (0x43)
#define MY_DEFAULT_MAC_BYTE6      (0x17)

#define TCP_CONFIGURATION      1


Thank you for your help!
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Sun May 12, 2019 12:19 pm     Reply with quote

500, is about the most generic server error, given when it can't
provide what has been asked for some reason. Commonest causes
on a working server, are permission issues.
I'm most suspicious of your import. You have to remember that while
a PIC18 can store two byte per instruction, the PIC24/30/33 can only
store 3 bytes per 4 byte instruction. There has to be a hole' at every
fourth byte. This is the format the data has to appear in memory to
be read correctly as a const.
Try an experiment. Generate a simple cutdown project, and import
the file into this. Then look at the data actually contained in the
resulting constant. Print it out or look at it with a debugger. I suspect
you are going to find the stored constant has a gap at the third byte,
where the const actually reads the third byte but the file is only loading
two bytes into the instruction. I think you need to use bpi=3 for a PIC24.
-Terppa-



Joined: 08 Jan 2018
Posts: 59
Location: Finland

View user's profile Send private message

PostPosted: Sun May 12, 2019 12:39 pm     Reply with quote

Thank you I try that idea I just found some debug tools inside mpfs.h /mpfs.c and see what that mpfs says..
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Mon May 13, 2019 3:50 am     Reply with quote

Can confirm this is an issue.
Just tried a basic experiment to see what the code gets with the import
done like this, and it has bytes missing from the data....
-Terppa-



Joined: 08 Jan 2018
Posts: 59
Location: Finland

View user's profile Send private message

PostPosted: Mon May 13, 2019 5:19 am     Reply with quote

Hmm.. I ripped out all stuff in main and it looks like that:

Code:

void main()
{
//pin_control();
led_test();


   IPAddressInit();
   TickInit();
   enable_interrupts(GLOBAL);
   StackInit();

//   set_HC12_lite_setup();

   delay_ms(300);


//   fprintf(debug_mpfs_putc,"Server test for DSPic v5.081");
//   fprintf(HW_CONSOLE,"Server test DSPic33EP512MC202 v5.081");


   while(TRUE)
   {
   StackTask();
   StackApplications();

//   heart_beat_led(BLINKLEDOFFTIME);
   }
}


And i also tested something like that in TCPIPconfig.h but i still get same issue.. Now what?

Code:

#define STACK_USE_DNS            1   
#define STACK_USE_NBNS            1                  
#define STACK_USE_ICMP_SERVER      1
#define STACK_USE_TCP            1
#define STACK_USE_DHCP_CLIENT      1
#define MY_UNIT_HOSTNAME         "DSPserver"
#define MY_DEFAULT_HOST_NAME      "DSPserver"

#define STACK_CCS_SMTP_TX_SIZE    0
#define STACK_CCS_SMTP_RX_SIZE    0

#define STACK_USE_CCS_HTTP2_SERVER
#define STACK_CCS_HTTP2_SERVER_TX_SIZE    1500
#define STACK_CCS_HTTP2_SERVER_RX_SIZE    500
#define HTTP_NUM_SOCKETS                  1
#define HTTP_PORT                         (80u)
#define HTTP_USE_DOUBLE_ESCAPE            1

//#import(RAW, file="mpfs/mpfsimg.bin", location=MPFS_Start, bpi=2)//original
//#import(RAW, file="mpfs/mpfsimg.bin", location=MPFS_Start)
//#import(RAW, file="mpfs/mpfsimg.bin", location=MPFS_Start, bpi=3)
//#import(RAW, file="mpfs/mpfsimg.bin", location=MPFS_Start, bpi=4)
#import(RAW, file="mpfs/mpfsimg.bin", location=MPFS_Start, bpi=5)

#define STACK_MY_HTTPC_RX_SIZE    0
#define STACK_MY_HTTPC_TX_SIZE    0

#define STACK_MY_TELNET_SERVER_TX_SIZE    0
#define STACK_MY_TELNET_SERVER_RX_SIZE    0
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Mon May 13, 2019 7:29 am     Reply with quote

bpi=5?...

Problem is that the code that actually reads this from memory, needs to
be modified to handle how the PIC24 stores things. The standard code
uses read_program_memory, and loads it into a RAM buffer to send.
What needs to happen is that you use bpi=3, and the loading code instead
of assuming the bytes are stored sequentially has to read three bytes, jump
forward one, then read three more bytes, jump one etc...
Unfortunately the ROM layout of the PIC24, is actually quite inconvenient
here...
-Terppa-



Joined: 08 Jan 2018
Posts: 59
Location: Finland

View user's profile Send private message

PostPosted: Mon May 13, 2019 8:52 am     Reply with quote

That bpi=5 is just testing. I'm use bpi=3 in this point.

Everything else has works, serial port, probably i2c, etc.
I still not understand why it works if i copy my working 18F67J60 folder "mpfsimg.bin" image to DSpic33ep512mc202 tcpip folder.

What if i change that project another DSpic? 24EP? or is that problem all of DSpic's?

Maybe CCSC has some solution/update for this?

Thank you for your help!
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Mon May 13, 2019 10:23 am     Reply with quote

It is the memory architecture of the DsPIC's.

On the PIC16, each 'word' of instruction memory, is 16bits long, and can
hold two bytes.
On the DsPIC's (24/30/33), each word of instruction memory is 24bits long
and can hold 3 bytes. However the memory itself is organised as 32bit
elements. So you get 3 bytes of data, then a one byte 'gap' that can't be
used. Then 3 bytes, and another gap. So when CCS stores consts, they
load a 32bit 'word' from the memory, then read 3 bytes out of this. Then
move forwards another word.

Now is it possible to access the ROM on the DSPIC's through RAM addresses
using 'PSV' (Program space visibility). In this mode two bytes of each
word only are used. However to do this would require you to be able
to load the data into an area of the program memory that the compiler
knows to map for this.
I think you should ask CCS if there is a way to import a file like this and
use it this way. It's a mode that few people use, and there may well be
'undocumented' ways of doing this.
-Terppa-



Joined: 08 Jan 2018
Posts: 59
Location: Finland

View user's profile Send private message

PostPosted: Mon May 13, 2019 11:03 am     Reply with quote

Thank you for that explanation!

I'm testing that a little bit more and put that mpfs.c data to terminal.
First test is put 18f67j60 working mpfsimg.bin to dsPIC33ep512mc202 project.
Webpage shows up when i change pbi=3 to pbi=2. Terminal window looks like this:
Code:
 
MPFSClose()
MPFSOpen() 'index.htm' p1='index.htm'0x1260 p2='INDEX.HTM'0x1260 START=0x4A2DC e=11 FLAG=0x0 FLAG=0x0 found_0x4BDE8
MPFSClose()
MPFSOpen() 'INDEX.HTM' p1='INDEX.HTM'0x13A6 p2='INDEX.HTM'0x13A6 START=0x4A2DC e=11 FLAG=0x0 FLAG=0x0 found_0x4BDE8
MPFSClose()
MPFSClose()
MPFSOpen() 'text_styles.css' p1='text_styles.css'0x1261 p2='TEXT_STYLES.CSS'0x1261 START=0x4A2DC e=11 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 found_0x4EDDE
MPFSClose()
MPFSOpen() 'TEXT_STYLES.CSS' p1='TEXT_STYLES.CSS'0x13A6 p2='TEXT_STYLES.CSS'0x13A6 START=0x4A2DC e=11 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 found_0x4EDDE
MPFSClose()
MPFSClose()
MPFSOpen() 'combined.js' p1='combined.js'0x1261 p2='COMBINED.JS'0x1261 START=0x4A2DC e=11 FLAG=0x0 found_0x4A353
MPFSClose()
MPFSOpen() 'COMBINED.JS' p1='COMBINED.JS'0x13A6 p2='COMBINED.JS'0x13A6 START=0x4A2DC e=11 FLAG=0x0 found_0x4A353
MPFSClose()


Second test is try to show that wizard generated page and it says "internal server error 500"
and terminal window looks like this:
Code:

MPFSClose()
MPFSOpen() 'index.htm' p1='index.htm'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x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0
.
.
.
MPFSOpen() 'error500.htm' p1='error500.htm'0x13A6 p2='ERROR500.HTM'0x13A6 START=0x519D4 e=11 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x0
.
.
.
FLAG=0x0 FLAG=0x0 FLAG=0x0 FLAG=0x1E invalid_flag
MPFSClose()

and so on. This ends "internal server error 500".
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