반응형

BareMetal 4

[MCU Flash] 플래시 메모리 데이터 깨짐 원인: Erase-before-Write 시퀀스 누락

내용 요약현상: 비휘발성 플래시 메모리(Non-volatile Flash Memory)에 데이터 저장 후, 읽을 시 깨진 데이터가 읽히는 현상.원인: 기존 데이터가 남아있는 영역에 지우기 시퀀스 없이 Write(Program) 명령을 직접 실행함.해법: 쓰기 명령을 실행하기 전, 저장될 섹터(Sector) 또는 페이지(Page)에 Flash Erase 시퀀스를 선행 호출내장 플래시 메모리 데이터 오염(Data Corruption) 발생 증상임베디드 시스템 개발 중 설정값, 캘리브레이션 데이터, 혹은 사용자 로그를 MCU 내장 또는 외장 플래시 메모리(Flash Memory)에 저장할 때 발생하는 대표적인 버그입니다. 최초 펌웨어 다운로드 이후 첫 번째 쓰기 동작은 정상적으로 수행되지만, 동일한 주소 영역..

[MCU 설계] 인터럽트 서비스 루틴(ISR) 내 delay/printf 사용 시 발생하는 지연 문제와 대책

[Quick Summary - For Global Developers]Symptom: 인터럽트 진입 후 메인 루프(Main Loop)가 완전히 멈추거나, 워치독 타이머 리셋(Watchdog Reset)이 발생하며, 특정 실시간 하드웨어 입력 인터럽트가 누락(Interrupt Missing)됨.Cause: 인터럽트 서비스 루틴(ISR) 내부에서 블로킹 방식의 delay 함수나 폴링 기반의 I/O 작업인 printf를 호출하여 상위/동일 우선순위 인터럽트 마스크 및 CPU 자원 독점이 발생함.Solution: ISR 내부의 무거운 오버헤드 코드를 전면 제거하고, 최소한의 정적 플래그(Volatile Flag) 세팅 또는 링 버퍼(Ring Buffer) 데이터 적재 후 메인 루프나 RTOS 태스크에서 처리하도..

ARM Cortex-M 하드폴트(Hard Fault) 디버깅: 레지스터 추적으로 원인 코드 찾는 법

Quick Summary - For Global DevelopersSymptom: The MCU suddenly stops executing normal code and jumps to an infinite loop inside the HardFault_Handler(), often causing the watchdog timer to reset the system.Cause: Execution of illegal instructions, memory access violations (such as null pointer dereferencing or unaligned memory access), or stacking failures during exception entry.Solution: Trace ..

[임베디드 C] 스택 오버플로우(Stack Overflow) 원인 분석과 MAP 파일 활용한 해결 방법

[Quick Summary - For Global Developers]Symptom: MCU enters HardFault_Handler or suddenly resets, causing memory corruption and unpredictable runtime behavior.Cause: A thread or function exceeds its allocated stack space due to large local variables, deep recursion, or high interrupt nesting.Solution: Optimize local memory allocation using static or dynamic memory, increase stack size in the link..

반응형