
39
UBC-220 User Manual
Chapter 3
S
oftware
Functionality
3.8.1
“Hello World!” Application and Execution
This section will guide you how to write a sample application “Hello World”. You can
refer to the following steps:
1.
Open "Terminal" on Ubuntu 10.04 LTS.
2.
$sudo su
(Change to “root” authority)
3.
Type user password.
4.
Change directory to BSP's scripts folder.
5.
#. setenv.sh
(To configure the developing environment automatically)
6.
#cd ../source
7.
#mkdir helloworld
(Create your own work directory on the Desktop)
8.
#cd helloworld
(Enter the work directory)
9.
#gedit helloworld.c
(Create a new C source file)
Edit the helloworld.c with the following source code:
#include <stdio.h>
void main()
{
printf("Hello World!\n");
}
10.
Save the file and exit.
11.
#$CC -o helloworld helloworld.c
(To compile helloworld.c)
12.
Then you can see “helloworld” in current directory.
13.
Insert the Linux system SD card to your developing computer.
14.
#cp helloworld /media/rootfs/tool
(/media/rootfs is the mounted
point of your Linux system SD card)
15.
Remove this SD card and insert it to UBC-220, then open serial console.
16.
On UBC-220 platform, type
#root
(Login)
17.
On UBC-220 platform, type
#cd /tool
18.
On UBC-220 platform, type
#./helloworld
19.
Now you should be able to see “Hello World!” shown on UBC-220.
3.8.2
Watchdog Timer Sample Code
WatchDog Timer (WDT) sample code is as below:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/watchdog.h>
#include <sys/ioctl.h>
#include <unistd.h>
void help_info(void);
int main(int argc, const char *argv[])
{
int fd, timeout, sleep_sec, test;
int count=1;
if (argc < 2) {
help_info();
return 1;
}
timeout = atoi(argv[1]);
sleep_sec = atoi(argv[2]);
Содержание UBC-220
Страница 6: ...UBC 220 User Manual vi...
Страница 12: ...UBC 220 User Manual 4...
Страница 36: ...UBC 220 User Manual 28...
Страница 37: ...Chapter 3 3 Software Functionality This chapter details the Linux operating system on the UBC 220 platform...
Страница 52: ...UBC 220 User Manual 44...