Skip to content

Commit b46c8dc

Browse files
authored
Merge pull request adafruit#2065 from hierophect/f411re-feature-buildout
F411re feature buildout
2 parents 16a8a34 + 479b047 commit b46c8dc

45 files changed

Lines changed: 1183 additions & 690 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ports/stm32f4/Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ endif
9898

9999
ifeq ($(MCU_SUB_VARIANT), stm32f411xe)
100100
C_DEFS = \
101+
-DUSE_FULL_LL_DRIVER \
101102
-DUSE_HAL_DRIVER \
102103
-DSTM32F411xE
103104
endif
104105

106+
C_DEFS += -DMCU_PACKAGE=$(MCU_PACKAGE)
107+
105108
#TODO: Add ASM Flags? -Werror
106109
CFLAGS += $(INC) -Wall -std=gnu11 -nostdlib $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
107110

@@ -133,7 +136,7 @@ LIBS += -lm
133136
endif
134137

135138
# TinyUSB defines
136-
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_STM32F4 -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=4096 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128
139+
CFLAGS += -DHSE_VALUE=8000000 -DCFG_TUSB_MCU=OPT_MCU_STM32F4 -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=4096 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128
137140

138141

139142
######################################
@@ -148,6 +151,7 @@ SRC_STM32 = \
148151
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c \
149152
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fsmc.c \
150153
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c \
154+
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c \
151155
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_i2c.c \
152156
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c \
153157
stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s.c \
@@ -183,6 +187,8 @@ SRC_C += \
183187
mphalport.c \
184188
tick.c \
185189
boards/$(BOARD)/board.c \
190+
boards/$(BOARD)/pins.c \
191+
peripherals/stm32f4/$(MCU_SUB_VARIANT)/pins.c \
186192
peripherals/stm32f4/$(MCU_SUB_VARIANT)/clocks.c \
187193
peripherals/stm32f4/$(MCU_SUB_VARIANT)/gpio.c \
188194
lib/libc/string0.c \
@@ -202,11 +208,6 @@ ifneq ($(USB),FALSE)
202208
SRC_C += lib/tinyusb/src/portable/st/stm32f4/dcd_stm32f4.c
203209
endif
204210

205-
ifeq ($(MCU_SUB_VARIANT), stm32f412zx)
206-
SRC_C += peripherals/stm32f4/stm32f412zx/pins.c
207-
SRC_C += boards/$(BOARD)/pins.c
208-
endif
209-
210211
SRC_S = \
211212
supervisor/cpu.s \
212213
boards/startup_$(MCU_SUB_VARIANT).s

ports/stm32f4/background.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ void run_background_tasks(void) {
4646
}
4747
running_background_tasks = true;
4848
filesystem_background();
49-
//usb_background();
49+
50+
#if USB_AVAILABLE
51+
usb_background();
52+
#endif
5053

5154
#if CIRCUITPY_DISPLAYIO
5255
displayio_background();
Lines changed: 96 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -1,189 +1,109 @@
11
/*
2-
******************************************************************************
3-
**
4-
5-
** File : LinkerScript.ld
6-
**
7-
** Author : Auto-generated by Ac6 System Workbench
8-
**
9-
** Abstract : Linker script for STM32F411VETx series
10-
** 512Kbytes FLASH and 128Kbytes RAM
11-
**
12-
** Set heap size, stack size and stack location according
13-
** to application requirements.
14-
**
15-
** Set memory bank area and size if external memory is used.
16-
**
17-
** Target : STMicroelectronics STM32
18-
**
19-
** Distribution: The file is distributed “as is,” without any warranty
20-
** of any kind.
21-
**
22-
*****************************************************************************
23-
** @attention
24-
**
25-
** <h2><center>&copy; COPYRIGHT(c) 2014 Ac6</center></h2>
26-
**
27-
** Redistribution and use in source and binary forms, with or without modification,
28-
** are permitted provided that the following conditions are met:
29-
** 1. Redistributions of source code must retain the above copyright notice,
30-
** this list of conditions and the following disclaimer.
31-
** 2. Redistributions in binary form must reproduce the above copyright notice,
32-
** this list of conditions and the following disclaimer in the documentation
33-
** and/or other materials provided with the distribution.
34-
** 3. Neither the name of Ac6 nor the names of its contributors
35-
** may be used to endorse or promote products derived from this software
36-
** without specific prior written permission.
37-
**
38-
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39-
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40-
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41-
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
42-
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43-
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44-
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
45-
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46-
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47-
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48-
**
49-
*****************************************************************************
2+
GNU linker script for STM32F411 via Micropython
503
*/
514

