Migration of goahead in armlinux

Source: Internet
Author: User
Goahead is an embedded web server that supports scripting languages such as ASP, CGI, and embedded protocol Crip.
Basically, in Windows or under redhat9, make is enough to run.  Small Embedded Server: GoAhead
GoAhead Web server is small and exquisite, providing commendable performance.

GoAhead Web Server is a web server mainly for embedded systems. Its goal may not be the current web server market, but the future of embedded systems going deep into our work and life, at that time, it may become the most widely used Web server.

GoAhead Web server is part of goahead's embedded management framework product. This software package is mainly used to solve future embedded system development problems. This Web server is very compact. Its Win CE version is less than 60 K after compilation, and its output is usually for some small screen devices. In terms of performance, a 68040 processor of 24mh Z can respond 20 times/second, and a 266mhz Pentium processor can respond 50 times/second.

The GoAhead Web server provides many service features. It supportsASP, Embedded javascrpt and memory CGI processing. However, some may doubt whether ASP support is necessary for embedded systems. The embedded Javascript interpretation engine cannot be used because it is used to create dynamic server content and ASP also needs to use it.

So far, the source code of goahead is completely free of charge, and no royalty or license fee is required to use it. For some hardware developers, this practice is common, such as many open-source systems owned by Sun. The main reason for this is that goahead wants it to become a web server standard platform in the embedded environment in the future and is optimistic about the growing market of more intelligent embedded devices.

Because the goahead release package containsC LanguageIn theory, you can use the GoAhead Web Server (as I did when writing this article) in a non-embedded environment ). Its reference platforms include Windows CE, Wind River VxWorks, Linux, lynx, QNX, and Windows 95/98/NT. It basically belongs to an http1.0 standard Web server and also supports some features of http1.1, such as persistent connections.

It is undeniable that the GoAhead Web Server is a product targeting specific market segments. It may be difficult for most people outside the market to focus too much on it. However, many analysts and leaders in the computer industry (including Linus Torvalds, the father of Linux) believe that in the future computer world, intelligent embedded systems will play an extremely important role, when the market matures, it is the goahead exhibition.

Advantages: free and small, supporting multiple platforms, fully designed for embedded systems, embedded Javascript and dynamic data page support.

Disadvantages: the support for ASP means that it depends on the Microsoft platform and has few security considerations.

/// // The following parts are to be modified/ //////////////////////////////////////// //// // till today /////////////////// ///// slightly modify the code in armlinux.

The source code changes are basically
1. Change fork to vfork,
2. Replace the gethostbyname function.
 
Change the makefile that comes with goahead to use arm-elf-GCC to compile and convert the ELF format of the application to Flt.
It's almost done.
 
The following are detailed steps recorded during the porting process:
 
FirstHttp://www.Goahead.com/webserver/webserver.htmGoahead source code package,
Take a look at the usr/DOC files in the web directory.
 
Modify the goahead/Linux/MAKEFILE file File
========================================================== ======================================
1. A macro is added to makefile:

Cflags =-dwebs-duemf-dos ="Linux"-Dlinux $ (umsw) $ (dasw) $ (sslsw)
$ (Ifmodsw)-d1_no_pack
-D1_no_pack is added by myself.
_ No_pack: # The program warning is generated when goahead compilation is blocked. It does not matter if this macro is not added.
 
2. Modify goahead/Linux/makefile
Ldflags + = $ (ssllib) $ (ifmodlib)-wl,-elf2flt
-Wl,-elf2flt and "+" are automatically added.
 
Add the-wall-O2 option to cflags. (Optimize code size and speed)
As follows:
Cflags + =-wall-O2-dwebs-duemf-dos ="Linux"-Dlinux $ (umsw) $ (dasw)
$ (Sslsw) $ (ifmodsw)-d1_no_pack
 
 
3. Modify the MAKEFILE file in uClinux to support add costume vender/user application.
You can skip this step and directly make clean and make the webs.exe file in the goahead and Linux directories.
Copy to the romfs directory.
(Create the home \ WEB \ directory under romfs)
 
For details, see 12. compilation process.
 

In uClinux, The make clean operation will clear the romfs directory, so it is best to put it in the makefile of goahead.
Add the following sections (make romfs will be automatically copied to the/home/web/directory .)
Romfs:
$ (Romfsinst)/home/web/$ (name)
 
