STM32 Upload executable file in STM32CubeIDE

Programmer

ST-LINK/V2 μ •ν’ˆ/ν˜Έν™˜ν’ˆμ„ μ΄μš©ν•˜μ‹œλ©΄ λ©λ‹ˆλ‹€. 섀정에 따라 UART, USB DFU 등을 μ‚¬μš©ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.

Boot mode

BOOT1BOOT2Boot modeAliasing
X0User Flash memoryUser Flash memory is selected as the boot space
01System memorySystem memory is selected as the boot space
11Embedded SRAMEmbedded SRAM is selected as the boot space
  • User Flash memory: (0x08000000)μ—μ„œ μ‹œμž‘ν•˜λŠ” 일반적인 λΆ€νŒ…μž…λ‹ˆλ‹€. ST-LINK/V2λ₯Ό μ‚¬μš©ν•˜λ©΄ μ‚¬μš©μžκ°€ μ‹€ν–‰ νŒŒμΌμ„ μ—…λ‘œλ“œ ν•  λ•Œ, ν”Œλž˜μ‹œ λ©”λͺ¨λ¦¬μ— μ‹€ν–‰ 파일이 λ‹€μš΄λ‘œλ“œ λ©λ‹ˆλ‹€. λ”°λΌμ„œ 첫 번째 μ˜΅μ…˜μœΌλ‘œ λΆ€νŒ…ν•œ 경우 μ‚¬μš©μžκ°€ μž‘μ„±ν•œ μ‹€ν–‰ 파일이 λ°”λ‘œ μ‹€ν–‰λ©λ‹ˆλ‹€.
  • System memory: (0x1FFFF000)μ—μ„œ μ‹œμž‘ν•˜λŠ” λΆ€νŒ…μž…λ‹ˆλ‹€. μ‹œμŠ€ν…œ λ©”λͺ¨λ¦¬μ—λŠ” 기본적인 λΆ€νŠΈλ‘œλ”κ°€ μžˆμŠ΅λ‹ˆλ‹€. 이 λΆ€νŠΈλ‘œλ”λŠ” μ—…λ‘œλ“œμ— μ‚¬μš©λ  톡신을 μ΄ˆκΈ°ν™”ν•˜κ³  ν•΄λ‹Ή 톡신이 μ‹œμž‘λ  λ•ŒκΉŒμ§€ κΈ°λ‹€λ¦½λ‹ˆλ‹€. 톡신을 톡해 μ‚¬μš©μžκ°€ μ‹€ν–‰ νŒŒμΌμ„ μ—…λ‘œλ“œν•˜λ©΄, ν”Œλž˜μ‹œ λ©”λͺ¨λ¦¬μ— λ‹€μš΄λ‘œλ“œ λ©λ‹ˆλ‹€. λ³΄λ“œλ§ˆλ‹€ μ§€μ›ν•˜λŠ” 톡신 방법이 λ‹€μ–‘ν•˜κΈ° λ•Œλ¬Έμ— AN2606 λ¬Έμ„œλ₯Ό μ°Έκ³ ν•˜μ‹œκΈ° λ°”λžλ‹ˆλ‹€.
  • Embedded SRAM: (0x20000000)μ—μ„œ μ‹œμž‘ν•˜λŠ” λΆ€νŒ…μž…λ‹ˆλ‹€.
tip

λ³΄λ“œλ₯Ό 보면 B0, B1 κ³Ό κ΄€λ ¨λœ 핀이 μžˆμŠ΅λ‹ˆλ‹€. ν•΄λ‹Ή 핀을 Vcc와 μ—°κ²°ν•˜λ©΄ μƒνƒœκ°€ 1 이 되고, GND와 μ—°κ²°ν•˜λ©΄ μƒνƒœκ°€ 0 이 λ©λ‹ˆλ‹€. User Flash memory와 System memoryλ₯Ό 주둜 μ‚¬μš©ν•˜κ²Œ 되기 λ•Œλ¬Έμ— B1λŠ” GND에 κ³ μ •ν•˜κ³  B0만 λ°”κΏ”κ°€λ©° μ‚¬μš©ν•˜λ©΄ λ©λ‹ˆλ‹€.

