Skip to content

Commit f414f2b

Browse files
authored
Merge pull request #2723 from jgillick/jgillick/circuitpython/stm32f411
Add new STM board: Thunderpack
2 parents 385ea9d + 8ed4dee commit f414f2b

File tree

13 files changed

+870
-0
lines changed

13 files changed

+870
-0
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ jobs:
229229
- "stringcar_m0_express"
230230
- "teensy40"
231231
- "teknikio_bluebird"
232+
- "thunderpack"
232233
- "trellis_m4_express"
233234
- "trinket_m0"
234235
- "trinket_m0_haxpress"
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
GNU linker script for STM32F411 via Micropython
3+
*/
4+
5+
/* Specify the memory areas */
6+
MEMORY
7+
{
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 = 32K /* sectors 1,2 are 16K */
11+
FLASH_NVM (rwx) : ORIGIN = 0x0800C000, LENGTH = 16K /* sector 3 is 16K */
12+
FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */
13+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
14+
}
15+
16+
/* produce a link error if there is not this amount of RAM for these sections */
17+
_minimum_stack_size = 2K;
18+
_minimum_heap_size = 16K;
19+
20+
/* Define the top end of the stack. The stack is full descending so begins just
21+
above last byte of RAM. Note that EABI requires the stack to be 8-byte
22+
aligned for a call. */
23+
_estack = ORIGIN(RAM) + LENGTH(RAM);
24+
25+
/* RAM extents for the garbage collector */
26+
_ram_start = ORIGIN(RAM);
27+
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
28+
_heap_start = _ebss; /* heap starts just after statically allocated memory */
29+
_heap_end = 0x2001c000; /* tunable */
30+
31+
ENTRY(Reset_Handler)
32+
33+
/* define output sections */
34+
SECTIONS
35+
{
36+
/* The startup code goes first into FLASH */
37+
.isr_vector :
38+
{
39+
. = ALIGN(4);
40+
KEEP(*(.isr_vector)) /* Startup code */
41+
42+
/* This first flash block is 16K annd the isr vectors only take up
43+
about 400 bytes. Micropython pads this with files, but this didn't
44+
work with the size of Circuitpython's ff object. */
45+
46+
. = ALIGN(4);
47+
} >FLASH_ISR
48+
49+
/* Non-volitile memory */
50+
.nvm_data :
51+
{
52+
. = ALIGN(4);
53+
KEEP(*(.nvm_data))
54+
. = ALIGN(4);
55+
} >FLASH_NVM
56+
57+
/* The program code and other data goes into FLASH */
58+
.text :
59+
{
60+
. = ALIGN(4);
61+
*(.text*) /* .text* sections (code) */
62+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
63+
/* *(.glue_7) */ /* glue arm to thumb code */
64+
/* *(.glue_7t) */ /* glue thumb to arm code */
65+
66+
. = ALIGN(4);
67+
_etext = .; /* define a global symbol at end of code */
68+
} >FLASH_TEXT
69+
70+
/* used by the startup to initialize data */
71+
_sidata = LOADADDR(.data);
72+
73+
/* This is the initialized data section
74+
The program executes knowing that the data is in the RAM
75+
but the loader puts the initial values in the FLASH (inidata).
76+
It is one task of the startup to copy the initial values from FLASH to RAM. */
77+
.data :
78+
{
79+
. = ALIGN(4);
80+
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
81+
*(.data*) /* .data* sections */
82+
83+
. = ALIGN(4);
84+
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
85+
} >RAM AT> FLASH_TEXT
86+
87+
/* Uninitialized data section */
88+
.bss :
89+
{
90+
. = ALIGN(4);
91+
_sbss = .; /* define a global symbol at bss start; used by startup code */
92+
*(.bss*)
93+
*(COMMON)
94+
95+
. = ALIGN(4);
96+
_ebss = .; /* define a global symbol at bss end; used by startup code and GC */
97+
} >RAM
98+
99+
/* this is to define the start of the heap, and make sure we have a minimum size */
100+
.heap :
101+
{
102+
. = ALIGN(4);
103+
. = . + _minimum_heap_size;
104+
. = ALIGN(4);
105+
} >RAM
106+
107+
/* this just checks there is enough RAM for the stack */
108+
.stack :
109+
{
110+
. = ALIGN(4);
111+
. = . + _minimum_stack_size;
112+
. = ALIGN(4);
113+
} >RAM
114+
115+
.ARM.attributes 0 : { *(.ARM.attributes) }
116+
}
117+
118+

