Forum Discussion
port goahead web server to nios2 uclinux
hi all:
I ported goahead websrver to nio2 use hippo's toolschain.
GoAhead WebServer 2.1 is a fully-featured, open-source embedded Web server that leverages Active Server Pages, embedded JavaScript, and in-process CGI forms processing (GoForms™) to deliver highly efficient and effective dynamic web page creation. Its source code is available free on the GoAhead website (http://www.goahead.com/webserver/wsregister.htm) to developers without royalties or proprietary lock-ins and is subject to the terms specified in the GoAhead .
The following step is my process:
1)download goahead webserver source code(webs218.tar.gz) from internet.
2)tar xzvf webs218.tar.gz
3)in the ../ws031202/LINUX dir,rework the original Makefile.
The original Make file is follow: attached
4)edit misc.c in the ../ws031202 dir
commet follow code:
//static int strnlen(char_t *s, unsigned int n);
/************************************************** ****************************/
/*
* Return the length of a string limited by a given length
*/
//static int strnlen(char_t *s, unsigned int n)
//{
// unsigned int len;
// len = gstrlen(s);
// return min(len, n);
//}
5)open the terminal ,cd ../ws031202/LINUX dir
6) PATH=$PATH:~/buildroot/build_nio2/staging_dir/bin
7)make
8)cp webs to ../rootfs/bin,cp ../ws031202/web dir to ../rootfs
9)rebuild kernel for inramfs use command "make ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc-"
10)nios2-linux-uclibc-strip vmlinux
11) under nios sdk shell,use command "nio2-download -g vmlinux" to download the vmlinux to your target board
12)open the windows terminal,cd /bin
13) exec command "hostname localhost"
14) exec command "webs"
now your goahead webserver is running on your target board.you can open your IE,then type your target board IP to visit the demo HTML.
ps: because I am a linux beginner.So my rework Makefile maybe have some bugs.if anyone find any mistakes,please tell me right here. Thanks.
15 Replies
- Altera_Forum
Honored Contributor
Hi Alex,
Good work. Please try out the new kernel. And let me know. You can use subversion to help tracking your works. Try "which svn", if you don't have it, install it with "yum install subversion". (for fedora core) 1. create the svn store, and check your original as rev1.
2. make your change to Makefile, misc.c .... build and test.... 3. after you finished, or when you want to save your change to store, as rev2cd ~ mkdir mysvn svnadmin create mysvn/webs tar xzvf webs218.tar.gz svn import ws031202 file:///home/alex/mysvn/webs/ws031202 -m="initial" rm -rf ws031202 svn co file:///home/alex/mysvn/webs/ws031202
Then you can send webs.diff to others 4. when other get your diff file, he can apply the patch and get the same update from yours.cd ws031202 svn commit -m="update for nios2 uclinux" svn diff -r1:2 >webs.diff
The subversion is very helpful. You can find more usages from the subversion guide on their web.tar xzvf webs218.tar.gz cd ws031202 patch -p0 <webs.diff - Altera_Forum
Honored Contributor
Hi hippo:
Thank you for suggestion. I have completed the diff file. Can you tell me how to upload attached file in the forum? - Altera_Forum
Honored Contributor
Great.
You can attach files in the "post your ip" area. Or you can add your diff file in line here. - Altera_Forum
Honored Contributor
the goahead webserver diff:
Index: LINUX/Makefile =================================================================== --- LINUX/Makefile (修订版 1) +++ LINUX/Makefile (修订版 2) @@ -9,6 +9,11 @@ all: compile +CC = nios2-linux-uclibc-gcc +AR = nios2-linux-uclibc-ar +LD = nios2-linux-uclibc-ld +OBJCOPY = nios2-linux-uclibc-objcopy + ARCH = libwebs.a NAME = webs @@ -56,11 +61,11 @@ ../security.o ../sym.o ../uemf.o ../url.o ../value.o ../md5c.o ../um.o ../umui.o ../websda.o ../emfdb.o ../webrom.o ../webs.o ../websuemf.o main.o -CFLAGS = -DWEBS -DUEMF -DOS="LINUX" -DLINUX $(UMSW) $(DASW) $(SSLSW) $(IFMODSW) +CFLAGS = -DWEBS -DUEMF -DOS="LINUX" -DLINUX -Dfork=vfork -D__uClinux__ $(UMSW) $(DASW) $(SSLSW) $(IFMODSW) OTHERS = -DB_STATS -DB_FILL -DDEBUG DEBUG = -g -Wall IFLAGS = -I.. -LDFLAGS = $(SSLLIB) $(IFMODLIB) +LDFLAGS = $(SSLLIB) $(IFMODLIB) -elf2flt="-s 64000" -Wl,-v -Wl,-d compile: $(NAME) @@ -75,7 +80,7 @@ # $(NAME): Makefile $(ARCH) $(CC) -o $(NAME) $(DEBUG) - $(CFLAGS) $(IFLAGS) + $(CFLAGS) main.o $(ARCH) $(LDFLAGS) clean: @@ -152,4 +157,4 @@ # Transition rules (add -o to put object in right directory) # .c.o: - cc -c -o $@ $(DEBUG) $(CFLAGS) $(IFLAGS) $< + $(CC) -c -o $@ $(DEBUG) $(CFLAGS) $(IFLAGS) $< Index: misc.c =================================================================== --- misc.c (修订版 1) +++ misc.c (修订版 2) @@ -58,7 +58,7 @@ static int dsnprintf(char_t **s, int size, char_t *fmt, va_list arg, int msize); -static int strnlen(char_t *s, unsigned int n); +//static int strnlen(char_t *s, unsigned int n); static void put_char(strbuf_t *buf, char_t c); static void put_string(strbuf_t *buf, char_t *s, int len, int width, int prec, enum flag f); @@ -425,13 +425,13 @@ * Return the length of a string limited by a given length */ -static int strnlen(char_t *s, unsigned int n) -{ - unsigned int len; +//static int strnlen(char_t *s, unsigned int n) +//{ +// unsigned int len; - len = gstrlen(s); - return min(len, n); -} +// len = gstrlen(s); +// return min(len, n); +//} /******************************************************************************/ /* - Altera_Forum
Honored Contributor
hi:
I got a applet.diff for gahead webs. I run svn diff -r1:2 >webs.diff But not success complete.How can I solve it? Thanks. [alex@localhost ws031202]$ patch -p0 <applet.diff (Stripping trailing CRs from patch.) patching file webs.h Hunk# 1 FAILED at 85. 1 out of 1 hunk FAILED -- saving rejects to file webs.h.rej (Stripping trailing CRs from patch.) patching file webs.c Hunk# 1 succeeded at 22 with fuzz 1. Hunk# 2 FAILED at 258. Hunk# 3 FAILED at 280. patch unexpectedly ends in middle of line Hunk# 4 FAILED at 1161. 3 out of 4 hunks FAILED -- saving rejects to file webs.c.rej [alex@localhost ws031202]$ - Altera_Forum
Honored Contributor
Where do you get the applet.diff?
- Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by hippo@Mar 2 2006, 09:42 PM where do you get the applet.diff?<div align='right'><{post_snapback}> (index.php?act=findpost&pid=13088)
--- quote end ---
--- Quote End --- I got the diff in a goahead bbs as follow: http://www.prolix.ro/dokuwiki/documentatio...et_does_not_run (http://www.prolix.ro/dokuwiki/documentation:goahead:general#java_applet_does_not_run) I copy the lines to blank text file,then I rename the file is *.diff
- Altera_Forum
Honored Contributor
They failed in white space, because we cut them from web page.
Use "-l" option in patch to ignore white space. Remove the old ws031202 dir, untar again, then apply patch,patch -l -p0 <applet.diff - Altera_Forum
Honored Contributor
<div class='quotetop'>QUOTE </div>
--- Quote Start --- I ported goahead websrver to nio2 use hippo's toolschain.[/b] --- Quote End --- Hi, can you help in doing the same but under the IDE ? Warm Regards - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by mfm@Apr 5 2006, 02:05 PM <div class='quotetop'>quote--- quote end ---
--- quote start ---
i ported goahead websrver to nio2 use hippo's toolschain. --- Quote End --- Hi, can you help in doing the same but under the IDE ? Warm Regards <div align='right'><{post_snapback}> (index.php?act=findpost&pid=14072)</div> [/b] --- Quote End --- Hi MFM: If you want to use goahead webserver in nios2 linux, you must use toolchains cross compile it. The IDE is difficult to compile it. I think the best way is build your nios2 toolchains under linux.