2011. 11. 24. 16:06

'[Z-01] 참고 ' 카테고리의 다른 글

EDID란?  (0) 2012.12.21
VirtualBox에서 USB로 부팅하기  (0) 2012.12.04
[Site] pdf 암호제거 tool  (0) 2011.11.07
[site] JEDEC (DDR2, DDR3 Standard 문서를 얻을 수 있는 곳)  (0) 2011.10.14
[Glossary] Segmentation fault  (0) 2011.06.15
Posted by eoseontaek
Posted by eoseontaek

'[Z-01] 참고 ' 카테고리의 다른 글

[Site] NotePad ++  (0) 2011.11.24
[Site] pdf 암호제거 tool  (0) 2011.11.07
[Glossary] Segmentation fault  (0) 2011.06.15
[site] Duplicate IP and MAC address ARP patch  (0) 2011.05.04
윈7에서 Administrator 계정 사용 방법  (0) 2011.04.21
Posted by eoseontaek
Posted by eoseontaek

Command

scp 전송할파일명 서버로그인아이디@서버아이피:/저장공간



Reference

http://mahome.net/index.php?page=33&mid=normal&document_srl=310

Posted by eoseontaek


Source

#include <stdio.h>

int main()
{
    int i = 0x00000001;

    if( ((char *)&i)[0])
        printf ("Little Endian\n");
    else
        printf ("Big Endian\n");

    return 0;
}


Reference site

http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/Network_Programing/Documents/endian#AEN57

http://www.jopenbusiness.com/mediawiki/index.php/Unix_to_Linux_Migration


Posted by eoseontaek
Posted by eoseontaek


man page 설치

yum install man-pages  # 페도라에서 맨 페이지 설치
apt-get install manpages-dev # 우분투에서 맨 페이지 설치
apt-get install manpages-posix-dev # 우분투에서 posix 함수 관련 맨 페이지 설치

Section 번호

맨 페이지에는 명령어 별로 섹션이 분류가 되있으며, 섹션 번호를 이용하면 원하는 명령어의 메뉴얼을 볼 수 있습니다. 섹션 번호는 다음과 같습니다.

Section 1 : user commands

Section 2 : system calls

Section 3 : C library functions

Section 4 : devices and special files

Section 5 : file formats and conventions

Section 8 : system administration tools and deamons

맨 페이지를 사용할 때 ” man [섹션 번호] command ” 와 같이 사용하면 원하는 특정 명령어를 찾을 수 있습니다.

vim에서는 커서를 함수이름에 위치 시킨 후 ” [섹션 번호] Shift + k ” 를 입력하면 맨 페이지로 이동합니다.

출처 : http://openracoon.org/?p=391

Posted by eoseontaek
Posted by eoseontaek

A segmentation fault (often shortened to segfault) or bus error is generally an attempt to access memory that the CPU cannot physically address. It occurs when the hardware notifies a Unix-like operating system about a memory access violation. Then the OS kernel sends a signal to the process which caused the exception. By default the process receiving the signal dumps core and terminates. The default signal handler can also be overridden to customize how the signal is handled.[1]

Contents

[hide]

[edit] Bus error

Bus errors usually are signaled with the SIGBUS signal, but SIGBUS can also be caused by any general device fault that the computer detects. A bus error rarely means that the computer hardware is physically broken - it is normally caused by a bug in a program's source code.

There are two main causes of bus errors:

non-existent address 
The CPU is instructed by software to read or write a specific physical memory address. Accordingly, the CPU sets this physical address on its address bus and requests all other hardware connected to the CPU to respond with the results, if they answer for this specific address. If no other hardware responds, the CPU raises an exception, stating that the requested physical address is unrecognized by the whole computer system. Note that this only covers physical memory addresses. Trying to access an undefined virtual memory address is generally considered to be a segmentation fault rather than a bus error, though if the MMU is separate, the processor can't tell the difference.
unaligned access 
Most CPUs are byte-addressable, where each unique memory address refers to an 8-bit byte. Most CPUs can access individual bytes from each memory address, but they generally cannot access larger units (16 bits, 32 bits, 64 bits and so on) without these units being "aligned" to a specific boundary. For example, if multi-byte accesses must be 16 bit-aligned, addresses 0, 2, 4, and so on would be considered aligned and therefore accessible, while addresses 1, 3, 5, and so on would be considered unaligned. Similarly, if multi-byte accesses must be 32-bit aligned, addresses 0, 4, 8, 12, and so on would be considered aligned and therefore accessible, and all addresses in between would be considered unaligned. Attempting to access a unit larger than a byte at an unaligned address can cause a bus error.

