Professional Documents
Culture Documents
Hacking The Teensy V3
Hacking The Teensy V3
1forSWDDebugging|MCUonEclipse
HackingtheTeensyV3.1for
SWDDebugging
PostedonAugust9,2014byErichStyger
I*love*theFreescaleFreedomboards,andyouprobablyrecognizedthatwithallmyprojectsusing
them.TheFreedomboardsaresmall,inexpensiveandcanbeeasilyextendedwithArduinoshields
whichmakesthemagreatplatformforprototyping.ButsometimesIjustneedanARM
microcontrollerwithsomeheaders,andthenthe85mmx55mmsizeoftheFreedomboardisnot
ideal.Thatsnothingnew,butIrealizedthatyetagainwhenIdidmyAdafruitNeoPixelclock:the
FRDMboardwasratherbulky,evenifhiddenbehindthatclock.Ineedsomethingmuchsmaller:
theTeensyboard!
SizeComparisonFRDMvs.Teensy
MeettheTeensyV3.1Board
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 1/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
IhavemettheTeensyboardthefirsttimewhenitwasfeaturedonHackaDaywiththe3.0and
laterwiththe3.1version.TheTeensyV3.1board(https://www.pjrc.com/teensy/index.html)isatiny
3517mmboard(Hint:theboardnametellsitall!)withfollowingmainfeatures:
FreescaleK20DX256ARMCortexM4Processor(72MHz,256KByteFLASH,64KByte
SRAM)
MINI54TANBootloaderDevice,anARMCortexM0(seethisthread)whichactsasUSB
Bootloader
ProgButton,connectedtotheNuvotonMINI54TAN
AUserLED,connectedtotheK20
USBportconnectedtotheK20.TheboardsupportsbydefaultUSBdeviceclass,butcanbe
modifiedforUSBhostfunctionality(Ihavenottriedthatyet).
Pinsonouterheadersandlowerpinpads,breadboardfriendly
Teensyv3.1TopSide
Onthebacksidetheboardispreparedfora32kHzoscillatorandUSBhostmode.Additionallyit
featuresaddedpinpadsandvarioustestpoints:
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 2/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
Teensyv3.1BackSide
Theschematicsarefoundonhttps://www.pjrc.com/teensy/schematic.html.Theboardcostsbelow
US$20andcanbeorderedfrommultiplesources(IorderedminefromAdafruit
(https://www.adafruit.com/products/1625)).
NoDebug?
Sofarsogood.Iwasveryreluctanttoordertheboardbecauseithasaproblem:Itdoes*not*
exposetheJTAG/SWDdebugpins:(.Thatmeans,itisnotpossibletodebugtheARMprocessor
onthatboardwiththeusualJTAG/SWDdebuggingtools.
Maybeitisjustme:IrespecttheArduinowayofprogramming,butitisjustnotthewayI
thinkdevelopmentshouldbedone.Ineedfullcontrolofthehardwarewhichincludesdeep
inspection(debugging)oftheapplication.Becauseinmyexperiencethehardproblems(and
therearemany!)ofembeddeddevelopmentcanonlybesolvedwithgooddebuggingtools.
Instead,aUSBbasedbootloaderisused,theTeensyLoader
(https://www.pjrc.com/teensy/loader.html).Withthatloaderprogramscanbeloadedtotheboard,
butitdoesnotallowmetodebugtheboardbyanynormalmeans.Thattopicisdiscussedinthe
forumstoo(seehttp://forum.pjrc.com/threads/6JTagonTeensy).Sotheboardisopen,butnotthat
bootloaderontheMINI54TANdevice.NothavingtheJTAG/SWDpinsexposedatleastontest
padsonthatgreatboardisdefinitelyapity.
IonlycanspeculatethatPaulStoffregen(https://www.pjrc.com/about/about_us.html)
wanttoprotecttheboardIPfrombeeingcloned,whichIcanunderstand.Butwhynotatleast
exposetestingpadsforJTAG/SWD?
AddingSWDDebugging
WARNING:ofcourse,anychangeoftheTeensyboardlikethiswillvoidanywarranty!
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 3/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
Lookingattheschematicsandtheboardlayoutunderthemicroscope,itwasclearthatitwouldbe
possibletoaddSWDdebugfunctionalitytoit.AsSWDonlyneeds5pins(GND,3.3V(power
sense),DIO,CLKandReset,itshouldnotbetoohardtorouteittoastandard10pinSWD/JTAG
header:
SWDHeaderPinout(Source:FRDMKl25ZSchematics)
SoIcheckedtheschematics(https://www.pjrc.com/teensy/schematic.html),andallthesignalsare
available,andSWD_CLKisonPTA0,andSWD_DIOisonPTA3:
Tokeepthingssimple,IonlyusedtheSWDpins,andnotthetwoadditionalonesforJTAG
(PTA1_JTAGTDIandPTA2_JTAGTDO),butthatwouldbecertainlydoablewithtwoextra
wires.
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 4/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
Teensyv3.1SchematicwithSWDPins(Source:basedon
https://www.pjrc.com/teensy/schematic.html)
Interestingly,theUSBDPandDMpinsare*not*connectedtotheMINI54TANdevice,butit
managesthebootloadingtotheK20throughUSB?IbeliveuponpressoftheProgbutton,the
MINI54TANprogramsasmallUSBbootloaderprogramtotheK20whichthenrunstheupdate?
WouldbeaninterestingapproachjusttouseasingleUSBconnector.
3.3VandGNDareeasilyavailableonthebacksideoftheTeensy:
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 5/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
3.3V,GNDandResetonTeensy3.1
ForSWD_CLKandSWD_DIOtherearenoeasyaccessiblepads.Butaninspectionofthe
layoutoftheboardsuggestedtocutthetracestotheMINI54TANandsolderwiresdirectlyto
theK20pads.
TheideatoremovetheMINI54TANandtouseitspadshasbeenconsidered.Butthenthis
wouldbeanonrevertiblechange(oratleastnoteasy).Socuttwotracesandwiresomewires
soundsthebetterapproach.Maybecuttingisnotnecessary,butIdidtoisolateitjustincase.
SWDDIOandCLKTracesonTeensyV3.1
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 6/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
NOTE:asdiscussedinthecommentssectionofthispost,thereisan*easier*waytogetSWD
debuggingfortheTeensy3.1,withouttheneedtocutwires:TheideaistopulldowntheResetline
oftheTANchip.Theresetlineislocatednearbythepin1onthebacksideoftheboard.Installa
jumpertoputthatlinetoGNDtoenableSWDdebugging:).
TANResetPad
Withthis,wiresgetsolderedonthemicrocontrollerK20pads(usesolderingfluxandheadthepin
withawirewrapwire):
SWD_CLKandSWD_DIOWiresSolderedtotheK20Pins
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 7/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
ThencutthetracestotheMINI54TAN:
CutTracestoMINI54TAN
TriedtouseSWDwithoutcuttingthetwolines,butthisdoesnotwork.Soindeed,thelineshas
tobecut,astheMiniTANisaffectingtheSWDcommunication.
Comparedtothepreviousstep,the3.3V,GNDandResetwiresonthebacksideoftheboardare
easy:
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 8/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
SolderedWiresonBackofTeensy3.1
Nextstepistoconnectthewirestothenormal25pinSWD/JTAGpinheader(oranadaptertoit).
Ihadaheaderwithcableathand,Idecidedtosolderthewirestoheader.
Thepinpitchisrathersmall.NexttimeIbettercreateasmalladapterPCBwhichwouldmake
solderingeasier.
Solderedwiresto25pinSWDJTAGHeader
PinsonSWDJTAGHeader
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 9/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
Withthis,IwasabletodebugtheTeensyV3.1withanormalJTAG/SWDhardwaredebuggingtool,
andwithinminutesIhadaProcessorExpertblinkingLEDprogrammadewithEclipseplusGNU
ARMtoolchainrunningontheTeensy:
DebuggingtheBlinkyonTeensy3.1withaP&EMultilink
Nowwiththisthatboardisfinallyusefulforme:IcandebugwithmyfavoriteEclipsetools:).
Summary
TheTeensyV3.1isafabulousboard,withaprocessorIlove:anARMCortexM4powerfulformost
ofmyprojects.Theboardistinyandsmall.ThebadthingisthattheusualJTAG/SWDpinsarenot
availableeitherontheoutsideorontestpads,makingJTAG/SWDdebuggingnotpossibleby
default.Butwithsomehackingandgoodsolderingskills,aTeensyboardcanbeturnedintoaboard
whichtalkswithaJTAG/SWDcablelikeaP&EMultilinkorSeggerJLink.Andthentheboardcan
beutilizedwithanIDElikeCodeWarrior,KinetisDesignStudiooraDIYEclipseARMToolchain:).
MywishisthatfutureTeensyboardshaveatleastthefootprintofastandard25JTAG/SWD
headeronit,withsomeisolationtraces.ThatwayIcansolderaheader,cutafewtracesandI
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 10/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
haveaboardIcandebugwiththetoolsImusedto.AndifIhaveanextrawish:Replacethe
MINI54TANwithaKinetisK20runningOpenSDAv2.1asontheFreedomboards,andtheTeensy
wouldbetheperfectboardforme:asmallandtinyopensourceboardwithanopensource
bootloaderandfirmware
Timetousethatboardnowformyprojects.
HappyTeensing
Advertisements
SH A R ETH IS:
Like
Bethefirsttolikethis.
R ELATED
ThisentrywaspostedinARM,Boards,Debugging,Embedded,Freescale,Tips&Tricksand
taggedDebugging,Freescale,OpenSDA,Tips&TricksbyErichStyger.Bookmarkthe
permalink[https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/]
.
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 11/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
AboutErichStyger
Embeddedismypassion....
ViewallpostsbyErichStyger
65THOUGHTSONHACKINGTHETEENSYV3.1FORSWDDEBUGGING
Manuel
onAugust9,2014at18:36said:
Hi,Erich.
Greatsite.
IfIreplacetheTeensy3.1MINI54TANwithaKinetisK20fromtheFreedomboardrunning
OpenSDAv2.1,woulditworkatthistime?
Weneedtoaskprjctodoanupgradetoteensy3.1withSWD.
Thanks,Manuel.
Like
ErichStyger
onAugust9,2014at18:52said:
HiManuel,
yes,thatwouldwork(butthefootprintoftheMINI54TANwouldnotbethesame,so
youcannotswapthisoutwithoutaboardchange).
IalreadyhaveaskedprjcforSWDsupport,andIknowothershadaskedthesame
ifIbrowsetheforum).Imwondering:whynotjustmakeaTeensycompatibleboard,
butwithaK20andOpenSDAv2onit?Myestimatewouldbethatsuchaboardin
100500quantitiesshouldbedoableinthe$1015range.
Like
Mevon
onAugust18,2014at06:45said:
HelloEveryone!
THISPOSTISAWESOME!!Ithinkthatonethingwouldbenicetodoisa
cheaperteensy3.2withaSWD/jtagportinsteadofamini54tanchip,that
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 12/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
woulddothetrickandmaybesellitalreadyprogrammedwithwitha
openSDAfirmwaresoyoucanuseonetodebuganotherone(ifpjrccould
sell2unitsfor20$orso)OronecouldusetheMCHCKtocreatean
opensdaprobe(https://mchck.org/about/)butstillpeoplearegoingtomiss
allthearduinolibrariesandsimpleprogrammingide.Personnaly,Inever
likedusingarduinoinmorecomplex(thensimplepollingfunctions)projects
becausehavingmorethenonefileopenisproblematicbutKDSandCW
reallybringthepowerofEclipsetotheIDE.Thiswriteupisgreat,thankyou
Erich!
Mevon
Like
ErichStyger
onAugust18,2014at07:56said:
Thanks
ImthinkingofcreatingaboardliketheTeensy3.1,butwithoutthe
MINI54TANchip:instead,therewouldbeanormal25SWD/JTAGheader
sothatboardcanbeprogrammedlikeanyothernormalboard.Imthinkingof
puttingaK20OpenSDAcircuitonthatboard:thatwayIcandebugthat
boardliketheFRDMboardsoverUSBwithOpenSDA.ThatDebugcircuit
wouldbeonthatboardinawaythatitispossibletobreakitapartfromthe
board:soyoucanbreaktheboardintotwoboards:thenIhaveanormal
boardwithJTAG/SWDinterface,andaOpenSDAboardIcanusefor
debugginganyboardswithOpenSDA.Ithinkitwouldbedoabletohavethat
waytwoboards(ateensylikeboardandaOpenSDAboard)forbelow
US$20.Butitwillbeallaboutquantities.Theretherewouldbeinterestfor
about100boardsofthatkind,whoknows?
Like
HillbillyInjunear
onAugust9,2014at20:12said:
Whatagreatcutelittleboard.Thanksforfiguringouthowtouseitforus.
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 13/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
IfoneneedsmoredigitalI/Os,hemightconsiderusingtheMAX695xserieschips(SPIor
I2C,20or28I/Os).IamcurrentlybuildingatestdeviceusingtwoMAX6957chipschained
together.Itgivesme56(!)customconfigurableI/OswithjustfourMCUpins(usingSPI.).
(TheMAX6957canalsodriveLEDsupto4mAperpin.)
ConnectoneortwoofthosechipstoatinyTeensyboardandonecangetalotof
processingpowerinatinyspace.
Likedby1person
ErichStyger
onAugust9,2014at21:29said:
yes,averycuteboard.IhavecreatedafolderonGitHubwhereIwillpostmy
projects:
https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/Eclipse/Teensy
Like
HillbillyInjunear
onAugust10,2014at02:50said:
Regardingcuttingtraces,Ihavefoundthatifonecutsthetraceataverysharpangle
(insteadofperpendiculartothetrace),onecanfrequentlyrollthetraceupoutoftheway
temporarily.Thisoftenallowsonetogentlysolderthetracebackintoplacewithoutusing
anyjumperwires.Onecanuseascalpel,Xactoknife,orevenafinelysharpenednail,ifone
iscareful.
Thisisnotarecomended,butsometimesnecessary,formofcomponentlevel
troubleshooting.
Like
ErichStyger
onAugust10,2014at06:22said:
Thatsagreattrick!Ihaveusuallycutthetraceperpendiculartothetrace,asnarrow
aspossible.Toresolderit,Iremovedthesoldermaskalittletoexposethetrace
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 14/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
surfaceoneachsideandthenappliedsolder.Ithinkcuttingitataverysharpangle
willmakeiteveneasiertosolder.Andyes,Ihaveusedthatwayoftroubleshooting
manytimestoo
Like
jcribeiro82
onAugust21,2014at13:23said:
HelloErichStyger,
Greatblog!
ImnowtestingourfirstKinetisMK22FX512VLK12customcontrollerboard.
InourdesignweincludedaSWDprogrammingconnector(VCC,GND,SWD_DIO,
SWD_CLK,RESET).ThesepinsareconnectedtothePEMicroMultilinkUniversal
(firmwarev6.10)PortB(TVCC,GND,TMS/SWD_DIO,TCK/SWD_CLK).
AfterseveralattemptsusingtheSWDinterfaceIalwaysgetaDeviceissecuremessage
onCW10.6andKDS1.1.0.Thisisthesamebehaviorasdescribedhere
(https://community.freescale.com/thread/318552).
NooneinthecommunitywasabletouseSWDinterfaceonMCUsthathaveJTAG/SWD
option.TheystatethatKL05,whichisSWDonly,worked
TheirsolutionwastoswitchtoJTAGmodeaddingTDIandTDO.
IalsomanagedtotweaktheboardandIaddedTDIandTDO.Itworks,butImlookingfora
waytouseSWDinterface.
TheKinetisusesJTAGatresetstate,buttheycanswitchfromJTAGtoSWDmodeusing
asequenceonTMSandTCK,sotheMultilinkshouldbeabletosendthiscommand.
(referencemanualpage2109.2.1JTAGtoSWDchangesequence)
ItseamsthatonlyyouweresuccessfullyusingSWDonK20usingtheMultilink
programmer.
Canyoupleasehelpusfindwhatcanbewrong?
Like
ErichStyger
onAugust21,2014at16:39said:
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 15/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
Thanks
IhavenothadanyproblemsatleastwiththeP&EMultilinktotalktoaK20inSWD
mode(asyouseewiththeTeensy),aswellwithmyownboards.Notsurewhatit
is,butIguessitmustbesomethingwiththeelectricallinesasmentionedinthat
forumpostyoureferenced?
Like
JosRibeiro
onAugust21,2014at19:59said:
HiErich,
Thankyouforyourreply.
Whatcanbesodifferentfromallotherboards?
1TeensydoesnthaveaResetpullupresistor.OK,Iwilltrywithoutit,but
itwasaFreescalerecommendationtouseRandC.Ihavealreadyremoved
thecapacitorandotherAmitKumarsrecommendationsintheforum.BTW
hewasnotabletodebugusingSWDtoo
2Multilinkfirmwareversion:6.10.Whatisyours?
3PORTBvsPORTG?Thosepinsareshortedbetweenthose
connectors,soitmakesnosense
4IDEKDS1.1.0andCW10.6.WhatIDEareyouusing?
5ImusingaK22vsK20.Didyoutestitonothermodels?
Like
ErichStyger
onAugust21,2014at20:28said:
HiJos,
1.Yes,havearesetpullupplusaC:thatmakesitmorerobustagainst
noise.ButifyourresistoristoolowortheCistoohigh,thenthedebugger
willnotbeabletopulltheresetlinelow.Removeitforyoutests.
2.Notsure(Imawayfrommydesk),butImusingthelatest(it
automaticallyupdatesit)
3.shouldnotmatter
4.ImusingKDS,CW10.6andstock(DIY)Eclipse
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 16/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
5.UsingitonaK20andaK22(https://mcuoneclipse.com/2014/07/26/zumo
robotwithwifiandgps/)
Like
ShubhamPaul
onOctober31,2015at15:34said:
Hello,
IhaveprogrammedmyMK22DX256VLF5customboardwithKeilusingtheSWD
portoftheOpenSDAcircuitry(oftheFRDM25klzboard).SoIthinktheopenSDA
circuitrycanalsobeusedinasimilarwayUSINGKEILtoprogramyour
MK22FX512VLK12.
Like
ErichStyger
onOctober31,2015at18:53said:
Yes,youcanuseKeilforthiskindofthingstoo,oranyotherdebuggerwhich
caninterfacetotheOpenSDAcircuit.
Like
Mevon
onAugust22,2014at20:12said:
HiEveryone!
OnethingIfindwithmostteensyusersistheneedforrobustusbapplicationlikemsd,
eitherashostordevice.Iwasjustwondering,andImonlypostingbecauseitsa
suggestionnotarequest,isiftheMINI54TANinterfearingwiththeusbapplicationofthe
K20.IknowwhenIworkedontheteensybackinspringicouldntgetthecputowork
correctly.mostlybecauseofwrongcpuconfigurationinProcessorExpertandsomeother
bugsIfoundoutlaterwiththeusbhostcomponent(72MHzconfigvs96Mhz
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 17/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
overclocking)butatthetimeIwasconsideringtheMINI54TANasapotentialsourceof
bugsforusbapplications.Also,anotherthingIwouldliketofindoutisifitspossibleto
generatetheHEXwithCW_IDEorKDS,anddownloaditintheteensywiththe
Teensyduinoexecutable.Thiswouldbeniceifyoudonthavethebudgettobuyexpensive
jtag/swdprobeordonthavetheskillstoprogram/createonewithanotherdevboard.Iknow
KDSseemstohavebetterconfigurationpossibilitieswiththeeclipsepartandgenerating
theHEXiseasierbutIdontknowifitsanIntelHexorMotorolaHexthatisgenerated(S19
vsiHex).Justsaying,butthisthreadisawesome!ThankyouErichforthiswork!
Mevon
Like
ErichStyger
onAugust22,2014at20:24said:
HiMevon,
accordingtotheschematics,theMINI54TANisnotconnectedtotheUSBbus
(USB_DMandUSB_DP),sothisreallyshouldnotinterferwiththeK20drivingthe
USB.IhadnotimeyettorunUSBcodeontheK20,butthisiscertainlysometingI
plantodo.IbelieveafterthePROGswitchispressed,theMINI54TANistaking
controlovertheK20withitsJTAG/SWDconnections.Ithinkitthenwilldownload
someUSBcodetotheK20thatway,andafterthattheK20isrunningthatUSB
protocoltothehostdevice,withtthatspecialprogrammingtool(Ihaveneverused,
btw).Imnotsurethatfileformatsthatprogrammingtooltakesasinput,butIdoubt
itisanormalS19orBINfile(notsure).Icannotverifythisasonmyboard
intentionallythatMINI54TANisnowoutofservice:).Itisveryeasytocreateeither
S19(MotorolaS19)orIntelHex(iHex)filesbothwithCodeWarriororKDS(Iposted
articlesaboutthis).
Thanks!
Like
Joe
onSeptember16,2014at22:38said:
IsitnecessarytocuttheMINI54TANsSWDtraces?Lookingatthetracesontheofficial
Teensypinoutphotos,itlooksliketheMINI54TANsRESETpin(pin2accordingtothe
schematicimage,andassumingthedotonthechipispin1)isroutedouttoatestpadon
thebottomoftheboard(immediatelyabovethe1silkscreenonthebottom).Perhapsits
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 18/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
possibletopullthepinup/downandremovetheMINI54TANsinfluenceontheSWDlines
(assumingtheMINI54TANspinsgoHiZduringreset)?
Ofcourse,ifthegoalweretoallowtheboardtobeusedasateensyagain,itwouldbecome
importanttofigureoutexactlyhowtheMINI54TANhandlesprogrammingandmakesure
thereisntanybootloaderontheK20whichmustbepreserved.IthinktheTeensyduino
downloadincludesalinkerscriptfortheK20whichcouldbeexaminedtodetermineany
areasofmemorythatwouldneedtobeprotected(orjustbackedupbeforeSWD
programming).
Like
ErichStyger
onSeptember17,2014at15:55said:
HiJoe,yes,Iwasthinkingaboutthesame.ButIhavenotinvestedanytimeinthis,
asIdidnotplantocontinuetousetheMINI54TANformyapplication.
Like
MaxP.
onApril14,2015at23:14said:
First,Erich,thanksforthegreatpost.Icannowdohardwarelevel
debuggingwithmyTeensy3.1,whichcanbeextremelyhandy.Joy!
Iwantedtosaythatindeed,allonehastodoisgroundtheTANRSTlineto
disabletheTANchip.Thereisnoreasontocutanytracesatall(mightas
welljustpulltheTANchipoffifyoudontneedit,IMHO ).
ThelittlesolderpadJoementionsabove(rightnexttothe#1pinholeonthe
backoftheTeensy)istheTANRSTlinesoIjustranajumperwirefrom
there,andwheneverIwanttouseSWDIsimplyconnectthatjumperto
ground.ObviouslythisdisabledthebootloaderandTeensybuttonentirely,so
toreflashsomefirmwarewiththenormalmethodyouhavetoremovethe
RSTgroundjumperandrestarttheTeensyboard(removethenapplypower).
ImusingtheSWDinterfacefoundonthecheapSTM32F4Discoveryboard
(alreadyhadthat).IuseWindows,withthefreeGDBserverfromSTMicro,
eabinonegdbfromYagarto,andEclipseLuna/CDT.(Forsomereasonthe
gdbexecutablefromWinGCC4.xdoesntseemtoworkaswell.)Iactually
haventtriedloadinganyfirmwareusingthismethod,yet.ButotherwiseI
havefullbreakpointcontrol,stepdebugging,canpauseandrestartthe
firmware,viewlocalsandglobals,etc.Fantastic!
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 19/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
Cheers,
Max
Like
ErichStyger
onApril15,2015at08:46said:
HiMax,
EXCELLENT!Ishouldhavethoughtaboutthatmyselftoo.KeepingtheTAN
deviceinresetisindeedamuchbetterapproach,thanksforsharingthat
greatsolution
Like
Constantin
onMarch28,2015at00:07said:
Greatarticle.Ihaveafewquestionsandacomment.
Firstthequestion:DoyouthinkthereareanyissueswiththeMiniTan54beingactivewhile
youaredebugging,loading,etc?Forexample,thewayIreadtheschematic,oneofthe
GPIOpinsontheMiniTan54isbeingusedtotogglepin26(RESET)ontheMK20.
Presumably,yourdebugger/flashdevicewouldpullresethigh,therebyconflictingwiththe
outputfromtheGPIOpin.Howtodealwiththat?Wouldasimple1Kresistorinserieswith
theMiniTAN54resetsignalallowthedrawtobesufficientlylowtoavoiddamage?Thisis
similartotheSerialportsolutionthattheArduinoUnouses.
Then,whattodowithSWD_DIOandSWD_CLK?Sameissue,butmuchhigherclock
frequencies!
Asformycomment,IdprefertheTeensytousethelittleareathereistomakeroomfora
tagconnectSWDcable.Theyuseverylittlespaceandcostnothingbuttheconnector
hardware,whichiswhyIamconsideringthemformyTeensyDIYdesigns.
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 20/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
Like
ErichStyger
onMarch28,2015at08:36said:
HiConstantin,
theresetlineisLOWactive,andpulledup.SotheMiniTANkeepsthatpinfloating.
UsingSWDwiththatresetlineisnoaproblem.ButyouhavetocutthetwoSWD
linesasshowninthispost,astheMiniTANisaffectingthecommuniction.Weare
buildinganadapterboardfortheTeensywithtwojumpersonittoisolateSWD_DIO
andSWD_CLK.Youreallyneedtoseparatethesignalsforpropercommunication.
Like
Pingback:USBCDCwiththeTeensy3.1Board|MCUonEclipse
Mark
onApril16,2015at23:59said:
HiallTeensyHackers!
IamsonderingwhethersomeonewhooftneusestheTeensyforbothSWDandNini54
programmingcouldhelptoverifyapotentialproblemthattheMini54has?
Thesubjectisdiscussedheretowardstheendofthethread:
https://forum.pjrc.com/threads/27457Needhelpwithabootloader
Itissuspectedthatthereisaprobemwiththeloaderifthechipissecured(0x40c=0xff)
andthattheMini54cantrecoverfromitcausingtheboardtobecomebrickedalthoughit
isnotreallyso.
IdontdaredothetestonmysingleboardsinceIdontwanttohavetobuildaprogrammer
torecover,ifitisthecase.
Doesanyonethereforehavethepossibilitytocommandamasseraseofthechipandsee
whethertheoriginalprogrammercanhandlethatstate?Asyouknown,normaldebuggers
willsimplysaythatitissecuredandunsecureitandsoyouhavenorisk.Itwouldhelp
clearupapotentialissuethatcouldbecausingaparentlybrickedTeensystobelost.
Thanks
Mark
Like
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 21/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
Pingback:ProofofConcept:OpenSourceARMSWDDebugandGeneralPurposeBoard|
MCUonEclipse
ArturoArellano
onJune25,2015at00:01said:
Hi!Thankyouforthisexcellentpost!
ImamnewtotheJTAG/SWDinterfacesbutIhavebeenworkingwiththeteensy3.1and
arduinoIDEforawhile.
Ineedtouploadthe.hexfilegeneratedfromtheIDEtotheteensywithaJLink.Doesthe
methoddescribedaboveisusefulforme?Oritisonlyfordebuggingpurposes?
Doyouthinkthe.hexfilegeneratedbytheIDEwilljustworkwithanyotherchanges?
Thanks!
Like
ErichStyger
onJune25,2015at13:59said:
HiArturo,
yes,withthismethodyoucanuploadorprogramanyfilesusingtheJLink.
Itshallworkwithoutanychanges.
Like
garetbiglow
onAugust11,2016at20:22said:
YoudonthavetomodifytheTeensylinkertoremovethememoryoffsetor
anything?Doesntthelinkercreateablockthatthebootloadersitsin?Id
liketoalsoupload.HEX(generatedbyTeensyduino)viaJTAG.
Like
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 22/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
ErichStyger
onAugust11,2016at20:40said:
No,thereisnobootloaderontheKinetis.Thebootloading/bootstrappingis
donebytheMINI54TAN.Soyoucanuseanormalhexfilesandprogramit
withSWD/JTAG.ImnotsureifTeensyduinoaddssomeextrastuff,butitis
defitelynotneeded.IusednormalIDEslikeIAR,KeilandKinetisDesign
StudiotoprogramtheTeensywithit.IdidnothadtouseTeensyduinoatall.
Like
RonaldArias
onAugust5,2015at16:26said:
ThankyouverymuchforallyourpostErich,theyhavebeenveryusefultostartwith
Freescale.
IvebeenusingTeensy3.1foraprojectandIneededdebuggingcapabilities,sobasedon
anotherofyourpostsImadethenecessaryhardwarechangesandnow,Icandebug
TeensyusingUSBDM+codewarriorandFRDMKL25Zcard.Sofarsogood.
Buttherecamethefirstquestion,whyunliketheFREEDOMboards,teensywasnot
programmedafterdebugging?.Andnow,Ivebeenaweektryingtoprogramtheteensycard
withoutsuccess.
MyfirstapproachwastouseCodewarriorFlashProgrammer(flashfiletotarget),soI
chosethissettings:
*MyteensyboardhasaK20DX256VLH7*
FlashconfigurationfileK20DX256M7.xml
filetoflash.elfoutputfile
offset0x0
Eraseoptions(Connection):Selectiveerase(bysector)
thenEraseandProgram
Butthisisthemessageoftheconsole:
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 23/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
Imagesizeis0bytes,nothingtoerase.
Nothingtoerase.Nosectorsselected
Erasecommandsucceeded
cmdwin::fl::write
Usingrestrictedaddressrange0x10000000to0x10007FFF
ProgrammingfileC:\xxxxxx.elf
Autodetectionissuccessful
fileisoftypeElfformat
0BytesProgrammed,CheckRestrictedAddressRange
ProgramCommandSuccedded
ThenItriedwiththe.hexfileandnothinghappendagain.Somysecondapproachwasto
usetheARMFlashprogrammerfromUSBDM,butItcantDetecttheDevice:
[Nomatchingdevice]
Iknowthispostisopenforayearnow,butIllbeverygratefulifyoucangivemesometip
orinformationtoprogramtheteensyflashusingakl25zfreedomboard,asitisdifficultfor
metoaffordaSeggerjlinkorsimilar.
Like
ErichStyger
onAugust5,2015at19:57said:
IbelieveyourproblemcouldbeUSBDM.CanyoutryusingtheSeggerJLink
firmwareinstead.UseKinetisDesignStudio(insteadofCodeWarrior)asKDSis
newerandthisiswhatImworkingwithtoo.
Asfortheimagesizeis0bytes,thisindicatesthatyour.elffileiseitheremptyor
corrupted?
Like
RonaldArias
onAugust6,2015at21:28said:
HiErich,ItriedwithSeggerJLinkfirmwareanditsworkingperfect,Ican
nowtoprogramtheTeensyflashanddebuggingfaster.
Thankyouverymuchforallyourpostandtips,fantasticjob!
Like
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 24/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
MarioGongora
onOctober27,2015at18:18said:
HiErich,IamusinganARMmicrocontrollerMK20DX256VLH7,whichistheprocessorthat
Teensy3.0containsonboard.
FirstIwasusingTeensy3.0,butlikeyouIwanttouseotherprogramationanddebugging
tools,soIdecidedtodesignmyownPCBwiththismicrocontroller.Iamtryingtoprogram
bySWDtoolinCodeWarrior10.6Icanseeyoudevelopasimilardebugging/programming
solutionhackingtheteensy3.0.
ActuallyIamusingmultilinkuniversaltoolfromPEmicro,butmyproblemisthatCode
Warriordoesntrecognizethetarget(ARMMK20DX256VLH7),everythingseemsok,
compliewithoutwarnings(justasimpleLEDprogram).
InthePEmicroblueandyellowledareilluminatedasitshouldbe.
Couldyouhelpmewiththis?
Thankssomuch!!
BR
Like
ErichStyger
onOctober27,2015at18:49said:
HiMario,
theblueLEDontheMultilinktellsyouthattheUSBdriversonthehostareproperly
installed(multilinkenumerated).TheorangeLEDtellsyouthatthetargethaspower.
SoIguessthereiseithersomethingwrongwithyourwiringtothetarget,oryouare
notusingSWDinthedebugsettings?
Ihopethishelps,
Erich
Like
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 25/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
rgviva
onDecember30,2015at19:59said:
Thisisgreatinfo!Ineedtoimprovemysolderingskillstobeabletosolderoneoutof64
tqfnpins.doyouneedspecialwiresforthis?
Like
ErichStyger
onDecember31,2015at07:21said:
Youcanusewirewrapwiresorthinwireswhichareusedfortransformators.
Like
BruceBoyes
onApril27,2016at23:27said:
Thisisgreat.Iagreewithyoursentimentsaboutdebugging.Thereareanumberofissuesin
thepopularArduinolibrarieswhichIamchasingrightnow.Theyarejustnotwrittenwiththe
sortofreliabilityandexceptionhandlingwhichcommercialembeddedsystemsassume.
Thanksforpostingthis.
Like
ErichStyger
onApril28,2016at09:47said:
HiBruce,
thatswhywehavedecidedtocreatethetinyK20
(https://mcuoneclipse.com/2015/11/22/dataloggerwithtinyk20board/)sowehave
truedebuggingcapabilitiesoutofthebox
Like
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 26/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
ChrisShuler
onMay2,2016at13:21said:
HelloErich,
thanksforYourtutorial,ithelpedmealot.
IrunasimpleprograminKDSwithfewintegersanditflashedanddebugedfine.
SomeproblemscamewhenItriedtodebugsomearduinostyleprogramstoKDS.Build
processisdone,flashingmemoryisok,wholeprogramisworkingfinebutwhenitcamesto
debugging,thebreakpointjumpsfromlinetolineinrandomsequence.
WhenItrytolookintosomeexpressionsIgetanerror:
iError:Multipleerrorsreported.\FailedtoexecuteMIcommand:varcreate*iError
messagefromdebuggerbackend:varcreate:unabletocreatevariableobject\Unableto
createvariableobject
MaybeIneedtochangesomesettingsofdebugconfiguration?FornowIcopiedthemfrom
thefirst(simple)program.
CouldYouhelpmewiththis?Sorryformybadenglish.
ThankYouinadvance!
Chris
Like
ErichStyger
onMay2,2016at13:31said:
HiChris,
canyouremoveallbreakpointsandifyouhaveallwatchpoints(thereisa
Breakpointviewwhichlistsallofthem).
Ifthedebuggerjumpsaround,thiscouldbeanindicationthatthedebuginformation
isnotcorrect,oryouarenotdebuggingthecorrectbinaryfile?
Erich
Like
ChrisShuler
onMay2,2016at13:47said:
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 27/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
IthinkIselectedtherightfile.
Ialsogotapopupmessage:
Nosourceavailablefor
(gdb[28].proc[42000].threadGroup[i1],gdb[28].proc[42000].OSthread[1]).threa
d[1].frame[0]
Maybeistheresomefaultsinmakefile?inwhichpartofitIshouldsearch?
Wherethedebuginformationiscreated?MaybeIdidsomethingwrongin
importing(withsomechanges)makefilefromarduino?
Thanks,
Chris
Like
ErichStyger
onMay2,2016at20:45said:
HiChris,
IdontrememberthatIhaveseenthatmessage.Idontthinkthatsomething
iswronginthemakefile,unlessyouhaveturnedoffdebuginformation?
Canyoumakesureyougeneratedebuginformationwiththeg3option?See
https://gcc.gnu.org/onlinedocs/gcc/DebuggingOptions.html#Debugging
Options
Erich
Like
ChrisShuler
onMay2,2016at13:48said:
andThanksforansweringin10minutes..wow
Like
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 28/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
nishant
onMay10,2016at07:23said:
Hi,
IhavegeneratedahexfilethroughTeensyduinoIDEandtheprogramusestheaudiolibrary
andsomeotherbasiclibraries.kindlyletmeknowthroughSWDIcanabletoburnthehex
fileinblankK20DX256VLH7processor?..
Like
ErichStyger
onMay10,2016at08:03said:
Hinishant,
seehttps://mcuoneclipse.com/2016/04/19/programmingsrecordswithgnuarm
eclipsedebuggerplugins/howyoucanprogramanybinarywithSWD.
Erich
Like
nishant
onMay10,2016at08:23said:
HiErich,
canyoutellmeaboutthehexfile.
Like
ErichStyger
onMay10,2016at12:39said:
Hinishant,
seehttps://mcuoneclipse.com/2014/04/20/binaryfilesforthembed
bootloaderwitheclipseandgnuarmeclipseplugins/
Like
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 29/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
nishant
onMay10,2016at13:39said:
Hiall,
Also,onequestioncanweuseISPforMK20DX256VLH7toburnhexfilegeneratedby
Arduinoide.
Like
ErichStyger
onMay11,2016at20:57said:
Hinishant,
ImnotsurewhatyoumeanwithISP?Canyoutellmewhatyoumeanwiththis?
Like
nishant
onMay10,2016at14:45said:
Hiall,
TellmewhetherIcando/workbelowornot.
Ihaveaprogramwrittenforteensy3.2inwhichIhaveusedaudio.h,snooze.handsome
basiclibraries,IamcompilingthroughArduinoideandthenIgotahexfile.
ThishexfileIamthinkingofburninginteensy3.2withoutbootloadersoIamplanningto
useSWD.Iwilldothesameconnectionasaboveandthinkingofburningviakeil_u5.
Like
ErichStyger
onMay11,2016at21:03said:
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 30/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
Yes,youcandownloadIntelHexfilesandS19(MotorolaSRecords).(Idothatwith
theSeggerconnection)andthatworks.Whatdoesnotworkarerawbinaryfiles.
Ihopethishelps?
Like
nishant
onMay19,2016at16:07said:
cananyonetellmewhatisconnectiontopowermk20dx256vlh7.
Like
ErichStyger
onMay20,2016at04:00said:
ThemostobviouswaytopowertheTeensyiswiththeUSBconnector.
Like
tonetagcom
onMay19,2016at16:08said:
cananyonetellmewhatistheinputconnectionformk20dx256vlh7.
Like
ErichStyger
onMay20,2016at04:01said:
Notsurewhatyoumeanwithinputconnection?youcanprettymuchuseanypin
oftheTeensyassomekindofinput.
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 31/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
Like
tonetagcom
onMay19,2016at16:09said:
alsoiamtryingswmodewithulink2armdebugger,isitokay?..
Like
ErichStyger
onMay20,2016at04:02said:
Idonothaveaulink2ARMDebugprobe,butifithasa10pinARMSWD/JTAG
connector,thatshouldworktoowithadebuggersupportingthatprobe.KDSdoes
notsupportthatprobe.
Like
tonetagcom
onMay19,2016at19:39said:
Andalsopleasetellhowyoudidthatsoldering.
AsImtryingbutitsosmallthatIcantabletodo.
Like
ErichStyger
onMay20,2016at04:03said:
Soldringhasbeendonewithafinesolderingtippluswithisolatatedwireswhichare
usedformotors.
Like
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 32/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
henk
onNovember1,2016at14:18said:
whatistheminimalhardwareneededtoprogramaMK20DX256VLH7?
isitdoablewiththeOlimexARMUSBOCDHdevice?(Idohavethisdevice)ordoIneed
oneofthoseexpensiveseggerdevices???
IliketocreateapcbwithonlyaMK20DX256VLH7withthemostnecessarycomponents
onitandsomeheaderstoanotherpcb.
(itshouldalsobenicetoprogramwithmbed)
thanks,
Henk
Like
ErichStyger
onNovember1,2016at18:05said:
HiHenk,
TechnicallyyoucanuseanySWD/JTAGcapabledebugdevice,giventhatyouhave
thesupportinourdebugger(e.g.OpenOCDorpyOCD).Myexperiencewith
OpenOCDandpyOCDisthattheyonlyworkforafewdevices,andespecially
OpenOCDisveryslow.TheSeggeronesarenotexpensive:havealookatthe
SEGGEREDUversionwhichisforeducationalornonprofitprojects,worththe
smallamountofmoneybyeverycent.
OtherwiseyoucanuseanyoftheFRDMboardse.g.withmbedtoprogramany
otherdevice.Iwroteseveralarticlesaboutthis,forexample
https://mcuoneclipse.com/2015/08/19/usingthefreescalefreedomfrdmkl43zto
debugotherboards/.
And:youmighthavealookatthetinyK20
(https://mcuoneclipse.com/category/boards/tinyk20/)whichisaMK20DX128withall
theminimalcomponents.
Ihopethishelps,
Erich
Like
henksalomons
onNovember2,2016at22:46said:
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 33/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
HelloErich,
thanksforyourextensiveanswer
IndeeddeEDUversionisaffordableandIorderedone
IalseorderedtheTWRK20D72M:http://www.nxp.com/products/software
andtools/hardwaredevelopmenttools/towerdevelopmentboards/mcuand
processormodules/kinetismodules/kinetisk2072mhzmcutowersystem
module:TWRK20D72M
todosomedevelopmentandtestingwithseveraldevices.
(Iplanonwiznet5500,mcp23017,pca9685,max7219formyfirstproject)
IwillhavealookatthetinyK20also
thanks,
Henk
Like
paolo
onFebruary18,2017at11:21said:
HelloErich,
Idliketodebugswonteensy3.0,HWpatchsaresimple,
butwhataboutSW?
UsuallyIuseOpenOCDandeclipse,doIneedspecialconfiglike.LDcontainsdifferentsw
relocation?
Anyinfoareappreciate.
regards
Paolo
Like
ErichStyger
onFebruary18,2017at12:50said:
HiPaolo,
becausethereisnospecialbootloaderontheKinetisonTeensy,youcanuseitlike
anyotherKinetis,andnospeciallinkerfileisneeded.
IdohaveaanEclipse(KinetisDesignStudio)projectonGitHubhere:
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 34/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/KDS/Teensy_3.
1
Erich
Like
paolo
onMarch3,2017at16:07said:
HiErich,
thanks!
Like
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 35/36
26/3/2017 HackingtheTeensyV3.1forSWDDebugging|MCUonEclipse
https://mcuoneclipse.com/2014/08/09/hackingtheteensyv31forswddebugging/ 36/36