版主: wanchong , wangyu , eepwwp , firedom

分享到:
共31条 2/4 « 1 2 3 4 »   

RE: QomoLiao的伽利略开发笔记

qomoliao
我是GG
高级会员

最后登陆时间:2014-07-08 13:18:17

11# 发表于 2014-08-23 20:49:12

好久没有更新了,因为实在是不喜欢galileo的系统,对于我们这种在ubuntu下惯了的人确实不太方便

连make命令都没有,驱动装不上,软件包管理也很难搞

今天发现一片帖子,说的是给galileo装debian,研究了一下,果然可行

先贴一下效果图片和原文链接,改天再把详细的中文教程补上

https://communities.intel.com/thread/48074

此帖由qomoliao于2014-08-23 20:50:08最后编辑

RE: QomoLiao的伽利略开发笔记

qomoliao
我是GG
高级会员

最后登陆时间:2014-07-08 13:18:17

12# 发表于 2014-08-24 21:23:19

这是debian 的wiki上关于debootstrap的描述

debootstrap is a tool which will install a Debian base system into a subdirectory of another, already installed system. It doesn't require an installation CD, just access to a Debian repository. It can also be installed and run from another operating system, so, for instance, you can use debootstrap to install Debian onto an unused partition from a running Gentoo system. It can also be used to create a rootfs for a machine of a different architecture. This is "cross-debootstrapping". There is also a largely equivalent version written in C: cdebootstrap, which is smaller, and thus used in debian-installer.

我们就是通过debootstrap构建在galileo上运行的debian系统

这些过程需要在一台能够联网的linux下操作

一、建立工作目录
> mkdir galileo-debian

> cd gaileo-debian

> mkdir mnt-loop sdcard image


二、创建一个空的镜像文件,并格式化

Let's create an empty image that we format with a filesystem and mount it.

> dd if=/dev/zero of=loopback.img bs=1G count=3

> mkfs.ext3 loopback.img

> sudo mount -o loop loopback.img mnt-loop

这个dd要比较长的时间,大家耐心等待

三、装载镜像文件后,我们就可以往镜像里加入我想加入的东西,debian的系统文件,通过debootstrap命令

sudo debootstrap --arch i386 wheezy ./mnt-loop http://http.debian.net/debian/

老外说i586应该也可以,我试了一下不行,谁试出来了可以分享一下

这个过程需要一点时间,大家可以去喝杯咖啡(原文翻译^_^)

四、拷贝官方镜像里的一些重要文件

官方下载的系统文件里有一个image-sdk-clanton.ext3,这就是官方的镜像文件

先把这个镜像加载到image目录,然后拷贝我们需要的东西到我们的镜像里


> sudo mount -o loop <这个/是到/镜像文件/所在目录/的路径/>image-sdk-clanton.ext3 image

> sudo cp -r image/lib/modules mnt-loop/lib

> sudo umount image

最后吧加载的镜像吐出来

有图有真相,也许有人对命令中的那串中文有困扰

在我这里它们是:~/SDCard/image-full-galileo-clanton.ext3

五、在拷贝镜像文件到sd卡前,需要设置密码和打开串口调试的功能


Before we copy and boot the image, we need to set a password and enable the serial console to login later.

> sudo mount -t proc proc mnt-loop/proc

> sudo mount -t sysfs sysfs mnt-loop/sys

> sudo chroot mnt-loop /bin/bash

> passwd

set new root password

> vi /etc/hostname

change the hostname

> vi /etc/inittab

I uncommented the T1 line (ttyS1) and changes 9600 to 115200

> exit

> sudo umount mnt-loop/proc

> sudo umount mnt-loop/sys



六、拷贝镜像文件到sd卡

Copy the image to the sdcard. On that sdcard there should be already be the initramdisk (core-image-minimal-initramfs-clanton.cpio.gz), bzImage and grub.conf (in boot/grub/) from the default Galileo yocto installation.

> sudo umount mnt-loop

这一步是卸载之前加载的镜像文件

如果大家对做镜像还有问题,也可以直接下载我的镜像文件,从这里开始下面的工作

http://pan.baidu.com/s/1pJ4rGdt

