Bootloaderwithreprogrammingfunctionalityforelectroniccontrolunitsinvehicles:Analysis,designandImplementationDavidPehrssonJesúsGarzaEXAMWORK2012ELECTRICALENGINEERINGThisthesisworkisperformedatJönköpingUniversity,SchoolofEngineering,withinthesubjectareaElectricalEngineering.Theworkispartofthetwoyearmaster’sdegreeprogrammewiththespecializationinEmbeddedSystems.Theauthorisresponsibleforthegivenopinions,conclusionsandresults.Examiner:ShashiKumarSupervisor:AlfJohanssonScope:30credits(secondcycle)Date:2012-12-18iAcknowledgementsWewouldliketothankeveryoneatQRTECHforthehelptheyhavegivenusandwewouldespeciallyliketothankAndreasKäckforthetechnicalsupportheprovidedwhenweneededit.WewillalsoliketothankLarsCarlssononQRTECHforallthehelpregardingthemasterthesis.WewouldalsoliketothanktheteachersatJTH,AlfJohanssonandShashiKumarfortheirsupport.AbstractiiAbstractInanautomotivecontexttoday’sneedoftestingfunctionswhileinfactory,correctingfaultsintheworkshoporaddingextravalueintheaftermarketmakesitveryimportanttoeasilybeabletodownloadnewsoftwaretotheelectroniccontrolunitsinvehicles.IntheplatformforstandardautomotivesoftwaredevelopmentcalledAUTOSAR,twoknownprotocolsarepresentedtospecifytheprocedureonhowtoimplementthisdownloadoperation:UnifiedDiagnosticServices(UDS)andtheUniversalMeasurementandCalibrationProtocol(XCP).HoweverthepartoftheUDSandXCPstandardsthatisaboutreprogrammingisnotcompletelyapartoftheAUTOSARstandardyet.Inthisthesis,UDSandXCPhavebeencomparedtoevaluatewhichofthetwothathasmostsupportinAUTOSARtodayandaremostlikelytobefullyintegratedintoAUTOSARinthefuture.SinceUDSalreadyhassupportinAUTOSARforsomeofthefunctionsneededforreprogrammingandbecauseofthefactthatUDSisapartoftheextensivelyusedOn-boardDiagnosticstandard(OBD-II),UDSischosentobethemostsuitableprotocolforimplementingreprogrammingfunctionalityaccordingtoAUTOSAR.AbootloaderwiththeabilitytodownloaddatahasbeendevelopedusingonlyrelevantfunctionsfromUDSandfollowingtheAUTOSARspecificationswhereitisapplicable.SammanfattningiiiSammanfattningFörattkunnatestafordonsfunktionerifabriken,åtgärdamjukvarufelunderserviceellerförattuppgraderafordonetmednyafunktionerärdetviktigtattkunnaladdanernymjukvaratillfordonetsstyrsystem.Denstandardiserademjukvaruplattformenförfordonsindustrin,AUTOSAR,innehållertvåprotokollsombådaspecificerarhurmjukvarakanladdasner:UnifiedDiagnosticServices(UDS)ochUniversalMeasurementandCalibrationProtocol(XCP).TyvärrärdedelarnaavUDSochXCPsombeskrivermjukvarunerladdninginteendelavAUTOSARän.IdethärexamensarbetetharUDSochXCPjämförtsförattutvärderavilkenavdebådasomidagslägetharstörststödförnerladdningavmjukvaraiAUTOSARochvilkensomtroligastkommerattbliendelavAUTOSARiframtiden.EftersomAUTOSARredanstödjernågraavdefunktioneriUDSsombehövsförnerladdningavmjukvarasamtpågrundavattUDSärendelavbranschstandardenförfordonsdiagnostikOBD-II,harUDSvaltssomdenmestlämpadeattidagslägetanvändasförattimplementeranerladdningavmjukvaraenligtAUTOSAR.EnbootloadersomstödjernerladdningavmjukvaraviaUDSharsedanimplementeratsenligtAUTOSAR-specifikationensålångtsommöjligt.KeywordsivKeywordsAUTOSARUDSXCPBootloaderReprogrammingECUSoftwareDownloadsCANTableofContentsvTableofContents1Introduction.............................................................................11.1BACKGROUND.............................................................................................................................11.2PURPOSEANDRESEARCHQUESTIONS..........................................................................................11.3DELIMITATIONS..........................................................................................................................21.4OUTLINE.....................................................................................................................................22Theoreticalbackground..........................................................32.1BOOTLOADER..............................................................................................................................32.2CONTROLLERAREANETWORK...................................................................................................52.2.1ConceptofCAN................................................................................................................52.3AUTOSAR.................................................................................................................................62.4UNIFIEDDIAGNOSTICSERVICES(UDS)......................................................................................92.4.1RelationshipbetweenUDSandAUTOSAR....................................................................142.4.2AnUDSusecase:FlashReprogramming......................................................................192.5UNIVERSALMEASUREMENTANDCALIBRATIONPROTOCOL(XCP)..........................................202.5.1Packets............................................................................................................................212.5.2Security........................