Archive for the 電腦和網際網路 Category

Ubuntu Dropbox 自動更新有問題

Posted in 電腦和網際網路, Linux, 未分類 on 2014 年 03 月 05 日 by Kun-Yi

這一兩天 我的Dropbox client 一直出現更新但沒成功過, 也不會秀 error message

剛手動重新安裝才發現問題點所在 (目前版本是 2.6.18 )

因為我用的的是 Ubuntu 12.10 x64 所以下載 dropbox-lnx.x86_64-2.6.18.tar.gz 這個版本

下載完放到Home 下面, 然後執行 tar xvf dropbox-lnx.x86_64-2.6.18.tar.gz 他會解開到 ~/.dropbox-dist 目錄下

然後按照說明 執行 dropboxd 會出現一個錯誤

importing ‘/home/{your account}/pylinux/__pycache__/_cffi__xa0c4f46bx1d95b4de.so’: No module named _cffi__xa0c4f46bx1d95b4de

根據這個訊息可以找到一個 bugreport 參照裏面的解法, 發現應該是本來舊的程式移除不完全
在我的機器上要執行下列步驟

sudo rm -rf /var/lib/dropbox/.dropbox-dist ; 這步我不確定機器上到底有沒有這個folder
rm -rf ~/.dropbox-dist
tar xvf dropbox-lnx.x86_64-2.6.18.tar.gz ; 一樣是在 HOME 下執行, 會重新產生 ~/dropbox-dist
dropbox start -i

Note: an UNetbootin tip

Posted in 電腦和網際網路, Works on 2012 年 05 月 15 日 by Kun-Yi

Today I need to setup a host machine to run Ubuntu 10.04 for my work(Android development), so I download an Ubuntu 10.04.4 LTS (Lucid Lynx)  ISO and UNetbootin for Windows version. Just went make a USB disk for Ubuntu install.

But always got a “NTLDR is missing”message when use the Install USB Disk to boot system.

I to try again and again to fixed the issues until reformat the USB Disk and file system change to FAT32.

Keypoint:should check your USB disk is FAT system first when use UNetbootin or similar program

Note: Rebuild Notepad++

Posted in 電腦和網際網路 on 2011 年 03 月 31 日 by Kun-Yi

當下載 Notepad++ 的source code 用Microsoft VC 來rebuild Scintilla 時, 也許會出現下列的錯誤訊息

Creating library ..\bin\SciLexer.lib and object ..\bin\SciLexer.exp Catalogue.obj : error LNK2001: unresolved external symbol “class LexerModule lmUserDefine" (?lmUserDefine@@3VLexerModule@@A) Catalogue.obj : error LNK2001: unresolved external symbol “class LexerModule lmSearchResult" (?lmSearchResult@@3VLexerModule@@A) Catalogue.obj : error LNK2001: unresolved external symbol “class LexerModule lmObjC" (?lmObjC@@3VLexerModule@@A) ..\bin\SciLexer.dll : fatal error LNK1120: 3 unresolved externals NMAKE : fatal error U1077: ‘link’ : return code ‘0x460’ Stop.

http://sourceforge.net/projects/notepad-plus/forums/forum/331754/topic/3908989#topic-reply

我的解決之道是, 執行 Scintilla\src\LexGen.py 它將重新產生 scintilla.mak 吻合實際狀況

另一個問題是在中文語系, 系統內定的codepage是950 時, 用VC2005將產生下列問題

..\src\Notepad_plus.cpp(1594) : error C2220: warning treated as error – no ‘object’ file generated
..\src\Notepad_plus.cpp(1594) : warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss

會產生這個問題的檔案 menuCmdID.h & Notepad_plus.cpp (Notepad++ 5.9 at Mar 31 2011)

解決之道是用Notepad++ 打開, 將檔案編碼改成 UTF-8 存檔後即可!

答:“火柴棍式”程序员面试题

Posted in 電腦和網際網路 on 2011 年 03 月 23 日 by Kun-Yi

剛看到 “火柴棍式”程序员面试题 ,
它的題目,  下面是一個C語言程式,想要輸出20個減號,不過,粗心的程式員把程式寫錯了,你需要把下面的程式碼修正,不過,你只能增加或是修改一個字元,請你給出三種答案。

 int n = 20;

 for( int i = 0; i < n; i--){
   printf("-");
 }

 就試答如下
1.
  int n = 20; 
  
  for(int i = 0; -i < n; i--){
    printf("-");
  }

2.
  int n = 20; 
  
  for(int i = 0; i < n; n--){
    printf("-");
  }
