UUU 명령 하나를 eMMC 파형과 드라이버 코드까지 연결해 보기
From One UUU Command to an eMMC Waveform and Driver Code
부팅이 되지 않는 i.MX 8M Mini 보드를 이용해, PC → UUU → Boot ROM/U-Boot → MMC 드라이버 → eMMC 흐름을 한 번에 이해해 보자.
This note connects the complete path—PC → UUU → Boot ROM/U-Boot → MMC driver → eMMC—using an i.MX 8M Mini board that does not boot normally.
먼저 구분할 것
UUU는 USB로 SoC와 통신하고 명령을 전달하는 도구다. eMMC 핀에서 실제 전기 신호를 관찰하는 장비는 아니다. 파형을 보려면 UUU와 함께 로직 애널라이저나 오실로스코프를 사용해야 한다.
Keep the roles separate: UUU communicates with the SoC over USB; it does not measure electrical signals on eMMC pins. Use a logic analyzer or oscilloscope alongside UUU.
1. 전체 실습 흐름 / The complete lab path
PC
└─ UUU (USB downloader/command tool)
└─ i.MX Boot ROM: SDP(Serial Download Protocol)
└─ RAM에 U-Boot 로드 및 실행
└─ U-Boot mmc 명령
└─ MMC subsystem
└─ USDHC host controller driver
└─ eMMC: CLK / CMD / DAT[7:0]
여기서 SDP는 SoC 내부 Boot ROM이 USB를 통해 이미지를 받을 수 있는 복구 모드다. 보드가 정상 부팅하지 않아도 이 모드로 진입할 수 있으면 RAM에서 U-Boot를 실행해 진단할 수 있다.
SDP (Serial Download Protocol) is the recovery mode in which the SoC Boot ROM receives an image over USB. Even when normal boot fails, RAM-loaded U-Boot can still be used for diagnosis if the board enters SDP.
2. UUU와 U-Boot의 역할 / What UUU and U-Boot each do
구성 요소Component역할Role
| Boot ROM | 부트 모드 확인, USB SDP 처리, 초기 이미지 수신 Checks the boot mode and receives the initial image over USB. |
| UUU | PC에서 이미지 전송, U-Boot 명령 전달 Transfers images and sends commands from the host PC. |
| U-Boot | 메모리·MMC·네트워크 등을 초기화하고 명령 실행 Initializes hardware and executes commands such as mmc. |
| Logic analyzer / oscilloscope | eMMC의 CLK, CMD, DAT 신호 측정 Measures the electrical CLK, CMD, and DAT signals. |
따라서 “UUU로 eMMC에 직접 CMD17을 보낸다”기보다, UUU가 실행 중인 U-Boot에 mmc read를 전달하고, U-Boot의 MMC 호스트 드라이버가 eMMC 프로토콜을 발생시킨다고 이해하는 편이 정확하다.
It is more accurate to say that UUU asks the running U-Boot to execute mmc read; U-Boot’s MMC host driver then generates the eMMC protocol command.
3. 실습 전 상태 확인 / Check the board state first
UUU가 보드를 어떤 상태로 인식하는지 먼저 확인한다.
uuu -lsusb
SDP 또는 SDPS가 보이면 Boot ROM 단계다. FB:가 보이면 이미 U-Boot Fastboot 단계까지 올라온 상태이므로, 다시 RAM 부팅을 시도하기보다 UUU의 FB: ucmd로 U-Boot 명령을 보낼 수 있다.
An SDP/SDPS entry means the board is at the Boot ROM stage. An FB: entry means U-Boot Fastboot is already running; in that case, use FB: ucmd to issue U-Boot commands.
uuu "FB: ucmd printenv emmc_dev"
uuu "FB: ucmd mmc list"
uuu "FB: ucmd mmc dev 2 0"
uuu "FB: ucmd mmc rescan"
uuu "FB: ucmd mmc info"
uuu "FB: ucmd mmc part"
uuu "FB: ucmd mmc partconf 2"
2는 이 실습 보드에서 확인한 eMMC device number를 예로 든 것이다. 다른 보드는 번호가 다를 수 있으므로 mmc list와 printenv emmc_dev 결과로 먼저 확인하고 바꿔야 한다. mmc partconf 2처럼 장치 번호만 주면 현재 설정을 출력하는 읽기 동작이며, 뒤에 세 개의 숫자를 추가하면 설정을 변경하는 쓰기 동작이 된다.
The number 2 is the eMMC device number verified for this example board; other boards may differ. Check mmc list and printenv emmc_dev first. With only the device number, mmc partconf 2 prints the current setting; adding three numbers changes it.
These commands print environment and device information, select the device, rescan it, and show geometry/partition information. They are intended as read-only checks.
일부 UUU/U-Boot 조합에서는 FB: ucmd가 명령의 성공·실패만 PC에 보여 주고 상세 출력은 UART 콘솔에 남길 수 있다. 전체 mmc info 결과가 필요하면 보드의 U-Boot UART 로그를 함께 확인한다.
Depending on the UUU/U-Boot combination, FB: ucmd may report only success or failure to the PC while detailed output appears on the U-Boot UART console. Use UART when the full mmc info output is needed.
주의 / Safety
실습 초기에는 mmc write, mmc erase, 파티션 변경, partconf 쓰기 동작을 실행하지 않는다. 저장장치 내용을 바꿀 수 있으므로 먼저 읽기 명령만 사용한다.
Do not run mmc write, mmc erase, partition changes, or write-side partconf operations during the first lab. Start with read-only commands.
4. 한 블록 읽기와 CMD17 / One-block read and CMD17
측정 장비를 먼저 Arm한 뒤, 사용자 영역의 한 블록만 읽는다.
uuu "FB: ucmd mmc dev 2 0"
uuu "FB: ucmd mmc read 0x42000000 0x0 0x1"
uuu "FB: ucmd md.b 0x42000000 0x40"
여기서 0x42000000은 예시 보드에서 사용할 수 있다고 확인한 DRAM 주소다. 실제 보드에서는 U-Boot의 relocation 영역, 스택, 다른 다운로드 버퍼와 겹치지 않는 자유 영역인지 확인한 뒤 사용한다. 주소와 eMMC device number를 다른 보드에 그대로 복사하지 않는다.
0x42000000 is a DRAM address verified as usable on the example board. On another board, first ensure it does not overlap U-Boot relocation, the stack, or another download buffer. Do not blindly copy the address or device number.
명령의 의미는 다음과 같다.
값의미Meaning
| 0x42000000 | 읽은 데이터를 저장할 RAM 주소 RAM destination address. |
| 0x0 | 읽기 시작 LBA(Logical Block Address) The first logical block address. |
| 0x1 | 읽을 블록 수. U-Boot MMC 블록 인터페이스에서는 보통 한 블록이 512바이트이며, 실제 장치 정보는 mmc info로 확인한다. Number of blocks. The U-Boot MMC block interface normally uses 512-byte blocks; confirm the device details with mmc info. |
단일 블록 읽기에서는 일반적으로 eMMC의 CMD17(READ_SINGLE_BLOCK)이 핵심 명령으로 관찰된다. 여러 블록을 읽으면 CMD18(READ_MULTIPLE_BLOCK)이 사용될 수 있다. 초기화나 상태 확인을 위해 앞뒤에 다른 명령이 함께 보이는 것은 정상이다.
A single-block read normally produces CMD17 (READ_SINGLE_BLOCK). A multi-block read may use CMD18. Additional commands around it are normal because the card is initialized and its state is checked.
CLK _|-|_|-|_|-|_|-|_|-|_|-|_|-|_|-|_
CMD ----[ command index + argument + CRC ]----
DAT0 ----------------[ response / 512-byte data ]--
5. 파형에서 무엇을 볼까? / What to look for on the waveform
CLK는 호스트가 제공하는 동기 신호, CMD는 명령과 응답이 오가는 선, DAT[7:0]은 데이터 선이다. 처음에는 CLK, CMD, DAT0 세 채널만 잡아도 읽기 흐름을 파악할 수 있다. 가능하면 DAT[7:0] 전체와 RST_n도 추가한다.
CLK is the host clock, CMD carries commands and responses, and DAT[7:0] carries data. Start with CLK, CMD, and DAT0; add all data lanes and RST_n when possible.
단순 오실로스코프 화면만 보는 것보다 eMMC 프로토콜 디코더가 있는 로직 애널라이저가 학습에는 편리하다. 다만 HS200/HS400처럼 속도가 높은 모드에서는 장비의 대역폭, 샘플링 속도, 프로브 부하를 먼저 확인해야 한다. 학습 목적으로는 가능한 경우 낮은 속도 모드에서 시작하는 것이 좋다.
A protocol-capable logic analyzer is easier for learning than a raw scope trace. For HS200/HS400, verify bandwidth, sample rate, and probe loading first. If possible, start in a lower-speed mode.
6. U-Boot 명령에서 드라이버까지 / From the U-Boot command to the driver
소스 코드를 읽을 때는 다음 순서로 내려가면 된다.
U-Boot command: mmc read
→ MMC block / core layer
→ host controller .send_cmd callback
→ i.MX USDHC host driver
→ controller registers and DMA setup
→ eMMC CMD17 and data transfer
여기서 호스트 컨트롤러는 SoC 쪽에서 eMMC 버스 신호를 만들어 주는 하드웨어 블록이고, DMA는 CPU가 모든 바이트를 직접 옮기지 않고 컨트롤러가 메모리와 장치 사이의 데이터를 옮기게 하는 방식이다.
The host controller is the SoC hardware block that drives the eMMC bus. DMA lets the controller move data between the device and memory without a CPU copy for every byte.
i.MX 계열 U-Boot에서는 보통 drivers/mmc/ 아래의 FSL eSDHC 계열 드라이버를 확인한다. 실제 빌드가 SDMA를 선택하는지, ADMA를 선택하는지, 어떤 분기에서 결정되는지는 사용한 U-Boot 소스와 설정을 읽어 확정해야 한다. 이미지 문자열만으로 DMA 경로를 단정하지 않는 것이 안전하다.
For i.MX U-Boot, inspect the FSL eSDHC-family code under drivers/mmc/. Confirm the actual SDMA/ADMA path from the exact source and configuration; do not infer it solely from strings in a binary image.
7. 이 실습이 BSP 공부에 중요한 이유 / Why this is a BSP exercise
BSP는 단순히 이미지를 빌드하는 일이 아니다. 보드의 핀, 클록, 전원, 메모리, 저장장치가 부트로더와 커널 드라이버에서 어떻게 표현되고 실제 신호로 바뀌는지 연결하는 일이다.
BSP work is more than building an image. It connects board pins, clocks, power, memory, and storage descriptions in the bootloader/kernel to real electrical signals.
이번 한 번의 mmc read를 다음 질문으로 확장해 보자.
- 왜 이 보드에서 eMMC가 mmc 2인가?
- Device Tree의 어느 USDHC 노드가 이 컨트롤러를 설명하는가?
- 현재 버스 폭과 실제 협상된 속도는 무엇인가?
- 읽은 데이터가 CPU 캐시를 거치지 않고 DMA로 어떻게 RAM에 도착하는가?
- U-Boot에서 관찰한 경로와 Linux 커널의 MMC 블록 장치 경로는 어떻게 이어지는가?
Extend the single mmc read into questions about the device number, the USDHC Device Tree node, negotiated bus speed, DMA/cache behavior, and the corresponding Linux block-device path.
핵심 정리 / Key takeaways
- UUU는 명령 전달 도구이고, 파형 측정은 별도의 계측기가 담당한다.
- 보드가 부팅되지 않아도 SDP 또는 Fastboot 상태라면 RAM U-Boot와 읽기 전용 MMC 진단을 시도할 수 있다.
- mmc read 한 번은 MMC 계층, USDHC 드라이버, DMA, eMMC CMD17, CLK/CMD/DAT 파형을 연결하는 좋은 실습이다.
- 실제 DMA 방식과 속도는 보드의 소스·설정·측정 결과로 확인해야 한다.
UUU sends commands, instruments measure the pins, and one read-only mmc read can connect the MMC stack, USDHC driver, DMA, CMD17, and the physical bus.
#BSP
#EmbeddedLinux
#UBoot
#UUU
#eMMC
#DeviceDriver
'임베디드' 카테고리의 다른 글
| Linux Kernel 핵심 흐름: System Call부터 동기화까지 (0) | 2026.09.12 |
|---|---|
| Device Tree와 Linux 플랫폼 드라이버 작성 입문 (0) | 2026.09.11 |
| BSP와 Linux Kernel을 공부하며 정리한 학습 지도 (0) | 2026.09.10 |
| 디바이스 트리, 리눅스 보드가 하드웨어를 보는 방법 (0) | 2026.09.08 |
| 임베디드 리눅스 부팅 과정, 부트로더부터 유저랜드까지 (0) | 2026.08.28 |
