So Tired !_! 逆水行舟, 不进则退!

9Feb/14

Cubietruck 安装lubuntu笔记

Posted by Nick Xu

系统下载地址: http://dl.cubieboard.org/software/a20-cubietruck/lubuntu/

其它下载地址: http://cubieboard.org/download/

线刷工具: http://docs.cubieboard.org/downloads

默认用户名密码linaro:linaro

Configuration

Install tools and change default setting

#sudo passwd root
#sudo apt-get install -y bash-completion vim tmux
#sudo apt-get install -y build-essential make gcc g++ git-core x11vnc

#ls /sys/class/leds/*/brightness | xargs -i -n1 echo "echo 0 > {}" | sh
#locale-gen en_US.UTF-8
#dpkg-reconfigure locales
#echo "export LC_ALL=en_US.UTF-8" >> /etc/profile
#echo "auto eth0:1" >> /etc/network/interfaces
#echo "iface eth0:1 inet static" >> /etc/network/interfaces
#echo "address 192.168.2.123" >> /etc/network/interfaces
#echo "netmask 255.255.255.0" >> /etc/network/interfaces
#echo bcmdhd >> /etc/modules

 

VNC

#vi /etc/init/x11vnc.conf

start on login-session-start
script
x11vnc -display :0 -auth /var/run/lightdm/root/:0 -forever -bg -rfbport 5900
end script

#reboot

Set Time Zone/DateTime

1.Set time zone

  $sudo tzselect

Select the Asia , press Enter and chose China ,at last selet Beijing.

2. Cope file to /etc directory

  $sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

3. Update time

  $sudo ntpdate time.windows.com

Set keyboard language

To be defined ….

Flashplayer

Download the flashplayerarm,type:

$tar zxvf flashplayerarm.tar.gz  
$sudo cp libpepflashplayer.so /usr/lib/chromium-browser/plugins
$sudo cp default /etc/chromium-browser

Wifi

CB1 and CB2 do not integraed wifi chip on board ,but we can use USB WIFI. Make sure the wifi driver you use have been loaded. If not ,use

  $insmod /lib/modules/3.4.XX/kernel/drivers/net/wireless/XXX.ko

CB3(cubietruck) has Integrated wifi chip .

Type : modprobe bcmdhd to load the driver .

Add "bcmdhd" at the end of file /etc/modules to activate WiFi during boot. For ecample with Lubuntu Desktop:

  $sudo nano /etc/modules

Configure wifi at cubieboards and cubietruck the same way as descibed her:

  $apt-get install linux-firmware
  $reboot
  $ifconfig wlan0 up   //open the wifi ,maybe wlan1 ..
  $iwlist wlan0 scan   //scan the wifi signal
  $wpa_passphrase SSID passwd >> /etc/wpa_supplicant.conf  // the SSid is name of signal want to be used
  $vi /etc/network/interfaces

Add below configuration to /etc/network/interfaces

  auto wlan0
  iface wlan0 inet dhcp
  wpa-conf /etc/wpa_supplicant.conf

Add below configuration to /etc/resolv.conf

  nameserver 8.8.8.8

Reboot the cubieboard,auto gain the IP.

Setting CPU Frequency

Cubieboard CPU frequency can be adjusted in real time, , the following file save as shell file, or placed in / etc / rc.local before the exit 0 can be executed. Specific CPU frequency maximum and minimum values ​​can be set based on usage .

  #!/bin/sh
  echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  echo 1000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
  echo 600000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
  echo 25 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
  echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor

After testing, Cubieboard single core version (A10) CPU frequency can be overclocked to 1.2GHz, stable operation (would be better to stick a CPU heatsink); Cubieboard dual-core version (A20) can also be overclocked to 1.2GHz

Developing

Using serial debug port

The tutorial how to use TTL cable: http://linux-sunxi.org/Cubieboard/TTL

Install the tool name minicom in your computer:

  $sudo apt-get install minicom

Set the minicom configuratiaon, TTL and cubieboard are connected ,then minicomin the terminal ,enter into the console.

Installing target Toolchains

  $sudo apt-get update
  $sudo apt-get upgrade
  $sudo apt-get install vim build-essential git libusb-1.0-0-dev pkg-config -y

Hardware Testing

The best way to test hardware is install the office firmware from http://dl.cubieboard.org and usr office fitting fromhttp://docs.cubieboard.org/addons,which can find the problem quickly you met. Of course ,you should save the data before reinstall firmware.

LEDs On Cubieboaed

These are blue LED1 meaning heartbeat and green LED2 on cb1 and cb2. LED1 - GPIO port PH21, LED2 - GPIO port PH20.
These are LED1~4 on cb3(cubietruck). LED1 - PH21, LED2 - PH20,LED3 - PH11,LED4 - PH07.Refer to FAQ about cubietruck 
For cb1 and cb2:

  $echo 1 > /sys/class/gpio/export   //open the PH20
  $echo 2 > /sys/class/gpio/export   //open the PH21

