June 23, 2019 | 1 Comment ECUHost OS Some people have been asking what is ECUHost? The simple answer is ECUHost OS is an automotive DIY operating system targeted at ARM Cortex-M micros, and the ECUHost V1.4 PCB is an example hardware module for the OS to run on. The heart of the ECUHost V1.4 PCB is the NXP MK60 micro that features two CAN interfaces, 10/100 Ethernet, a multitude of timed, analog and digital I/O, and optionally a wifi module. The OS and the V1.4 PCB are found in the GP-meter 6.0. The GP-meter 6.0 comes programmed with a boot-loader, the ECUHost OS Kernel, and an application to control the LSU4.2 sensor and display the result on the LCD display. Boot-loader & Kernel These components are the basis of the ECUHost OS. The boot-loader always runs at power up for 5 seconds. If a programming session doesn’t start, control jumps to the Kernel. This sequence is typical of pretty much all automotive electronic modules. If a programming session is needed, the boot-loader contains code that can update the software of the ECU. The Kernel contains all of the functions needed for a user application to ‘make things happen’ at the outputs of the ECU, in response to the inputs of the ECU. The Kernel is stand-alone machine that ‘knows’ how to perform timed fuel injection, measure an input frequency, read a temperature sensor, send a message over the CAN bus as well as a multitude of other tasks. It doesn’t have a mind of it’s own however – the Kernel only responds to requests from the user application. If there is no user application, the Kernel will pretty much sit in a loop doing nothing! User Application You can see in the above picture, the ECUHost (user) application sits on top of the software stack and is effectively the brains of the system. For example in the GP-meter 6.0, the user application measures and controls the LSU4.2 sensor temperature and pump current in order to calculate and display the air fuel ratio. In the Rabbit ECU Project the user applications main task is to measure engine sensor inputs, calculate a fuel injection quantity and trigger a fuel injection pulse. The way in which the user application interacts with the Kernel in ECUHost is by the Supervisor Call (SVC). This instruction is common to all ARM Cortex-M micros. Each SVC carries with it a function code, here are some examples of functions you can use with ECUHost OS: SETUP SetClientStartTask Adds a user module start function to user functions list SetClientCyclicTask Adds a user module run function to user functions list SetClientTerminateTask Adds a user module stop function to user functions list RequestIOResource Requests exclusive use of a resource SetupIOResource Configures an IO resource e.g. analog input SetupCTRLResource Configures a control resource e.g. PID controller block SetupSpreadResource Sets up a map spread resource SetupTableResource Sets up a 2D table SetupWorkingPage Sets up the calibration page dimensions SetupCrankTriggerEdgePattern Sets up the crank trigger pattern SetupSimpleCamSync Sets up cam sync pattern SetupSyncPointsPattern Sets up the sync points pattern ConfigureUserTEPMInput Sets up a user managed on/off timed sequence ConfigureKernelTEPMOutput Sets up a kernel managed on/off timed sequence SetupMapResource Sets up a 3D table PopulateADArray Sets a list of ADC channels to convert RUNNING IterateCTRLResource Runs a control resource once e.g. PID controller CalculateSpread Calculates the current spread e.g. MAP load spread CalculateTable Calculates a 2D table output based on input spreads CalculateMap Calculates a 3D table output based on input spreads GetSpreadResult Returns the current spread e.g. MAP load spread GetDIOResource Gets state of digital IO AssertDIOResource Turns on/off a digital IO output TriggerADQueue Starts an ADC conversion list AppendTEPMQueue Adds timed on/off sequence e.g. igniter output, PWM output WriteDACQueue Writes values to be output at DAC GetTimerValue Gets a hardware timer current value GetCRC16 Gets CRC16 of the calibration page CheckPartition Checks the calibration page for validity NVMWorkingCopy Copies NVM calibration to working buffer QueueCANMessage Sends a CAN message RequestIOBusTransfer Requests data transfer on a serial IO ECUHost & Teensy Teensy from pjrc.com is an ARM based DIY learning/interactive development PCB that I am porting ECUHost OS to. The beauty of Teensy is both its low cost and small size. The tiny dimensions of Teensy are great for creating a small automotive electronics project. The size compares favourably with the ECUHost V1.4 PCB. Teensy 3.5 features a BGA version of the NXP MK64 micro. The only downsides of using Teensy over ECUHost V1.4 are the loss of Ethernet and wifi as well a having only a single CAN bus and fewer analog inputs. The result is still a very powerful DIY system, with a whopping 18 timers, 6 analog inputs, 5 general purpose IO and plenty of communications. If you are game to solder onto the underside Teensy SMD pads, you can even unlock some additional I/O! The porting of ECUHost to Teensy is ongoing and will allow much smaller devices to be made DIY style. A sample boot-loader, Kernel and user application example will be available soon.