CPUs generally access data at the full width of their data bus at all times. To address bytes, they access memory at the full width of their data bus, then mask and shift to address the individual byte. This is inefficient, but tolerated as it is an essential feature for most software, especially string processing. Unlike bytes, larger units can span two aligned addresses and would thus require more than one fetch on the data bus. It is possible for CPUs to support this, but this functionality is rarely required directly at the machine code level, thus CPU designers normally avoid implementing it and instead issue bus errors for unaligned memory access.

[edit] Segmentation/Page fault

Example of human generated signal

A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a read-only location, or to overwrite part of the operating system).

Segmentation is one approach to memory management and protection in the operating system. It has been superseded by paging for most purposes, but much of the terminology of segmentation is still used, "segmentation fault" being an example. Some operating systems still have segmentation at some logical level although paging is used as the main memory management policy.

On Unix-like operating systems, a signal called SIGSEGV is sent to a process that accesses an invalid memory address. On Microsoft Windows, a process that accesses invalid memory receives the STATUS_ACCESS_VIOLATION exception.

[edit] Common causes

A few causes of a segmentation fault can be summarized as follows:

  • attempting to execute a program that does not compile correctly. Note that most compilers will not output a binary given a compile-time error.
  • a buffer overflow.
  • using uninitialized pointers.
  • dereferencing NULL pointers.
  • attempting to access memory the program does not own.
  • attempting to alter memory the program does not own (storage violation).

Generally, segmentation faults occur because: a pointer is either NULL, points to random memory (probably never initialized to anything), or points to memory that has been freed/deallocated/"deleted".

e.g.

    char *p1 = NULL;           // Initialized to null, which is OK,
// (but cannot be dereferenced on many systems).
char *p2; // Not initialized at all.
char *p3 = new char[20]; // Great! it's allocated,
delete [] p3; // but now it isn't anymore.

Now, dereferencing any of these variables could cause a segmentation fault.

[edit] Examples

[edit] Bus error example

This is an example of un-aligned memory access, written in the C programming language.

#include <stdlib.h>

int main(int argc, char **argv) {
int *iptr;
char *cptr;

#if defined(__GNUC__)
# if defined(__i386__)
/* Enable Alignment Checking on x86 */
__asm__("pushf\norl $0x40000,(%esp)\npopf");
# elif defined(__x86_64__)
/* Enable Alignment Checking on x86_64 */
__asm__("pushf\norl $0x40000,(%rsp)\npopf");
# endif
#endif

/* malloc() always provides aligned memory */
cptr = malloc(sizeof(int) + 1);

/* Increment the pointer by one, making it misaligned */
iptr = (int *) ++cptr;

/* Dereference it as an int pointer, causing an unaligned access */
*iptr = 42;

return 0;
}

Compiling and running the example on Linux on x86 demonstrates the error:

$ gcc -ansi sigbus.c -o sigbus
$ ./sigbus
Bus error
$ gdb ./sigbus
(gdb) r
Program received signal SIGBUS, Bus error.
0x080483ba in main ()
(gdb) x/i $pc
0x80483ba <main+54>: mov DWORD PTR [eax],0x2a
(gdb) p/x $eax
$1 = 0x804a009
(gdb) p/t $eax & (sizeof(int) - 1)
$2 = 1

The GDB debugger shows that the immediate value 0x2a is being stored at the location stored in the EAX register, using X86 assembly language. This is an example of register indirect addressing.

Printing the low order bits of the address shows that it is not aligned to a word boundary ("dword" using x86 terminology).

[edit] Segmentation fault example

Here is an example of ANSI C code that should create a segmentation fault on platforms with memory protection:

 int main(void)
{
char *s = "hello world";
*s = 'H';
}

When the program containing this code is compiled, the string "hello world" is placed in the section of the program binary marked as read-only; when loaded, the operating system places it with other strings and constant data in a read-only segment of memory. When executed, a variable, s, is set to point to the string's location, and an attempt is made to write an H character through the variable into the memory, causing a segmentation fault. Compiling such a program with a compiler that does not check for the assignment of read-only locations at compile time, and running it on a Unix-like operating system produces the following runtime error:

