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