Skip to content

STM32: Meowbit support #2404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
d8d95d9
Minor meowbit changes
hierophect Nov 20, 2019
00e953e
delete old boards
hierophect Dec 9, 2019
b0a5e81
Merge remote-tracking branch 'upstream/master' into stm32-meowbit
hierophect Dec 9, 2019
e328e9c
minor text changes
hierophect Dec 10, 2019
70d899d
WIP to successful USB test
hierophect Dec 11, 2019
9339903
Revert "delete old boards"
hierophect Dec 12, 2019
842f8b2
Revert "Remove meowbit for now"
hierophect Dec 12, 2019
2be18a7
revert dumb thing
hierophect Dec 12, 2019
7e07191
Revert "remove F401 additions to streamline"
hierophect Dec 12, 2019
ab3762d
Merge branch 'dumb-git-stuff' into stm32-meowbit
hierophect Dec 12, 2019
e4fb414
clean up definitions post merge
hierophect Dec 12, 2019
99c02b5
usb not working...
hierophect Dec 12, 2019
4bfb255
merge Thach's suggestion
hierophect Dec 17, 2019
f136ef2
add most remaining pindefs
hierophect Dec 17, 2019
ba19cd9
Internal filesystem displayIO test
hierophect Dec 17, 2019
3a5de7e
Remove merge overflow
hierophect Dec 18, 2019
5b70fa0
enable internal SPI intercepts. can brick USB
hierophect Dec 18, 2019
902e242
Revert "enable internal SPI intercepts. can brick USB"
hierophect Dec 18, 2019
5b9209a
Merge remote-tracking branch 'upstream/master' into stm32-meowbit
hierophect Dec 30, 2019
28b1d71
Tests for PWM issues, style changes
hierophect Dec 30, 2019
36088be
PWM Fix, plus debugging
hierophect Jan 4, 2020
d0fab1c
Clean up debugging edits
hierophect Jan 4, 2020
53238ad
yaml changes
hierophect Jan 4, 2020
f355642
Boot linker edits
hierophect Jan 4, 2020
7198cc8
Changes to UF2 settings, reboot working, no usb
hierophect Jan 6, 2020
fff5f8e
Merge remote-tracking branch 'upstream/master' into stm32-meowbit
hierophect Jan 6, 2020
0bbeae1
WIP edits
hierophect Jan 6, 2020
1229de4
attempt to get control going again
hierophect Jan 10, 2020
1544d60
working control
hierophect Jan 10, 2020
de2379b
minor WIP debug edits
hierophect Jan 13, 2020
c0dacba
remove comment confusing py tools
hierophect Jan 14, 2020
05093f7
Fix VTOR relocate, add bootloader makefile handling
hierophect Jan 14, 2020
1070f2c
Merge remote-tracking branch 'upstream/master' into stm32-meowbit
hierophect Jan 14, 2020
3f43155
Meowbit bus conflict WIP
hierophect Jan 17, 2020
b326ee0
fix microcontroller pin ommission
Jan 22, 2020
3679292
Revert dangling pointer issue in PWMOut
hierophect Jan 22, 2020
e9f9cee
Invert duty cycle intensity
hierophect Jan 22, 2020
d8bc57c
Flash and display control
hierophect Jan 23, 2020
2afca4e
Fix flash-display conflict error
hierophect Jan 24, 2020
70932ca
Simplify the flash-display conflict fix
hierophect Jan 24, 2020
b5b94b7
Return to bootloader options
hierophect Jan 24, 2020
ab9483b
Add internal display definitions, fails at startup
hierophect Jan 28, 2020
3c86005
Implement requested changes
hierophect Jan 28, 2020
8a9c309
Add port-specific requested changes
hierophect Jan 29, 2020
b9bed98
Merge stm32-meowbit
hierophect Jan 29, 2020
1004099
Move board_init to main.c
hierophect Jan 29, 2020
898f4e1
Merge branch 'master' into stm32-meowbit
hierophect Jan 29, 2020
1a25d3c
fix merge issue
hierophect Jan 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ jobs:
- "kicksat-sprite"
- "makerdiary_nrf52840_mdk"
- "makerdiary_nrf52840_mdk_usb_dongle"
- "meowbit_v121"
- "meowmeow"
- "metro_m0_express"
- "metro_m4_airlift_lite"
Expand Down
5 changes: 5 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
#include "supervisor/shared/stack.h"
#include "supervisor/serial.h"