> sudo mount /dev/mmcblk0p1 sdcard

> sudo rm sdcard/image-full-clanton.ext3

> sudo cp loopback.img sdcard/image-full-clanton.ext3

> sudo umount sdcard

这几个命令实际上是将按官方手册做的sd卡中的镜像换成我们制作的镜像文件

你也可以通过图形界面完成


七、最后,将sd卡插入插槽,然后启动系统,你会发现一些错误信息,按下面的提示可以解决


Put the sdcard into the Galileo board and put it to work. The first time I booted, I missed the mount point and got this error message:

> mount: mounting /media/mmcblk0p1 on /rootfs//media/realroot failed: No such file or directory

> Couldn't remount /media/mmcblk0p1, dropping to shell

A simple mkdir and reset will do the trick:

> mkdir /roofs/media/realroot

这个命令对解决问题很重要,然后重启,一切就OK了


If you are lucky, your board should boot into a serial console now.


Now that the Galileo board boots up with that fileset, let's use it. We have a real package management system.

> ifconfig eth0 up

> dhclient eth0

> apt-get update

> apt-get install ...

Put the sdcard into the Galileo board and put it to work. The first time I booted, I missed the mount point and got this error message:

> mount: mounting /media/mmcblk0p1 on /rootfs//media/realroot failed: No such file or directory

> Couldn't remount /media/mmcblk0p1, dropping to shell

A simple mkdir and reset will do the trick:

> mkdir /roofs/media/realroot


If you are lucky, your board should boot into a serial console now.


Now that the Galileo board boots up with that fileset, let's use it. We have a real package management system.

> ifconfig eth0 up

> dhclient eth0

Put the sdcard into the Galileo board and put it to work. The first time I booted, I missed the mount point and got this error message:

> mount: mounting /media/mmcblk0p1 on /rootfs//media/realroot failed: No such file or directory

> Couldn't remount /media/mmcblk0p1, dropping to shell

A simple mkdir and reset will do the trick:

> mkdir /roofs/media/realroot


If you are lucky, your board should boot into a serial console now.


Now that the Galileo board boots up with that fileset, let's use it. We have a real package management system.

> ifconfig eth0 up

> dhclient eth0

这是在配置网络

> apt-get update

> apt-get install ...

这个更新软件库和安装软件


The bad part is, that I have the same issue that Bruce reported. Seg-faults in libpthread is also happening, so you don't really win anything. I discovered it when installing the SSH server, set-up a new user and tried to connect. Bang …

这个问题我貌似没有碰到,安装ssh server后正常

可以通过网络ssh到我的伽利略




此帖由qomoliao于2014-08-24 22:43:52最后编辑

RE: QomoLiao的伽利略开发笔记(最新的debian系统)

qomoliao
我是GG
高级会员

最后登陆时间:2014-07-08 13:18:17

13# 发表于 2014-08-25 11:03:52

最后面的打开网络,有点麻烦,每次都有手动敲两个命令

其实可以通过配置文件自动完成,编辑/etc/network/interfaces文件

root@qomo-galileo:~# vim /etc/network/interfaces

然后可以重启网络,使用新的配置,也可以重启机器,这里只是重启网络就好了

root@qomo-galileo:~# /etc/init.d/networking restart

然后看看网络情况,可以获取IP了

此帖由qomoliao于2014-08-25 11:04:19最后编辑

RE: QomoLiao的伽利略开发笔记(最新的debian系统)

caocheng
我是GG
高级会员

最后登陆时间:2014-07-23 11:45:14

14# 发表于 2014-08-27 15:44:55
铜柱比我塑料的管然高大上许多

Galileo微博连接

qomoliao
我是GG
高级会员

最后登陆时间:2014-07-08 13:18:17

15# 发表于 2014-08-27 18:21:52

参考:

- http://github.liaoxuefeng.com/sinaweibopy/

- https://github.com/michaelliao/sinaweibopy/wiki/OAuth2-HOWTO

- http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E#.E7.A7.BB.E5.8A.A8.E5.BA.94.E7.94.A8.E7.9A.84.E9.AA.8C.E8.AF.81.E6.8E.88.E6.9D.83