$ gcc segfault.c -g -o segfault
$ ./segfault
Segmentation fault

Backtrace from gdb:

Program received signal SIGSEGV, Segmentation fault.
0x1c0005c2 in main () at segfault.c:6
6 *s = 'H';

The conditions under which segmentation violations occur and how they manifest themselves are specific to an operating system.

Because a very common program error is a null pointer dereference (a read or write through a null pointer, used in C to mean "pointer to no object" and as an error indicator), most operating systems map the null pointer's address such that accessing it causes a segmentation fault.

 int *ptr = NULL;
*ptr = 1;

This sample code creates a null pointer, and tries to assign a value to its non-existent target. Doing so causes a segmentation fault at runtime on many operating systems.

Another example is recursion without a base case:

 int main(void)
{
main();
}

which causes the stack to overflow which results in a segmentation fault.[2]

[edit] See also

[edit] External links

[edit] References

  1. ^ Expert C programming: deep C secrets By Peter Van der Linden, page 188
  2. ^ What is the difference between a segmentation fault and a stack overflow? at Stack Overflow


Link :
http://en.wikipedia.org/wiki/Segmentation_fault

Posted by eoseontaek

net_ratelimit()

net_ratelimit()은 printk_ratelimit()와 같은 역할을 합니다. 단지 네트워크 코드에서 사용하기 편하게 하기위해 net_ratelimit() 라는 함수를 따로 정의하였습니다. printk_ratelimit() 함수는 커널 메시지를 지나치게 많이 출력함으로써 시스템의 동작에 영향을 미치는 것을 막기 위해 도입한 함수입니다. 커널 코드는 이 함수를 불러서 일정한 시간 안에 출력한 메시지의 수가 정해진 수 이하인 경우에만 printk()를 호출하여 메시지를 출력합니다.
중요한 메시지의 경우는 이를 사용하지않고 직접 printk()를 호출합니다.



Reference

http://kldp.org/node/45471

http://www.linuxforums.org/forum/kernel/168631-what-net_ratelimit.html

Posted by eoseontaek
IP and MAC address conflict에 대한 patch를 얻을 수 있는 곳

http://marc.merlins.org/linux/arppatch/
Posted by eoseontaek

1. 장치관리자 실행

2. 동작->레거시 하드웨어 추가 클릭

3. C:\Program Files (x86)\Atmel\AVR Tools\usb64\windrvr6.inf 경로의 WinDriver 설치

이후 USB에 AVRISP mkII 연결하면 자동으로 드라이버 설치됨.


http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=82994




'[C-04] ATmega2560' 카테고리의 다른 글

[AVR] Intel Hex File Format  (0) 2010.06.25
uIP-AVR  (0) 2009.11.09
Linux에서 AVR 컴파일환경 만들기  (0) 2009.11.09
AVR221: Discrete PID controller  (0) 2009.11.06
AVR Timer 계산기  (0) 2009.10.26
Posted by eoseontaek

관리자 권한으로 cmd.exe를 실행 후 아래 명령어 실행하면 됩니다.

net user administrator /active:yes

 

administrator로 로그인시 모든 명령들이 관리자 권한으로 실행됩니다.


Posted by eoseontaek

1. 아래의 링크에서 Putty, Plink, Pageant, Puttygen을 받습니다.
   나중에 서버에서 생성된 파일을 얻기 위해 WinSCP도 받는게 좋더군요.
  
Putty Family: http://www.chiark.greenend.org.uk/~sgtatham/putty/
WinSCP : http://winscp.net/eng/download.php

2. 자, 이제 Public Key와 Private Key를 생성합니다.
   Putty를 이용하여 서버에서 아래의 명령어를 칩니다.
   암호라고 되어 있는 부분에 자신이 사용할 암호를 적습니다.



   이 암호는 아래의 단계들에서 계속 사용하므로 잘 기억하고 있는게 좋습니다.

ssh-keygen -b 1024 -t dsa -N 암호 -f keyfile

3. ls 명령으로 keyfile(개인 키)과 keyfile.pub(공개 키)가 만들어 진 것을 확인 합니다.

4. 자신의 폴더(~)에 .ssh 라는 폴더가 없으면 만들고, 여기에 keyfile.pub을 authorized_keys라는 파일명으로 저장합니다.