#include "boards/board.h"

#if CIRCUITPY_DISPLAYIO
#include "shared-module/displayio/__init__.h"
#endif
Expand Down Expand Up @@ -425,6 +427,9 @@ int __attribute__((used)) main(void) {
// no SPI flash filesystem, and we might erase the existing one.
filesystem_init(safe_mode == NO_SAFE_MODE, false);

// displays init after filesystem, since they could share the flash SPI
board_init();

// Reset everything and prep MicroPython to run boot.py.
reset_port();
reset_board();
Expand Down
3 changes: 0 additions & 3 deletions ports/atmel-samd/supervisor/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ safe_mode_t port_init(void) {
// Reset everything into a known state before board_init.
reset_port();

// Init the board last so everything else is ready
board_init();

#ifdef SAMD21
if (PM->RCAUSE.bit.BOD33 == 1 || PM->RCAUSE.bit.BOD12 == 1) {
return BROWNOUT;
Expand Down
3 changes: 0 additions & 3 deletions ports/mimxrt10xx/supervisor/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,6 @@ safe_mode_t port_init(void) {
// Reset everything into a known state before board_init.
reset_port();

// Init the board last so everything else is ready
board_init();

if (board_requests_safe_mode()) {
return USER_SAFE_MODE;
}
Expand Down
3 changes: 0 additions & 3 deletions ports/nrf/supervisor/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ safe_mode_t port_init(void) {
rtc_init();
#endif

// Will do usb_init() if chip supports USB.
board_init();

return NO_SAFE_MODE;
}

Expand Down
9 changes: 7 additions & 2 deletions ports/stm32f4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
DEBUG = 1
# DEBUG = 1

# Select the board to build for.
ifeq ($(BOARD),)
Expand Down Expand Up @@ -85,10 +85,15 @@ ifeq ($(DEBUG), 1)
CFLAGS += -fno-inline -fno-ipa-sra
else
CFLAGS += -Os -DNDEBUG
CFLAGS += -ggdb
# TODO: Test with -flto
### CFLAGS += -flto
endif

ifndef BOOTLOADER_OFFSET
BOOTLOADER_OFFSET := 0x8000000
endif

C_DEFS = -DMCU_PACKAGE=$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(CMSIS_MCU)

CFLAGS += $(INC) -Werror -Wall -std=gnu11 -nostdlib $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
Expand Down Expand Up @@ -256,7 +261,7 @@ $(BUILD)/firmware.hex: $(BUILD)/firmware.elf

$(BUILD)/firmware.uf2: $(BUILD)/firmware.hex
$(ECHO) "Create $@"
$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/firmware.uf2" $^
$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b $(BOOTLOADER_OFFSET) -c -o "$(BUILD)/firmware.uf2" $^

include $(TOP)/py/mkrules.mk

Expand Down
132 changes: 132 additions & 0 deletions ports/stm32f4/boards/STM32F401.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
GNU linker script for STM32F401 with bootloader (from Meowbit Micropython)
Doesn't work:

Traceback (most recent call last):
File "../../tools/build_memory_info.py", line 64, in <module>
regions[region] = int(eval(space))
File "<string>", line 1, in <module>
NameError: name 'FLASH_ISR' is not defined
*/

/* Specify the memory areas */
/* FLASH_FS (rx) : ORIGIN = 0x08020000, LENGTH = 128K */
/* sectors 5 128K */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash */
FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K /* sector 4, sec 0~3 reserved for booloader */
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sectors 5, 6,7 are 128K */
RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194
}

/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 2K;
_minimum_heap_size = 16K;

/* Define the stack. The stack is full descending so begins just above last byte
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM) - _estack_reserve;
_sstack = _estack - 16K; /* tunable */

/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
_heap_start = _ebss; /* heap starts just after statically allocated memory */
_heap_end = _sstack;

ENTRY(Reset_Handler)

/* define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */

/* This first flash block is 16K annd the isr vectors only take up
about 400 bytes. So we pull in a couple of object files to pad it
out. */

. = ALIGN(4);

/* NOTE: If you update the list of files contained in .isr_vector,
then be sure to also update smhal/Makefile where it forcibly
builds each of these files with -Os */

*/ff.o(.text*)
*/vfs_fat_*.o(.text*)
*/py/formatfloat.o(.text*)
*/py/parsenum.o(.text*)
*/py/mpprint.o(.text*)

*/py/compile.o(.text*)
*/py/objset.o(.text*)
*/py/mpz.o(.text*)
*/py/vm.o(.text*)

. = ALIGN(4);
} >FLASH_ISR

/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text*) /* .text* sections (code) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
/* *(.glue_7) */ /* glue arm to thumb code */
/* *(.glue_7t) */ /* glue thumb to arm code */

. = ALIGN(4);
_etext = .; /* define a global symbol at end of code */
} >FLASH_TEXT