3.
  int n = 20; 
  
  for(int i = 0; i + n; i--){
    printf("-");
  }

Note: Setting VC2010 compiler for Phoenix SCT2

Posted in BIOS, 電腦和網際網路 on 2011 年 01 月 05 日 by Kun-Yi

Microsoft Download center provide  Windows 7 SDK with .Net framework 4 The SDK include a free VC 2010 compiler.


File: SetVars.bat,  VC 2010 Environment variables, see below

set VCROOT=D:\VC2010
IF NOT “%VC2010Install%" == “" set VCROOT=%VC2010Install%

SET PATH=%VCROOT%\bin\dll;%VCROOT%\bin;%PATH%
SET INCLUDE=%VCROOT%\include;%VCROOT%\PlatformSDK\Include;
SET LIB=%VCROOT%\lib;%VCROOT%\PlatformSDK\Lib;
set VCINSTALLDIR=%VCROOT%


File: BuildEnv.bat in SCT Directory, see below

%comspec% /k call SetVars.bat


File: setvars.bat in SCT Directory, see below

call D:\VC2010\setvars.bat
PATH=%CD%\TOOLS;%PATH%
CD projects\AlpineBayCrb00


the VC2010 just need the following parts

├─bin
│  ├─1033
│  ├─dll
│  ├─ia64
│  │  └─1033
│  ├─x86_amd64
│  │  └─1033
│  └─x86_ia64
│      └─1033
├─crt
│  └─src
│      ├─AMD64
│      ├─cliext
│      ├─cvt
│      ├─IA64
│      ├─intel
│      ├─msclr
│      │  └─com
│      └─sys
├─include
│  ├─cliext
│  ├─CodeAnalysis
│  ├─cvt
│  ├─Manifest
│  ├─msclr
│  │  └─com
│  └─sys
├─lib
│  ├─amd64
│  └─ia64
└─PlatformSDK
├─Include
│  └─gl
├─Lib
│  ├─AMD64
│  └─IA64
└─misc
├─Include Updates
└─mdac2.8
└─Conformance
└─Tests
└─Libs
├─amd64
└─x86

Note: A simple PCI device scan under DOS

Posted in BIOS, 電腦和網際網路 on 2010 年 10 月 22 日 by Kun-Yi

Use OpenWatcom v1.9, Test on VMWare Workstation and FreeDOS 1.0

the demo code just check & show VID:DID


// FILE: main.c
#include <stdio.h>
#include “pcilib.h"

void printProgramInfo(void);
void printExitInfo(void);

int main(int argc, char *argv[])
{
    int bus = 0;
    int dev = 0;
    int func = 0;
    unsigned char cfg[256];
    printProgramInfo();

    do {
        if (dev > MAX_PCIDEV) {
            bus++;
            dev = 0;
        }
        if (EnumerationPCIDevice(bus, dev, func, cfg, sizeof(cfg)) == 0) {
            PCI_COMMCFG *commcfg = (PCI_COMMCFG*)cfg;

            printf(“B%02X:D%02X:F%02X, VID:%04X, DID:%04X\n",
                bus, dev, func,
                commcfg->vid, commcfg->did);
            if (func == 0) {
                func++;
                continue;
            }
        }

        if (func >= MAX_PCIFUNC) {
            func = 0;
        } else {
            func++;
        }
        if (func == 0) dev++;
    } while (bus < MAX_PCIBUS);
    printExitInfo();
    return 0;
}