ports/stm/boards/thunderpack/board.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "boards/board.h"
28+
29+
void board_init(void) {
30+
}
31+
32+
bool board_requests_safe_mode(void) {
33+
return false;
34+
}
35+
36+
void reset_board(void) {
37+
38+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
#define MICROPY_HW_BOARD_NAME "THUNDERPACK"
27+
#define MICROPY_HW_MCU_NAME "STM32F411CE"
28+
29+
// Non-volatile memory config
30+
#define CIRCUITPY_INTERNAL_NVM_SIZE (0x4000)
31+
#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x0800C000)
32+
#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_3
33+
34+
// Putting the entire flash sector in the NVM byte array buffer
35+
// would take up too much RAM. This limits how much of the sector we use.
36+
#define NVM_BYTEARRAY_BUFFER_SIZE 512
37+
38+
// Flash config
39+
#define FLASH_SIZE (0x80000)
40+
#define FLASH_PAGE_SIZE (0x4000)
41+
#define BOARD_FLASH_SIZE (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE- 0x2000 - 0xC000)
42+
43+
#define BOARD_OSC_DIV (24)
44+
#define BOARD_OVERWRITE_SWD (1)
45+
#define BOARD_NO_VBUS_SENSE (1)
46+
47+
// Status LEDs
48+
#define MICROPY_HW_LED_STATUS (&pin_PA02)
49+
50+
#define DEFAULT_I2C_BUS_SCL (&pin_PB06)
51+
#define DEFAULT_I2C_BUS_SDA (&pin_PB07)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
USB_VID = 0x239A
2+
USB_PID = 0x806A
3+
USB_PRODUCT = "Thunderpack STM32F411"
4+
USB_MANUFACTURER = "Jeremy Gillick"
5+
USB_DEVICES = "CDC,MSC"
6+
7+
INTERNAL_FLASH_FILESYSTEM = 1
8+
LONGINT_IMPL = NONE
9+
10+
CIRCUITPY_NVM = 1
11+
12+
MCU_SERIES = m4
13+
MCU_VARIANT = stm32f4
14+
MCU_SUB_VARIANT = stm32f411xe
15+
MCU_PACKAGE = 48
16+
CMSIS_MCU = STM32F411xE
17+
LD_FILE = boards/STM32F411VETx_nvm_FLASH.ld
18+
STARTUP_FILE = startup_stm32f411xe.s
19+
20+

ports/stm/boards/thunderpack/pins.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "shared-bindings/board/__init__.h"
2+
3+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
4+
{ MP_ROM_QSTR(MP_QSTR_PA0), MP_ROM_PTR(&pin_PA00) },
5+
{ MP_ROM_QSTR(MP_QSTR_PA1), MP_ROM_PTR(&pin_PA01) },
6+
{ MP_ROM_QSTR(MP_QSTR_PA2), MP_ROM_PTR(&pin_PA02) },
7+
{ MP_ROM_QSTR(MP_QSTR_PA3), MP_ROM_PTR(&pin_PA03) },
8+
{ MP_ROM_QSTR(MP_QSTR_PA4), MP_ROM_PTR(&pin_PA04) },
9+
{ MP_ROM_QSTR(MP_QSTR_PA5), MP_ROM_PTR(&pin_PA05) },
10+
{ MP_ROM_QSTR(MP_QSTR_PA6), MP_ROM_PTR(&pin_PA06) },
11+
{ MP_ROM_QSTR(MP_QSTR_PA7), MP_ROM_PTR(&pin_PA07) },
12+
{ MP_ROM_QSTR(MP_QSTR_PA8), MP_ROM_PTR(&pin_PA08) },
13+
{ MP_ROM_QSTR(MP_QSTR_PA9), MP_ROM_PTR(&pin_PA09) },
14+
{ MP_ROM_QSTR(MP_QSTR_PA10), MP_ROM_PTR(&pin_PA10) },
15+
{ MP_ROM_QSTR(MP_QSTR_PA13), MP_ROM_PTR(&pin_PA13) },
16+
{ MP_ROM_QSTR(MP_QSTR_PA14), MP_ROM_PTR(&pin_PA14) },
17+
18+
{ MP_ROM_QSTR(MP_QSTR_PB5), MP_ROM_PTR(&pin_PB05) },
19+
{ MP_ROM_QSTR(MP_QSTR_PB6), MP_ROM_PTR(&pin_PB06) },
20+
{ MP_ROM_QSTR(MP_QSTR_PB7), MP_ROM_PTR(&pin_PB07) },
21+
22+
{ MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_PA00) },
23+
{ MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_PA01) },
24+
{ MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_PA02) },
25+
{ MP_ROM_QSTR(MP_QSTR_LED4), MP_ROM_PTR(&pin_PA03) },
26+
27+
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_PB04) },
28+
29+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) },
30+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) },
31+
32+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
33+
};
34+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

0 commit comments

Comments
 (0)