pc13번 언급이 있어서 확인해보니 RTC_OUT / RTC_TAMPER로 설정이 가능하다.
Tamper를 활성화 하면 RTC_OUT 에서 RTC Output on the Tamper pin이 사용 불가능해진다.
Tamper는 인터럽트가 있는걸 봐서는.. 일종의 input 으로 설정되나보다.
rtc_Tamper를 rtc out으로 쓰지 않으면, 기본으로 tamper는 disble 되는 듯
stm32f1xx_hal_rtc.c
*** Tamper configuration *** ============================ [..] (+) Enable the RTC Tamper and configure the Tamper Level using the HAL_RTCEx_SetTamper() function. You can configure RTC Tamper with interrupt mode using HAL_RTCEx_SetTamper_IT() function. (+) The TAMPER1 alternate function can be mapped to PC13
/** * @brief Initializes the RTC peripheral * @param hrtc pointer to a RTC_HandleTypeDef structure that contains * the configuration information for RTC. * @retval HAL status */ HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc) { /* Set Initialization mode */ if (RTC_EnterInitMode(hrtc) != HAL_OK) { /* Set RTC state */ hrtc->State = HAL_RTC_STATE_ERROR;
if (hrtc->Init.OutPut != RTC_OUTPUTSOURCE_NONE) { /* Disable the selected Tamper pin */ CLEAR_BIT(BKP->CR, BKP_CR_TPE); }
/* Set the signal which will be routed to RTC Tamper pin*/ MODIFY_REG(BKP->RTCCR, (BKP_RTCCR_CCO | BKP_RTCCR_ASOE | BKP_RTCCR_ASOS), hrtc->Init.OutPut); } }
stm32f1xx_hal_rtc.h
/** @defgroup RTC_output_source_to_output_on_the_Tamper_pin Output source to output on the Tamper pin * @{ */
#define RTC_OUTPUTSOURCE_NONE 0x00000000U /*!< No output on the TAMPER pin */ #define RTC_OUTPUTSOURCE_CALIBCLOCK BKP_RTCCR_CCO /*!< RTC clock with a frequency divided by 64 on the TAMPER pin */ #define RTC_OUTPUTSOURCE_ALARM BKP_RTCCR_ASOE /*!< Alarm pulse signal on the TAMPER pin */ #define RTC_OUTPUTSOURCE_SECOND (BKP_RTCCR_ASOS | BKP_RTCCR_ASOE) /*!< Second pulse signal on the TAMPER pin */
/** Initialize RTC Only */ hrtc.Instance = RTC; hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND; hrtc.Init.OutPut = RTC_OUTPUTSOURCE_ALARM; if (HAL_RTC_Init(&hrtc) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN RTC_Init 2 */
/* USER CODE END RTC_Init 2 */
}
HAL_RTC_MspInit()을 통해
stm32f1xx_hal_rtc.c
(+) To write to the RTC Backup Data registers, use the HAL_RTCEx_BKUPWrite() function. (+) To read the RTC Backup Data registers, use the HAL_RTCEx_BKUPRead() function.
/** * @brief Initializes the RTC peripheral * @param hrtc pointer to a RTC_HandleTypeDef structure that contains * the configuration information for RTC. * @retval HAL status */ HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc) { uint32_t prescaler = 0U; /* Check input parameters */ if (hrtc == NULL) { return HAL_ERROR; }
/* Check the parameters */ assert_param(IS_RTC_ALL_INSTANCE(hrtc->Instance)); assert_param(IS_RTC_CALIB_OUTPUT(hrtc->Init.OutPut)); assert_param(IS_RTC_ASYNCH_PREDIV(hrtc->Init.AsynchPrediv));
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) #else if (hrtc->State == HAL_RTC_STATE_RESET) { /* Allocate lock resource and initialize it */ hrtc->Lock = HAL_UNLOCKED;
/** * @brief Initializes the RTC MSP. * @param hrtc pointer to a RTC_HandleTypeDef structure that contains * the configuration information for RTC. * @retval None */ __weak void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc) { /* Prevent unused argument(s) compilation warning */ UNUSED(hrtc); /* NOTE : This function Should not be modified, when the callback is needed, the HAL_RTC_MspInit could be implemented in the user file */ }
백업 레지스터에 접근할수 있도록 풀어준다. Core/Src/stm32f1xx_hal_msp.c
/** * @brief RTC MSP Initialization * This function configures the hardware resources used in this example * @param hrtc: RTC handle pointer * @retval None */ void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) { if(hrtc->Instance==RTC) { /* USER CODE BEGIN RTC_MspInit 0 */
/* USER CODE END RTC_MspInit 0 */ HAL_PWR_EnableBkUpAccess(); /* Enable BKP CLK enable for backup registers */ __HAL_RCC_BKP_CLK_ENABLE(); /* Peripheral clock enable */ __HAL_RCC_RTC_ENABLE(); /* USER CODE BEGIN RTC_MspInit 1 */
/* USER CODE END RTC_MspInit 1 */
}
}
CR_DBP_BB 라는 레지스터에 활성화 해주는것 코드 느낌. 무슨 레지스터인지 따라가긴 귀찮으니 패스
stm32f1xx_hal_pwr.c
/** * @brief Enables access to the backup domain (RTC registers, RTC * backup data registers ). * @note If the HSE divided by 128 is used as the RTC clock, the * Backup Domain Access should be kept enabled. * @retval None */ void HAL_PWR_EnableBkUpAccess(void) { /* Enable access to RTC and backup registers */ *(__IO uint32_t *) CR_DBP_BB = (uint32_t)ENABLE; }
/** * @brief Disables access to the backup domain (RTC registers, RTC * backup data registers). * @note If the HSE divided by 128 is used as the RTC clock, the * Backup Domain Access should be kept enabled. * @retval None */ void HAL_PWR_DisableBkUpAccess(void) { /* Disable access to RTC and backup registers */ *(__IO uint32_t *) CR_DBP_BB = (uint32_t)DISABLE; }
아무튼 백업레지스터 접근이 허용되면
HAL_RTCEx_BKUPWrite() 를 통해 쓰고
HAL_RTCEx_BKUPRead() 를 통해 읽을 수 있다.
stm32f1xx_hal_rtc_ex.c
/** * @brief Writes a data in a specified RTC Backup data register. * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains * the configuration information for RTC. * @param BackupRegister: RTC Backup data Register number. * This parameter can be: RTC_BKP_DRx where x can be from 1 to 10 (or 42) to * specify the register (depending devices). * @param Data: Data to be written in the specified RTC Backup data register. * @retval None */ void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data) { uint32_t tmp = 0U;
/** * @brief Reads data from the specified RTC Backup data Register. * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains * the configuration information for RTC. * @param BackupRegister: RTC Backup data Register number. * This parameter can be: RTC_BKP_DRx where x can be from 1 to 10 (or 42) to * specify the register (depending devices). * @retval Read value */ uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister) { uint32_t backupregister = 0U; uint32_t pvalue = 0U;
1.9 Backup registers RTC_BKPxR, where x=0 to n backup registers (80 bytes), are reset when a tamper detection event occurs. These registers are powered-on by VBAT when VDD is switched off, so that they are not reset by a system reset, and their contents remain valid when the device operates in low-power mode. Note: The number “n” of backup registers depends on the product. Please refer to Table 15: Advanced RTC features.
3.7.2 System reset sources Power-on reset initializes all registers while system reset reinitializes the system except for the debug, part of the RCC and power controller status registers, as well as the backup power domain. A system reset is generated in the following cases: • Power-on reset (pwr_por_rst) • Brownout reset • Low level on NRST pin (external reset) • Independent watchdog 1 (from D1 domain) • Independent watchdog 2 (from D2 domain) • Window watchdog 1 (from D1 domain) • Window watchdog 2 (from D2 domain) • Software reset • Low-power mode security reset • Exit from Standby
/** * @brief This is the code that gets called when the processor first * starts execution following a reset event. Only the absolutely * necessary set is performed, after which the application * supplied main() routine is called. * @param None * @retval : None */
/****************************************************************************** * * The minimal vector table for a Cortex M3. Note that the proper constructs * must be placed on this to ensure that it ends up at physical address * 0x0000.0000. * ******************************************************************************/ .section .isr_vector,"a",%progbits .type g_pfnVectors, %object .size g_pfnVectors, .-g_pfnVectors
/* Sections */ SECTIONS { /* The startup code into "FLASH" Rom type memory */ .isr_vector : { . = ALIGN(4); KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); } >FLASH
/* The program code and other data into "FLASH" Rom type memory */ .text : { . = ALIGN(4); *(.text) /* .text sections (code) */ *(.text*) /* .text* sections (code) */ *(.glue_7) /* glue arm to thumb code */ *(.glue_7t) /* glue thumb to arm code */ *(.eh_frame)
KEEP (*(.init)) KEEP (*(.fini))
. = ALIGN(4); _etext = .; /* define a global symbols at end of code */ } >FLASH
/* Constant data into "FLASH" Rom type memory */ .rodata : { . = ALIGN(4); *(.rodata) /* .rodata sections (constants, strings, etc.) */ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ . = ALIGN(4); } >FLASH }
$ readelf -a test.elf ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: ARM Version: 0x1 Entry point address: 0x8009499 Start of program headers: 52 (bytes into file) Start of section headers: 1299152 (bytes into file) Flags: 0x5000200, Version5 EABI, soft-float ABI Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 4 Size of section headers: 40 (bytes) Number of section headers: 26 Section header string table index: 25
Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .isr_vector PROGBITS 08000000 001000 0001e4 00 A 0 0 1 [ 2] .text PROGBITS 080001e8 0011e8 012144 00 AX 0 0 8 [ 3] .rodata PROGBITS 08012330 013330 002338 00 A 0 0 8 [ 4] .ARM.extab PROGBITS 08014668 01622c 000000 00 W 0 0 1 [ 5] .ARM ARM_EXIDX 08014668 015668 000008 00 AL 2 0 4 [ 6] .preinit_array PREINIT_ARRAY 08014670 01622c 000000 04 WA 0 0 1 [ 7] .init_array INIT_ARRAY 08014670 015670 000004 04 A 0 0 4 [ 8] .fini_array FINI_ARRAY 08014674 015674 000004 04 A 0 0 4 [ 9] .data PROGBITS 20000000 016000 00022c 00 WA 0 0 4 [10] .bss NOBITS 20000230 016230 001b44 00 WA 0 0 8 [11] ._user_heap_stack NOBITS 20001d74 016d74 000604 00 WA 0 0 1 [12] .ARM.attributes ARM_ATTRIBUTES 00000000 01622c 000029 00 0 0 1 [13] .debug_info PROGBITS 00000000 016255 01da16 00 0 0 1 [14] .debug_abbrev PROGBITS 00000000 033c6b 0056f5 00 0 0 1 [15] .debug_aranges PROGBITS 00000000 039360 001bf8 00 0 0 8 [16] .debug_rnglists PROGBITS 00000000 03af58 0015ba 00 0 0 1 [17] .debug_macro PROGBITS 00000000 03c512 0206fd 00 0 0 1 [18] .debug_line PROGBITS 00000000 05cc0f 022fc5 00 0 0 1 [19] .debug_str PROGBITS 00000000 07fbd4 0aae1c 01 MS 0 0 1 [20] .comment PROGBITS 00000000 12a9f0 000043 01 MS 0 0 1 [21] .debug_frame PROGBITS 00000000 12aa34 008440 00 0 0 4 [22] .debug_line_str PROGBITS 00000000 132e74 000064 01 MS 0 0 1 [23] .symtab SYMTAB 00000000 132ed8 0072e0 10 24 1208 4 [24] .strtab STRTAB 00000000 13a1b8 002ffa 00 0 0 1 [25] .shstrtab STRTAB 00000000 13d1b2 00011c 00 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), D (mbind), y (purecode), p (processor specific)
Unwind section '.ARM' at offset 0x15668 contains 1 entry:
0x8000228 <strlen>: 0x1 [cantunwind]
Symbol table '.symtab' contains 1838 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 08000000 0 SECTION LOCAL DEFAULT 1 .isr_vector 2: 080001e8 0 SECTION LOCAL DEFAULT 2 .text 3: 08012330 0 SECTION LOCAL DEFAULT 3 .rodata 4: 08014668 0 SECTION LOCAL DEFAULT 4 .ARM.extab 5: 08014668 0 SECTION LOCAL DEFAULT 5 .ARM 6: 08014670 0 SECTION LOCAL DEFAULT 6 .preinit_array 7: 08014670 0 SECTION LOCAL DEFAULT 7 .init_array 8: 08014674 0 SECTION LOCAL DEFAULT 8 .fini_array 9: 20000000 0 SECTION LOCAL DEFAULT 9 .data 10: 20000230 0 SECTION LOCAL DEFAULT 10 .bss 11: 20001d74 0 SECTION LOCAL DEFAULT 11 ._user_heap_stack (많아서 생략)
No version information found in this file. Attribute Section: aeabi File Attributes Tag_CPU_name: "7-M" Tag_CPU_arch: v7 Tag_CPU_arch_profile: Microcontroller Tag_THUMB_ISA_use: Thumb-2 Tag_ABI_PCS_wchar_t: 4 Tag_ABI_FP_denormal: Needed Tag_ABI_FP_exceptions: Needed Tag_ABI_FP_number_model: IEEE 754 Tag_ABI_align_needed: 8-byte Tag_ABI_enum_size: small Tag_CPU_unaligned_access: v6
For ELF targets, the .type directive is used like this:
.type name , type description This sets the type of symbol name to be either a function symbol or an object symbol. There are five different syntaxes supported for the type description field, in order to provide compatibility with various other assemblers.
Because some of the characters used in these syntaxes (such as ‘@’ and ‘#’) are comment characters for some architectures, some of the syntaxes below do not work on all architectures. The first variant will be accepted by the GNU assembler on all architectures so that variant should be used for maximum portability, if you do not need to assemble your code with other assemblers.
STT_FUNC function Mark the symbol as being a function name.
STT_GNU_IFUNC gnu_indirect_function Mark the symbol as an indirect function when evaluated during reloc processing. (This is only supported on assemblers targeting GNU systems).
STT_OBJECT object Mark the symbol as being a data object.
그래서 reset 누르고 재기동 하면 ACM이 살아는 있지만 정상적으로 작동을 하지 않는건가?
If you reset the bluepill you need to pull down the D+ line for several milliseconds to let know the host that it has to start the enumeration process.
느린(?) eclipse 사용을 감수하는 이유가 cubeMX 설치없이 cubeIDE 에서 다 할 수 있어서 였는데
그 장점을 포기한 분리라.. 왜 이런 쓰레기 결정이 통과된거지?
We are pleased to announce that STM32CubeIDE 2.0.0 release is available. STM32CubeIDE is now independent from STM32CubeMX. With this release, device configuration, previously handled within STM32CubeIDE via STM32CubeMX, is now exclusively available through the stand-alone STM32CubeMX tool. Users will configure microcontroller peripherals and generate initialization code separately in STM32CubeMX, then import the generated projects into STM32CubeIDE for coding and debugging. STM32CubeIDE, is now a stand-alone tool, offers the possibility to create empty project through its own MCU/Board selectors now present inside. What does this change mean for developers?
Separate download and installation: STM32CubeMX is no more integrated in STM32CubeIDE, requiring separate download alongside STM32CubeIDE 2.0.0 for configuration and code generation.
Tool update flexibility: Developers can update and freeze STM32CubeMX and STM32CubeIDE independently, with multiple versions of each installed side-by-side.
Memory footprint and performance: Removing STM32CubeMX integration reduces installation size (~3.7GB to 2.9GB) and lowers CPU/RAM usage, improving stability especially on Linux and Mac.
Other relevant updates in STM32CubeIDE 2.0.0
Microcontroller, microprocessor, and board lists aligned with STM32CubeMX v6.16.0:
Added the support for new microcontrollers in the STM32N6 series
Added the support for new microcontrollers in the STM32H5 series
Added the support for new microcontrollers in the STM32WBA series
Added the support for new microcontrollers in the STM32WL3x product line
Added the support for new boards: NUCLEO-WL3RKB1 and NUCLEO-WL3RKB2
User authentication removed
ST-MCU-FINDER-PC removed
Support for ST-ARM-CLANG, STMicroelectronics LLVM-based toolchain for Arm®, through site update mechanism
Support for GCC 14 toolchain through site update mechanism
Support for semihosting feature through debug via ST-LINK GDB server
Or update your current installation of STM32CubeIDE using: Help > Check for updates (The in-tool update does not allow updating the drivers and STLINK server tool. Full installation is required for this to be done).
$ sudo demsg -w [25664.443438] usb 1-2: new full-speed USB device number 26 using xhci_hcd [25664.574720] usb 1-2: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00 [25664.574741] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [25664.574748] usb 1-2: Product: STM32 Virtual ComPort [25664.574754] usb 1-2: Manufacturer: STMicroelectronics [25664.579419] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
$ lsusb -t -v /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M ID 1d6b:0002 Linux Foundation 2.0 root hub |__ Port 2: Dev 26, If 0, Class=Communications, Driver=cdc_acm, 12M ID 0483:5740 STMicroelectronics Virtual COM Port |__ Port 2: Dev 26, If 1, Class=CDC Data, Driver=cdc_acm, 12M ID 0483:5740 STMicroelectronics Virtual COM Port
minicom은 9600으로 하던 115200 으로 하던 동일하게 값이 잘 들어온다. 신기하네
다만 많은 데이터가 있을때는 어떻게 될 진 미지수. 나중에 테스트 해봐야지
1회 굽기는 되는데 그 이후로 rebooting이 안될 때
step 1. reset 누르고 connect 누르고 reset 뗀다음 full chip erase
step 2. cubeide에서 swd 핀 할당해주기
"no debug" 로 두면 PA13/PA14가 주황색으로 되는데, 그러면 계속 retry 뜨니까 Serial Wire로 변경해준다.(SWO)
이건 실패시
STMicroelectronics ST-LINK GDB server. Version 7.8.0 Copyright (c) 2024, STMicroelectronics. All rights reserved.
Starting server with the following options: Persistent Mode : Disabled Logging Level : 1 Listen Port Number : 61234 Status Refresh Delay : 15s Verbose Mode : Disabled SWD Debug : Enabled
Waiting for debugger connection... Debugger connected Waiting for debugger connection... Debugger connected Waiting for debugger connection... ------------------------------------------------------------------- STM32CubeProgrammer v2.17.0 -------------------------------------------------------------------
Log output file: /tmp/STM32CubeProgrammer_RFILwX.log ST-LINK SN : 31000D000D2D343632525544 ST-LINK FW : V2J45S7 Board : -- Voltage : 3.21V SWD freq : 4000 KHz Connect mode: Under Reset Reset mode : Hardware reset Device ID : 0x410 Revision ID : Rev X Device name : STM32F101/F102/F103 Medium-density Flash size : 128 KBytes Device type : MCU Device CPU : Cortex-M3 BL Version : --
Erasing memory corresponding to segment 0: Erasing internal memory sectors [0 31] Download in Progress:
File download complete Time elapsed during download operation: 00:00:01.365
Verifying ...
Download verified successfully
Shutting down... Target is not responding, retrying... Target is not responding, retrying... Target is not responding, retrying... Target is not responding, retrying... Target is not responding, retrying...
이건 설정해주고 잘 될 때
STMicroelectronics ST-LINK GDB server. Version 7.8.0 Copyright (c) 2024, STMicroelectronics. All rights reserved.
Starting server with the following options: Persistent Mode : Disabled Logging Level : 1 Listen Port Number : 61234 Status Refresh Delay : 15s Verbose Mode : Disabled SWD Debug : Enabled
Waiting for debugger connection... Debugger connected Waiting for debugger connection... Debugger connected Waiting for debugger connection... ------------------------------------------------------------------- STM32CubeProgrammer v2.17.0 -------------------------------------------------------------------
Log output file: /tmp/STM32CubeProgrammer_0DypHa.log ST-LINK SN : 31000D000D2D343632525544 ST-LINK FW : V2J45S7 Board : -- Voltage : 3.21V SWD freq : 4000 KHz Connect mode: Under Reset Reset mode : Hardware reset Device ID : 0x410 Revision ID : Rev X Device name : STM32F101/F102/F103 Medium-density Flash size : 128 KBytes Device type : MCU Device CPU : Cortex-M3 BL Version : --