cd ~
mkdir .ssh
cat keyfile.pub >> /home/당신/.ssh/authorized_keys


5. 이제 TortoiseSVN을 사용할 로컬(Windows PC)로 이동해서 개인키를 등록합니다.
   WinSCP를 이용해서 서버에 있는 개인키(keyfile)를 로컬로 이동시킨 다음,
   PuttyGen을 실행해서 Conversions -> Import Key를 실행하고, keyfile을 넣은 다음
   Save Private key를 실행해서 keyfile.ppk로 저장합니다.
  
6. Pageant를 실행한 다음, Add keys를 선택하고 keyfile.ppk를 넣어줘야 합니다.

7. 이제 TortoiseSVN 으로 접속하면, 로긴 창이 뜨지도 않고 로긴 됩니다!
   단, 접속할 때 svn+ssh://당신아이디@URL 식으로 //와 @사이에 넣어줘야
   ID를 안 물어봅니다. 만약 이 작업을 하지 않으면, 아이디만 3번 물어보더군요.


TortoiseSVN에서 ssh+svn 사용 방법

http://vrzin.blogspot.com/2010/01/tortoisesvn%EC%97%90%EC%84%9C-sshsvn-%EC%82%AC%EC%9A%A9-%EB%B0%A9%EB%B2%95.html


SFTP 클라이언트 : WinSCP 사용법

http://m9.pe.kr/sftp/index.htm


TortoiseSVN 설정

윈도우 탐색기의 아무 곳에서나 오른쪽 클릭하고 "TortoiseSVN"->"Settings(설정)"을 선택합니다.
"Network"탭에서 "SSH"설정을 바꿔줘야 원하는 계정으로 svn+ssh를 사용할 수 있습니다.
(요기서 엄청난 삽질을 했습니다.. 뭘 어떻게 해도 "Connection closed unexpectedly"만 메세지만 잔뜩.. ㅠㅁㅠ)
"SSH"항목에 다음과 같은 내용을 자신의 환경에 맞도록 입력합니다.
"D:\Program Files\TortoiseSVN\bin\TortoisePlink.exe" -l 계정 -pw 암호
-pw 암호 옵션은 안 줄 경우 매번 접속시 입력해야 합니다.
그리고 계정과 암호는 반드시 subversion이 설치된 리눅스 머신에 있는 계정이어야 합니다.
사실 svn+ssh라는 것이 ssh로 터널링하는 것이라 ssh로 접속할 수 있는 계정이라고 하는 것이 맞을 것같습니다.

http://liverpooh.tistory.com/3


Posted by eoseontaek
Posted by eoseontaek

'[Z-01] 참고 ' 카테고리의 다른 글

TortoiseSVN에서 ssh+svn 사용 방법  (0) 2011.04.14
[UTIL] wireshark - network protocol analyzer  (0) 2011.04.14
[site] Free Electrons  (0) 2011.03.18
[site] Linux Shell Scripting Tutorial  (0) 2011.01.26
[site] 리눅스 시스템 관리  (0) 2011.01.21
Posted by eoseontaek


CFG_I2C_NOPROBES

이 옵션은 'i2c probe' 명령이 issue되었을 때, skipp될 I2C device의 list를 명시한다.
만약  CONFIG_I2C_MULTI_BUS 가 설정되었다면 bus-device pairs의 list를 명시하고, 그렇지 않으면 device address의 1차 배열을 명시해서 사용한다.

e.g. 

      #undef  CONFIG_I2C_MULTI_BUS
      #define CFG_I2C_NOPROBES    {0x50,0x68}

하나의 i2c bus에서  0x50, 0x68의  address를 skip할 것이다.

            #define CONFIG_I2C_MULTI_BUS
            #define CFG_I2C_MULTI_NOPROBES  {{0,0x50},{0,0x68},{1,0x54}}

bus0에서 0x50, 0x68의 address를 skip하고, bus1에서는 0x54의 address를 skip할 것이다.

Posted by eoseontaek

Embedded Linux 포팅관련 문서를 얻을 수 있는 곳


http://free-electrons.com/


Posted by eoseontaek
file : (TOPDIR)/cpu/s5pc11x/start.S

⊙ ARM process의 power on(reset)후 actions

.....



⊙ ENTRY POINT (_start)
Supervisor mode,arm state,pc 값이 0x0이므로 Linker script file의 entry point에서 선언된 ‘_start’부터 프로그램 코드가 실행된다.

