Browse Source

🐛 Fix Artillery Ruby (startup code, build flags) (#23446)

Kyle Hu 3 years ago
parent
commit
8e490e84be
No account linked to committer's email address
3 changed files with 125 additions and 1 deletions
  1. 0
    1
      .gitignore
  2. 124
    0
      buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S
  3. 1
    0
      ini/stm32f4.ini

+ 0
- 1
.gitignore View File

@@ -41,7 +41,6 @@ applet/
41 41
 *.rej
42 42
 *.bak
43 43
 *.idea
44
-*.s
45 44
 *.i
46 45
 *.ii
47 46
 *.swp

+ 124
- 0
buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S View File

@@ -0,0 +1,124 @@
1
+ /**
2
+  ******************************************************************************
3
+  * @file      startup_stm32f401xc.s
4
+  * @author    MCD Application Team
5
+  * @version   V2.4.2
6
+  * @date      13-November-2015
7
+  * @brief     STM32F401xCxx Devices vector table for GCC based toolchains.
8
+  *            This module performs:
9
+  *                - Set the initial SP
10
+  *                - Set the initial PC == Reset_Handler,
11
+  *                - Set the vector table entries with the exceptions ISR address
12
+  *                - Branches to main in the C library (which eventually
13
+  *                  calls main()).
14
+  *            After Reset the Cortex-M4 processor is in Thread mode,
15
+  *            priority is Privileged, and the Stack is set to Main.
16
+  ******************************************************************************
17
+  * @attention
18
+  *
19
+  * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
20
+  *
21
+  * Redistribution and use in source and binary forms, with or without modification,
22
+  * are permitted provided that the following conditions are met:
23
+  *   1. Redistributions of source code must retain the above copyright notice,
24
+  *      this list of conditions and the following disclaimer.
25
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
26
+  *      this list of conditions and the following disclaimer in the documentation
27
+  *      and/or other materials provided with the distribution.
28
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
29
+  *      may be used to endorse or promote products derived from this software
30
+  *      without specific prior written permission.
31
+  *
32
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
36
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
38
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
39
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
40
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
+  *
43
+  ******************************************************************************
44
+  */
45
+
46
+  .syntax unified
47
+  .cpu cortex-m4
48
+  .fpu softvfp
49
+  .thumb
50
+
51
+/**
52
+ * @brief  This is the code that gets called when the processor first
53
+ *          starts execution following a reset event. Only the absolutely
54
+ *          necessary set is performed, after which the application
55
+ *          supplied main() routine is called.
56
+ * @param  None
57
+ * @retval : None
58
+ */
59
+
60
+  .section  .text.Reset_Handler
61
+  .globl Reset_Handler
62
+  .type  Reset_Handler, %function
63
+Reset_Handler:
64
+/* Check for magic code at the end of SRAM to detemine whether to jump to DFU */
65
+  ldr   r0, =0x2000FFF0 // End of SRAM for your CPU
66
+  ldr   r1, =0xDEADBEEF
67
+  ldr   r2, [r0, #0]
68
+  str   r0, [r0, #0] // Invalidate
69
+  cmp   r2, r1
70
+  beq   Jump_To_DFU
71
+
72
+/* Original Reset_Handler code */
73
+  ldr   sp, =_estack      /* set stack pointer */
74
+
75
+/* Copy the data segment initializers from flash to SRAM */
76
+  movs  r1, #0
77
+  b  LoopCopyDataInit
78
+
79
+CopyDataInit:
80
+  ldr  r3, =_sidata
81
+  ldr  r3, [r3, r1]
82
+  str  r3, [r0, r1]
83
+  adds  r1, r1, #4
84
+
85
+LoopCopyDataInit:
86
+  ldr  r0, =_sdata
87
+  ldr  r3, =_edata
88
+  adds  r2, r0, r1
89
+  cmp  r2, r3
90
+  bcc  CopyDataInit
91
+  ldr  r2, =_sbss
92
+  b  LoopFillZerobss
93
+/* Zero fill the bss segment. */
94
+FillZerobss:
95
+  movs  r3, #0
96
+  str  r3, [r2], #4
97
+
98
+LoopFillZerobss:
99
+  ldr  r3, = _ebss
100
+  cmp  r2, r3
101
+  bcc  FillZerobss
102
+
103
+/* Call the clock system intitialization function.*/
104
+  bl  SystemInit
105
+/* Call static constructors */
106
+  bl __libc_init_array
107
+/* Call the application's entry point.*/
108
+  bl  main
109
+  bx  lr
110
+
111
+Jump_To_DFU:
112
+  ldr   r0, =0x40023844 // RCC_APB2ENR
113
+  ldr   r1, =0x00004000 // ENABLE SYSCFG CLOCK
114
+  str   r1, [r0, #0]
115
+  ldr   r0, =0x40013800 // SYSCFG_MEMRMP
116
+  ldr   r1, =0x00000001 // MAP ROM AT ZERO
117
+  str   r1, [r0, #0]
118
+  ldr   r0, =0x1FFF0000 // ROM BASE
119
+  ldr   sp, [r0, #0]    // SP @ +0
120
+  ldr   r0, [r0, #4]    // PC @ +4
121
+  bx    r0
122
+.size  Reset_Handler, .-Reset_Handler
123
+
124
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 1
- 0
ini/stm32f4.ini View File

@@ -570,5 +570,6 @@ build_flags       = ${common_stm32.build_flags}
570 570
                     -DSTM32F401xC -DTARGET_STM32F4 -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32
571 571
                     -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS
572 572
                     -DUSB_PRODUCT=\"Artillery_3D_Printer\"
573
+                    -DFLASH_DATA_SECTOR=1U -DFLASH_BASE_ADDRESS=0x08004000
573 574
 extra_scripts     = ${common_stm32.extra_scripts}
574 575
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py

Loading…
Cancel
Save