52-
/* Entry Point */
53-
ENTRY(Reset_Handler)
54-
55-
/* Highest address of the user mode stack */
56-
_estack = 0x20020000; /* end of RAM */
57-
/* Generate a link error if heap and stack don't fit into RAM */
58-
_Min_Heap_Size = 0x200; /* required amount of heap */
59-
_Min_Stack_Size = 0x400; /* required amount of stack */
60-
615
/* Specify the memory areas */
626
MEMORY
637
{
64-
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
65-
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
8+
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */
9+
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */
10+
FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 48K /* sectors 1,2,3 are 16K */
11+
FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */
12+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
6613
}
6714

68-
/* Define output sections */
15+
/* produce a link error if there is not this amount of RAM for these sections */
16+
_minimum_stack_size = 2K;
17+
_minimum_heap_size = 16K;
18+
19+
/* Define tho top end of the stack. The stack is full descending so begins just
20+
above last byte of RAM. Note that EABI requires the stack to be 8-byte
21+
aligned for a call. */
22+
_estack = ORIGIN(RAM) + LENGTH(RAM);
23+
24+
/* RAM extents for the garbage collector */
25+
_ram_start = ORIGIN(RAM);
26+
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
27+
_heap_start = _ebss; /* heap starts just after statically allocated memory */
28+
_heap_end = 0x2001c000; /* tunable */
29+
30+
ENTRY(Reset_Handler)
31+
32+
/* define output sections */
6933
SECTIONS
7034
{
71-
/* The startup code goes first into FLASH */
72-
.isr_vector :
73-
{
74-
. = ALIGN(4);
75-
KEEP(*(.isr_vector)) /* Startup code */
76-
. = ALIGN(4);
77-
} >FLASH
78-
79-
/* The program code and other data goes into FLASH */
80-
.text :
81-
{
82-
. = ALIGN(4);
83-
*(.text) /* .text sections (code) */
84-
*(.text*) /* .text* sections (code) */
85-
*(.glue_7) /* glue arm to thumb code */
86-
*(.glue_7t) /* glue thumb to arm code */
87-
*(.eh_frame)
88-
89-
KEEP (*(.init))
90-
KEEP (*(.fini))
91-
92-
. = ALIGN(4);
93-
_etext = .; /* define a global symbols at end of code */
94-
} >FLASH
95-
96-
/* Constant data goes into FLASH */
97-
.rodata :
98-
{
99-
. = ALIGN(4);
100-
*(.rodata) /* .rodata sections (constants, strings, etc.) */
101-
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
102-
. = ALIGN(4);
103-
} >FLASH
104-
105-
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
106-
.ARM : {
107-
__exidx_start = .;
108-
*(.ARM.exidx*)
109-
__exidx_end = .;
110-
} >FLASH
111-
112-
.preinit_array :
113-
{
114-
PROVIDE_HIDDEN (__preinit_array_start = .);
115-
KEEP (*(.preinit_array*))
116-
PROVIDE_HIDDEN (__preinit_array_end = .);
117-
} >FLASH
118-
.init_array :
119-
{
120-
PROVIDE_HIDDEN (__init_array_start = .);
121-
KEEP (*(SORT(.init_array.*)))
122-
KEEP (*(.init_array*))
123-
PROVIDE_HIDDEN (__init_array_end = .);
124-
} >FLASH
125-
.fini_array :
126-
{
127-
PROVIDE_HIDDEN (__fini_array_start = .);
128-
KEEP (*(SORT(.fini_array.*)))
129-
KEEP (*(.fini_array*))
130-
PROVIDE_HIDDEN (__fini_array_end = .);
131-
} >FLASH
132-
133-
/* used by the startup to initialize data */
134-
_sidata = LOADADDR(.data);
135-
136-
/* Initialized data sections goes into RAM, load LMA copy after code */
137-
.data :
138-
{
139-
. = ALIGN(4);
140-
_sdata = .; /* create a global symbol at data start */
141-
*(.data) /* .data sections */
142-
*(.data*) /* .data* sections */
143-
144-
. = ALIGN(4);
145-
_edata = .; /* define a global symbol at data end */
146-
} >RAM AT> FLASH
147-
148-
149-
/* Uninitialized data section */
150-
. = ALIGN(4);
151-
.bss :
152-
{
153-
/* This is used by the startup in order to initialize the .bss secion */
154-
_sbss = .; /* define a global symbol at bss start */
155-
__bss_start__ = _sbss;
156-
*(.bss)
157-
*(.bss*)
158-
*(COMMON)
159-
160-
. = ALIGN(4);
161-
_ebss = .; /* define a global symbol at bss end */
162-
__bss_end__ = _ebss;
163-
} >RAM
164-
165-
/* User_heap_stack section, used to check that there is enough RAM left */
166-
._user_heap_stack :
167-
{
168-
. = ALIGN(8);
169-
PROVIDE ( end = . );
170-
PROVIDE ( _end = . );
171-
. = . + _Min_Heap_Size;
172-
. = . + _Min_Stack_Size;
173-
. = ALIGN(8);
174-
} >RAM
175-
176-
177-
178-
/* Remove information from the standard libraries */
179-
/DISCARD/ :
180-
{
181-
libc.a ( * )
182-
libm.a ( * )
183-
libgcc.a ( * )
184-
}
185-
186-
.ARM.attributes 0 : { *(.ARM.attributes) }
35+
/* The startup code goes first into FLASH */
36+
.isr_vector :
37+
{
38+
. = ALIGN(4);
39+
KEEP(*(.isr_vector)) /* Startup code */
40+
41+
/* This first flash block is 16K annd the isr vectors only take up
42+
about 400 bytes. Micropython pads this with files, but this didn't
43+
work with the size of Circuitpython's ff object. */
44+
45+
. = ALIGN(4);
46+
} >FLASH_ISR
47+
48+
/* The program code and other data goes into FLASH */
49+
.text :
50+
{
51+
. = ALIGN(4);
52+
*(.text*) /* .text* sections (code) */
53+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
54+
/* *(.glue_7) */ /* glue arm to thumb code */
55+
/* *(.glue_7t) */ /* glue thumb to arm code */
56+
57+
. = ALIGN(4);
58+
_etext = .; /* define a global symbol at end of code */
59+
} >FLASH_TEXT
60+
61+
/* used by the startup to initialize data */
62+
_sidata = LOADADDR(.data);
63+
64+
/* This is the initialized data section
65+
The program executes knowing that the data is in the RAM
66+
but the loader puts the initial values in the FLASH (inidata).
67+
It is one task of the startup to copy the initial values from FLASH to RAM. */
68+
.data :
69+
{
70+
. = ALIGN(4);
71+
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
72+
*(.data*) /* .data* sections */
73+
74+
. = ALIGN(4);
75+
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
76+
} >RAM AT> FLASH_TEXT
77+
78+
/* Uninitialized data section */
79+
.bss :
80+
{
81+
. = ALIGN(4);
82+
_sbss = .; /* define a global symbol at bss start; used by startup code */
83+
*(.bss*)
84+
*(COMMON)
85+
86+
. = ALIGN(4);
87+
_ebss = .; /* define a global symbol at bss end; used by startup code and GC */
88+
} >RAM
89+
90+
/* this is to define the start of the heap, and make sure we have a minimum size */
91+
.heap :
92+
{
93+
. = ALIGN(4);
94+
. = . + _minimum_heap_size;
95+
. = ALIGN(4);
96+
} >RAM
97+
98+
/* this just checks there is enough RAM for the stack */
99+
.stack :
100+
{
101+
. = ALIGN(4);
102+
. = . + _minimum_stack_size;
103+
. = ALIGN(4);
104+
} >RAM
105+
106+
.ARM.attributes 0 : { *(.ARM.attributes) }
187107
}
188108

189109

0 commit comments

Comments
 (0)