2016年12月31日 星期六

juju

Juju | Cloud | Ubuntu
https://www.ubuntu.com/cloud/juju

Getting started with Juju | Documentation | Juju
https://jujucharms.com/docs/stable/getting-started

Charm hooks | Documentation | Juju
https://jujucharms.com/docs/stable/authors-charm-hooks

Dealing with errors encountered by charm hooks | Documentation | Juju
https://jujucharms.com/docs/devel/authors-hook-errors

Debugging Juju charm hooks | Documentation | Juju
https://jujucharms.com/docs/1.25/authors-hook-debug

Charm Tools | Documentation | Juju
https://jujucharms.com/docs/1.25/tools-charm-tools

juju debug-hooks _unit_ _hooks_
juju resolved _unit_

gradle

Installing Gradle - Gradle User Guide Version 3.2.1
https://docs.gradle.org/current/userguide/installation.html

Build Script Basics - Gradle User Guide Version 3.2.1
https://docs.gradle.org/current/userguide/tutorial_using_tasks.html

2016年12月27日 星期二

ansible

Installation — Ansible Documentation
http://docs.ansible.com/ansible/intro_installation.html#latest-releases-via-apt-ubuntu
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible

Getting Started — Ansible Documentation
http://docs.ansible.com/ansible/intro_getting_started.html
/etc/ansible/hosts

Intro to Playbooks — Ansible Documentation
http://docs.ansible.com/ansible/playbooks_intro.html

Playbook Roles and Include Statements — Ansible Documentation
http://docs.ansible.com/ansible/playbooks_roles.html



Tags — Ansible Documentation

http://docs.ansible.com/ansible/playbooks_tags.html

Playbook Debugger — Ansible Documentation
https://docs.ansible.com/ansible/playbooks_debugger.html

An Ansible Tutorial - Servers for Hackers
https://serversforhackers.com/an-ansible-tutorial


2016年12月24日 星期六

Linux Google Drive

sudo apt-get install golang git mercurial
go get -u github.com/odeke-em/drive/cmd/drive
drive init


drive list
drive pull
drive push

An Official Google Drive for Linux is Here, Sort Of — Maybe This Is All We’ll Ever Get
http://www.howtogeek.com/196635/an-official-google-drive-for-linux-is-here-sort-of-maybe-this-is-all-well-ever-get/

GitHub - odeke-em/drive: Google Drive client for the commandline
https://github.com/odeke-em/drive#requirements

GitHub - tools/godep: dependency tool for go
https://github.com/tools/godep

2016年11月16日 星期三

Setting PCIe MPS/MRRS with setpci

setpci(8): configure PCI devices - Linux man page
https://linux.die.net/man/8/setpci

PCI express maximal payload size: Finding it and its impact on bandwidth
http://billauer.co.il/blog/2011/05/pcie-pci-express-linux-max-payload-size-configuration-capabilities-tlp-lspci/

Intel Ethernet Drivers and Utilities / Mailing Lists
https://sourceforge.net/p/e1000/mailman/message/30249072/

Intel PCI Express base 1.0 spec.pdf
http://teacher.en.rmutt.ac.th/ktw/MicroProcessor/buses/Intel%20PCI%20Express%20base%201.0%20spec.pdf
p337, ch7.8.3. Device Capabilities Register (Offset 04)
p341, ch7.8.4. Device Control Register (Offset 08h)

dev=0002:01:02.2

setpci --dumpregs

setpci -v -s $dev CAP_EXP.l
#display the first 4-byte of CAP_EXP...
for a in $(lspci | cut -d' ' -f1 ); do echo $a ----; --;setpci -v -s $a CAP_EXP.l 2>&1 ; done | less

#Show Device Capabilities Register
setpci -v -s $dev CAP_EXP+4.l
#Show Device Control Register
setpci -v -s $dev CAP_EXP+8.l

#Set value to Device Control Register 
setpci -v -s $dev CAP_EXP+8.l=aabbccdd

2016年11月9日 星期三

btrfs


Installing btrfs as boot drive on Ubuntu 14.04 - James DiGioia
http://jamesdigioia.com/installing-btrfs-boot-drive-ubuntu-14-04/

btrfs - Community Help Wiki
https://help.ubuntu.com/community/btrfs#Converting_Ubuntu_12.10_ext4_root_filesystem

How to Create and Manage Btrfs Snapshots and Rollbacks on Linux (part 2) | Linux.com | The source for Linux information
https://www.linux.com/learn/how-create-and-manage-btrfs-snapshots-and-rollbacks-linux-part-2

How to Manage Btrfs Storage Pools, Subvolumes And Snapshots on Linux (part 1) | Linux.com | The source for Linux information
https://www.linux.com/learn/how-manage-btrfs-storage-pools-subvolumes-and-snapshots-linux-part-1

2016年11月1日 星期二

MCORD: No module named translator.toscalib.tosca_template

CORD build info is in here:
http://mkl-note.blogspot.com/2016/10/cord-in-box-quick-start-guide-target.html
https://gerrit.opencord.org/vBBU faab9e27521d0c2cdf34c36cd99b6327760d56eb
https://gerrit.opencord.org/vPGWC faab9e27521d0c2cdf34c36cd99b6327760d56eb

M-CORD Developer Environment - CORD - CORD Wiki
https://wiki.opencord.org/display/CORD/M-CORD+Developer+Environment

The following error occurs when building MCORD step "make xos":
    ImportError: No module named translator.toscalib.tosca_template

bash /home/ubuntu/service-profile/common/wait_for_xos_port.sh 80
Waiting for XOS to start listening on port 80
.......................XOS is ready
[PODCONFIG]
python /home/ubuntu/service-profile/common/run_tosca.py 80 padmin@vicci.org letmein setup.yaml
ERR: recieved status 500
Traceback (most recent call last):
  File "/opt/xos/api/utility/toscaapi.py", line 43, in post_run
    from tosca.engine import XOSTosca
  File "/opt/xos/tosca/engine.py", line 3, in
    import resources
  File "/opt/xos/tosca/resources/__init__.py", line 27, in
    module = __import__(fn[:-3])
  File "/opt/xos/tosca/resources/VPGWCComponent.py", line 6, in
    from translator.toscalib.tosca_template import ToscaTemplate
ImportError: No module named translator.toscalib.tosca_template
According to the following, the TOSCA parser is updated, but most of the import
is unnecessary. This patch remove those unnecessary import.

