From 60a1242c90aa73369f69fb209be32914ff9d4c65 Mon Sep 17 00:00:00 2001 From: Timo Sandmann Date: Wed, 1 Jun 2022 17:22:46 +0200 Subject: [PATCH] Create eep file if using VSCode instead of Eclipse Building the EEPROM image file was missing when using VSCode as IDE or platformio CLI --- mcu_post_build.py | 23 +++++++++++++++++++++++ mcu_pre_build.py | 21 +++++++++++++++++++++ native_linkflags.py | 2 ++ platformio.ini | 7 ++++++- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 mcu_post_build.py create mode 100644 mcu_pre_build.py diff --git a/mcu_post_build.py b/mcu_post_build.py new file mode 100644 index 00000000..13a464dc --- /dev/null +++ b/mcu_post_build.py @@ -0,0 +1,23 @@ +# +# c't-Bot +# +# This program is free software; you can redistribute it +# and/or modify it under the terms of the GNU General +# Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your +# option) any later version. +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307, USA. + + +Import("env") + +env.AddPostAction("$BUILD_DIR/${PROGNAME}.elf", env.VerboseAction(" ".join(["$OBJCOPY", "-j", ".eeprom --set-section-flags=.eeprom='alloc,load'", + "--change-section-lma", ".eeprom=0", "-O", "ihex", '"$BUILD_DIR/${PROGNAME}.elf"', '"$BUILD_DIR/${PROGNAME}.eep"']), "Building $BUILD_DIR/${PROGNAME}.eep") +) diff --git a/mcu_pre_build.py b/mcu_pre_build.py new file mode 100644 index 00000000..93ef3f0e --- /dev/null +++ b/mcu_pre_build.py @@ -0,0 +1,21 @@ +# +# c't-Bot +# +# This program is free software; you can redistribute it +# and/or modify it under the terms of the GNU General +# Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your +# option) any later version. +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307, USA. + + +Import("env") + +env.Replace(PROGNAME="ct-Bot") diff --git a/native_linkflags.py b/native_linkflags.py index fdb5ddcf..2608d5f3 100644 --- a/native_linkflags.py +++ b/native_linkflags.py @@ -20,6 +20,8 @@ Import("env") +env.Replace(PROGNAME="ct-Bot") + if "windows" in get_systype(): env.Append( LIBS=[ diff --git a/platformio.ini b/platformio.ini index c5c83f3b..bca35ecf 100644 --- a/platformio.ini +++ b/platformio.ini @@ -19,6 +19,9 @@ board_build.f_cpu = 16000000UL ;board_build.f_cpu = 20000000UL build_unflags = -std=gnu++11 -fno-fat-lto-objects -flto -fuse-linker-plugin build_flags = -std=gnu++17 -Wextra -Wmissing-declarations -Wshadow -Wformat=2 -Wconversion -DMCU -Iinclude -Iinclude/bot-logic -Imcu/SdFat +extra_scripts = + pre:mcu_pre_build.py + post:mcu_post_build.py upload_protocol = avr109 upload_flags = -u @@ -30,6 +33,7 @@ platform = ${mcu.platform} board_build.f_cpu = ${mcu.board_build.f_cpu} build_unflags = ${mcu.build_unflags} build_flags = ${mcu.build_flags} -Wl,--section-start=.bootloader=0x1F800 +extra_scripts = ${mcu.extra_scripts} upload_protocol = ${mcu.upload_protocol} upload_flags = ${mcu.upload_flags} @@ -41,6 +45,7 @@ platform = ${mcu.platform} board_build.f_cpu = ${mcu.board_build.f_cpu} build_unflags = ${mcu.build_unflags} build_flags = ${mcu.build_flags} -Wl,--section-start=.bootloader=0x1F800 +extra_scripts = ${mcu.extra_scripts} upload_protocol = ${mcu.upload_protocol} upload_flags = ${mcu.upload_flags} @@ -49,7 +54,7 @@ upload_port = ${mcu.upload_port} [native] platform = native build_flags = -std=gnu++17 -Wextra -Wmissing-declarations -Wshadow -Wformat=2 -g -O2 -DPC -Iinclude -Iinclude/bot-logic -lpthread -extra_scripts = native_linkflags.py +extra_scripts = pre:native_linkflags.py [env:native] platform = ${native.platform}