embeded/Cortex-M3 STM2025. 11. 26. 17:43

좀 더 써봐야 알겠지만, STM32F103C8T6과 STLink v2 클론 SWD로 작동 확인완료!

그나저나 reset은 안해놔서 리셋이 될지 모르겠네

 

Posted by 구차니
embeded/Cortex-M3 STM2025. 11. 24. 19:08

pre-build steps 에서 명령을 주어 특정 파일을 행성해서 그 변수에 값을 넣어주는 방식

머.. 어짜피 이것도 makefile로 생성될테니 방법은 방법이지

 

 

git log --pretty=format:'#define GIT_INFO_PRESENT%n static const char* GIT_INFO = "Version Information=[%H,%d]\r\n";' -n 1 > ../Core/Inc/gitcommit.h

[링크 : https://community.st.com/t5/stm32-mcus-embedded-software/git-commit-hash-flashed-along-with-my-code/td-p/179180]

Posted by 구차니
embeded/Cortex-M3 STM2025. 11. 22. 20:26

예제

[링크 : https://github.com/miniwinwm/BluePillDemo]

 

ATMEL AVR 아두이노 대신 stm32를 넣기 시작한게 bluepill 인가..?

[링크 : https://deepbluembedded.com/stm32-blue-pill-pinout-programming-guide/]

 

c8과 c6 두가지가 있다는데 플래시와 메모리 용량이 차이가 많이 난다.

  • Arm® 32-bit Cortex®-M3 CPU core
    • 72 MHz maximum frequency, 1.25 DMIPS/MHz (Dhrystone 2.1) performance at 0 wait state memory access
    • Single-cycle multiplication and hardware division
  • Memories
    • 64 or 128 Kbytes of Flash memory
    • 20 Kbytes of SRAM

[링크 : https://www.st.com/en/microcontrollers-microprocessors/stm32f103c8.html]

 

  • ARM 32-bit Cortex™-M3 CPU Core
    • 72 MHz maximum frequency,1.25 DMIPS/MHz (Dhrystone 2.1) performance at 0 wait state memory access
    • Single-cycle multiplication and hardware division
  • Memories
    • 16 or 32 Kbytes of Flash memory
    • 6 or 10 Kbytes of SRAM

[링크 : https://www.st.com/en/microcontrollers-microprocessors/stm32f103c6.html]

Posted by 구차니
embeded/Cortex-M3 STM2025. 11. 22. 19:40

단순하게 전원만 연결되는줄 알았는데

윈도우에서는 잘못된 장치라고 떠서, 리눅스에서 확인

 

boot0 - 0  / boot1 - 0 에 usb 연결

[   50.788963] usb 1-1.1: new full-speed USB device number 4 using ehci-pci
[   50.853992] usb 1-1.1: device descriptor read/64, error -32
[   51.023960] usb 1-1.1: device descriptor read/64, error -32
[   51.196938] usb 1-1.1: new full-speed USB device number 5 using ehci-pci
[   51.261946] usb 1-1.1: device descriptor read/64, error -32
[   51.429943] usb 1-1.1: device descriptor read/64, error -32
[   51.533019] usb 1-1-port1: attempt power cycle
[   52.113007] usb 1-1.1: new full-speed USB device number 6 using ehci-pci
[   52.524932] usb 1-1.1: device not accepting address 6, error -32
[   52.589928] usb 1-1.1: new full-speed USB device number 7 using ehci-pci
[   53.004924] usb 1-1.1: device not accepting address 7, error -32
[   53.005142] usb 1-1-port1: unable to enumerate USB device

 

boot0 - 1 / boot1 - 0에 usb 연결. 차이는 없다.

[  225.014866] usb 1-1.1: new full-speed USB device number 8 using ehci-pci
[  225.079866] usb 1-1.1: device descriptor read/64, error -32
[  225.253817] usb 1-1.1: device descriptor read/64, error -32
[  225.420787] usb 1-1.1: new full-speed USB device number 9 using ehci-pci
[  225.485801] usb 1-1.1: device descriptor read/64, error -32
[  225.654762] usb 1-1.1: device descriptor read/64, error -32
[  225.756872] usb 1-1-port1: attempt power cycle
[  226.337664] usb 1-1.1: new full-speed USB device number 10 using ehci-pci
[  226.756996] usb 1-1.1: device not accepting address 10, error -32
[  226.820602] usb 1-1.1: new full-speed USB device number 11 using ehci-pci
[  227.236577] usb 1-1.1: device not accepting address 11, error -32
[  227.236751] usb 1-1-port1: unable to enumerate USB device

 

 

일단 PA9이 USART1_TX / PA10이 USART1_RX니까 USB TTL을 이용해서 적당히 연결해줘본다.

[링크 : https://www.st.com/resource/en/datasheet/stm32f103c8.pdf]

 

USB TTL이 /dev/ttyUSB0으로 인식해서 설정하고 읽어보면 잘 읽힌다.

$ stm32flash /dev/ttyUSB0
stm32flash 0.5

http://stm32flash.sourceforge.net/

Interface serial_posix: 57600 8E1
Warning: the interface was not closed properly.
Version      : 0x30
Option 1     : 0x00
Option 2     : 0x00
Device ID    : 0x0410 (STM32F10xxx Medium-density)
- RAM        : Up to 20KiB  (512b reserved by bootloader)
- Flash      : Up to 128KiB (size first sector: 4x1024)
- Option RAM : 16b
- System RAM : 2KiB

 

프로그램이 없어서 그런가 boot0 - 0, boot1 - 0 으로 되어있어도 내부 부트로더가 작동한다.

[링크 : https://eteo.tistory.com/417]

 

무언가 구으면 boot0 - 1, boot1 - 0 으로 하고 리셋눌러줘야 stm32flash에 응답한다.

'embeded > Cortex-M3 STM' 카테고리의 다른 글

stm32 cubeide git commit hash  (0) 2025.11.24
stm32f103c8t6 blue pill board  (0) 2025.11.22
stm32f103 dfu (Device Firmware Upgrade)  (0) 2025.11.19
stn32f103 usb cdc(communication device class)  (0) 2025.11.19
stm32f103 도착  (0) 2025.11.19
Posted by 구차니
embeded/Cortex-M3 STM2025. 11. 19. 19:47

리눅스/우분투

[링크 : https://manpages.ubuntu.com/manpages/xenial//man1/dfu-util.1.html]

 

윈도우

Description

STSW-STM32080 package contains all binaries and source code for DfuSe USB device firmware upgrade (DFU) software, including the demonstration, debugging GUIs and protocol layers.
It includes the DFU driver compatible with the latest Microsoft®OS.
DfuSe utility can be used to interact with the STM32 system memory bootloader or any In-Application Programming (IAP) firmware, running from the user Flash, thus allowing internal memories programming through USB.
All source files for Microsoft®Visual Studio 2012 are provided as well, to allow the customization of the default GUI interface.
  • All features

    • DfuSE USB Programming
    • Command line version
    • All binaries and sources provided
 

[링크 : https://www.st.com/en/development-tools/stsw-stm32080.html]

 

[링크 : https://community.st.com/t5/stm32cubeide-mcus/programming-stm32-in-bootloader-mode-under-linux/td-p/277572]

[링크 : https://www.os4all.com/m/70]

[링크 : https://www.os4all.com/m/69]

 

dfu 부트로더

[링크 : https://bigcoco.tistory.com/m/6]

 

 

'embeded > Cortex-M3 STM' 카테고리의 다른 글

stm32f103c8t6 blue pill board  (0) 2025.11.22
stm32f103 usb c 연결 + usb ttl 연결  (0) 2025.11.22
stn32f103 usb cdc(communication device class)  (0) 2025.11.19
stm32f103 도착  (0) 2025.11.19
stm32 adc + dma.. part 2?  (0) 2025.10.29
Posted by 구차니
embeded/Cortex-M3 STM2025. 11. 19. 19:39

간단하게.. ft232 같은 것 없어도 usb를 통해서 바로 통신이 가능한 com 포트를 생성해주는 기능

cubeIDE에서 따라해봐야겠다.

[링크 : https://jeonhj.tistory.com/m/29]

 

 

 

PA11 / PA12가 CAN or USB 포트로 사용을 해야 하는것 같군..

[링크 : https://www.st.com/resource/en/datasheet/stm32f103c8.pdf]

[링크 : https://www.st.com/en/microcontrollers-microprocessors/stm32f103c8.html]

 

 

뚫어져라 보니

B7 / A6 + B8 으로 연결되어서 쭈욱 따라가니 A11 / A12로 연결된 듯.

[링크 : https://electronics.stackexchange.com/questions/610007/how-to-wire-usb-c-connector]

'embeded > Cortex-M3 STM' 카테고리의 다른 글

stm32f103 usb c 연결 + usb ttl 연결  (0) 2025.11.22
stm32f103 dfu (Device Firmware Upgrade)  (0) 2025.11.19
stm32f103 도착  (0) 2025.11.19
stm32 adc + dma.. part 2?  (0) 2025.10.29
stm32 부트로더로 부팅 전환하기  (0) 2025.10.21
Posted by 구차니
embeded/Cortex-M3 STM2025. 11. 19. 19:26

micro USB인줄 알았는데 usb c로 왔다 -ㅁ-!

[링크 : http://mitem.auction.co.kr/vip?itemNo=F241860522] 2,970 * 2 + 3000

 

상면에는 리셋, BOOT0/BOOT1 핀을 위한 점퍼

STM32F103C8T6 MCU

8MHz / 32.768kHz 클럭

 

U1 - LDO LB2K 3.3V 500mA 인듯한데.. ams1117 같은 레귤레이터도 비싸다고 이런걸 넣은건가?

[링크 : https://www.alibaba.com/product-detail/Hainayu-Electronic-chip-SOT-23-5_1601244058700.html]

 

 

 

BOOT0 - 1

BOOT1 - 0 으로 점퍼를 셋팅하고 A9 / A10을 시리얼로 연결하면 stm32flash 등으로 올릴수있나 보다.

[링크 : https://medium.com/@paramaggarwal/programming-an-stm32f103-board-using-usb-port-blue-pill-953cec0dbc86]

 

 

USB는 전원공급전용인가?

[링크 : https://ko.aliexpress.com/item/1005009880645839.html]

RT9193-33GB  3.3V 300MA SOT23-5

[링크 : https://www.eleparts.co.kr/goods/view?no=210486]

Posted by 구차니
embeded/Cortex-M3 STM2025. 10. 29. 14:45

cluade.ai의 도움으로 해결 -_-

아무튼,  값이 밀리는 것 처럼 보였던 이유는 dma를 circular로 하지 않아서 수동으로 시작했고, 첫 adc는 버려야 하는데

버리니까 두번째 들어오지 않는 문제 발생. 그래서 매번 dma_start를 해줘서 문제가 되었던 듯 하다.

 

ADC_Settings 에서 Continuous Conversion Mode 를 Disable -> Enable

 

DMA는 Mode Normal 에서 Circular로 해주면 끝

 

NVIC는 DMA1만 인터럽트 활성화 해주면 된다.

 

코드에서는 main() 에서 while() 들어가기 전에

HAL_ADC_Start_DMA() 한번 호출해주고 그 이후로는

adc callback 에서 다 받아왔을 때 값을 옮겨주고 처리루틴 부르면 끝

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
  if(hadc->Instance == ADC1)
  {
//    memcpy(ADCRaw, ADCResult, sizeof(uint16_t) * 4);
//    adc_dma_flag = 2;
  }
}

 

2024.11.04 - [embeded/Cortex-M3 STM] - stm32f103 adc + dma

'embeded > Cortex-M3 STM' 카테고리의 다른 글

stn32f103 usb cdc(communication device class)  (0) 2025.11.19
stm32f103 도착  (0) 2025.11.19
stm32 부트로더로 부팅 전환하기  (0) 2025.10.21
EEPROM emulation for stm32  (0) 2025.10.16
stm32 cpp  (0) 2025.08.08
Posted by 구차니
embeded/Cortex-M3 STM2025. 10. 21. 18:21

stm32 시리즈 마다 달라서  boot_addr를 확인해야 하지만

아무튼 아래와 같이 작성된 코드를 호출하면 boot0 쇼트한것 처럼 부트로더가 시작된다고 한다.

/* USER CODE BEGIN 4 */
#define BOOT_ADDR 0x1FFFF000 // my MCU boot code base address
#define MCU_IRQS 70u // no. of NVIC IRQ inputs

struct boot_vectable_ {
    uint32_t Initial_SP;
    void (*Reset_Handler)(void);
};

#define BOOTVTAB ((struct boot_vectable_ *)BOOT_ADDR)

void JumpToBootloader(void)
{
/* Disable all interrupts */
__disable_irq();

/* Disable Systick timer */
SysTick->CTRL = 0;

/* Set the clock to the default state */
HAL_RCC_DeInit();

/* Clear Interrupt Enable Register & Interrupt Pending Register */
for (uint8_t i = 0; i < (MCU_IRQS + 31u) / 32; i++)
{
NVIC->ICER[i]=0xFFFFFFFF;
NVIC->ICPR[i]=0xFFFFFFFF;
}

/* Re-enable all interrupts */
__enable_irq();

// Set the MSP
__set_MSP(BOOTVTAB->Initial_SP);

// Jump to app firmware
BOOTVTAB->Reset_Handler();
}

/* USER CODE END 4 */

[링크 : https://community.st.com/t5/stm32-mcus/how-to-jump-to-system-bootloader-from-application-code-on-stm32/ta-p/49424]

'embeded > Cortex-M3 STM' 카테고리의 다른 글

stm32f103 도착  (0) 2025.11.19
stm32 adc + dma.. part 2?  (0) 2025.10.29
EEPROM emulation for stm32  (0) 2025.10.16
stm32 cpp  (0) 2025.08.08
stm32 eeprom emulation  (0) 2025.07.29
Posted by 구차니
embeded/Cortex-M3 STM2025. 10. 16. 18:29

stm32용 eeprom 에뮬레이션 패키지.

cube ide에서 packs 에서 설치가 될 줄 알았는데 없고, 수동으로 풀어서 넣어주어야 한다.

 

[링크 : https://community.st.com/t5/stm32cubemx-mcus/how-to-install-x-cube-eeprom-on-stm32cube/td-p/78773]

[링크 : https://community.st.com/t5/stm32cubemx-mcus/how-can-i-install-and-use-x-cube-eeprom-middleware-in/m-p/122931]

 

받고, 풀고

[링크 : https://www.st.com/en/embedded-software/x-cube-eeprom.html#tools-software]

 

적당히 때려넣어주면 끝

[링크 : https://blog.naver.com/chcbaram/223153496808]

'embeded > Cortex-M3 STM' 카테고리의 다른 글

stm32 adc + dma.. part 2?  (0) 2025.10.29
stm32 부트로더로 부팅 전환하기  (0) 2025.10.21
stm32 cpp  (0) 2025.08.08
stm32 eeprom emulation  (0) 2025.07.29
stm32f103ret flash program / erase 테스트  (0) 2025.07.28
Posted by 구차니