Académique Documents
Professionnel Documents
Culture Documents
Fig. 0-1 Installation of Cygwin 2) Choose installation directory. Please note the installation directory must locates at the NTFS partition of the hard disk, or it will affect the file attributes thus leads to an error. If your hard disk is not in the NTFS format, you need to convert it into NTFS under DOS. For example you can use this DOS command: convert F: /FS:NTFS. Please note this command can only be used under Win2000 or above. After you execute the convert command, restart the PC. So the partition can be changed into NTFS. Select the Unix Text File Type, then click Next Step . More details please refer to the below fig. 0-2.
-1-
Fig. 0-2 Choose Installation Directory 3) Select local package directoryfor example \cygwin 1.5.1\cygwin. Then click Next Step . As fig. 0-3 shows.
-2-
4) Select Packages. You can adjust the packages by clicking Default which is at the left hand side of the dialog window. In order to be able to develop ucLinux, the below packages must be selected. Admin Archive Base Devel Libs Net Shells Utils Includes boot service tools such as cygrunsrv and so on. Necessary for booting NFS. Compress or decompress files tools Basic Linux tools Development kit, includes gcc, make etc. Function Library Network tools General Shell tools Tools such as bzip2 etc.
Fig. 0-4 Select packages Do step by step according to the prompt after the packages are installed, then you can normally run the Cygwin.
S3CEV40\uClinux-s3cev40.tar.gz.Please copy it to directory cygwin/usr/local/src . If the folder src is not existing. Please execute the command mkdir /usr/local/src to create it. In order to unzip it, please execute the following commands: cd /usr/local/src tar xzvf uClinux-s3cev40.tar.gz After the commands are fully executed, if there is a prompt as: tar: Error exit delayed from previous errors Please ignore this prompt due to it is normal. Once the decompression is finished, there will be directory named uclinux-s3cev40 under /usr/local/src, which is used to put the source code. Hereafter all the operation will be acted under this directory. Please note, the latest ucLinux source code can be downloaded here: http://www.uclinux.org/pub/uClinux/dist
Fig. 0-5
Fix the installation directory at the above dialog. The Arm toolchain will be installed to the directory of /usr/local/armtools. l Path configuration of the ARM toolchain After the installation was finished, please run the below command at the Cygwin console, so that the installation path of ARM toolchain can be regarded as a system default path. Please make sure that the path of ARM toolchain has been regarded as the system default path before compiling ucLinux. export PATH=/usr/local/armtools/bin:$PATH
-4-
Another way is to modify the /home/.bash_profile, add the above command to the end of the file. After this, this command will be auto-executed when the console boots.
Fig. 0-6
Fig. 0-7 Vendor/Product Selection Choose Embest at Select the Vendor you wish to target , then click Main Menu return to the main configuration interface. Click Kernel/Library/Defaults Selection at the main configuration interface, you will see a new dialog window as fig. 0-8:
-5-
Diagram 1-1 Target platform option Choose linux-2.4.x at the Kernel Version option; And choose uClibc at the Libc Version option. Please choose n(no) at Customize Kernel Settings and Customize / Vendor/User Settings options because uClinux-s3cev40 has been set properly after released. Or you can choose to customize it by yourself. Then click Main Menu return to the main configuration interface. Click Save and Exit at the main configuration interface, by now the ucLinux configuration is finished.
5 Compile uClinux
In order to compile ucLinux, please execute the following commands under Cygwin orderly: make dep make clean make lib_only
-6-
make user_only make romfs make image The above commands comments are as below: Make dep Search the relationship between the compile output of ucLinux and source code, hereby generate the rely files. Make clean Delete all the object files, module files and temporary files which are generated while creating the kernel. Make lib_only To compile the uC-libc function library, then generate function library files such as libc.a libm.a and so on. Make user_only To compile the applications. Make romfs To generate the Romfs file system, using applications which are well compiled (romfs directory). Make image Use the romfs directory to generate file system image, then compile the kernel, thus get the kernel image. Finally we get these two files under images directory: zImage Executive image file of uClinux, kernel 2.4.x. romfs.img Image of file system zImage has included the image of file system, so you can use it to burn the Flash chip directly.
-7-
Fig. 0-9 Flash Programmer configuration Select Flash chip SST39LF/VF160 as above fig. 0-9. Select S3C44B0X as fig. 0-10:
2 Program the image file First we need to download bootloader, which locates at CD1_S3CEV40 General\Software\Image\uclinux\blob.s3cev40.bin. Select sector 1-16 of the flash as fig. 0-11.
Fig. 0-11 Download the bootloader Download zImage to the 17-192 section Flash address, which locates at CD1_S3CEV40 General\Software\Image\uclinux\zImage, please refer to fig. 0-12
Then download the romfs.img at 193-400 sector of the flash following above the method. please refer to following fig
7 Run uClinux
Use the accompanying serial cable to connect UART0 of target board with COM1 of PC host. Run the HyperTerminal at PC host, set to 115200 baud rate, 8, N/A, 1, N/A. Please refer to fig. 0-13:
- 10 -
Fig. 0-13 Configuration of HyperTerminal Run the ucLinux, result is as fig. 0-14 shows:
After this is done, you will see a menu User Applicationat the user application configuration interface. 5. Edit the Makefile Edit the \cygwin\usr\local\src\uClinux-s3cev40\user\Makefile to add our new application. Please add the sentence below to \cygwin\usr\local\src\uClinux-s3cev40\user\Makefile.
- 12 -
dir_$(CONFIG_USER_LED)
+= app
Usually compiler will visit the new applications automatically to get the necessary information. 6. To compile the ucLinux Re-compile the ucLinux, so that the new application will be added to file system. Then burn the file system to the corresponding section of Flash, then run it. export PATH=/usr/local/armtools/bin:$PATH make xconfig make dep make lib_only make user_only make romfs make image Please note: When using the make xconfig , select Kernel/Library/Defaults Selection , then click Yat Customize Ventor/User Settingand return and click save and exit . Then choose User Application at the pop-up Application Configuration window. Then choose led at the User Application . More details please refer to the fig. below.
(a)
(b) If you amended the application and want to re-compile it, you can just start at the command make user_only . 7. Load EmbestS3CEV40.cfg at the Embest Flash Programmer, then download bootloaderblob.s3cev40.bin to Flash address 1-16 sector. Download zImage to Flash address 17-192 sector and romfs.img to the 193-400 sector.
- 13 -
8. Run ucLinux at the Embest S3CEV40 platform. You can observe the running of ucLinux by using HyperTerminal. Once ucLinux is fully booted, you can see the interface as below:
Sash command shell (version 1.1.1) />
Thus you can see LED1 and LED2 turn on and off and the same time . 2 Example code as reference
/******************************************************* * File Name led.c * Description timing interrupt * Author * Date *******************************************************/ #include <stdio.h> #include <signal.h> #include <unistd.h> /*define port configuration register and port data register address*/ #define PCONB #define PDATB int i=0; /*you may modify the value of PDATB and change the led output.PB9 and PB10 are corresponding pins to led1 OUTPUT and led2 OUTPUT. Howover,each of port B pins is controled by register PDATB.SO you may modify the corresponding bit of PDATB to control the led OUTPUT.*/ static void sig_alarm(int signumber) { if(i==0) { PDATB |= 0xFF; i = 1; } else { PDATB &= 0xCF; i = 0; } alarm(2); } int main(void) { if(signal(SIGALRM,sig_alarm) == SIG_ERR) - 14 (*(volatile unsigned *)0x01D20008) (*(volatile unsigned *)0x01D2000C)
The led generated is in flat format, which can directly run under uClinux. 2) Copy executable file to file system. romfs directory is a generated file system directory, it is generated when execut ing make romfs command, if user has executed make romfs command, he can co py the generated executable file led to the directory romfs/bin, no need execute t he command again. Caution: if user has executed make clean command, all the c ontents under romfs will be cleaned. 3) Generate images of file system User can directly execute the following command to generate images of file syst em romfs.img in the uclinux-s3cev40 folder:
genromfs -v -V "ROMdisk" f romfs.img -d /usr/local/src/uclinux-s3cev40/romfs
Now the images of file system romfs.img includes the new application program l -ed.
compiler arm-elf-gcc to conduct secondary compilation, in the end, transplant it t o uClinux system for running. This method has wide variety of tools for your choice, and it is fast, especially s uitable for prophase debug of large complex applications. In this method, user must pay attention to the concerns of implanting from Linu x to uClinux, the biggest concerns are the difference between uClinux functions and Linux functions, and using Vfork to substitute fork. 2) Serial port printing debug Serial port printing debug information is an important debug approach for uClinu x to develop application program. The moment the program directly runs in target board, the target board is conn ected with host through serial port, the information output during the running of pro gram is displayed in the serial port terminal of the host. The programmer adds Printf sentences to source code of program at appropriate location, after compilation, when the program runs to specific sentence while runni ng on Uclinux, it will print some important variables, parameters onto terminal interf ace through serial port at real-time, allow the developer to observe the running stat us of the program in timely way, and provide important basis and information for fu ture amendment and optimization. 3) Remote interactive debug Run gdbserver on uClinux system, The communication between the target syste ms such as GDB of ARM running in host and gdbserver of the target board are reali zed through serial port or Ethernet, gbserver controls the running of program and fe edback the running status of program with debug instructions of GDB. In the above debug methods, codes are frequently modified and recompiled, so how to download the application to uClinux fast and conveniently is another concern of developer during the debug, we will introduce a the m ost common approach to download and debug application programs in the following section: FTP/TFTP method
- 16 -
k, small-capacity solidified fixed TFTP, UDP and IP memory is enough; its disadvant ages: transfer is less reliable, no password, etc. TFTP is usually applied in the development of uClinux. 2) Establish FTP/TFTP server in PC Run tftpd32.exe, the TFTP server program, to setup working status, authority an d local tftp directory, in default state, it will directly start working, and current direc tory is the default local tftp directory.
Figure 11-1
3) Transfer application program by means of TFTP (take multithreaded program for example) Prepare experimental environment, use the serial port cable supplied with Embest S3CEV40 target board to connect UART0 and PC s serial port COM1 of target board, use the net cable supplied with Embest S3CEV40 target board to connect the net port of target board and PC. Run Windows s own super terminal serial port communication program in PC, set Baud Rate of 115200, 1 stop bit, no panty bit, no hardware flow control. Run tftpd32.exe in PC, setup the path to point at the binary file evfork. Run uClinux embedded system on Embest S3CEV40 target board, you will see the following interface in the super terminal screen:
Sash command shell (version 1.1.1) />
- 17 -
Run cygwin in PC, compile the routine evfork.c in routine list, execute the following commands, a binary file evfork will be generated:
arm-elf-gcc o evfork evfork.c elf2flt
Execute TFTP command in super terminal window to download the program evfork to file system of target board, when the command is acco mplished, a executable file evfork will appear in the var folder under root directory uClinux. Notice : 192.192.192.39 is IP address of PC.
/>tftp g l /var/evfork r evfork 192.192.192.39
Execute the following command in super terminal window, first add executable authority for evfork file, then run the program.
/>cd var var>chmod 777 evfork /var> ./evfork i am the child process, my process id is 21 end pid is 21 i am the parent process, my process id is 20
if (pid < 0) //creat failed. printf("error in fork!\n"); else if (pid == 0) //return 0 ,exec the child. printf("i am the child process, my process id is %d\n",getpid()); else { //return the child pid,exec the parent. printf("i am the parent process, my process id is %d\n",getpid()); exit(0); } printf("end pid is %d\n",getpid()); }
- 19 -