I know this is an old post but I can’t find firmware.bin anywhere. The project(s) I am working on are a variant of Teensy 3.1 (custom design using the NXP Kinetis MK20DX128… called teensy3x). My .pioenvs folder(s) don’t have a nodemcu folder and only have firmware.elf and firmware.hex in the .pioenvs folder.
What I have is all I typically need but I am looking at how to use utasker as a bootloader and I need binary files for that. I am using a JLINK as HEX file uploader and debugger and that is working OK.
The previous post by Ivan states the firmware.bin file is created by default but it looks like for Teensy this isn’t the case. What do I need to change to get the binary file?
My platformio.ini, extra_script.py, teensy3x.json, and mk20dx128V.ld files follow:
platformio.ini:
[env:jlink_debug_and_upload]
platform = teensy
framework = arduino
board = teensy3x
board_build.f_cpu = 96000000L
monitor_speed = 115200
extra_scripts = extra_script.py
debug_tool = custom
debug_init_break =
debug_server =
C:\JLINK\JLinkGDBServerCL.exe
-singlerun
-if ;was ifls?
SWD
-select
USB
-port
2331
-device
MK20DX128xxx7
extra_script.py:
from os import makedirs
from os.path import isdir, join
Import('env')
# Optional block, only for Teensy
env.AddPostAction(
"$BUILD_DIR/firmware.hex",
env.VerboseAction(" ".join([
"sed", "-i.bak",
"s/:10040000FFFFFFFFFFFFFFFFFFFFFFFFDEF9FFFF23/:10040000FFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFD/",
"$BUILD_DIR/firmware.hex"
]), "Fixing $BUILD_DIR/firmware.hex secure flash flags"))
def _jlink_cmd_script(env, source):
build_dir = env.subst("$BUILD_DIR")
if not isdir(build_dir):
makedirs(build_dir)
script_path = join(build_dir, "upload.jlink")
commands = ["h", "loadbin %s,0x0" % source, "r", "q"]
with open(script_path, "w") as fp:
fp.write("\n".join(commands))
return script_path
env.Replace(
__jlink_cmd_script=_jlink_cmd_script,
UPLOADER="C:\JLINK\JLINK.exe",
UPLOADERFLAGS=[
"-device", "MK20DX128xxx7",
"-speed", "4000",
"-if", "swd",
"-autoconnect", "1"
],
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -CommanderScript ${__jlink_cmd_script(__env__, SOURCE)}'
)
teensy3x.json:
{
"build": {
"core": "teensy3",
"cpu": "cortex-m4",
"extra_flags": "-D__MK20DX256__ -DTEENSY31",
"f_cpu": "96000000L",
"ldscript": "mk20dx128V.ld",
"mcu": "mk20dx128"
},
"debug": {
"jlink_device": "MK20DX128xxx7"
},
"frameworks": [
"arduino"
],
"name": "teensy3x",
"upload": {
"maximum_ram_size": 16384,
"maximum_size": 131072,
"protocols": [
"jlink"
],
"protocol": "jlink"
},
"url": "https://www.pjrc.com/store/teensy31.html",
"vendor": "Teensy"
}
mk20dx128V.ld:
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K
RAM (rwx) : ORIGIN = 0x1FFFC000, LENGTH = 32K
}
SECTIONS
{
.text : {
. = 0;
KEEP(*(.vectors))
*(.startup*)
/* TODO: does linker detect startup overflow onto flashconfig? */
. = 0x400;
KEEP(*(.flashconfig*))
*(.text*)
*(.rodata*)
. = ALIGN(4);
KEEP(*(.init))
. = ALIGN(4);
__preinit_array_start = .;
KEEP (*(.preinit_array))
__preinit_array_end = .;
__init_array_start = .;
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
__init_array_end = .;
} > FLASH = 0xFF
.ARM.exidx : {
__exidx_start = .;
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
__exidx_end = .;
} > FLASH
_etext = .;