At the same time in uClinux/venders/Samsung/44b0/makefile
Romfs_dirs = bin Dev etc home lib MNT proc USR var home/httpd home/Web
Home/httpd home/web is added by yourself.
 
4.
Add
######################################## #############################
Cross_compile = arm-elf-
As = $ (cross_compile)
LD = $ (cross_compile) LD
Cc = $ (cross_compile) GCC
CPP = $ (CC)-e
AR = $ (cross_compile) Ar
Nm = $ (cross_compile) nm
Strip = $ (cross_compile) strip
Objcopy = $ (cross_compile) objcopy
Objdump = $ (cross_compile) objdump

######################################## ############################
 
Change DEBUG =-g-wall
DEBUG =-wall
Obviously, this is to modify GCC to arm-elf-GCC for compilation and remove the debug information.
Or you can directly change a few $ (CC) to arm-elf-GCC.
 
 
Modify the goahead source code:
========================================================== ======================================
5. uClinux uses uclib-C (I used the lib to use uclib-C, but I have not tried it with uclibc)
 
6. modify all macros not recognized by arm-elf-GCC. Rewrite these macros into one line. Generally, this is because"\"
And so on.
 
7. Change fork to vfork (main. C (Linux ))
 
8. webs. C line 1434.
Fmtalloc (& msgbuf, webs_max_url + 80,
T ("<HTML> \
T ("ThisDocumentHas moved to a new <a href = \"% S \"> Location </a>. \ r
\
T ("Please update yourDocumentS to reflect the new location. \ r
\

T ("</Body> "), URL );
Arm-elf-GCC does not seem to understand the "\" Conformity. It can only write the fmtalloc statement as one line.
 
9. UEMF. h file line 242
Remove the timeval definition, which is repeated in uClinux.
# If (defined (Linux )&&! Defined (_ struct_timeval ))
Struct timeval
{
Time_t TV _sec;/* seconds .*/
Time_t TV _usec;/* microseconds .*/
};
# DEFINE _ struct_timeval 1
# Endif
 
10. Main. C (Linux)
In the websgetcgicommname (...) Function
Set pname1 = tempnam (null, T ("CGI"); Changed
Pname1 = (char_t *) mkstemp (T ("CGI"); (It is estimated that no change to tempnam will not cause any serious problems)
 
 
11.
Main. C (Linux) File

In the initwebs (...) function:
/*
If (HP = gethostbyname (host) = NULL ){
Error (e_l, e_log, T ("Can'T get host address"));
Fprintf (stderr,"Initwebs: host name % s \ r
", Host );
Return-1;
}
Memcpy (char *) & intaddr, (char *) HP-> h_addr_list [0],
(Size_t) HP-> h_length );
*/
Intaddr. s_addr = inet_addr ("192.168.0.128"); // The IP address of the 44b0 Nic
 
The gethostbyname function is invalid here. I have blocked this section and have to write the IP address directly
Intaddr.
 
If debugging fails, it takes me more than half of the time to get the gethostbyname.
The most terrible thing is that the TFTP in my 44b0 board does not work, so I have to compile the kernel on one side,
Download to the board and run to view the serial port data.
Otherwise, you can use TFTP to download webs over the network to run on the board, so you do not need to compile the kernel.
 
12. compilation process:
 

> Under the CD uClinux directory
> Make config; make clean;
> Make lib_only; Make user_only
> Make romfs
> Cd to go To the goahead/Linux directory
> Make clean
> Make
> CP-I webs.exe/romfs/home/web/webs.exe (about 80 KB left after the webs.exe program is compiled
Right .)
> Cd to the uClinux directory
> Make image
> Make
 
 
 
13. Disable the IE proxy.
Ping the target board to see if the network is disconnected, or ping the PC on the target board.
The IP address is the IP address specified in step 1.
Then
> Cd/home/web/
>./Webs
Start goahead. The webpage can be stored in the same web directory as webs.exe. The web directory is a goahead source.

When there is a webpage request in goahead running, the following things will appear in my Super Terminal:
"> Skput: over: 0c071aa4: 272 put: 272 Dev: eth0 <2> kernel bug at skbuff. C: 92 !"
I don't know what it means.
 
14. Detailed documentation is provided under goahead/web. The configure and install parameters must be checked.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.