[UDOO] LED 제어

2025. 5. 30. 16:29·2025(학부 3학년)/임베디드시스템

1. 서론

크로스 컴파일 환경 세팅하는건 나중에 시간되면 따로 글 올릴 예정

 

목표 : UDOO 보드에 있는 LED 제어 

 

HOST (uame -a)

리눅스 버전 : Linux jaewon-VirtualBox 6.11.0-25-generic #25~24.04.1- Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 17:20:50 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

 

TARGET  (uame -a)

Linux udoo 3.14.56-02048-geaaf16e- dirty #1 SMP PREEMPT Mon May 15 20:35:41 KST 2017 armv7l armv7l armv7l GNU/Linux

 

HOST와 Target의 리눅스 커널 버전이 다르므로 개발은 HOST에서 하되, 컴파일을 target 버전에 맞게끔 해주어야한다. 

즉 크로스컴파일을 해주어야한다.

 

UDOO 보드에 맞는 커널 소스를 설치해주어야하는데 (== 크로스 컴파일 개발환경 세팅) 이건 나중에 시간 나면 따로 글을 올릴 예정이다. 

 

2. led.ko (디바이스 드라이버) 작성 및 파일 전송

추가 예정

 

scp leddrv.ko ecube@192.168.137.192:/home/ecube/driver_sample/LED

 

3.ledTest.c 작성 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <ctype.h>
#include <sys/ipc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#define LED_DRIVER_NAME "/dev/periled"

void doHelp(void)
{
	printf("Usage:\n");
	printf("ledtest <hex byte>  : data bit0 operation 1=>on 0=>off\n");
	printf("ex) ledtest 0x04 : 3th led on\n");
	printf("    ledtest 0x05 : 4th and 1th led on\n");
	printf("    ledtest 0xff : all led on\n");
	printf("    ledtest 0x00 : all led off\n");
}

int main(int argc , char **argv)
{
	unsigned int data = 0;	
	
	int fd;
	
	if (argc < 2 )
	{
		perror(" Args number is less than 2\n");
		doHelp();
		return 1;
	}
	
	data = strtol(argv[1],NULL,16);
	printf("wrate data :0x%X\n", data);
	
	// open  driver 
	fd = open(LED_DRIVER_NAME,O_RDWR);
	if ( fd < 0 )
	{
		perror("driver (//dev//cnled) open error.\n");
		return 1;
	}
	write(fd,&data,4);

	close(fd);
	
	return 0;
}

 

4.크로스 컴파일 및 UDOO 보드로 파일 전송(SCP)

arm-linux-gnueabi-gcc -o ledTest.elf ledTest.c
scp ledTest.elf ecube@192.168.137.192:/home/ecube/driver_sample/LED

 

 

scp 경로 및 아이피 설정은 알잘딱 

 

 

4.커널 모듈(leddrv.ko) 적재하기 

2에서 전송한  leddrv.ko 파일을 udoo 보드에서 insmod 해준다.

 

/home/ecube/driver_sample/LED 경로로 파일을 전송했으니 해당 디렉토리 터미널에서 적재해줬다.

sudo insmod leddrv.ko

 

 

lsmod 확인

 

/dev/perild 확인 

 

5.실행 

sudo ./ledTest.elf 0xff // 모든 LED ON

 

'2025(학부 3학년) > 임베디드시스템' 카테고리의 다른 글

IPC(Inter Process Communication)  (1) 2025.06.08
[UDOO] scp 파일 전송  (0) 2025.05.13
[UDOO] SSH 연결  (0) 2025.05.13
[UDOO] Serial 파일 전송  (0) 2025.05.13
[UDOO] 네트워크 연결  (0) 2025.05.13
'2025(학부 3학년)/임베디드시스템' 카테고리의 다른 글
  • IPC(Inter Process Communication)
  • [UDOO] scp 파일 전송
  • [UDOO] SSH 연결
  • [UDOO] Serial 파일 전송
JaewonAhn
JaewonAhn
  • JaewonAhn
    JwAhn_Embedded
    JaewonAhn
  • 전체
    오늘
    어제
    • 분류 전체보기 (136)
      • MCU (21)
        • esp32 (6)
        • stm32 (15)
      • SW (30)
        • 백준 (27)
        • C, C++ (2)
        • 자료구조 (0)
        • 파이썬 (1)
      • Tool (2)
        • KiCAD (0)
        • Git (0)
        • Visual Studio Code (1)
        • CubeIDE (1)
      • Balancing robot (28)
        • HW (11)
        • FW&SW (2)
        • 일지 (13)
        • 이론공부 (1)
      • 1&2학년 (17)
        • 1학년(2021) (2)
        • 2학년(2022) (4)
        • [2022 03 ~ 09] IoT Project (8)
        • [2022 09 ~ 12] 융합 프로젝트 (3)
      • 2025(학부 3학년) (14)
        • 신호 및 시스템 (1)
        • 전자회로 (0)
        • 제어 및 AI 입문 (3)
        • 임베디드시스템 (8)
        • 기타 (2)
      • 잡솔 (3)
      • 군대 (7)
        • 이등병 (1)
        • 일병 (4)
        • 병장 (2)
      • Driving_Assistance_Device (14)
        • Hailo (7)
        • 일지 (3)
        • 기타 (4)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    10866
    뇌절
    쇠막대기
    arudino
    이계도함수
    스택
    library
    10799
    headerfile
    Arduino
    10845
    합성함수의 미분법
    2학년
    WiFi.local() to char
    vscode
    10828
    nucelo
    9012
    plotly
    백준
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
JaewonAhn
[UDOO] LED 제어
상단으로

티스토리툴바