The directories /sys/class/gpio/gpio1_PH20 and/sys/class/gpio/gpio2_PH21 had been create .

  $cd /sys/class/gpio /gpio1_PH20
  $echo out > direction    //set PH20 as output
  $echo 1 > value          //set PH20 as high ,grenn LED is light
  $echo 0 > value          //set PH20 as low,turn off the LED

HDMI

It would be best way connect the HDMI cable before power on the cubieboard,becuse some cable maybe appear the promble of sequence in time.
If your have not full screen display, you can try the following commands

$fbset -left 10

1.If you are using lubuntu, try the following commands

$wget http://dl.cubieboard.org/software/tools/armhf/cb-display-tool
$chmod 777 cb-display-tool
$cb-display-tool -o 8 -m 11  //switch to VGA type
$cb-display-tool -o 4 -m 4  //switch to HDMI type

If you switch to other resolution, you need to restart your X after the modification

2.The default display configuration in script.bin of uboot partition of official desktop-firmware as :

;disp init configuration
;
;disp_mode            (0:screen0<screen0,fb0> 1:screen1<screen1,fb0> 2:two_diff_screen_diff_contents<screen0,screen1,fb0,fb1>
;                      3:two_same_screen_diff_contets<screen0,screen1,fb0> 4:two_diff_screen_same_contents<screen0,screen1,fb0>)
;screenx_output_type  (0:none; 1:lcd; 2:tv; 3:hdmi; 4:vga)
;screenx_output_mode  (used for tv/hdmi output, 0:480i 1:576i 2:480p 3:576p 4:720p50 5:720p60 6:1080i50 7:1080i60 8:1080p24 9:1080p50 10:1080p60 11:pal 14:ntsc)
;screenx_output_mode  (used for vga output, 0:1680*1050 1:1440*900 2:1360*768 3:1280*1024 4:1024*768 5:800*600 6:640*480 10:1920*1080 11:1280*720)
;fbx format           (4:RGB655 5:RGB565 6:RGB556 7:ARGB1555 8:RGBA5551 9:RGB888 10:ARGB8888 12:ARGB4444)
;fbx pixel sequence   (0:ARGB 1:BGRA 2:ABGR 3:RGBA) --- 0 for linux, 2 for android
;lcd0_bright          (lcd0 init bright,the range:[0,256],default:197
;lcd1_bright          (lcd1 init bright,the range:[0,256],default:197

[disp_init]
disp_init_enable = 1
disp_mode = 0
screen0_output_type = 3
screen0_output_mode = 4
screen1_output_type = 0
screen1_output_mode = 4
fb0_width = 1024
fb0_height = 768
fb0_framebuffer_num = 2
fb0_format = 10
fb0_pixel_sequence = 0
fb0_scaler_mode_enable = 0
fb1_width = 1024
fb1_height = 768
fb1_framebuffer_num = 2
fb1_format = 10
fb1_pixel_sequence = 0
fb1_scaler_mode_enable = 0

Modify the parameter according to the using HDMI displayer . You can get more information about display from Display and modify script.bin from edit_the_system_configuration

VGA

Refer to HDMI section.

USB Host

The quickly way to test the interface of USB is plug the U disk . The system will identify the U disk .Use fdisk -l can see its information which meaning the interface of USB is working.

IR

IR had beed add into the kernel .If not, use command to load the moudle:

  $insmnod /lib/modules/3.4.X/kernel/drivers/input/keyboard/sun4i-ir.ko
  $sudo cat /dev/input/event0 | hexdump

Press the key of IR remote control,the terminal will print the message as:

0000000 8415 525f 50cf 0003 0001 0094 0001 0000
0000010 8415 525f 50db 0003 0000 0000 0000 0000
0000020 8415 525f 22f7 0007 0001 0094 0000 0000
0000030 8415 525f 22ff 0007 0000 0000 0000 0000

The digital '0094' is keycode of the remote control .

Headphone Jack

There are two audio devices HDMI and headphone in the cubieboard.

  $sudo  alsamixer

There are two audio devices named sunxi-sndhdmi and sunxi-CODEC in the system. The sound output is send out from HDMI by default . You can adjust volume and other configuration ,use Ctrl + z to save it.
alsamixer GUI

To set sound care being sunxi-CODEC modify /etc/asound.conf to turn on the headphone.

  pcm.!default {
    type hw
    card 0    //If you want to set HDMI as output ,turn 0 to 1.
    device 0
  }
  ctl.!default {
    type hw
    card 0   //If you want to set HDMI as output ,turn 0 to 1.
  }

If Plug in the headphone and type:

  $speaker-test -twav -c2

The sound "sound left,sound right,sound left" will output from headphone.

Let cubieboard speak by package named espeak :

  $sudo apt-get install espeak
  $espeak "hello"            //say: hello
  $espeak "hello_cubieboar"  //say: hello cubieboard

Camera

Most of the camera driver has integrated in the kernel,so it is available insert usb-camera into the cubieboard.

$sudo apt-get install luvcview
$luvcview -s 1080x720 (can modify the resolution)
   
site
site