Linux Kit Quickstart


Add to my manuals
106 Pages

advertisement

Linux Kit Quickstart | Manualzz

phyCORE-i.MX35 Getting More Involved

You will see the following output:

Welcome to the World of the phyCORE-i.MX35! (serial)

Welcome to the World of the phyCORE-i.MX35!

Close Microcom.

When you start the application over an SSH session, you only see one output line. When you execute the program with Microcom, you see two output lines.

The first line is a direct output on the serial interface. You can’t see this line in an SSH session, because you are connected over a TCP/IP connection to the target. With Microcom, however, you have direct access to serial interface, so you can also see the line that it written to the serial console.

In this passage you have changed an existing application. You also learned how to access the serial interface. First you called the function open() on the device /dev/console. The return value of this function was a file descriptor. With the file descriptor you called the function write() to send n bytes to the device /dev/console. After that, the file descriptor was closed with the function close().

This procedure is in principle quite typical for Linux because Linux treats everything like a file.

3.5 Starting a Program out of Eclipse on the Target

After compiling a project in Eclipse, the program is copied to the target and directly executed. A program can also be executed on the target without compiling a project. In the following section you will learn how to start a program on the target as an external tool.

© 2009 PHYTEC Messtechnik GmbH L-724e_2

65

phyCORE-i.MX35 Quick Start Instructions

Select RunExternal ToolsExternal Tools from the menu bar.

66

Select Program.

Select New.

© 2009 PHYTEC Messtechnik GmbH L-724e_2

phyCORE-i.MX35 Getting More Involved

In the Name input field, enter: myHelloWorld Target

Enter /usr/bin/ssh in the Location input field.

Enter [email protected] ./myHelloWorld into the Arguments field.

Select Apply.

Select Run.

If you want to execute the program the next time, you can use the

Run External Programs

button from the menu bar.

© 2009 PHYTEC Messtechnik GmbH L-724e_2

67

phyCORE-i.MX35 Quick Start Instructions

3.6 Automatically Starting the Program when Booting the

Target

In this passage you will integrate the myHelloWord program into the startup process of the target. When you have finished this part, the

myHelloWorld

application will be started automatically each time you are starting the target.

The scripts for controlling the system startup live in /etc/init.d.

These are executed directly or indirectly by /sbin/init, the father of all processes. The configuration of /sbin/init is placed in /etc/inittab.

After system startup, /sbin/init will switch to the default run level, as configured in /etc/inittab. It calls the run level master script /etc/init.d/rcS to start or stop services provided by the other scripts in /etc/init.d. This is done by the help of symbolic links in the directory /etc/rc.d. These links point to the actual startup scripts in /etc/init.d.

First you will have to create a startup script in /etc/init.d.

Click the FTP for Target icon on your KDE desktop.

68

© 2009 PHYTEC Messtechnik GmbH L-724e_2

phyCORE-i.MX35 Getting More Involved

Browse to the target’s /etc/init.d. If an authorization dialog should appear, just click on OK (no password is required for FTP access).

In the directory /etc/init.d you can see the existing scripts.

Right-click in the opened window and select Create NewText File.

Enter myHelloWorld.

Click OK.

Right-click on myHelloWorld and select Open with.

Enter kwrite and click OK.

The text editor KWrite starts with an empty document.

© 2009 PHYTEC Messtechnik GmbH L-724e_2

69

phyCORE-i.MX35 Quick Start Instructions

70

Enter the following two lines:

#!/bin/sh

/home/myHelloWorld

Select FileSave.

Close the KWrite window.

Close the FTP window.

Click the Telnet for Target icon on your desktop.

© 2009 PHYTEC Messtechnik GmbH L-724e_2

phyCORE-i.MX35 Getting More Involved

Enter root and press Enter to login.

The startup script we have just created with KWrite must be made executable in order to run it later:

chmod a+x /etc/init.d/myHelloWorld

Change to the directory /etc/rc.d. Type the following command:

cd /etc/rc.d

Enter ls -l to list the directory contents.

You can see the different links to the scripts in the directory

/etc/init.d

. The scripts are started in alphabetic order: The script udev is the first script started because the link starts with S00…, whereas

S99zzz_PHYTEC_BSP_version_startup_script

will be started last.

To start your myHelloWorld application automatically when the system boots, you have to create a new link to the start script

/etc/init.d/myHelloWorld.

In

/etc/rc.d,

create a symbolic link which points to

/etc/init.d/myHelloWorld.

Enter the following command:

ln -s /etc/init.d/myHelloWorld /etc/rc.d/S99myHelloWorld

Type ls -l again to check the newly created link.

Close the window.

Open Microcom.

Push the RESET button on the target to restart your system.

© 2009 PHYTEC Messtechnik GmbH L-724e_2

71

phyCORE-i.MX35 Quick Start Instructions

The program myHelloWorld now starts automatically on startup.

Because its link in /etc/rc.d starts with S99…, you should see

myHelloWorld

’s output near the output of the two other scripts that start with S99… (which print all sorts of version information).

Close Microcom.

Now you can add your own programs to the root file system and start these programs automatically when your phyCORE-i.MX35 boots.

You have successfully passed the “Getting More Involved” part of this Quick Start.

72

© 2009 PHYTEC Messtechnik GmbH L-724e_2

advertisement

Was this manual useful for you? Yes No
Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Related manuals

advertisement

Table of contents