XOS Service Developers - please review imports in xos/tosca/resources/*.py - Google Groups
https://groups.google.com/a/opencord.org/forum/#!msg/cord-dev/eIemZc-BuUk/MhzlDuIhBQAJ
TOSCA parser in XOS core will be updated, and many services unnecessarily import the old TOSCA parser (along with other unneeded imports) in a way that will break your service after this update is merged.

Remove the line import ToscaTemplate from the following 4 files:
  1. vBBU/xos/tosca/resources/mcordservice.py
  2. vBBU/xos/tosca/resources/vbbucomponent.py
  3. vPGWC/xos/tosca/resources/VPGWCService.py
  4. vPGWC/xos/tosca/resources/VPGWCComponent.py

@@ -3,7 +3,7 @@ import pdb
 import sys
 import tempfile
 sys.path.append("/opt/tosca")
-from translator.toscalib.tosca_template import ToscaTemplate
+#from translator.toscalib.tosca_template import ToscaTemplate
 import pdb


You need to remove the existing docker image for the changes to take effect:
cd ~/service-profile/mcord/
make stop
make cleanup
sudo docker rm -f $(docker ps -aq)

make xos

2016年10月31日 星期一

CORD-in-a-Box Quick Start Guide: Target Server on CloudLab

ClouldLab, OnePC-Ubuntu14.04.4
https://github.com/opencord/cord/blob/master/docs/quickstart.md
https://github.com/opencord/cord.git  b5796fb8a34b779885abc9e8809e361d3463cde9
https://github.com/opencord/platform-install.git   b5796fb8a34b779885abc9e8809e361d3463cde9
bash ~/cord-in-a-box.sh -t | tee ~/install.out
Host Ubuntu 14.04
20161031
(Why so detail? because there's no guarantee it always work with the same environment)

mkl Note: CORD: LC_ALL not configured cause postgresql default cluster not created
http://mkl-note.blogspot.com/2016/10/cord-lcall-not-configured-cause.html

With the new script, I only encounter the above issue. Then I can finally see the holy X "BUILD SUCCESSFUL".

  1. Ensure no password sudo:
    sudo visudo -f /etc/sudoers.d/90-clouding-ubuntu
    Add the following line:
    user_name ALL=(ALL) NOPASSWD:ALL
  2. On your HOST, do not forward your locale to remote server by editing /etc/ssh/ssh_config and comment out SendEnv LANG LC_* line.
    sudo sed -e '/SendEnv/ s/^#*/#/' -i /etc/ssh/ssh_config
    Set the locale, then log out.
    sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
    exit
    Log in again and try printing the LC_ALL
    printenv | grep LC
    => LC_ALL=en_US.UTF-8

  3. Install the required package (curl I understand, but juju....)
    sudo apt-get update
    sudo apt-get install -y build-essential curl juju git vim tmux
  4. Download the installation script and run. No sudo running the script.
    curl -o ~/cord-in-a-box.sh https://raw.githubusercontent.com/opencord/cord/master/scripts/cord-in-a-box.sh
    mv  -v --backup=numbered ~/install.out ~/install.out.bak; time bash ~/cord-in-a-box.sh -t 2>&1 | tee ~/install.out

The last part of the log:
test-exampleservice : Install curl in testclient ----------------------- 29.69s
maas-test-client-install : Install software ---------------------------- 27.43s
test-vsg : Create a sample CORD subscriber ------------------------------ 3.58s
maas-test-client-install : Install PIP packages ------------------------- 3.16s
test-vsg : Re-run 'make vtn' (work around bug in synchronizer) ---------- 3.07s
test-vsg : Test external connectivity in test client -------------------- 3.04s
test-exampleservice : Re-run 'make vtn' (work around bug in synchronizer) --- 3.02s
setup ------------------------------------------------------------------- 2.49s
setup ------------------------------------------------------------------- 2.14s
test-exampleservice : Get mgmt IP of VM --------------------------------- 2.02s
test-exampleservice : Get public IP of VM ------------------------------- 1.93s
test-vsg : Get mgmt IP of VM -------------------------------------------- 1.81s
test-vsg : Wait for vSG VM to come up ----------------------------------- 1.81s

BUILD SUCCESSFUL

Total time: 29 mins 7.094 secs
Connection to 192.168.121.252 closed.
+ [[ 0 -eq 1 ]]
+ exit 0

real    204m41.956s
user    2m18.897s
sys    0m34.802s
Yes, it's almost 3.5hr, with CloudLab's server.....

CORD: LC_ALL not configured cause postgresql default cluster not created

ClouldLab, OnePC-Ubuntu14.04.4
bash ~/cord-in-a-box.sh -t | tee ~/install.out
When installing maas, the script failed. Running "sudo apt-get install maas" manually get the following error:

psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

It says there's no sql server listening at port 5432. "sudo apt-get install postgresql" shows the postgresql is already installed, but no default sql clusters created:
# pg_lsclusters
Ver Cluster Port Status Owner    Data directory    Log file
FIX1:
Setting a custom data directory for a new PostreSQL installation on Linux | Open Geospatial Technologies
http://geospatial.commons.gc.cuny.edu/2016/10/10/setting-a-custom-data-directory-for-a-new-postresql-installation-on-linux/

Let's create one:
sudo mkdir /data/sql-cluster -p
sudo pg_createcluster -d /data/sql-cluster --start 9.3 main
And you should see:
# pg_lsclusters
Ver Cluster Port Status Owner    Data directory    Log file
9.3 main    5432 online postgres /data/sql-cluster /var/log/postgresql/postgresql-9.3-main.log
Then install maas again:
sudo apt-get install maas

FIX2:
The default sql cluster is not created because the LC_ALL not configured.
command line - How do I fix my locale issue? - Ask Ubuntu
http://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue

  1. At you ssh client, do not forward your locale to remote server by editing /etc/ssh/ssh_config and comment out SendEnv LANG LC_* line. Or run the following:
    sed -e '/SendEnv/ s/^#*/#/' -i /etc/ssh/ssh_config
  2. Connect to remote server, and:
    sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
  3. Then log-out and log-in again, LC_ALL should be there.
    # printenv | grep LC
    LC_ALL=en_US.UTF-8
Then if you do "sudo apt-get install postgresql", you should see the default cluster is created.
(........................)

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Processing triggers for ureadahead (0.100.0-16) ...
Setting up postgresql-9.3 (9.3.14-0ubuntu0.14.04) ...
Creating new cluster 9.3/main ...
  config /etc/postgresql/9.3/main
  data   /var/lib/postgresql/9.3/main
  locale en_US.UTF-8
  port   5432
update-alternatives: using /usr/share/postgresql/9.3/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
 * Starting PostgreSQL 9.3 database server                               [ OK ]