/* used by the startup to initialize data */
_sidata = LOADADDR(.data);

/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
It is one task of the startup to copy the initial values from FLASH to RAM. */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
*(.data*) /* .data* sections */

. = ALIGN(4);
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
} >RAM AT> FLASH_TEXT

/* Uninitialized data section */
.bss :
{
. = ALIGN(4);
_sbss = .; /* define a global symbol at bss start; used by startup code */
*(.bss*)
*(COMMON)

. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end; used by startup code and GC */
} >RAM

/* this is to define the start of the heap, and make sure we have a minimum size */
.heap :
{
. = ALIGN(4);
. = . + _minimum_heap_size;
. = ALIGN(4);
} >RAM

/* this just checks there is enough RAM for the stack */
.stack :
{
. = ALIGN(4);
. = . + _minimum_stack_size;
. = ALIGN(4);
} >RAM

.ARM.attributes 0 : { *(.ARM.attributes) }
}
106 changes: 106 additions & 0 deletions ports/stm32f4/boards/STM32F401_boot.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
GNU linker script for STM32F401 with bootloader (such as the Meowbit)
*/

/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash */
FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sector 4 is 64K, sectors 5,6,7 are 128K */
RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194
}

/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 2K;
_minimum_heap_size = 16K;

/* Define tho top end of the stack. The stack is full descending so begins just
above last byte of RAM. Note that EABI requires the stack to be 8-byte
aligned for a call. */
_estack = ORIGIN(RAM) + LENGTH(RAM);

/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

ENTRY(Reset_Handler)

/* define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */

/* This first flash block is 16K annd the isr vectors only take up
about 400 bytes. Micropython pads this with files, but this didn't
work with the size of Circuitpython's ff object. */

. = ALIGN(4);
} >FLASH_ISR

/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text*) /* .text* sections (code) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
/* *(.glue_7) */ /* glue arm to thumb code */
/* *(.glue_7t) */ /* glue thumb to arm code */

. = ALIGN(4);
_etext = .; /* define a global symbol at end of code */
} >FLASH_TEXT

/* used by the startup to initialize data */
_sidata = LOADADDR(.data);

/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
It is one task of the startup to copy the initial values from FLASH to RAM. */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
*(.data*) /* .data* sections */

. = ALIGN(4);
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
} >RAM AT> FLASH_TEXT

/* Uninitialized data section */
.bss :
{
. = ALIGN(4);
_sbss = .; /* define a global symbol at bss start; used by startup code */
*(.bss*)
*(COMMON)

. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end; used by startup code and GC */
} >RAM

/* this is to define the start of the heap, and make sure we have a minimum size */
.heap :
{
. = ALIGN(4);
. = . + _minimum_heap_size;
. = ALIGN(4);
} >RAM

/* this just checks there is enough RAM for the stack */
.stack :
{
. = ALIGN(4);
. = . + _minimum_stack_size;
. = ALIGN(4);
} >RAM

.ARM.attributes 0 : { *(.ARM.attributes) }
}


Loading