void printProgramInfo(void)
{
    printf(“PCI SCAN by KunYi Chen\n");
    printf(“kunyi.chen (at) gmail.com\n");
}

void printExitInfo(void)
{
    ; // do nothing!
}


// FILE: pcilib.c
#include <assert.h>
#include <dos.h>
#include <conio.h>
#include <stdio.h>
#include “pcilib.h"

static u32 mkconf(int bus, int dev, int func)
{
    assert((bus <= MAX_PCIBUS) && (bus >= 0));
    assert((dev <= MAX_PCIDEV) && (dev >= 0)) ;
    assert((func <= MAX_PCIFUNC) && (func >= 0));
    return ((1<<31) | (bus<<16) | (dev<<11) | (func<<8));
}

int EnumerationPCIDevice(int bus, int dev, int func, unsigned char *cfg, int buffsize)
{
    u32 conf;
    u32 id;
    int i;
    assert((buffsize <= 256) && (buffsize > 0));
    conf = mkconf(bus, dev, func);
    outpd(IO_PCICFG, conf);
    id = inpd(IO_PCIDATA);
    if (id == 0xFFFFFFFF) {
        return -1;
    }

    // currently, buffsize should be 256 bytes, others value maybe will get a failed  result
    for (i = 0; i < buffsize; i+=4) {
    u32 tmp;
    outpd(IO_PCICFG, conf+i);
    tmp = inpd(IO_PCIDATA);
    *((u32*)(cfg+i)) = tmp;
    }
    return 0;
}


// FILE: pcilib.h
#ifndef _PCILIB_H_
#define _PCILIB_H_

typedef unsigned long    u32;
typedef unsigned short    u16;
typedef unsigned char    u8;

#define MAX_PCIBUS    (255)
#define MAX_PCIDEV    (31)
#define MAX_PCIFUNC    (7)

#define IO_PCICFG    (0xCF8)
#define IO_PCIDATA    (0xCFC)

int EnumerationPCIDevice(int bus, int dev, int func, unsigned char *cfgbuf, int bufsize);

typedef struct _PCI_CFGSPACE_ {
    u16 vid; // Vendor ID
    u16 did; // Device ID
    u16 cmd; // Command
    u16 sts; // Status
    u8  rid; // Revision ID
    u8  itf; // Interface
    u8  scls; // Sub Class
    u8  bcls; // Base Class
    u8  reserve[244];
    /*
    u8  cache; // Cache line size
    u8  latch; // Latch Timer
    u8  typ; // Head type
    u8  bist; // BIST, Built In Self Test
    */
} PCI_COMMCFG, *PPCI_COMMCFG;

#define BSCLS_BUILTIN                   (0x00)
#define BSCLS_MASS_STORAGE              (0x01)
#define BSCLS_NETWORK                   (0x02)
#define BSCLS_DISPLAY                   (0x03)
#define BSCLS_MULTIMEDIA                (0x04)
#define BSCLS_MEMORY                    (0x05)
#define BSCLS_BRIDGE                    (0x06)
#define BSCLS_SIMPLE_COMMUNICATION      (0x07)
#define BSCLS_BASE_SYSTEM               (0x08)
#define BSCLS_INPUT                     (0x09)
#define BSCLS_DOCKING_STATION           (0x0A)
#define BSCLS_PROCESSOR                 (0x0B)
#define BSCLS_SERIAL_BUS                (0x0C)
#define BSCLS_WIRELESS                  (0x0D)
#define BSCLS_IIO                       (0x0E)
#define BSCLS_SATELLITE_COMMUNICATION   (0x0F)
#define BSCLS_CRYPTION                  (0x10)
#define BSCLS_DAQ                       (0x11)
#endif /* END OF _PCILIB_H_ */


# FILE: MAKEFILE
#CC = wcc
CC = wcc386

#CFLAGS = -zq
#CFLAGS = -mf -zq -d3
CFLAGS = -mf -zq

# use CauseWay
# Debug command line: WD /trap=cw pciscan.exe
#LNKOPT = system CauseWay DEBUG all
LNKOPT = system CauseWay

.EXTENSIONS:
.EXTENSIONS: .exe .lib .obj .c

pciscan.exe : main.obj pcilib.obj
    wlink $(LNKOPT) file main.obj, pcilib.obj name pciscan

.c.obj:
    $(CC) $^& $(CFLAGS)

Note: PCI & PCI-E Configuration Space Access Method on PC-AT Compatible system

Posted in BIOS, 電腦和網際網路 on 2010 年 10 月 05 日 by Kun-Yi

PCI & PCI-E Configuration Space Memory Map

image

PCI Configuration Space Access Method, Just read 256 Bytes space

Use a pair IO Register to access the spaces on PC-AT compatible System.

Config Address Register(0xCF8, 32bits width) & Config Data Register(0xCFC, 32bits width)

image

PCI Express Enhanced Configuration Address Mapping

Use MMIO (Memory Mapping IO) to access the Enhanced Configuration Space.

ACPI support a MCFG Table to describe PCI Express Root Base address [63:0]

[63:28] is base address part, [27:0] format following the below figure

image

ref. http://www.pcisig.com/developers/main/training_materials/get_document?doc_id=2196e7be4778f458579ed38efb2a3d5b21d4efa7

AMD has a document to describe “how to access the configuration spaces in PCI/PCI-E in Windows/Linux/Solaris”

http://developer.amd.com/Assets/pci%20-%20pci%20express%20configuration%20space%20access.pdf

問題來了, 在非 PC Embedded System 這個MCFG 要怎樣處里, 透過Boot Parameter 通知Kernel?