ok6410流水灯c语言程序,ok6410 uboot os 文件系统 流水灯

飞凌OK6410 开发板简单教程

安装交叉编译器编译器

cross-4.2.2 -eabi.tar.bz2

mkdir /usr/local/arm

chmod 777 /usr/local/arm      //赋给最大权限

tar jxvf cross-4.2.2 -eabi.tar.bz2

解压得到文件后 cd /usr/local/arm/4.2.2-eabi/usr/bin

看到编译器所在的目录 进行环境配置 参考http://my.oschina.net/u/274829/blog/181536否则会出现:内核编译出错 arm-linux-gcc: not found

编译uboot

tar zxvf uboot1.1.6.tgz           //解压源码 得到uboot1.1.6目录

make clean                        //清除 原来生产的文件和中间文件,不会删除源码和配置文件(可以运行下)

gedit Makefile                    //找到与开发板匹配的配置选项。如forlinux_nand_ram128.config

make forlinux_nand_ram128.config  //配置环境

make                              //得到uboot.bin

编译内核

tar zxvf linux-3.0.1.tar.gz -C /forlinux (-C 指定解压目录)     //解压

cd linux-3.0.1                    //到解压文件目录

make zImage -j4                   //j4(4为cpu4内核,编译快) zImage(内核影像压缩文件)

编译文件系统 yaffs2

tar zxvf fileSystem.yaffs2.tar.gz            //得到 FileSystem_Yaffs2

chmod 7777 mkyaffs2

./mkyaffs2 FileSystem_Yaffs2 rootfs.yaffs2   //得到文件系统

好了,现在就可以把上面三个文件下载到开发板,然后上电运行。

介绍 LED应用例子

arm11与普通单片机区别,想控制硬件,用用户程序通过系统调度驱动程序

硬件设备

驱动程序

系统内核

应用程序

ok6410 led 驱动代码

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#define DEVICE_NAME "leds"

static long s3c6410_leds_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)

{

switch(cmd) {

unsigned tmp;

case 0:

case 1:

if (arg > 4)

{

return -EINVAL;

}

tmp = readl(S3C64XX_GPMDAT);

if(cmd==0)

{

tmp &= (~(1<

}

else

{

tmp |= (1<

}

writel(tmp,S3C64XX_GPMDAT);

//printk (DEVICE_NAME": %d %d\n", arg, cmd);

return 0;

default:

return -EINVAL;

}

}

static struct file_operations dev_fops = {

.owner                = THIS_MODULE,//设备所有者

.unlocked_ioctl        = s3c6410_leds_ioctl,//需要自己实现

};

static struct miscdevice misc = {

.minor = MISC_DYNAMIC_MINOR,//注册设备号

.name = DEVICE_NAME,//注册设备名称

.fops = &dev_fops,//设备操作

};

static int __init dev_init(void)

{

int ret;

unsigned tmp;

//gpm0-3 output mode 初始化控制寄存器

tmp =readl(S3C64XX_GPMCON);

tmp &= (~0xFFFF);

tmp |= 0x1111;

writel(tmp,S3C64XX_GPMCON);

//gpm0-3 output 0 初始化数据寄存器

tmp = __raw_readl(S3C64XX_GPMDAT);

tmp |= 0x10;

writel(tmp,S3C64XX_GPMDAT);

//注册设备

ret = misc_register(&misc);

return ret;

}

static void __exit dev_exit(void)

{

misc_deregister(&misc);

}

module_init(dev_init);//模块的初始化及注册

module_exit(dev_exit);//模块的卸载

LED 应用代码

/*******************************

led.c

*******************************/

#include 

#include 

#include 

#include 

#define LEDS "/dev/leds"

int fd;

int main(void)

{

fd = open("/dev/leds", O_RDWR);

if (fd 

{

perror("Open /dev/leds failed");

exit(1);

}

int i = 0;

while(1)

{

for(i = 0; i 

{

ioctl(fd, 0, i);

sleep(1);

ioctl(fd, 1, i);

}

}

close(fd);

return 0;

}

将应用代码进行交叉编译 arm-linux-gcc led.c -o led

将编译生成的led应用下载到arm开发板

创建一个用户

ce609a95d9c5a42f78b320158b17d8f3.png

选择连接的com 口

05609572877c605182279b52577abf22.png

选择波特率 数据位 8 奇偶校验 无 停止位 1 数据流控制 无

f5924e9de292fe2e98e86fc576bdc8e0.png

打开后,右键下载文件,文件下载进去之后。

chmod 777 led                  //更改led应用的权限

./led                          //运行流水灯

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值