嵌入式开发入门-01

嵌入式开发入门01

1、开发板简介:

GEC6818:

       开发板          1块

嵌入式开发入门-01

       泡沫板           1块(图略)

       电源线           1根

嵌入式开发入门-01

       串口线           1根

嵌入式开发入门-01

       USB转串口线       1根

嵌入式开发入门-01

       网线              1根(图略)

       OTG线          1根(图略)

 

2、登录开发板:

       在开发板上存在一个Linux操作系统,我们要使用开发板进行项目开发,必须

先登录到开发板系统中。

 

       1,连接串口线

       开发板 《--》 串口线  《--》USB转串口线 《--》电脑

嵌入式开发入门-01

嵌入式开发入门-01

嵌入式开发入门-01

       2,查看设备管理器 com口

       如果没有找到usb转串口的com口,就安装USB转串口驱动

       双击安装PL2303_Prolific_GPS_1013_20090319.exe --》finish

             

       -->查看USB-to-serial comm port(com?)     记住这个com口

嵌入式开发入门-01

 

       3,使用仿真软件登录开发板

       secureCRT.RAR     --> 解压文件 --> 进入secureCRT文件夹

--> 双击运行 secureCRT.exe

      

       文件 --》 快速连接 --》配置连接信息

       协议:serial

       端口:com?   (自己在设备管理器中看到的端口号)

       波特率:115200

       流控:把√去掉

       ==》点击连接

嵌入式开发入门-01

       按下ctrl + c ,再按下回车,出现以下现象说明连接成功

^C[[email protected] /IOT]#

[[email protected] /IOT]#

[[email protected] /IOT]#

[[email protected] /IOT]#

[[email protected] /IOT]#

 

3.第一个嵌入式开发程序实验:

1,在共享文件夹下新建一个嵌入式工程

[email protected]:/mnt/hgfs/zdnf/day2/code$ touch helloworld.c

[email protected]:/mnt/hgfs/zdnf/day2/code$ ls

helloworld.c

      

2,编辑工程文件

3,编译工程文件                      

[email protected]:/mnt/hgfs/zdnf/day2/code$ arm-linux-gcc helloworld.c -o helloworld

[email protected]:/mnt/hgfs/zdnf/day2/code$ ls

helloworld  helloworld.c

 

arm-linux-gcc:     交叉工具链(在Linux系统下编译arm架构运行的C语言程序)

helloworld.c:       C语言文件

 -o :                  输出 -output

helloworld      :   可执行文件 (最终程序)

 

4,烧写程序 (程序下载到开发板) 在secureCRT上执行下载命令

       mkdir /zdnf16

       cd /zdnf16

       烧写命令: rx 程序名

rx helloworld --> 点击回车 --> "传输" --> 发送“xmodem” -->选择 helloworld文件

--》点击发送

[[email protected] /zdnf16]#rx helloworld

CCC

  100%       5 KB    5 KB/s 00:00:01       0 Errors

 

[[email protected] /zdnf16]#ls

Helloworld

 

5,测试程序

              执行程序 ./程序名       ==》 ./helloworld

[[email protected] /zdnf16]#chmod 777 helloworld

[[email protected] /zdnf16]#./helloworld

hello world!   

 

46818LCD使用

嵌入式开发入门-01

       如何使用LCD显示图案?

       Linux下一切都是文件 --》LCD也是一个文件 --》 "/dev/fb0" --> 文件IO (linux提供的操作文件的函数接口)

      

       open(), read(), write(), close();     

 

如何使用函数?    ==》使用Linux提供的函数手册 man

       man man

 

NAME

   man - an interface to the on-line reference manuals

 

       1   Executable programs or shell commands      //shell命令 (Linux命令)ls cd mkdir rm ...

       2   System calls (functions provided by the kernel)    //系统调用函数,文件IO

       3   Library calls (functions within program libraries) //库调用函数,printf()

       4   Special files (usually found in /dev)

       5   File formats and conventions eg /etc/passwd

       6   Games

       7   Miscellaneous  (including macro packages and conventions), e.g. man(7),

          groff(7)

       8   System administration commands (usually only for root)

       9   Kernel routines [Non standard]

 

1,查看open函数的用法 --》 man 2 open

NAME    //函数功能简介

   open, creat - open and possibly create a file or device           //打开一个文件或者设备

 

SYNOPSIS

   #include <sys/types.h>

   #include <sys/stat.h>

   #include <fcntl.h>                  //头文件,告诉编译器函数的定义和用法

 

   int open(const char *pathname, int flags);              //函数原型,参数个数看逗号个数,一个逗号2个参数

       int : 返回值类型,整型

       pathname :文件 路径名    ==》 需要打开的文件名

       flags :标志  打开文件的操作权限

                                   O_RDONLY, //只读

                                   O_WRONLY,        //只写

                                   or O_RDWR.  //读写

       返回值:返回一个新的文件描述符,本质是一个整数           ==》把硬盘当成一座大楼,把文件当成大楼里面的房间

                     (文件的操作钥匙)

                     失败返回 -1

例子:使用open函数打开LCD文件 参考代码:open.c

       查看是否能打开LCD成功?

       查看文件描述符的数值是否为3?

 

观察现象 --》LCD屏幕是否有变化?      ==》 没有图像显示,

 

2,write函数 man 2 write函数

 

#include <unistd.h>

 

ssize_t write(int fd, const void *buf, size_t count);

              fd: 文件描述符

              buf:数据缓冲区 ,存放将要写入的文件的数据

              count:想要写入到文件的字节数

       返回值:实际写入到文件的字节数

              失败: -1

      

3,close

       close(fd);

 

1.俄罗斯国旗

嵌入式开发入门-01

嵌入式开发入门-01

 

2、 xx国旗

嵌入式开发入门-01

嵌入式开发入门-01

3、xx国旗

嵌入式开发入门-01

嵌入式开发入门-01

 

 

  1. LCD屏幕的分辨率是多大?代表着什么?像素点是哪些数据?

答:GEC6818的LCD屏幕的分辨率为800*480, 代表有800*480个像素点,每个像素点由4个字节组成。像素点是由ARGB(即A: 透明度, R: 三原色中的红色,G: 三原色中的绿色,B:三原色中的蓝色)组成,也就是包含了4个字节的数据,例如: 红色:0x00ff0000(采用十六进制计法).

 

  1. 编写完代码之后都要进行哪些操作查看到效果?

答:

首先按照要求连接开发板与电脑的线路,然后按如下步骤操作:

1)将代码在Ubuntu下编译好。

2)将Ubuntu下编译好的代码移动或复制到共享文件夹下。

3)将共享文件夹下的文件通过SecureCRT传输至开发板。

4)在开发板上运行编译好的对应文件(在运行前,应给足文件权限)。