From 49bd13adc4ab51636744e613179328313acfcf61 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Mon, 27 Apr 2015 20:25:47 +0300 Subject: [PATCH] Move documentation example with creating especial platform to right place. --- docs/librarymanager/creating.rst | 114 -------------------------- docs/platforms/creating_platform.rst | 115 +++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 114 deletions(-) diff --git a/docs/librarymanager/creating.rst b/docs/librarymanager/creating.rst index c54b564e..88011f12 100644 --- a/docs/librarymanager/creating.rst +++ b/docs/librarymanager/creating.rst @@ -135,117 +135,3 @@ The registration requirements: Now, you can :ref:`register ` your library and allow others to :ref:`install ` it. -Examples --------- - -Create :ref:`platform_ststm32` based platform which uses GDB for uploading - -First of all, we need to create new folder ``platforms`` :ref:`projectconf_pio_home_dir` and copy there two files: - -1. Platform manifest file ``ststm32gdb.py`` with the next content: - -.. code-block:: python - - import os - - from platformio.platforms.ststm32 import Ststm32Platform - - - class Ststm32gdbPlatform(Ststm32Platform): - - """ - ST STM32 using GDB as uploader - - http://www.st.com/web/en/catalog/mmc/FM141/SC1169?sc=stm32 - """ - - def get_build_script(self): - - return os.path.join( - os.path.dirname(os.path.realpath(__file__)), - "ststm32gdb-builder.py" - ) - -2. Build script file ``ststm32gdb-builder.py`` with the next content: - -.. code-block:: python - - """ - Builder for ST STM32 Series ARM microcontrollers with GDB upload. - """ - - from os.path import join - - from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, - DefaultEnvironment, SConscript) - - - env = DefaultEnvironment() - - SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) - - env.Replace( - UPLOADER=join( - "$PIOPACKAGES_DIR", "toolchain-gccarmnoneeabi", - "bin", "arm-none-eabi-gdb" - ), - UPLOADERFLAGS=[ - join("$BUILD_DIR", "firmware.elf"), - "-batch", - "-x", join("$PROJECT_DIR", "upload.gdb") - ], - - UPLOADCMD="$UPLOADER $UPLOADERFLAGS" - ) - - env.Append( - CPPDEFINES=[ - "${BOARD_OPTIONS['build']['variant'].upper()}" - ], - - LINKFLAGS=[ - "-nostartfiles", - "-nostdlib" - ] - ) - - # - # Target: Build executable and linkable firmware - # - - target_elf = env.BuildFirmware() - - # - # Target: Build the .bin file - # - - if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.bin") - else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) - - # - # Target: Print binary size - # - - target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") - AlwaysBuild(target_size) - - # - # Target: Upload by default .bin file - # - - upload = env.Alias( - ["upload", "uploadlazy"], target_firm, "$UPLOADCMD") - AlwaysBuild(upload) - - # - # Target: Define targets - # - - Default([target_firm, target_size]) - -You should see ststm32gdb platform in ``platformio search`` command output. -Now, you can install new platform via :ref:`platformio install ststm32gdb ` command. - -For more detailed information how to use this platform please follow to `issue 175 `_ diff --git a/docs/platforms/creating_platform.rst b/docs/platforms/creating_platform.rst index 811a4038..1bb556cb 100644 --- a/docs/platforms/creating_platform.rst +++ b/docs/platforms/creating_platform.rst @@ -300,3 +300,118 @@ Installation Now, you can use ``test`` for the :ref:`projectconf_env_platform` option in :ref:`projectconf`. + +Examples +-------- + +Create :ref:`platform_ststm32` based platform which uses GDB for uploading + +First of all, we need to create new folder ``platforms`` :ref:`projectconf_pio_home_dir` and copy there two files: + +1. Platform manifest file ``ststm32gdb.py`` with the next content: + +.. code-block:: python + + import os + + from platformio.platforms.ststm32 import Ststm32Platform + + + class Ststm32gdbPlatform(Ststm32Platform): + + """ + ST STM32 using GDB as uploader + + http://www.st.com/web/en/catalog/mmc/FM141/SC1169?sc=stm32 + """ + + def get_build_script(self): + + return os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "ststm32gdb-builder.py" + ) + +2. Build script file ``ststm32gdb-builder.py`` with the next content: + +.. code-block:: python + + """ + Builder for ST STM32 Series ARM microcontrollers with GDB upload. + """ + + from os.path import join + + from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, + DefaultEnvironment, SConscript) + + + env = DefaultEnvironment() + + SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) + + env.Replace( + UPLOADER=join( + "$PIOPACKAGES_DIR", "toolchain-gccarmnoneeabi", + "bin", "arm-none-eabi-gdb" + ), + UPLOADERFLAGS=[ + join("$BUILD_DIR", "firmware.elf"), + "-batch", + "-x", join("$PROJECT_DIR", "upload.gdb") + ], + + UPLOADCMD="$UPLOADER $UPLOADERFLAGS" + ) + + env.Append( + CPPDEFINES=[ + "${BOARD_OPTIONS['build']['variant'].upper()}" + ], + + LINKFLAGS=[ + "-nostartfiles", + "-nostdlib" + ] + ) + + # + # Target: Build executable and linkable firmware + # + + target_elf = env.BuildFirmware() + + # + # Target: Build the .bin file + # + + if "uploadlazy" in COMMAND_LINE_TARGETS: + target_firm = join("$BUILD_DIR", "firmware.bin") + else: + target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) + + # + # Target: Print binary size + # + + target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") + AlwaysBuild(target_size) + + # + # Target: Upload by default .bin file + # + + upload = env.Alias( + ["upload", "uploadlazy"], target_firm, "$UPLOADCMD") + AlwaysBuild(upload) + + # + # Target: Define targets + # + + Default([target_firm, target_size]) + +You should see ``ststm32gdb`` platform in :ref:`platformio search ` command output. +Now, you can install new platform via :ref:`platformio install ststm32gdb ` command. + +For more detailed information how to use this platform please follow to `issue 175 `_