mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Implement STM32 platform with support for Discovery boards
This commit is contained in:
@ -1,31 +1,49 @@
|
|||||||
{
|
{
|
||||||
"STM32F4DISCOVERY": {
|
"stm32f4discovery": {
|
||||||
"build": {
|
"build": {
|
||||||
"core": "STM32F4",
|
"core": "stm32",
|
||||||
"f_cpu": "1680000000L",
|
"f_cpu": "168000000L",
|
||||||
"ldscript": "STM32F407VGT6.ld",
|
"ldscript": "stm32f405x6.ld",
|
||||||
"mcu": "cortex-m4",
|
"mcu": "cortex-m4",
|
||||||
"variant": "STM32F407VGT6"
|
"variant": "stm32f4",
|
||||||
|
"extra_flags": "-DSTM32F40_41xxx"
|
||||||
},
|
},
|
||||||
"name": "STM32F4DISCOVERY (168 MHz)",
|
"name": "STM32F4Discovery (168 MHz) with digital accelerometer, digital microphone, audio DAC",
|
||||||
"platform": "stm32",
|
"platform": "stm32",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 131071,
|
"maximum_ram_size": 131071,
|
||||||
"maximum_size": 1048575
|
"maximum_size": 1048575
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"STM32VLDISCOVERY": {
|
"stm32ldiscovery": {
|
||||||
"build": {
|
"build": {
|
||||||
"core": "STM32F1",
|
"core": "stm32",
|
||||||
"f_cpu": "240000000L",
|
"f_cpu": "32000000L",
|
||||||
"ldscript": "STM32F100RBT6.ld",
|
"ldscript": "stm32l15xx6.ld",
|
||||||
"mcu": "cortex-m3",
|
"mcu": "cortex-m3",
|
||||||
"variant": "STM32F100RBT6"
|
"variant": "stm32l1",
|
||||||
|
"extra_flags": "-DSTM32L1XX_MD"
|
||||||
},
|
},
|
||||||
"name": "STM32VLDISCOVERY (24 MHz)",
|
"name": "STM32LDiscovery (32 MHz) ultra low-power development kit",
|
||||||
"platform": "stm32",
|
"platform": "stm32",
|
||||||
"upload": {
|
"upload": {
|
||||||
"maximum_ram_size": 8192,
|
"maximum_ram_size": 16384,
|
||||||
|
"maximum_size": 131072
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"stm32f3discovery": {
|
||||||
|
"build": {
|
||||||
|
"core": "stm32",
|
||||||
|
"f_cpu": "72000000L",
|
||||||
|
"ldscript": "stm32f30xx.ld",
|
||||||
|
"mcu": "cortex-m4",
|
||||||
|
"variant": "stm32f3",
|
||||||
|
"extra_flags": "-DSTM32F303xC"
|
||||||
|
},
|
||||||
|
"name": "STM32F3Discovery (72 MHz) with accelerometer, gyroscope and e-compass",
|
||||||
|
"platform": "stm32",
|
||||||
|
"upload": {
|
||||||
|
"maximum_ram_size": 262144,
|
||||||
"maximum_size": 131072
|
"maximum_size": 131072
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
142
platformio/builder/scripts/stm32.py
Normal file
142
platformio/builder/scripts/stm32.py
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||||
|
# See LICENSE for details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
Builder for STMicroelectronics
|
||||||
|
STM32 Series ARM microcontrollers.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from os.path import join
|
||||||
|
|
||||||
|
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
||||||
|
DefaultEnvironment)
|
||||||
|
|
||||||
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
|
env.Replace(
|
||||||
|
AR="arm-none-eabi-ar",
|
||||||
|
AS="arm-none-eabi-gcc",
|
||||||
|
CC="arm-none-eabi-gcc",
|
||||||
|
CXX="arm-none-eabi-g++",
|
||||||
|
OBJCOPY="arm-none-eabi-objcopy",
|
||||||
|
RANLIB="arm-none-eabi-ranlib",
|
||||||
|
|
||||||
|
ARFLAGS=["rcs"],
|
||||||
|
|
||||||
|
ASFLAGS=[
|
||||||
|
"-c",
|
||||||
|
"-g", # include debugging info (so errors include line numbers)
|
||||||
|
"-x", "assembler-with-cpp",
|
||||||
|
"-Wall",
|
||||||
|
"-mthumb",
|
||||||
|
"-mcpu=${BOARD_OPTIONS['build']['mcu']}"
|
||||||
|
],
|
||||||
|
|
||||||
|
CCFLAGS=[
|
||||||
|
"-g", # include debugging info (so errors include line numbers)
|
||||||
|
"-Os", # optimize for size
|
||||||
|
"-ffunction-sections", # place each function in its own section
|
||||||
|
"-fdata-sections",
|
||||||
|
"-Wall",
|
||||||
|
"-mthumb",
|
||||||
|
"-mcpu=${BOARD_OPTIONS['build']['mcu']}",
|
||||||
|
"-MMD" # output dependancy info
|
||||||
|
],
|
||||||
|
|
||||||
|
CXXFLAGS=[
|
||||||
|
"-fno-rtti",
|
||||||
|
"-fno-exceptions"
|
||||||
|
],
|
||||||
|
|
||||||
|
UPLOADER=join("$PIOPACKAGES_DIR", "tool-stlink", "st-flash"),
|
||||||
|
UPLOADERFLAGS=[
|
||||||
|
"write", # write in flash
|
||||||
|
"$SOURCES", # firmware path to flash
|
||||||
|
"0x08000000" # flash start adress
|
||||||
|
],
|
||||||
|
|
||||||
|
UPLOADCMD="$UPLOADER $UPLOADERFLAGS"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
env.Append(
|
||||||
|
CPPDEFINES=[
|
||||||
|
"F_CPU=$BOARD_F_CPU",
|
||||||
|
"${BOARD_OPTIONS['build']['variant'].upper()}"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
env.Append(
|
||||||
|
LINKFLAGS=[
|
||||||
|
"-Os",
|
||||||
|
"-nostartfiles",
|
||||||
|
"-nostdlib",
|
||||||
|
"-Wl,--gc-sections",
|
||||||
|
"-mthumb",
|
||||||
|
"-mcpu=${BOARD_OPTIONS['build']['mcu']}"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
if (env.get("BOARD_OPTIONS", {}).get("build", {}).get("mcu")[-2:] == "m4"):
|
||||||
|
env.Append(
|
||||||
|
ASFLAGS=[
|
||||||
|
"-mfloat-abi=hard",
|
||||||
|
"-mfpu=fpv4-sp-d16",
|
||||||
|
"-fsingle-precision-constant"
|
||||||
|
],
|
||||||
|
CCFLAGS=[
|
||||||
|
"-mfloat-abi=hard",
|
||||||
|
"-mfpu=fpv4-sp-d16",
|
||||||
|
"-fsingle-precision-constant"
|
||||||
|
],
|
||||||
|
LINKFLAGS=[
|
||||||
|
"-mfloat-abi=hard",
|
||||||
|
"-mfpu=fpv4-sp-d16",
|
||||||
|
"-fsingle-precision-constant"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
env.Append(
|
||||||
|
BUILDERS=dict(
|
||||||
|
ElfToBin=Builder(
|
||||||
|
action=" ".join([
|
||||||
|
"$OBJCOPY",
|
||||||
|
"-O",
|
||||||
|
"binary",
|
||||||
|
"$SOURCES",
|
||||||
|
"$TARGET"]),
|
||||||
|
suffix=".bin"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
CORELIBS = env.ProcessGeneral()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Target: Build executable and linkable firmware
|
||||||
|
#
|
||||||
|
|
||||||
|
target_elf = env.BuildFirmware(CORELIBS + ["c", "gcc", "m", "nosys"])
|
||||||
|
print(target_elf)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Target: Build the .bin file
|
||||||
|
#
|
||||||
|
|
||||||
|
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||||
|
target_bin = join("$BUILD_DIR", "firmware.bin")
|
||||||
|
else:
|
||||||
|
target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Target: Upload by default .bin file
|
||||||
|
#
|
||||||
|
|
||||||
|
upload = env.Alias(["upload", "uploadlazy"], target_bin, ("$UPLOADCMD"))
|
||||||
|
AlwaysBuild(upload)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Target: Define targets
|
||||||
|
#
|
||||||
|
|
||||||
|
Default(target_bin)
|
27
platformio/platforms/stm32.py
Normal file
27
platformio/platforms/stm32.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||||
|
# See LICENSE for details.
|
||||||
|
|
||||||
|
from platformio.platforms.base import BasePlatform
|
||||||
|
|
||||||
|
|
||||||
|
class Stm32Platform(BasePlatform):
|
||||||
|
"""
|
||||||
|
An embedded platform for STMicroelectronics ARM microcontrollers
|
||||||
|
"""
|
||||||
|
|
||||||
|
PACKAGES = {
|
||||||
|
|
||||||
|
"toolchain-gccarmnoneeabi": {
|
||||||
|
"alias": "toolchain",
|
||||||
|
"default": True
|
||||||
|
},
|
||||||
|
|
||||||
|
"ldscripts": {
|
||||||
|
"default": True
|
||||||
|
},
|
||||||
|
|
||||||
|
"tool-stlink": {
|
||||||
|
"alias": "uploader",
|
||||||
|
"default": True
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user