一、安装

安装pip

qomo@qomo-galileo:~$ sudo apt-get install python-pip
因为我用了debian系统,所以就是这么简单,yocto的朋友就自己想办法了

安装新浪微博SDK

qomo@qomo-galileo:~$ sudo pip install sinaweibopy
因为装了pip管理软件,所以就是这么简单

二、申请微博开发平台

我只告诉你网址,要怎么做,相信大家都知道。http://open.weibo.com/index.php

三、创建应用

我选择的是其他应用

应用地址应该是无所谓的

然后填写一些必填的项目,保存

然后是设置授权和授权回调页,授权回调页是官方提供的一个地址

取消授权回调页不知道填什么,我就填了个一样的,不过不影响我的使用

 

最后还需要添加测试账号,要不然是不能够获得授权的,只有测试账号的用户能够使用这个应用。


四、python发微博

ssh或者通过串口登陆伽利略开发板,进入python命令行

输入图片中的命令

其中APP_KEY、APP_SECRET在应用基本信息里可以查到。

CALLBACK_URL(回调地址)用我们之前设置的

复制最后生成的URL,在浏览器里打开,然后点击授权,会跳转到如下页面

记下地址栏里code=后面的字符串

最后,运行下面代码

我们可以开始发第一条Hello World了

此帖由qomoliao于2014-08-27 19:09:51最后编辑

RE: QomoLiao的伽利略开发笔记(最新的debian系统)

qomoliao
我是GG
高级会员

最后登陆时间:2014-07-08 13:18:17

16# 发表于 2014-08-27 19:11:30
至于其他微博命令,就参考我给的两个链接好了

RE: QomoLiao的伽利略开发笔记(发微博)

nakey
我是MM
高级会员

最后登陆时间:2015-12-28 15:04:55

17# 发表于 2014-08-28 15:33:11

pyGalileo热释红外与舵机控制

qomoliao
我是GG
高级会员

最后登陆时间:2014-07-08 13:18:17

18# 发表于 2014-08-28 17:08:31

pyGalileo库:https://github.com/galileo-chofrock/pyGalileo

舵机:http://www.guokr.com/article/5292/

http://www.geek-workshop.com/thread-70-1-1.html

之前玩arduino的盾板,刚好可以用上

通过盾板和3Pin线与热释红外传感器,与舵机进行连接,非常方便

这里只是测试对这两个模块的使用,所以就随便摆放着,没有做什么架子之类的东西,这个以后在做

再来一张热释红外的特写,可以看到两个变阻器。

通过后面的测试发现,这两个旋钮貌似分别调节灵敏度和探测角度的


一、 Hello pyGalileo

pyGalileo是一个python库,通过这个库可以用与arduino非常相似的代码进行编程

它实际上操作的是GPIO,这个在前面的某楼有提到过