.globl _start              @ flash start
_start: b   reset         @ offset jump이므로 dram으로 이동하지 않는다.
    ldr pc, _undefined_instruction
    ldr pc, _software_interrupt
    ldr pc, _prefetch_abort
    ldr pc, _data_abort
    ldr pc, _not_used
    ldr pc, _irq
    ldr pc, _fiq

.global _start
Linker에게 ‘_start’ symbol 처리할 수 있도록 export한다.

_start의 첫번째 instruction은 ‘b reset’이므로 reset 함수로 branch하여
reset으로 제어가 옮겨진다.

나머지는 ARM에서 발생할 수 있는 exception으로 상황에 대한 처리 routine들로 exception이 발생하면 해당하는 핸들러로 branch할 것이다.
 _undefined_instruction
 _software_interrupt
 _prefetch_abort
 _data_abort
 _not_used
 _irq
 _fiq


⊙ reset :
[1] mode setting 및 interrupt disable

/*
 * the actual reset code
 */

reset:
    /*  
     * set the cpu to SVC32 mode and IRQ & FIQ disable
     */  
    @;mrs   r0,cpsr          @ cpsr값을 r0레지스터로 옮긴다.
    @;bic   r0,r0,#0x1f       @ Mode bit을 clear한다.
    @;orr   r0,r0,#0xd3       @ interrupt 을 disable,supervisor mode
    @;msr   cpsr,r0           @ r0값으로 cpsr값을 바꾼다.
    msr cpsr_c, #0xd3       @ I & F disable, Mode: 0x13 - SVC


cpu_init_crit
중요한 registers 및 memory timing 등을 setup한다.

cpu_init_crit:

#ifndef CONFIG_EVT1
#if 0  
    bl  v7_flush_dcache_all
#else
    bl  disable_l2cache

    mov r0, #0x0    @
    mov r1, #0x0    @ i
    mov r3, #0x0
    mov r4, #0x0
lp1:
    mov r2, #0x0    @ j
lp2:
    mov r3, r1, LSL #29     @ r3 = r1(i) <<29
    mov r4, r2, LSL #6      @ r4 = r2(j) <<6
    orr r4, r4, #0x2        @ r3 = (i<<29)|(j<<6)|(1<<1)
    orr r3, r3, r4
    mov r0, r3          @ r0 = r3
    bl  CoInvalidateDCacheIndex
    add r2, #0x1        @ r2(j)++
    cmp r2, #1024       @ r2 < 1024
    bne lp2         @ jump to lp2
    add r1, #0x1        @ r1(i)++
    cmp r1, #8          @ r1(i) < 8
    bne lp1         @ jump to lp1

    bl  set_l2cache_auxctrl

    bl  enable_l2cache
#endif
#endif

    bl  disable_l2cache

    bl  set_l2cache_auxctrl_cycle

    bl  enable_l2cache

       /*
        * Invalidate L1 I/D
        */
        mov r0, #0                  @ set up for MCR
        mcr p15, 0, r0, c8, c7, 0   @ invalidate TLBs
        mcr p15, 0, r0, c7, c5, 0   @ invalidate icache

       /*
        * disable MMU stuff and caches
        */
        mrc p15, 0, r0, c1, c0, 0
        bic r0, r0, #0x00002000     @ clear bits 13 (--V-)
        bic r0, r0, #0x00000007     @ clear bits 2:0 (-CAM)
        orr r0, r0, #0x00000002     @ set bit 1 (--A-) Align
        orr r0, r0, #0x00000800     @ set bit 12 (Z---) BTB
        mcr     p15, 0, r0, c1, c0, 0


        /* Read booting information */
        ldr r0, =PRO_ID_BASE
        ldr r1, [r0,#OMR_OFFSET]

        bic r2, r1, #0xffffffc1

#ifdef CONFIG_VOGUES
    /* PS_HOLD(GPH0_0) set to output high */
    ldr r0, =ELFIN_GPIO_BASE
    ldr r1, =0x00000001
    str r1, [r0, #GPH0CON_OFFSET]

    ldr r1, =0x5500
    str r1, [r0, #GPH0PUD_OFFSET]

    ldr r1, =0x01
    str r1, [r0, #GPH0DAT_OFFSET]
#endif

Posted by eoseontaek