Setting up postgresql (9.3+154ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...

$ pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
9.3 main    5432 online postgres /var/lib/postgresql/9.3/main /var/log/postgresql/postgresql-9.3-main.log
Thus cord-in-a-box.sh won't failed here.



2016年10月27日 星期四

PXE boot

PXE boot will download images as well as their configs, while tftp boot only download assigned image.

Preboot Execution Environment - Wikipedia
https://en.wikipedia.org/wiki/Preboot_Execution_Environment

After parsing a PXE enabled DHCP server DHCPOFFER, the client will be able to set its own network IP address, IP Mask, etc., and to point to the network located booting resources, based on the received TFTP Server IP address and the name of the NBP. The client next transfers the NBP into its own random-access memory (RAM) using TFTP, possibly verifies it (i.e. UEFI Secure Boot), and finally boots from it. NBPs are just the first link in the boot chain process and they generally request via TFTP a small set of complementary files in order to get running a minimalistic OS executive (i.e. WindowsPE, or a basic Linux kernel+initrd). The small OS executive loads its own network drivers and TCP/IP stack. At this point, the remaining instructions required to boot or install a full OS are provided not over TFTP, but using a robust transfer protocol (such as HTTP, CIFS, or NFS).
Ubuntu Netboot Images
http://cdimage.ubuntu.com/netboot/

Installation/Netboot - Community Help Wiki
https://help.ubuntu.com/community/Installation/Netboot#Set_Up_DHCP-BOOT
(Use DNSMASQ)

Ubuntu 14.04 LTS (Trusty Tahr) Netboot
http://cdimage.ubuntu.com/netboot/14.04/

Installation Guide for Ubuntu 14.04
https://help.ubuntu.com/14.04/installation-guide/

Ubuntu Installation Guide
https://help.ubuntu.com/14.04/installation-guide/amd64/install.en.txt

PXEInstallServer - Community Help Wiki
https://help.ubuntu.com/community/PXEInstallServer
(Use isc-dhcp-server)

tftpd-hpa + isc-dhcp-server + netboot.tar.gz
Dell PowerEdge R430, Ubuntu 14.04, 4.4, AMD64,
Cavium ThunderX, Ubuntu14.04, 4.2, ARM64

  1. Install the required services. Download and decompress the netboot.tgz to TFTP server directory.
    apt-get install tftpd-hpa isc-dhcp-server
    cd /var/lib/tftpboot
    tar xf netboot.tar.gz
  2. tftpd-hpa doesn't support symbolic link, but AMD64 netboot.tar.gz contains some links.
    ./ubuntu-installer/amd64/pxelinux.cfg/default -> ../boot-screens/syslinux.cfg
    ./pxelinux.0 -> ubuntu-installer/amd64/pxelinux.0
    ./pxelinux.cfg -> ubuntu-installer/amd64/pxelinux.cfg
    This result in "could not find image...". So I have the DHCP next file parameter to be the "ubuntu-installer/amd64/pxelinux.0" instead of "pxelinux.0", and make ./ubuntu-installer/amd64/pxelinux.cfg/default a real file by copy(or hard link) the linked file.
  3. (Only on R430, not on ThundeX)
    During booting, the screen shows:
    TFTP prefix: ubuntu-installer/amd64
    All the path in the config files should be changed to relative to ubuntu-installer/amd64/, or the bootloader will not be able to boot the installation procedure.
    $ sudo sed -e 's/ubuntu-installer\/amd64\///g' * -i
  4. /etc/dhcp/dhcpd.conf
    subnet 192.168.1.0 netmask 255.255.255.0 {
      range 192.168.1.10 192.168.1.15;
      option broadcast-address 192.168.1.255;
      option routers 192.168.1.1;             # our router
      option domain-name-servers 168.95.1.1;
      option domain-name-servers 168.95.192.1;
      filename "ubuntu-installer/arm64/bootnetaa64.efi"; # (this we will provide later)
    }

    group {
      next-server 192.168.1.204;                # our Server
      host tftpclient {
        filename "ubuntu-installer/arm64/bootnetaa64.efi"; # (this we will provide later)
      }
    }
  5. Restart the service.
    sudo service tftpd-hpa restart; sudo service isc-dhcp-server restart;

 





2016年10月26日 星期三

ANSIBLE: "ansible_processor_count" and "ansible_processor_vcpus" reported as 0

Ubuntu14.04, Linux kernel 4.2.0-19.20-generic, ThunderX 48 cores
ansible-2.1.2.0-1ppa~trusty
Installing MCORD by single-node-pod.sh
master, e003c8989e2

Error:
TASK [prereqs-common : CPU quantity Check] *************************************
Wednesday 26 October 2016  14:46:20 -0700 (0:00:00.335)       0:00:21.442 *****
fatal: [localhost]: FAILED! => {"assertion": "ansible_processor_vcpus >= 12", "changed": false, "evaluated_to": false, "failed": true}


FIX:
"ansible_processor_count" and "ansible_processor_vcpus" reported as 0 · Issue #16533 · ansible/ansible
https://github.com/ansible/ansible/issues/16533

This indicate the cause, but not the fix. This is my fix:

 facts.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/facts.py b/facts.py
index e93757b..89b66bf 100644
--- a/facts.py
+++ b/facts.py
@@ -1005,13 +1005,12 @@ class LinuxHardware(Hardware):

             # model name is for Intel arch, Processor (mind the uppercase P)
             # works for some ARM devices, like the Sheevaplug.
-            if key in ['model name', 'Processor', 'vendor_id', 'cpu', 'Vendor']:
+            if key in ['model name', 'Processor', 'vendor_id', 'cpu', 'Vendor','processor']:
                 if 'processor' not in self.facts:
                     self.facts['processor'] = []
                 self.facts['processor'].append(data[1].strip())
-                if key == 'vendor_id':
+                if key == 'processor':
                     vendor_id_occurrence += 1
-                if key == 'model name':
                     model_name_occurrence += 1
                 i += 1
             elif key == 'physical id':
--
1.9.1

cpuinfo
processor    : 0
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 1
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 2
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 3
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 4
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 5
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 6
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 7
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 8
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 9
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 10
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 11
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 12
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 13
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 14
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 15
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 16
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 17
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 18
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 19
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 20
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 21
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 22
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 23
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 24
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 25
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 26
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 27
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 28
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 29
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 30
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 31
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 32
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 33
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 34
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 35
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 36
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 37
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 38
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 39
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 40
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 41
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 42
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 43
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 44
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 45
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 46
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0

processor    : 47
Features    : fp asimd aes pmull sha1 sha2 crc32
CPU implementer    : 0x43
CPU architecture: 8
CPU variant    : 0x0
CPU part    : 0x0a1
CPU revision    : 0
 


Error: server certificate verification failed.


My newly installed ARM64 Ubuntu complaint about certificate verification fail, on apt-get update, wget,..., e.g.

Err https://private-ppa.launchpad.net trusty/main arm64 Packages
  server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
WFetched 3853 kB in 21s (180 kB/s)
: Failed to fetch https://private-ppa.launchpad.net/yarmouth-team/15.11/ubuntu/dists/trusty/main/binary-arm64/Packages  server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
There are lots of info there that I think is useful:
/etc/ssl/certs/
/etc/ssl/certs/ca-certificates.crt

echo -n | openssl s_client -showcerts -connect private-ppa.launchpad.net:443 2>/dev/null  | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'

curl-config --ca
sudo update-ca-certificates
But what really fix the issue is the time. Yes, I know certificates has valid started date and expiration date, but I just didn't check it!!!
root@ubuntu:~/prj/opencord# date
Thu Jan  1 16:53:04 PST 1970
server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none - Stack Overflow
http://stackoverflow.com/questions/21181231/server-certificate-verification-failed-cafile-etc-ssl-certs-ca-certificates-c

How to install certificates for command line - Ask Ubuntu
http://askubuntu.com/questions/645818/how-to-install-certificates-for-command-line

2016年10月21日 星期五

M-CORD

CORD: Central Office Re-architected as a Datacenter - ONOS - Wiki
https://wiki.onosproject.org/display/ONOS/CORD%3A+Central+Office+Re-architected+as+a+Datacenter

CORD started as an ONOS use case, but has since been spun off into its own open source project.
Central Office Re-architected as a Datacenter (CORD) - CORD - CORD Wiki
https://wiki.opencord.org/pages/viewpage.action?pageId=1278047
Software Building Blocks
  1. OpenStack [3] is the cluster management suite that provides the core IaaS capability, and is responsible for creating and provisioning virtual machines (VMs) and virtual networks (VNs).
  2. Docker [4] provides a container-based means to deploy and interconnect services. It also plays a key role in configuring and deploying CORD itself (e.g., the other elements—XOS, OpenStack, and ONOS—are instantiated in Docker containers on the POD head nodes.
  3. ONOS [5] is the network operating system that manages the underlying white-box switching fabric. It both hosts a collection of control applications that implement services on behalf of Telco subscribers and is responsible for embedding virtual networks in the underlying fabric, which is in turn accessed via OpenStack’s Neutron API.
  4. XOS [6] is a framework for assembling and composing services. It unifies infrastructure services (provided by OpenStack), control plane services (provided by ONOS), and any data plane or cloud services (running in OpenStack-provided virtual machines and Docker-provided containers).
the reference implementation supports services running in virtual machines (KVM), in containers running directly on bare metal (Docker), and in containers nested inside virtual machines (Docker in KVM).


Mobile CORD
https://wiki.opencord.org/display/CORD/Mobile+CORD

M-CORD
http://opencord.org/wp-content/uploads/2016/03/M-CORD-March-2016.pdf
Mobile CORD - Google Groups
https://groups.google.com/a/opencord.org/forum/#!forum/mobile

opencord invitation bot
https://slackin.opencord.org/

OpenStack Releases: OpenStack Releases
https://releases.openstack.org/

VTN (Virtual Tenant Network)

OpenDaylight Virtual Tenant Network (VTN):Overview - OpenDaylight Project
https://wiki.opendaylight.org/view/OpenDaylight_Virtual_Tenant_Network_%28VTN%29:Overview

OASIS TOSCA (Topology and Orchestration Specification for Cloud Application)
Version 1.0
http://docs.oasis-open.org/tosca/TOSCA/v1.0/os/TOSCA-v1.0-os.html

ONIE (Open Network Install Environment) for switch
http://onie.opencompute.org/

2016年10月20日 星期四

locale.Error: unsupported locale setting

# openstack service create --name keystone --description "OpenStack Identity" identity

Traceback (most recent call last):
  File "/usr/bin/openstack", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/dist-packages/openstackclient/shell.py", line 342, in main
    return OpenStackShell().run(argv)
  File "/usr/lib/python2.7/dist-packages/openstackclient/shell.py", line 79, in __init__
    command_manager=commandmanager.CommandManager('openstack.cli'))
  File "/usr/lib/python2.7/dist-packages/cliff/app.py", line 74, in __init__
    self._set_streams(stdin, stdout, stderr)
  File "/usr/lib/python2.7/dist-packages/cliff/app.py", line 82, in _set_streams
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python2.7/locale.py", line 579, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting


List locale supported (installed) by current system:
locale -a
Or install the locale by:
sudo apt-get install language-pack-id
Re-generate the locale:
sudo dpkg-reconfigure locales
If I set LC_ALL to something not installed, I got
warning: setlocale: LC_ALL: cannot change locale (zh_TW.UTF-8)
If the LC_ALL is empty:
# sudo dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = "",
        LC_PAPER = "zh_TW.UTF-8",
        LC_ADDRESS = "zh_TW.UTF-8",
        LC_MONETARY = "zh_TW.UTF-8",
        LC_NUMERIC = "zh_TW.UTF-8",
        LC_TELEPHONE = "zh_TW.UTF-8",
        LC_IDENTIFICATION = "zh_TW.UTF-8",
        LC_MEASUREMENT = "zh_TW.UTF-8",
        LC_TIME = "zh_TW.UTF-8",
        LC_NAME = "zh_TW.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
Generating locales...
  en_AG.UTF-8... up-to-date
  en_AU.UTF-8... up-to-date
  en_BW.UTF-8... up-to-date
  en_CA.UTF-8... up-to-date
  en_DK.UTF-8... up-to-date
  en_GB.UTF-8... up-to-date
  en_HK.UTF-8... up-to-date
  en_IE.UTF-8... up-to-date
  en_IN.UTF-8... up-to-date
  en_NG.UTF-8... up-to-date
  en_NZ.UTF-8... up-to-date
  en_PH.UTF-8... up-to-date
  en_SG.UTF-8... up-to-date
  en_US.UTF-8... up-to-date
  en_ZA.UTF-8... up-to-date
  en_ZM.UTF-8... up-to-date
  en_ZW.UTF-8... up-to-date
Generation complete.
In my case, my LC_ALL is empty. Setting it to something installed fix the issue:
export LC_ALL=en_US.UTF-8
export LC_ALL='C'


export LC_ALL='zh_TW.UTF-8'
export LC_ALL=''

2016年10月6日 星期四

Paracord Survival Bracelet傘繩求生手環

我以前就會想帶些繩子以防不時之需。但是童軍繩太粗了,很難用。後來看到這些傘繩手環就很心動,但是戶外用品店賣的都貴的誇張了,於是上網查了編法,想要自己編一個。

Youtube上有超多教學影片,可是我不是要裝飾用的漂亮帥氣或者很炫的結,而是要能方便使用,使用時要方便拆解,下面這個就是。

How To Make the "True Survival" Paracord Bracelet (Tutorial) by The Cord Kid - YouTube
https://youtu.be/hiWqLbA6apY


酷酷坊 求生手環 3秒快拆 傘繩手環 kukufun paracord - YouTube
https://youtu.be/V2GGUBzgK_k

§酷酷手作§ DIY傘繩手環組件 新款 四合一 傘繩專用插扣 打火石 求生哨 指北針 鑰匙圈 | 露天拍賣-台灣 NO.1 拍賣網站
http://goods.ruten.com.tw/item/show?21602631882896
買了些零件試作和插扣試作,但是買到了才發現使用 塑膠插扣 不能作到快拆!! 因為當你要拆開時,尾端的零件要能拆掉或者是直接用繩結解開。若是直接打在塑膠扣上,除非剪繩或破壞塑膠扣,不然就只能一條一條慢慢解開了。

打火石+求生哨+指北針實在是很吸引我。但是哨子很難吹,而塑膠扣不能快拆對我來說是個大問題。



所以最後我用D卸扣+調整扣做頭。看起來真的不錯,但是卸扣解開比較不方便。
傘繩全長532cm, 產出25.5cm的手環
大約 手環長=傘繩長/21.69
不過我編的算緊了,再緊應該也緊不到哪去,所以參數大約抓20~22應該沒問題。

2016年9月10日 星期六

Make Ubuntu kernel

Edit debian.master/changelog, add some string to distinguish from the original one:

linux (4.5.7-040507.201606100436-test15+23e5a3b) unstable; urgency=low
Add execution permission to build scripts:
chmod a+x debian/rules; chmod a+x debian/scripts/*; chmod a+x debian/scripts/misc/*;
"make oldconfig"
debian/rules updateconfigs
debian/scripts/misc/oldconfig ARCH
"make menuconfig":
fakeroot debian/rules clean
fakeroot debian/rules editconfigs #
Build:
fakeroot debian/rules clean
fakeroot debian/rules binary-headers binary-generic
Build image with dbgsym:
fakeroot time debian/rules binary-headers binary-generic skipdbg=false
https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel
https://wiki.ubuntu.com/KernelTeam/GitKernelBuild
https://wiki.ubuntu.com/Kernel/MainlineBuilds


Ubuntu prebuilt kernel:
https://launchpad.net/~kernel-ppa/+archive/ubuntu/ppa
https://launchpad.net/~canonical-kernel-team/+archive/ubuntu/ppa
http://kernel.ubuntu.com/~kernel-ppa/mainline/
http://kernel.ubuntu.com/~kernel-ppa/mainline/daily/current/




2016年9月8日 星期四

宜一荒野限定冷笑話/腦筋急轉彎

太陽爸和太陽媽,生了個太陽兒子,我們該說什麼祝賀詞恭喜他們? 生日快樂
那這樣總共有幾顆太陽呢?一顆,因為太陽他爸是漂流木,太陽他媽是母老虎,所以只有一顆陳太陽

https://youtu.be/MOI3etHEYRM


誰最會講笑話?酵母,因為會發酵
不可以對誰講笑話? 海浪,因為海浪笑了 會海嘯
(原始:在哪邊不可以講笑話?海邊,因為海笑(嘯)了很恐怖)

綿羊被剃毛後為什麼會睡不著呢?因為 失綿 了

黑人和白人結婚會生出什麼? 灰狼
小黃 小白 小黑 和 小紅 坐車誰會吐?  小白兔 和 小黃兔

2016年9月2日 星期五

Kernel Crash Dump

sudo apt install linux-crashdump

Verification
cat /proc/cmdline
dmesg | grep -i crash
kdump-config show

cat /proc/sys/kernel/sysrq

Active kdump
kdump-config load

Enabling various types of panics
To make Linux kernel to panic on different situations please use:

echo 1 > /proc/sys/kernel/hung_task_panic          # panic when hung task is detected
echo 1 > /proc/sys/kernel/panic_on_io_nmi          # panic on NMIs from I/O
echo 1 > /proc/sys/kernel/panic_on_oops            # panic on oops or kernel bug detection
echo 1 > /proc/sys/kernel/panic_on_unrecovered_nmi # panic on NMIs from memory or unknown
echo 1 > /proc/sys/kernel/softlockup_panic         # panic when soft lockups are detected
echo 1 > /proc/sys/vm/panic_on_oom                 # panic when out-of-memory happens

Test Crash kernel
sudo -s
echo c > /proc/sysrq-trigger

Get vmlinux with debug symbol
sudo tee /etc/apt/sources.list.d/ddebs.list << EOF
deb http://ddebs.ubuntu.com/ $(lsb_release -cs)          main restricted universe multiverse
deb http://ddebs.ubuntu.com/ $(lsb_release -cs)-security main restricted universe multiverse
deb http://ddebs.ubuntu.com/ $(lsb_release -cs)-updates  main restricted universe multiverse
deb http://ddebs.ubuntu.com/ $(lsb_release -cs)-proposed main restricted universe multiverse
EOF

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECDCAD72428D7C01
sudo apt-get update
sudo apt-get install linux-image-$(uname -r)-dbgsym

Inspecting the crash dump using crash

Debug kernel: /usr/lib/debug/boot/
Crash dump: /var/crash/

crash <debug kernel> <crash dump>


Kernel/CrashdumpRecipe - Ubuntu Wikihttps://wiki.ubuntu.com/Kernel/CrashdumpRecipe

Kernel Crash Dump
https://help.ubuntu.com/lts/serverguide/kernel-crash-dump.html

2016年9月1日 星期四

Random abnormal high CPU sys usage related to timer

Test files and logs are available in GitHub
https://github.com/mkl0301/abnormal-cpu-load


20160910 update:
Up to now I still don't know clearly whether this is simply a display issue, or something is actually being executed.
  1. Even with the issue happening, the application seems works normally.
  2. But with previous perf report, the data sampling rate when the issue happen is higher than the rate when issue not happen.
I happened to found that on v3.13, enabling CONFIG_CONTEXT_TRACKING_FORCE can fix this issue. But unfortunately the kernel I'm using is 3.4, which doesn't have the context tracking feature added, so the hunting keeps on....

Forcing context tracking only works until 4.5, doing so on 4.6 and after still see the issue.



Random abnormal high CPU sys usage related to timer
https://lkml.org/lkml/2016/8/26/383

We were having issue with our userspace application which
__sometimes__ result in high CPU sys usage at each execution. The high
sys CPU usage persist until the application is killed.

We simplified the application to just creating a timer and its handler
then does nothing, but looping and sleeping for the timer to be
triggered. With top, the CPU that running the application usually
takes almost 0% for sys usage. But sometimes it will occupy certain
amount of sys usage, up to 100% at most of the time on my embedded
device.

On my laptop, Intel Core i5-4200U, running Ubuntu 14.02.2, Linux
3.13.0-45-generic and 4.4.0-34-generic, the issue can be reproduced
with lower sys usage (7~50%). The same can be reproduced with
buildroot+vanilla kernel 4.7 and 3.13.

Restart the application could temporarily fix the the issue, but there
are chances to happen again.

/proc/timer_stats, /proc/interrupts, and perf didn't show any abnormal value or useful clue.
Comparing the good and fail log got the following
  • The /proc/timer_stats is almost the same, but perf events shows extra softirq/timer events.
  • The perf sample of the failed case is much more than the good case, but the ratio of the sampled functions are basically the same.


One issue is found that seems related, but no further action.

Keystone II Linux: Random High CPU usage - userspace application using 1 full core - Linux forum - Linux - TI E2E Community
http://e2e.ti.com/support/embedded/linux/f/354/p/433791/1553204



The Documentation/cpu-load.txt discussed a situation that the cpu load reported by top might underestimated. The C code is very alike to ours. But it's discussing a different topic.

Documentation/cpu-load.txt
https://www.kernel.org/doc/Documentation/cpu-load.txt
https://lkml.org/lkml/2007/2/12/6




Why you should avoid using SIGALRM for timer – Linux, Embedded, Android and Security blog
https://nativeguru.wordpress.com/2015/02/19/why-you-should-avoid-using-sigalrm-for-timer/

Linux timer | 菜鳥的三年成長史
https://wirelessr.gitbooks.io/working-life/content/linux_timer.html
The best timer | 菜鳥的三年成長史
https://wirelessr.gitbooks.io/working-life/content/the_best_timer.html


Linux Timers | Blog | Upvoid
https://upvoid.com/devblog/2014/05/linux-timers/

kernel debug


Linux kernel tracing
http://www.slideshare.net/vh21/linux-kernel-tracing

Ktap A New Scripting Dynamic Tracing Tool For Linux
http://events.linuxfoundation.org/sites/events/files/lcjpcojp13_zhangwei.pdf

Using GDB to Help You Read Linux Kernel Code without Running It - Google Docs
https://docs.google.com/document/d/1w1nPmCLpeRN3kEYglzHwozhWXY0ddT9oe6JCZocsPNE/edit#heading=h.8bskh6ejh6u7

2016年8月28日 星期日

一條河

【第二屆十大「節」出綠繪本.得獎作品賞】第一名:《海邊的診所》 - 環境通訊網
http://enw.e-info.org.tw/content/1949
【第二屆十大「節」出綠繪本.得獎作品賞】海大富獎:《海龜的願望》 - 環境通訊網
http://enw.e-info.org.tw/content/1954
The Survival of the Sea Turtle - YouTube
https://youtu.be/t-KmQ6pGxg4
【第二屆十大「節」出綠繪本.得獎作品賞】佳作:《不要的垃圾》 - 環境通訊網
http://enw.e-info.org.tw/content/1953
海邊什麼垃圾最多? - 台灣環境資訊協會
http://teia.tw/zh-hant/event/story/6974
世界烏龜日 淨灘垃圾化身繽紛大海龜 - 環境通訊網
http://enw.e-info.org.tw/content/2832
(18) 還地球幸福的笑臉 - 【分享30萬次,捐出30萬元!金曲歌后彭佳慧用音樂幫助小海龜】...
https://www.facebook.com/protect.earth.ocean/videos/642067719285206/

【賞讀.綠繪本】野溪整型記 | 台灣環境資訊協會-環境資訊中心
http://e-info.org.tw/node/112255

塑膠袋流浪記
https://youtu.be/eXoozwXK6RE

單元名稱:從山裡逃出來/垃圾,丟啊!
http://ee.tc.edu.tw/06edu%20popularize/99/picture%20book/98/teaching%20plan/book-1.pdf

海洋科學繪本-你為什麼住這裡?
https://youtu.be/eMAo7iQAWPQ

 

2016年8月25日 星期四

FATAL: kernel too old

I used buildroot to generate bzImage and rootfs.cpio.gz, but always get "FATAL: kernel too old", no matter how I config the BR2_KERNEL_HEADERS_XXX and BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_XXX.

Google said the glibc need --enable-kernel, but buildroot already gave that. Then I found that my 3.13 kernel include/linux/version.h has LINUX_VERSION_CODE configured to something like 3.4....

I'm using Linux kernel checkout by git. It seems that the include/linux/version.h was generated when I were using 3.4, which I don't even remember when.

So if you got this error, and happen to be using linux source checkout by git, maybe try

git clean -xfd
Hopes this save your day, cause I've spent mine on this stupid reason. sigh.

2016年8月24日 星期三

2016年8月8日 星期一

Linux perf "irq/sec"

perf top has a value "irq/sec"

linux/tools/perf/builtin-top.c, perf_top__mmap_read_idx(), top->samples is increased whenever read a sample.

linux/tools/perf/util/top.c, perf_top__header_snprintf(), the irq/sec is the value of samples_per_sec, which is calculated by:
        float samples_per_sec = top->samples / top->delay_secs;

Therefor, the irq/sec is, sample rate. Period.

2016年7月31日 星期日

虹光漆 筆記


刮除壁癌
有些地方很好刮除,但有些地方很奸詐,沒水不會浮,有水就浮給你看,後來我都再刷一層水檢查有沒有浮起的地方一起刮除。

防壁癌漆

批土


底漆 白漆兩層
虹牌450水性水泥漆 白色 平光 與 有光 1:1混合,加10~20%水混合,油漆刷沾上去要有點糊,刷兩層。



色漆3-4層

德寶 環保水性木器塗料 水性環保75%平光面漆 1L
奇美油漆行

易耕 溼水彩
黃,藍綠,綠,黃綠
牛頓 要用 透明水彩

漆與水的比例(顏料算水)漆:水

第一層
一般顏色以 1:9,藍色比較重1:13。
塗到邊緣時要漸層,方便下次或下個人接續,才不會在相接處形成明顯的線條

第二層 1:6
第三層 1:4

四年級
第一層淡金黃,第二層濃金黃,第三層藍綠,第四層黃綠色做漸層
二年級
淡橙紅/橙紅/橙黃

暖色要先上

橘 先上橙紅 再上橙黃
綠 先上黃 再上藍綠


色料三原色 | .✣Miffy✣騎大象✣.
http://loveaesthetic.blogspot.tw/2007/08/johannes-itten-1888-19671961.html

透明水彩六大調色觀念
http://artprince.shop2000.com.tw/edm/3870

2016年6月21日 星期二

Linux: How to find the device driver used for a device?

Linux: How to find the device driver used for a device?
http://unix.stackexchange.com/questions/41817/linux-how-to-find-the-device-driver-used-for-a-device

#!/bin/bash
for f in /sys/class/net/*; do
    dev=$(basename $f)
    driver=$(readlink $f/device/driver/module)
    if [ $driver ]; then
        driver=$(basename $driver)
    fi
    addr=$(cat $f/address)
    operstate=$(cat $f/operstate)
    printf "%10s [%s]: %10s (%s)\n" "$dev" "$addr" "$driver" "$operstate"
done


2016年6月12日 星期日

[git-svn] customized branch checkout

To clone the SVN repo that is not standard layout, only part of the branches are required.

Edit .git/config:

[svn-remote "svn"]
        url = http://blabla.com/svn/
        fetch = foo1/bar1:refs/remotes/svn/bar1
        branches = foo2/{bar2,bar3, bar4}:refs/remotes/svn/*
        branches = foo3/{bar5}:refs/remotes/svn/*

Checkout only certain branches with git-svn · GitHub
https://gist.github.com/trodrigues/1023167

2016年4月29日 星期五

不專業碳排計算

使用免洗杯/盤/碗/吸管 0.02kg/個
購買瓶裝飲料0.295kg/罐
塑膠袋0.0001kg/個
購買進口食品/蔬果(以每公斤蔬果運送1000km)0.02kg
自行開車0.22kg/km
搭電梯0.22kg/樓
開冷/暖氣1.4kg/小時
使用電腦0.156kg/小時



種樹減碳是正途 - stanleyhsu 的部落格 - udn部落格
http://blog.udn.com/stanleyhsu/13535052

水黃皮固碳能力
400顆/公頃
43.99T/年公頃
110kg/顆年
行政院環保署 台灣產品碳足跡
https://cfp.epa.gov.tw/CARBON/EZCFM/FUNCTION/PLATFORMINFO/FLACTIVITY/CARBONTIPS.ASPX
每天少開一小時冷氣。(以冷氣功率220W計算) 1.40kg
[商業交流] - 碳管理趨勢概述_以食品碳足跡為例(FOR 銘傳).pdf
http://gad.mcu.edu.tw/sites/default/files/u3/%E7%A2%B3%E7%AE%A1%E7%90%86%E8%B6%A8%E5%8B%A2%E6%A6%82%E8%BF%B0_%E4%BB%A5%E9%A3%9F%E5%93%81%E7%A2%B3%E8%B6%B3%E8%B7%A1%E7%82%BA%E4%BE%8B%28FOR%20%E9%8A%98%E5%82%B3%29.pdf
運具
kgCO2/\公噸-公里
航空1.58
卡車0.27
海運0.02
行政院環保署 台灣產品碳足跡
https://cfp.epa.gov.tw/CARBON/EZCFM/FUNCTION/PLATFORMINFO/FLABELPRODUCT/FLFOREIGNPRODUCTEMISSIONS.ASPX
Average(360,240,170,360,240,500,150,340)/1000=0.295kg
http://www.candcprinting.com/upload/file/green/GreenNewsletter201004_tch.pdf
10對一次性筷子,碳排放量為0.2千克
一個塑膠袋碳排放量為0.1克。
電梯每上下一層,碳排放量為0.218千克
少搭電梯=少開車? | 台灣環境資訊協會-環境資訊中心 
http://e-info.org.tw/node/37587
搭乘電梯上下一層樓會排放0.218kg的CO2
汽車的碳排放係數0.22kg/km



2016年4月26日 星期二

GIT newline configuration

Usually I prefer to disable autocrlf:

git config --global core.autocrlf false

When you see any of the following message, it means git autocrlf is working:
warning: CRLF will be replaced by LF in XXXXX.
The file will have its original line endings in your working directory.

fatal: CRLF would be replaced by LF in XXXXX.


Dealing with line endings - User Documentation
https://help.github.com/articles/dealing-with-line-endings/

Help

core.safecrlf

    If true, makes Git check if converting CRLF is reversible when end-of-line conversion is active. Git will verify if a command modifies a file in the work tree either directly or indirectly. For example, committing a file followed by checking out the same file should yield the original file in the work tree. If this is not the case for the current setting of core.autocrlf, Git will reject the file. The variable can be set to "warn", in which case Git will only warn about an irreversible conversion but continue the operation.

    CRLF conversion bears a slight chance of corrupting data. When it is enabled, Git will convert CRLF to LF during commit and LF to CRLF during checkout. A file that contains a mixture of LF and CRLF before the commit cannot be recreated by Git. For text files this is the right thing to do: it corrects line endings such that we have only LF line endings in the repository. But for binary files that are accidentally classified as text the conversion can corrupt data.

    If you recognize such corruption early you can easily fix it by setting the conversion type explicitly in .gitattributes. Right after committing you still have the original file in your work tree and this file is not yet corrupted. You can explicitly tell Git that this file is binary and Git will handle the file appropriately.

    Unfortunately, the desired effect of cleaning up text files with mixed line endings and the undesired effect of corrupting binary files cannot be distinguished. In both cases CRLFs are removed in an irreversible way. For text files this is the right thing to do because CRLFs are line endings, while for binary files converting CRLFs corrupts data.

    Note, this safety check does not mean that a checkout will generate a file identical to the original file for a different setting of core.eol and core.autocrlf, but only for the current one. For example, a text file with LF would be accepted with core.eol=lf and could later be checked out with core.eol=crlf, in which case the resulting file would contain CRLF, although the original file contained LF. However, in both work trees the line endings would be consistent, that is either all LF or all CRLF, but never mixed. A file with mixed line endings would be reported by the core.safecrlf mechanism.

core.autocrlf

    Setting this variable to "true" is almost the same as setting the text attribute to "auto" on all files except that text files are not guaranteed to be normalized: files that contain CRLF in the repository will not be touched. Use this setting if you want to have CRLF line endings in your working directory even though the repository does not have normalized line endings. This variable can be set to input, in which case no output conversion is performed.

Ubuntu 16.04 error: undefined reference to `create_module'


Building module-init-tools-3.2 in Ubuntu16.04 failed:
lsmod.o: In function `try_old_version':
./module-init-tools-3.2/backwards_compat.c:56: undefined reference to `create_module'
This is because 16.04 uses GLIBC 2.23 which doesn't export the obsoleted API create_module.

create_module(2) - Linux manual page
http://man7.org/linux/man-pages/man2/create_module.2.html
This obsolete system call is not supported by glibc. No declaration is provided in glibc headers, but, through a quirk of history, glibc versions before 2.23 did export an ABI for this system call. Therefore, in order to employ this system call, it was sufficient to manually declare the interface in your code; alternatively, you could invoke the system call using syscall(2).
Xenial (16.04) : glibc package : Ubuntu
https://launchpad.net/ubuntu/xenial/+source/glibc
glibc (......) version: 2.23-0ubuntu3

FIX:
Enable CONFIG_NO_BACKWARDS_COMPAT for module-init-tools-3.2.

2016年4月25日 星期一

kernel failed building kernel on Ubuntu 16.04: Can't use 'defined(@array)'

Error while building kernel with Ubuntu16.04:

  TIMEC kernel/timeconst.h
Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.
Fixed by:
Linux Kernel - [PATCH 1/5] kbuild: remove deprecated use of defined in timeconst.pl
http://linux-kernel.2935.n7.nabble.com/PATCH-1-5-kbuild-remove-deprecated-use-of-defined-in-timeconst-pl-td556009.html

Problem compiling Linux Kernel linux-3.0.35-fsimx6-V2.0 - armStoneA9 - Freescale i.mx6 - F&S Support Forum
http://forum.fs-net.de/index.php/Thread/3959-Problem-compiling-Linux-Kernel-linux-3-0-35-fsimx6-V2-0/
It seems there is a problem with Perl v5.22.0.



2016年4月19日 星期二

外來種



紅色生態劊子手:美國螯蝦 | 台灣環境資訊協會-環境資訊中心
http://e-info.org.tw/node/86945

福壽螺入侵台灣的事件 @ 真珠美人魚 :: 隨意窩 Xuite日誌
http://blog.xuite.net/dkes61121/61121/23900385-%E7%A6%8F%E5%A3%BD%E8%9E%BA%E5%85%A5%E4%BE%B5%E5%8F%B0%E7%81%A3%E7%9A%84%E4%BA%8B%E4%BB%B6

臺中區農業改良場 - 福壽螺引進的省思
http://www.tdais.gov.tw/show_monthly.php?id=tdais_tdais_edit_20080313015242





銅錢草
http://kplant.biodiv.tw/%E9%8A%85%E9%8C%A2%E8%8D%89/%E9%8A%85%E9%8C%A2%E8%8D%89.htm

二子坪濕地清出150籃3大袋外來種 渣打志工戰果豐 | 台灣環境資訊協會-環境資訊中心
http://e-info.org.tw/node/43718

荒野保護協會雙連埤環境教育基地: 雙連埤環境教育基地與外來種2013.02.07
http://shuanglianpi.sow.org.tw/2013/02/20130207.html

銅錢草- 台灣Wiki
http://www.twword.com/wiki/%E9%8A%85%E9%8C%A2%E8%8D%89







2016年4月14日 星期四

Setupt PIC32 Development environment


PIC32 Development on Mac OS X and Linux
http://www.paintyourdragon.com/uc/osxpic32/index.html

Download the required images:
http://www.paintyourdragon.com/uc/osxpic32/c32-build.tar.gz
http://ww1.microchip.com/downloads/en/DeviceDoc/MPLABC32-v105-Evaluation.exe
http://ww1.microchip.com/downloads/en/DeviceDoc/pic32-microchip-release-1-05-20090302-source.tar.gz
http://ww1.microchip.com/downloads/en/DeviceDoc/pk2cmdv1.20LinuxMacSource.tar.gz


Ubuntu 14.04.2+c32-build = not work~
After the following patch:
http://www.microchip.com/forums/m416697.aspx

But still have issue on bison 3.0 (Ubuntu 14.04). The general solution to this is to downgrade to bison 2.7.  I don't want to try this on my working computer.


VirtualBox+Ubuntu8.04+c32-build = work!!
I setup a VirtualBox with Ubuntu8.04.
https://help.ubuntu.com/community/EOLUpgrades
Edit /etc/apt/sources.list, replace all the server with "old-releases.ubuntu.com".
Then install the required package:

apt-get update
apt-get install bison cpp flex g++ gcc gettext  patch patchutils
libncurses5-dev  automake  libtool build-essential libncurses5-dev
zlib1g-dev gawk ccache gettext libssl-dev xsltproc g++ zlib1g-dev gawk
libncurses5-dev
apt-get install wine libusb-dev
apt-get install openssh-server
Then I could complete the procedure without problem.

Ubuntu 14.04.2 + Latest MPLab X IDE + My project

MPLAB- XC Compilers | Microchip Technology Inc.
http://www.microchip.com/mplab/compilers

Get Started with MPLAB® X IDE and Microchip Tools - Developer Help
http://microchip.wikidot.com/tls0101:start


Install the following:

Install MPLAB® X IDE - Developer Help
http://microchip.wikidot.com/install:mplabx

http://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v3.26-linux-installer.tar
http://ww1.microchip.com/downloads/en/DeviceDoc/xc32-v1.40-full-install-linux-installer.run

http://ww1.microchip.com/downloads/en/DeviceDoc/xc32-v1.31-linux-installer.run.tar

Execute the following to run MPLAB X IDE:
/opt/microchip/mplabx/v3.26/mplab_ide/bin/mplab_ide

I installed the JRE in /usr/java. (ref here)
(java need to be in $PATH, or manually make symbolic link /usr/bin/java to the newly installed JRE java binary)
or on Ubuntu16.04 install JRE directly by:
sudo apt install openjdk-8-jre

Windows 8 + Latest MPLab X IDE + My project
Install the following:
http://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v3.26-windows-installer.exe
http://ww1.microchip.com/downloads/en/DeviceDoc/xc32-v1.40-full-install-windows-installer.exe
(It seems XC32 r1.4.0 has known issues, multiple definition of `_atexitptr')
http://ww1.microchip.com/downloads/en/DeviceDoc/xc32-v1.31-windows-installer.exe
http://ww1.microchip.com/downloads/en/DeviceDoc/harmony_v1_07_01_windows_installer.exe

MPLAB® Harmony Configurator (MHC) Installation ...
http://microchip.wikidot.com/harmony:mhc-installation

(2010/12/27) GnuWin32
http://gnuwin32.sourceforge.net/
http://gnuwin32.sourceforge.net/packages.html

Download and install the following to C:\Program Files (x86)\Microchip\MPLABX\v3.26\gnuBins:
http://iweb.dl.sourceforge.net/project/gnuwin32/sed/4.2.1/sed-4.2.1-setup.exe
http://nchc.dl.sourceforge.net/project/gnuwin32/grep/2.5.1-2/grep-2.5.1-2-bin.exe
http://heanet.dl.sourceforge.net/project/win32svn/1.8.15/Setup-Subversion-1.8.15.msi

(2011/03/17) win-bash - bash port for Windows
http://win-bash.sourceforge.net/
http://nchc.dl.sourceforge.net/project/win-bash/shell-complete/latest/shell.w32-ix86.zip
ONLY copy the sh.exe to C:\Program Files (x86)\Microchip\MPLABX\v3.26\gnuBins\GnuWin32\bin.

I have a Chinese Windows 8, but it seems MPLAB X doesn't support Chinese and the error message during building project become Chinese and not readable on MPLAB X. I tried changing the system language but not work.

This could be workaround by removing the locale C:\Program Files (x86)\Microchip\MPLABX\v3.26\gnuBins\GnuWin32\share\locale.
(Just rename doesn't work, don't know why)

(2016/10/07) I got missing java.exe on another newly Win7

Changes to port a project between Windows and Linux MPLAB
  1. Windows executables has suffix .exe, e.g. date.exe, while Linux doesn't
  2. Windows path separate with slash "\", while Linux with backslash"/". Sometimes file path might be written in Windows form, e.g in nbproject/configurations.xml:
    ..\..\harmony\framework\driver\ethmac\src\drv_ethmac_local.h
    Change to:
    ../../harmony/framework/driver/ethmac/src/drv_ethmac_local.h
  3. Windows "make" can expand wildcard in double quote, while Linux doesn't. For example, Linux cannot handle the following:
    cp -r "./foo/*" "./foobar"
    I have double quote on every parameter and even some command, it cause problem when there are wildcard in it.
  4. Windows "make" seems require additional escape char, while Linux doesn't. For example:
    sed -i '/<\\/head>/ i\\' "header.inc"





http://www.paintyourdragon.com/uc/ubw32/index.html

https://www.microchip.com/development-tools

http://microchip.wikidot.com/tls0101:start

http://microchip.wikidot.com/tls0101:get-compiler

http://www.microchip.com/mplab/compilers

http://ww1.microchip.com/downloads/en/DeviceDoc/MPLABC32-v105-Evaluation.exe

http://ww1.microchip.com/downloads/en/DeviceDoc/pic32-microchip-release-1-05-20090302-source.tar.gz

http://ww1.microchip.com/downloads/en/DeviceDoc/pk2cmdv1.20LinuxMacSource.tar.gz

http://ww1.microchip.com/downloads/en/DeviceDoc/MPLABC32-v105-Upgrade.exe

http://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v3.26-linux-installer.tar

2016年4月7日 星期四

Priority Inversion in Linux

2016.04.08
Latest vanilla kernel: 4.5, 4.6-rc2
Used kernel: 3.4.27

Priority inversion - Wikipedia, the free encyclopedia
https://en.wikipedia.org/wiki/Priority_inversion
Introduction to Priority Inversion | Embedded
http://www.embedded.com/electronics-blogs/beginner-s-corner/4023947/Introduction-to-Priority-Inversion

20060303-Priority inheritance in the kernel [LWN.net]
https://lwn.net/Articles/178253/

20140307-RT PREEMPT HOWTO - RTwiki
https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO
Index of /pub/linux/kernel/projects/rt
https://www.kernel.org/pub/linux/kernel/projects/rt/

Preemption (computing) - Wikipedia, the free encyclopedia
https://en.wikipedia.org/wiki/Timeslicing
https://en.wikipedia.org/wiki/Preemption_%28computing%29#Time_slice

2016年3月24日 星期四

MME UE S1AP ID 2


LTE HO : Why two MME UE S1AP IDs present within the S1-AP HO Request message ?
http://tech.queryhome.com/45691/lte-ho-why-two-mme-s1ap-ids-present-within-the-request-message
http://www.3gpp.org/ftp/tsg_ran/WG3_Iu/TSGR3_70bis/Docs/R3-110241.zip

2    Discussion
2.1    X2 HO between HeNBs (Source and Target connected via the GW)
http://www.3gpp.org/ftp/tsg_ran/wg3_iu/TSGR3_70/Docs/R3-103812.zip
If the GUMMEI IE is contained in the INITIAL CONTEXT SETUP REQUEST message, the eNB shall store this information in the UE context and use it for subsequent X2 handovers.
If the MME UE S1AP ID 2 IE is contained in the INITIAL CONTEXT SETUP REQUEST message, the eNB shall store this information in the UE context and use it for subsequent X2 handovers.
ETSI TS 136 413 V10.0.1 (2011-01 )
LTE; Evolved Universal Terrestrial Radio Access Network (E- UTRAN); S1 Application Protocol (S1AP) (3GPP TS 36.413 version 10.0.1 Release 10 )
http://www.etsi.org/deliver/etsi_ts/136400_136499/136413/10.00.01_60/ts_136413v100001p.pdf

2016年2月26日 星期五

Cisco HeNBGW require "Source MME GUMMEI" in the Path Switch Request?

3GPP specification: 36.413
http://www.3gpp.org/DynaReport/36413.htm

ETSI TS 136 413 V10.9.0
http://www.etsi.org/deliver/etsi_ts/136400_136499/136413/10.09.00_60/ts_136413v100900p.pdf ,p.88

9.1.5.8 PATH SWITCH REQUEST
Source MME GUMMEI "Optional"
http://www.etsi.org/deliver/etsi_ts/136400_136499/136413/09.10.00_60/ts_136413v091000p.pdf ,p.83
9.1.5.8 PATH SWITCH REQUEST(No Source MME GUMMEI field)

Although the "Source MME  GUMMEI" is optional in release 10, it's said that Cisco HeNBGW require it in its Path Switch Request?

LTE X2 Handover Messaging
http://www.eventhelix.com/lte/handover/LTE-X2-Handover-Messaging.pdf#page=6

LTE eNodeB Handover over the X2 Interface
http://www.eventhelix.com/lte/handover/x2/lte-x2-handover-sequence-diagram.htm#.VtBxLTWkVC1

HeNB - GW Administration Guide, StarOS  Release 17 Last Updated February 27, 2015
http://www.cisco.com/c/dam/en/us/td/docs/wireless/asr_5000/17-0/PDF/17-HeNBGW-Admin.pdf
HENBGW have to route S1 PATH SWITCH REQUEST message from HENB towards the MME based on the GUMMEI of the source MME received from the HeNB. If HENBGW receives CSG ID IE and Cell Access Mode IE in the S1 PATH SWITCH REQUEST, the same should be forwarded to MME. In case of S1 PATH SWITCH REQUEST ACKNOWLEDGE message, HENBGW will inform the HeNB about the MME UE S1AP ID assigned by the MME and the MME UE S1AP ID assigned by the HeNB GW for the UE.