到这个网站(https://github.com/galileo-chofrock/pyGalileo)把库程序下载下来,然后通过任何办法拷贝到galileo里

我是把galileo做成了个samba服务器,文件的上传下载都非常方便

这个不需要按github上的安装方法,拷贝到你需要它的目录下就可以了

因为当前路径本来就是python搜索库文件的路径之一

对于arduino来说,Hello World就是Blink,我们看看它的blink程序

#!/usr/bin/env python
import sys

#galileo_path = "/media/mmcblk0p1/";    #我们把这个程序
# 放在pyGalileo所在的目录下,它是能够找到pyGalileo库的,就不必用这三句添加库所在的路径了
#if galileo_path not in sys.path:
#    sys.path.append(galileo_path);

from pyGalileo import *

'''/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 '''

#// the setup routine runs once when you press reset:
def setup():
    pinMode(led, OUTPUT);     

def loop():
    digitalWrite(led, HIGH);   #// turn the LED on (HIGH is the voltage level)
    delay(1000);               #// wait for a second
    digitalWrite(led, LOW);    #// turn the LED off by making the voltage LOW
    delay(1000);               #// wait for a second

#When the file is run from the command line, this fucntion will execute.
#This function just calls setup once, then calls loop over and over.
if __name__ == "__main__":
    led = 13;
    setup();
    while(1):
        loop();

保存代码后,在命令行运行

qomo@qomo-galileo:~$ sudo python blink.py

就可以看到盾板上的LED灯在闪烁,注意:galileo板上的LED是不闪的,因为那个LED并不是接着13号接口对应的GPIO上???这一句是我的揣度,望高手澄清一下

看视频说话



二、热释红外探测器

热释红外探测器能够探测人或者动物的走动

当它探测到的红外热有变化时,就会产生一个高电平信号,我们用digitalRead就能够把这个信号读出来

下面是代码,修改至pyGalileo的Example里的Button.py


#!/usr/bin/env python
import sys

#galileo_path = "/media/mmcblk0p1/";
#if galileo_path not in sys.path:
#    sys.path.append(galileo_path);

from pyGalileo import *
'''/*
  Button
 
 Turns on and off a light emitting diode(LED) connected to digital  
 pin 13, when detect someone get close to the senser attached to pin 4. 
 
 
 The circuit:
 * LED attached from pin 13 to ground 
 * IRdetect senser attached to pin 2 5V and GND
 
 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13.
 
 created 2005
 by DojoDave 
 modified 30 Aug 2011
 by Tom Igoe
 modified 27 Aug 2014
 by QomoLiao
 
 This example code is in the public domain.
 
 http://www.arduino.cc/en/Tutorial/Button
 */'''

#// constants won't change. They're used here to 
#// set pin numbers:
#const int buttonPin = 2;     // the number of the pushbutton pin
irPin = 4;
#const int ledPin =  13;      // the number of the LED pin
ledPin =  13;

#// variables will change:
#int buttonState = 0;         // variable for reading the pushbutton status
irState = 0;

#void setup() {
def setup():
  #// initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  #// initialize the pushbutton pin as an input:
  pinMode(irPin, INPUT);     
#}

#void loop(){
def loop():
  while(1):
      #// read the state of the pushbutton value:
      irState = digitalRead(irPin);

      #// check if the pushbutton is pressed.
      #// if it is, the buttonState is HIGH:
      if (irState == HIGH):# {     
        #// turn LED on:    
        digitalWrite(ledPin, HIGH);  
      #} 
      else:# {
        #// turn LED off:
        digitalWrite(ledPin, LOW); 
      #}
#}

setup();
loop()


三、舵机的控制

舵机是通过脉冲控制的。

最小的角度对应1ms的脉冲、中间角度对应1.5ms脉冲,最大角对应2ms脉冲

参考上面两个图片里面的信息,写了如下的控制程序

pyGalileo里没有延迟微秒的函数,所以这里自己写了这个函数,以后会视情况看是否将他放到pyGalileo里

这个程序只是实现了对舵机的控制,还不是很方便使用

以后的修改将会把它封装到函数或者类里,通过角度参数使用

#!/usr/bin/env python
# coding=utf-8

import sys
from pyGalileo import *

servoPin = 5

def delaymicro(mcTime):
    """
    delaymicro(mcTime)

    Description:
        Delays the execution of the script for number of microseconds.

    Input:
        mcTime - (int) number of microseconds to delay
    Returns:
        None
    Example:
        delaymicro(500);    - Delay the script for 500 microseconds.
    """
    time.sleep(mcTime/1000000);

def setup():
    pinMode(servoPin, OUTPUT)

def loop():
    while(1):
        digitalWrite(servoPin, HIGH)
        delaymicro(1500)
        digitalWrite(servoPin, LOW)
        delay(20)

setup()
loop()

 

此帖由qomoliao于2014-08-28 19:12:51最后编辑

我来试下USB-VGA显卡做startx

ishaq5niu
我是GG
高级会员

最后登陆时间:2014-07-25 16:35:49

19# 发表于 2014-09-01 10:15:04
12345678

RE: QomoLiao的伽利略开发笔记(pyGalileo热释红外与舵机使用)

谦谦公子
我是GG
高级会员

最后登陆时间:2014-08-16 16:12:15

20# 发表于 2014-09-02 15:36:49

高大上

共31条 2/4 « 1 2 3 4 »   
快速回复主题
  • 匿名不能发帖!请先 [ 登陆 注册 ]