UART

UARTλ‘œλŠ” ν”Œλž˜μ‹œ λ©”λͺ¨λ¦¬μ— μ‹€ν–‰ νŒŒμΌμ„ 직접 μ—…λ‘œλ“œ ν•  수 μ—†κΈ° λ•Œλ¬Έμ—, λΆ€νŠΈλ‘œλ”μ˜ 도움을 λ°›μ•„μ•Ό ν•©λ‹ˆλ‹€. λΆ€νŠΈλ‘œλ”λ₯Ό μ‚¬μš©ν•˜κΈ° μœ„ν•΄ λΆ€νŠΈ λͺ¨λ“œλŠ” System memoryλ₯Ό μ„ νƒν•˜λ©΄ λ©λ‹ˆλ‹€. λ”°λΌμ„œ B1은 GND에 B0λŠ” Vcc에 μ—°κ²°ν•©λ‹ˆλ‹€. μ‹€ν–‰ νŒŒμΌμ„ μ—…λ‘œλ“œν•œ λ’€μ—λŠ” λΆ€νŠΈ λͺ¨λ“œλ₯Ό λ‹€μ‹œ User Flash memory둜 λ°”κΎΌ ν›„, 리셋 λ²„νŠΌμ„ λˆŒλŸ¬μ•Όν•©λ‹ˆλ‹€.

λ³΄λ“œλ§ˆλ‹€ UART 핀이 λ‹€λ₯΄κΈ° λ•Œλ¬Έμ— λΆ€νŠΈλ‘œλ”κ°€ μ§€μ›ν•˜λŠ” 톡신과 핀을 확인 ν•΄μ•Όν•©λ‹ˆλ‹€. STM32F103 λ³΄λ“œμ˜ 경우 UART1을 μ‚¬μš©ν•˜κΈ° λ•Œλ¬Έμ— USBtoUART와 λ³΄λ“œμ˜ UART1을 μ—°κ²°ν•˜λ©΄ λ©λ‹ˆλ‹€.

ST-LINK/V2

ST-LINK/V2λ₯Ό μ‚¬μš©ν•˜λ©΄ ν”Œλž˜μ‹œ λ©”λͺ¨λ¦¬μ— μ‹€ν–‰ 파일이 λ°”λ‘œ μ—…λ‘œλ“œ 되기 λ•Œλ¬Έμ— λΆ€νŠΈ λͺ¨λ“œλŠ” User Flash memoryλ₯Ό μ„ νƒν•˜λ©΄ λ©λ‹ˆλ‹€. λ”°λΌμ„œ B1, B0 λͺ¨λ‘ GND에 μ—°κ²°ν•©λ‹ˆλ‹€.

Error: init mode failed (unable to connect to the target)
in procedure 'program'
in procedure 'init' called at file "embedded:startup.tcl", line 495
in procedure 'ocd_bouncer'
** OpenOCD init failed **
shutdown command invoked
*** [upload] Error 1

μœ„μ™€ 같은 μ—λŸ¬λ₯Ό 보면 System memory λͺ¨λ“œλ‘œ 1회 μ—…λ‘œλ“œ ν›„ λ‹€μ‹œ User Flash memory둜 λ³€κ²½ ν›„ μ‚¬μš©ν•˜μ‹œκΈ° λ°”λžλ‹ˆλ‹€.

Upload

STM32CubeIDE

  • Run -> Debug Configurations
  • STM32 Coretex-M C/C++ Application -> <project> Debug -> Debugger νƒ­
  • Debug probe -> ST-LINK
  • GDB Server Command Line Options
    • SWD, JTAG 쀑 선택
    • Check ST-Link S/N -> Scan
  • Click Apply -> Debug

μ„€μ • ν›„μ—λŠ” Run -> Run or Debug λ˜λŠ” Run or Debug(F11) λ²„νŠΌμ„ 눌러 μ—…λ‘œλ“œν•˜κ³  λ””λ²„κΉ…ν•˜λ©΄ λ©λ‹ˆλ‹€.

Last updated on