Close

CANable 2.5 Firmware from ElmüSoft - Slcan & Candlelight

While I added support for CANable adapters to HUD ECU Hacker I found so many issues that I ended up writing a new firmware.
The official firmware that you find on Github and that comes with the adapters bought in China is of low quality.
Here you find the first CANable firmware that can be used for professional CAN bus applications.
  1. I united 2 formerly separate firmware projects Slcan and Candlelight into one project with a common code base.
  2. The new CANable 2.5 firmware is high quality and open-source.
  3. If you noticed in the legacy firmware that CAN communication did not work you had no chance to find out why.
  4. Here you find the first CANable firmware with correctly implemented error handling telling you what is wrong.
  5. Although many new features were added, the new firmware is 100% backward compatible with legacy software.
  6. The firmware has been tested successfully with CAN FD baudrates up to 10 Mega baud.
  7. The firmware has been designed to be easily expandable for future requirements.
  8. The firmware has been written by a software developer with 40+ years of programming, reverse engineering and electronic experience.
Additionally with HUD ECU Hacker you get a powerfull tool with lots of features, the swiss knife for CAN bus.
  1. With the Firmware Updater you can upload the new firmware to your CANable with one click.
  2. Additionally you get a high speed CAN Raw Terminal that supports all the new features, but works also with legacy adapters.
  3. You can grab logfiles of CAN bus traffic.
  4. You can decode the CAN bus protocols ISO 15765, J1939 and NMEA 2000 that are used in motorbikes, cars, trucks and vessels.
  5. You can write ultra fast macro scripts that communicate with devices on CAN bus.

 

1.) User Manual

CANable Adapters

CANable - MKS Makerbase, Openlight Labs Adapter
Show Full Size
 
CANable - MKS Makerbase CANable board
Show Full Size
The CANable is a very cheap ($15 US) CAN bus adapter with CAN FD support.
Several Chinese companies sell different versions like: MKS MakerbaseDSD TechWalfront.
If you buy one make sure that it is a CANable 2.0 and has the STM32G431 processor.
Do not buy the older CANable 1.0 adapters which are obsolete because they don't support CAN FD.

I recommend the MKS Makerbase because it has a robust case and CAN bus is electrically isolated from USB.
It uses an ADM3050E isolated CAN Transceiver (Datasheet) and a B05050S-1WR3 isolated DC-DC Converter (Datasheet).
It has a manual switch that can connect a 120 Ω termination resistor to CAN bus.
I tested it thoroughly and it works perfectly up to 10 Mega baud.

Hardware Misdesign

CANable adapters have an extremely stupid hardware design:
They use the same processor pin for CAN RX and for BOOT0.
CANable 2.0 diagram
Show Full Size
When the pin BOOT0 is High during power ON the processor goes into Bootloader Mode.
In a correctly designed hardware this would only happen when the Boot Mode jumper is set.
But in this misdesign they must make sure that the CAN RX pin is Low when the processor is reset.
Therefore they use the transistors Q1 and Q2 which delay the power supply for the CAN transceiver.
Without these transistors the processor would always start in Boot Mode.

In Boot Mode the processor runs it's internal bootloader and is ready to receive a firmware update.
In Boot Mode only the red LED is on and you see a "STM Device in DFU mode" in Device Manager.
(DFU stands for "Device Firmware Updgrade")
In Boot Mode you cannot use the adapter to connect to CAN bus.

The consequence of this misdesign is that short interruptions of the 5V USB power will immediately enter Boot Mode.
This happens when you merely move the USB plug a little bit or when you reboot the computer.
During a reboot the mainboard interrupts the USB power supply for a short time.
Finally the Boot Mode jumper is not required to enter Boot Mode.
If you want to enter Boot Mode you only have to quickly disconnect and reconnect the USB cable.

If you want to leave Boot Mode you must disconnect the USB cable, wait 5 seconds, and reconnect USB.
If you don't wait 5 seconds you will get Boot Mode again. The condensator C3 must be discharged first.

This misdesign really sucks.
Therefore my CANable 2.5 firmware comes with a solution: You can disable the pin BOOT0.

Official Firmware for STM32G431

The CANable adpters use an open source firmware that was first developed by Geschwister Schneider.
Later it was adapted on Github to multiple processors and CAN FD support was added.
There are 2 versions: CANable 1.0 for older processors and version 2.0 with CAN FD support.
A big problem is the low quality and low speed of the officially available firmware.
Here you see the web updater on canable.io that offers 2 different firmware types.
canable.io   Web Updater
Official CANable firmware update
Show Full Size
This web updater works only in Chrome and requires that you install a driver which gives a website access to your USB devices.
I would never do that. This opens a security hole.

Slcan Protocol

When you connect a CANable with Slcan firmware a COM port will appear on Windows.
The entire communcation with CAN bus is transferred as ASCII characters.
This is a highly inefficient way to transmit binary data over a USB cable.
For each byte that you send to CAN bus two bytes must be transferred over USB.
The USB speed is limited to 12 Mbit/s but CAN bus can reach speeds up to 10 Mbaud.
The only advantage of the Slcan protocol is that it is simple.
There are even people who send commands manually to the adapter in Teraterm.
Slcan is for people who play around with CAN bus at the hobby level.
But Slcan is slow and not recommended for any professional use.

Candlelight Protocol

The Candlelight protocol sends binary data over USB and could theoretically make the best use of the USB speed.
But the official firmware from canable.io does not even implement CAN FD.
A correctly working Candlelight firmware for the STM32G431 processor did not exist nowhere.
I'am the first one who releases a functional Candlelight firmware for the STM32G431.
And my Candlelight 2.5 firmware implements a new protocol that optimizes USB data transfer to the maximum.
However, my firmware is still 100% backward compatible with the legacy protocol.

Inefficient USB Data Transfer

The following table compares the efficiency of different firmware versions receiving a CAN FD packet.
The payload in this example consists of a 29 bit CAN ID + 16 data bytes + flags = 21 byte.

19F50C02: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F (FDF, BRS)
FirmwarePayloadTransferred over USBEfficiency
Legacy Official Slcan21 bytePayload x 2 + 2 = 44 byte48 %
ElmüSoft Slcan 2.521 bytePayload x 2 + 2 = 44 byte48 %
Legacy Official Candlelight21 byteCAN FD not implemented0 %
ElmüSoft Candlelight 2.521 bytePayload + 2 = 23 byte91 %

Legacy Candlelight Installation not working

When you connect a CANable with Candlelight firmware, Windows should install the WinUSB driver automatically.
This works only if the firmware responds correctly to the Microsoft OS descriptor request.
Windows asks the firmware which driver it needs and the firmware tells Windows that it needs a WinUSB driver.
As simple as this is, you will not find any official firmware where this is implemented 100% correctly.
And the official firmware from canable.io is even such a crap that no driver is installed at all.
Many people have complained about this problem, but nobody ever cared to fix the many ugly bugs during six years.

This was another reason why I had to write a new firmware.
When you upload the new Candlelight 2.5 firmware from ElmüSoft, Windows will instantly install 2 drivers.
This happens so fast that you don't even notice it. There will be no window telling you that a driver is installed.
Windows installs the driver invisibly in the background in one second.

Microsoft OS Descriptor Request

The new Candlelight 2.5 firmware is the first Candlelight firmware that works 100% correctly on Windows.
Now you can test this on your own: Open your adapter with HUD ECU Hacker and you see all details in the Trace pane.
HUD ECU Hacker sends the Microsoft OS descriptor requests to the adapter and shows the adapter responses.
There are 3 requests that the adapter must answer correctly for 2 interfaces.

1.)
Here you see the correct response of the CANable 2.5 firmware:
String ID: 0xEE, Signature: "MSFT100", VendorCode: 0x20
Interface: 0, Version: 1.00, MS Compatible ID: "USB\MS_COMP_WINUSB"
Interface: 1, Version: 1.00, MS Compatible ID: "USB\MS_COMP_WINUSB"
Interface: 0, Property: "DeviceInterfaceGUIDs", Type: MultiString, Data: "{c15b4308-04d3-11e6-b3ea-6057189e6443}\0\0"
Interface: 1, Property: "DeviceInterfaceGUIDs", Type: MultiString, Data: "{c25b4308-04d3-11e6-b3ea-6057189e6443}\0\0"
Interface 0 is the Candlelight interface and Interface 1 is the DFU Firmware Update interface.
Both interfaces need a unique identifier (GUID) so Windows can install a driver for each interface.

2.)
This is the response of a legacy Candlelight 1.0 firmware that does not have a version number:
String ID: 0xEE, Signature: "MSFT100", VendorCode: 0x20
Interface: 0, Version: 1.00, MS Compatible ID: "USB\MS_COMP_WINUSB"
Interface: 1, Version: 1.00, MS Compatible ID: "USB\MS_COMP_WINUSB"
Interface: 0, Property: "DeviceInterfaceGUIDs", Type: MultiString, Data: "{c15b4308-04d3-11e6-b3ea-6057189e6443}\0\0"
Interface: 1, Error requesting MS OS Extended Properties descriptor.
The device has a buggy firmware. The driver for the firmware update (DFU) interface cannot be installed automatically.

3.)
And the worst is the Candlelight firmware ba6b1dd from the canable.io Web Updater.
No driver is installed at all because the firmware does not respond to the request. This firmware is garbage.

The new Firmware Updater

HUD ECU Hacker has a built-in Firmware Updater for all types of STM32 processors from ST Microelectronics.
HUD ECU Hacker
HUD ECU Hacker - CANAble Firmware Update
Show Full Size
 
Firmware Updater
HUD ECU Hacker - CANAble Firmware Update
Show Full Size
When you install HUD ECU Hacker you can chose between 4 different CANable 2.5 firmware versions:
File NameDestination Adapters
STM32G431 - Slcan2.5 - MksMakerbase.dfuMKS Makerbase, DSD Tech, Walfront
STM32G431 - Slcan2.5 - OpenlightLabs.dfuOpenlight Labs
STM32G431 - Candlelight2.5 - MksMakerbase.dfuMKS Makerbase, DSD Tech, Walfront
STM32G431 - Candlelight2.5 - OpenlightLabs.dfuOpenlight Labs
The only difference between the adapters is the pin that is used for the green LED.
Openlight Labs uses processor pin B11, while the other companies use pin A0.
If you install the wrong firmware the green LED will always be off.
If you have another adapter with a different pin assignment, send me an email, this can easily be adapted.

The firmware has been tested on the STM32G431 processor. But it should work on all processors of this serie:
STM32G441, STM32G471, STM32G473, STM32G474, STM32G483, STM32G484, STM32G491, STM32G4A1.

The HUD ECU Hacker Firmware Updater can flash any STM32 processor, also in older CANable 1.0 adapters.
Flashing the CANable is no risk. The processor has a hard-coded bootloader that cannot be destroyed.
When you connect the USB cable and the blue and green LED are not blinking alternatingly, the firmware is not working.
This may happen when you upload the firmware to the wrong processor. In this case you can simply flash it again.
Therefore it is strongly recommended that you first make a backup of the current firmware in the adapter.
With the button 'Download' you can store the current firmware into a DFU file.
This allows you to always revert the adapter to it's original state.

The firmware updater works with the DFU file format that has been developed by ST Microelectronics.
Apart from the flash data the DFU file contains additional information like name, target, version, memory address,...
If you have other firmware formats, like BIN, HEX or S19 you can copy them into the subfolder 'Firmware'.
The firmware updater will convert the files automatically into DFU files that match the currently selected device.

Before clicking the button 'Upload' you must select the target 'Internal Flash'.
The Firmware Updater can also write the Option Bytes and the One Time Programmable memory. But this is only for experts.

When you click the button 'Identify' the LED's on the CANable will blink, and with the next click they stop blinking.
This allows to distinguish with which adapter you are communicating if multiple adapters are connected at the same time.

The button 'Disable pin Boot0' is a workaround for the annoying hardware misdesign.
The processor will ignore the pin Boot0 and not enter bootloader mode alone when you only reboot the computer.
But this means that the processor will also NOT enter bootloader mode when you set the Boot Mode jumper.
You can easily revert this by clicking the button 'Enter DFU mode'.
The firmware will first activate the pin Boot0 again before you can upload any other firmware.

The new CANable 2.5 firmware has a command to enter the bootloader.
This means with the new firmware you just click a button and don't need to put a jumper on the board.

Meaning of the LED's

The red LED is connected to 5 Volt from USB. It cannot be controlled by the firmware. It is always On.
LED'sMeaningLED'sMeaning
The adapter is ready and closed.
1.) The adapter is open: No CAN bus traffic.
2.) The adapter is in Firmware Update mode.
3.) The USB bus is suspended in sleep mode.
1.) The adapter is open: RX CAN bus traffic.
2.) The adapter is closed: USB command received.
The adapter is blocked after a severe error
buffer overflow or bus off.
The adapter is open: TX CAN bus traffic.
1.) After Power-On both LED's flash alternatingly.
2.) Also when you click the button 'Identify'.
The adapter is open: RX+TX CAN bus traffic.
NOTE: The behaviour of the LED's has been fixed by ElmüSoft.
The legacy Slcan firmware did not show TX CAN bus traffic at all.
The legacy Candlelight firmware flashed the TX LED even if there was an error and the packet was never sent.

With the new CANable 2.5 firmware both LED's show exactly what is happening on CAN bus.
The green TX LED will only flash if a CAN packet has been sent successfully and acknowledged by the recipient.
The blue RX LED will always flash when a CAN packet was received even if the packet is blocked by a filter.

Cangaroo

People are told to use the Cangaroo software to connect to their CANable.
But the developer of Cangaroo was not able to calculate the settings for any given baudrate / samplepoint combination.
Instead he implemented hard-coded tables only for processors with 16 Mhz, 48 MHz and 170 MHz clock.
Cangaroo gives you very few options for CAN bus baudrates and much less options for the samplepoint.
When you connect an adapter with any other clock (for example 160 MHz) you cannot select any baudrate.
Cangaroo is not even able to show you an error message. It simply does not work and you don't know why you see nothing.
Cangaroo uses WinUSB in the wrong way which may result in wrong packet order at a high bus load.
Cangaroo may suddenly hang eternally and even crash.
Cangaroo is low quality software, as many projects on Github that have never been finished and that have bugs that never get fixed.

HUD ECU Hacker

The good news is that now you can use your CANable with HUD ECU Hacker, a high quality software.
HUD ECU Hacker is charityware, which means that the author does not earn any money with it.
If you like the software you are asked to give a donation to a charity organization of your choice.
CAN Raw Terminal
HUD ECU Hacker - CAN Raw Terminal
Show Full Size
 
J1939 Protocol
HUD ECU Hacker - J1939 Protocol
Show Full Size
 
NMEA 2000 Protocol
HUD ECU Hacker - J1939 Protocol
Show Full Size
HUD ECU Hacker is a powerful tool with lots of features, like the swiss knife for CAN bus and ECU's.
The CAN Raw Terminal allows you to see CAN bus traffic and send packets manually.
You can open multiple Terminal windows at once, one for each adapter.
You can also write macro scripts that receive packets and send responses and simulate any CAN controller.
You can grab logfiles from CAN bus traffic.
You can send the content of an entire logfile to CAN bus.

The CAN Raw Terminal is designed to communicate with a device on CAN bus.
There is another Terminal, the Sniff Terminal which allows to sniff CAN bus traffic silently without interference.
In the Sniff Terminal packets are normally not ACKnowledged, the adapter works in Silent Mode.

But HUD ECU Hacker would not be very useful if it would only show the raw packets that are transferred over CAN bus.
HUD ECU Hacker can decode the protocols ISO 15765, J1939 and NMEA 2000.
The J1939 protocol is used in on-highway, construction, agriculture and forestry vehicles.
The NMEA 2000 protocol is used in yachts, sailing boats, fisher boats and vessels.
And if you provide a DBC file HUD ECU Hacker can decode the CAN packets of any vehicle, like for example from your car.

CAN bus Settings

Here you can configure how HUD ECU Hacker connects to CAN bus.

CAN bus - Connection Settings  
Send always 8 data bytes
If you send classic packets with less than 8 bytes they are padded to 8 bytes,
while CAN FD packets are always padded to the next possible data length.

Show all packets on the bus
This checkbox turns off all filters and also the combobox "ID Length" is ignored.
No matter if you selected '11 Bit' or '29 Bit', you will see all packets on the bus.

Automatic Retransmission if no ACK received
If this checkbox is On the processor tries to send a packet until it is achnowledged.
After trying it 128 times in vain the processor goes into error state Bus Passive.
If the checkbox is Off the processor sends the packet in One shot mode.
If the packet is not acknowledged the processor does not send it again.

Show sent packets in Trace if ACK received
When a packet was acknowledeged you see the 'echo' of the Tx packet in olive color.
You see the exact timestamp when the packet has been acknowledged.
If the packet is not acknowledged you will not see any echo and the green LED does not flash.
This allows you to verify that a packet has been sent and received successfully.
The CANable 2.5 firmware is the first firmware where this is implemented correctly.
The legacy Slcan firmware did not implement this feature.
The legacy Candlelight firmware showed a fake echo, also for not acknowledged packets.

Suppress repeating identical CAN bus packets
CAN bus traffic is often very repetitive.
Here you can hide all packets that have already been shown with the same ID and data bytes.
You see each unique packet only once.

CAN Filter

Filters are a new feature that was missing in the legacy firmware.
CAN bus filters can drastically reduce the traffic over USB.
This is important because the USB speed is limited to 12 Mbit/s while CAN data may come with up to 10 Mbaud.
All traffic that does not interest you will not be sent over USB.

The screenshot above shows a filter that lets only pass the CAN ID's from 18EE0000 to 18EEFFFF.
Please read the chapter about CAN filters in the HUD ECU Hacker manual.

NOTE: The blue LED flashes when a CAN packet is received. It also flashes for packets that are blocked by the filters.
This means that the green and blue LEDs always show the entire CAN bus traffic, even if your filter blocks everything.

Samplepoint

The samplepoint is not really important for classic CAN.
But if you plan to use CAN FD you must enter the correct samplepoints, otherwise you will get problems
because on a CAN bus many controllers must synchronize to each other using the exactly same settings.

CAN Samplepoint

One bit of a CAN packet is sub-divided into multiple Time Quantums, in this example sixteen.
The samplepoint is the exact moment when the processor measures the state of the CAN bus: High or Low.
The samplepoint must be a fraction of 2 integers: 1/2 = 50%, 3/4 = 75%, 5/8 = 62.5%, 4/5 = 80%, 7/8 = 87.5%
A later samplepoint has the advantage that it allows longer cables, to compensate for the delay of distant controllers.
An earlier samplepoint has the advantage that it is more robust against cheap, unprecise oscillators and jitter.

But the major problem is that CAN FD switches the baudrate exactly at the samplepoint of the BRS bit.
If you did not enter the two samplepoints correctly you will not be able to communicate with the CAN bus.
You find a more detailed description with an oscilloscope screenshot in my Oszi Waveform Analyzer manual.

Baudrates

The processor needs 3 settings to configure baudrate and samplepoint:
  1. Bitrate Prescaler: the CAN clock is divided by the prescaler which gives the clock for one Time Quantum.
  2. Segment1: defines the count of time quantums before the samplepoint (in the above example = 11).
  3. Segment2: defines the count of time quantums after the samplepoint (in the above example = 4).
The STM32 processors treat the Synchronization segment separately. Therefore you must add 1 to Segment 1.
Example: CAN Clock = 160 MHz, Baudrate = 500 kBaud, Samplepoint = 75%, Time Quantums (TQ) per bit = 16.
This can be achieved by passing the following settings to the processor: Prescaler = 20, Segment1 = 11, Segment2 = 4.

Baudrate = 160 MHz / 20 / (1 + 11 + 4) = 500 kbaud
Samplepoint =   (1 + 11) / (1 + 11 + 4) = 0.75 = 75%

The legacy Slcan firmware gives poor options for the CAN FD baudrates: only 2 and 5 Mega baud.
The legacy Candlelight firmware can theoretically set any baudrate that is possible.
But for the calculation the host application must know the limits for the settings Prescaler, Segment1 and Segment2.
Every processor has a different range for these values.
The legacy Candlelight firmware reports wrong limits and so a correct calculation is impossible.

Summary: With none of the legacy firmware's can you set a precise baudrate/samplepoint as needed.
Additionally the legacy firmware uses a CAN clock frequency of 170 Mhz which is not an intelligent choice.
It is not possible to derive baudrates like 2, 4, 5 or 8 Mbaud with 50%, 62.5%, 75% or 87.5% samplepoint from 170 Mhz.
Therefore the new CANable 2.5 firmware changes the CAN clock to 160 MHz.

It is recommended by ST Microelectronics that the nominal and the data baudrate use the same prescaler.
The baudrate is switched exactly at the samplepoint of the BRS bit.
If the baudrates do not use the same prescaler, a phase shift will be the consequence which may corrupt the timing.
Another recommendation is that the prescaler should be as low as possible.
And the Synchronization Jump Width should be: SJW = min(Segment1, Segment2).
For more details read the PDF documents in subfolder Documentation.

All this baudrate / samplepoint stuff is quite complex and I have found many bugs in legacy code, so I implemented a check.
The host application sends the values for Prescaler, Segment 1 + 2 for the nominal and the data baudrate to the firmware.
And the firmware calculates the exact values and reports them in a debug message back to the host application.
When you open the adapter you see this debug message from the firmware:

Nominal: 500k baud, 87.5%; Data: 2M baud, 50.0%; Perfect match: Yes

When you see Perfect Match: Yes, this means that both baudrates use the same prescaler.
HUD ECU Hacker implements a complex algorithm that does all this calculation for you.
HUD ECU Hacker tries to find the perfect settings for your nominal/data baudrates/samplepoints.
If a samplepoint cannot be matched exactly, it shows a warning and uses the nearest value that is possible.
If a baudrate cannot be matched it shows an error.

CAN FD Arbitration / Data phase

CAN bus Errors

The legacy Slcan firmware has no error reporting at all.
When you send a packet to CAN bus you have no idea if the packet was really sent or not.
After sending an invalid parameter, for example when setting the baudrate, you will never know why you cannot connect to CAN bus.
And the legacy Candlelight firmware has an error reporting, but only for CAN bus errors and there are many issues.

I implemented a proper error reporting for CAN bus errors and also for command errors.
Whenever a software or firmware does not work, but shows no error, be sure that it was written by a sloppy programmer.
With the new firmware it will never again happen that something does not work and you have no idea why.

  1. The first error on CAN bus is always reported immediately.
  2. A second error is only reported after 100 ms have elapsed and only if the second error is different from the
    previously reported. This is important to avoid flooding the host with thousands of errors as the legacy firmware did.
  3. If the same error stays present for a long time, it is reported in intervals of 3 seconds.
21:20:14.788Send Packet
21:20:14.78818EEFF01: 01 02 03 04 05 06 07 08             <—— this packet was sent successfully
21:20:14.79018EEFF01: 01 02 03 04 05 06 07 08             <—— this is the Tx echo
21:20:18.119Send Packet                                   <—— send with auto-retransmission ON
21:20:18.11914A90022: 01 02 03 04 05 06 07 08             <—— this packet was not acknowledged
21:20:18.120Bus Active, Tx Errors: 8                      <—— first error immediately
21:20:18.220Bus Passive, No ACK received, Tx Errors: 128  <—— second error after 100 ms
21:20:18.738Send Packet
21:20:18.73814A90022: 01 02 03 04 05 06 07 08             <—— this packet was not acknowledged
21:20:21.216Bus Passive, No ACK received, Tx Errors: 128
21:20:24.212Bus Passive, No ACK received, Tx Errors: 128  <—— same error repeated every 3 seconds
21:20:27.208Bus Passive, No ACK received, Tx Errors: 128

All controllers on CAN bus share the same two data wires.
If only one controller has a bug and breaks the rules of CAN bus, it will screw up the traffic of all the others.
Thefore it is fundamentally important that a controller turns off it's transmitter, when it has detected a problem.
This error detection must be implemented in hardware. It must be immediate and bullet proof.
Therefore all processors that have a CAN bus controller distinguish these 4 states:
  1. Bus Actice (no errors or less than 96 errors)
  2. Warning Level (between 96 and 128 errors)
  3. Bus Passive (between 128 and 248 errors)
  4. Bus Off (more than 248 errors)

In the arbitration phase it is allowed that multiple controllers send at the same time. One of them will win the arbitration.
But in the data phase there must be only one controller sending data.
If the processor detects a case of a severe data corruption it immediately stops transmitting and goes into Bus Off state.
Bus Off is a severe error that you can create by sending packets between two adapters configured for different baudrates.

22:21:24.187Send Packet
22:21:24.187170AA3CB: 01 02 03 04 05 06 07 08
22:21:24.623Bus Passive, Bit stuffing error,  Tx Errors: 128, Rx Errors: 8 <—— corruption while sending
22:21:27.618Bus Passive, Recessive bit error, Tx Errors: 128, Rx Errors: 8
22:21:30.367Bus Off, Frame format error, Tx Errors: 248, Rx Errors: 127    <—— corrupt packet received

With a little experience you can deduce what is wrong on CAN bus by understanding what these errors mean.
If there is a severe error like Bus Off of Buffer Overflow, the green and blue LED's are permanently On.

Transmit Timeout

If automatic retransmission is enabled and the processor does not receive an ACK it goes into Tx Bus Passive state.
In this state the processor re-transmits the first packet in the Tx FIFO eternally creating 95% bus load.
The name 'Bus Passive' is totally misleading. The bus is not passive. In the opposite it is flooded with traffic.
On the oscilloscope you see the same packet retransmitted with nearly no pauses in between.

CAN traffic duringh Bus Passive

Therefore I implemented a Tx timeout. Pending Tx requests are cancelled after 500 ms.
You see an error report:

Bus Passive, Tx Timeout, No ACK received, Tx Errors: 128

The error counter stops counting at 128, but without a timeout there may be thousands of failed transmit attempts.

Transmit Echo Markers

The legacy Slcan firmware never gave you any feedback if a packet was sent or not.
The legacy Candlelight firmware had a wrongly designed feedback mechanism for Tx packets:
When the firmware received a Tx packet it has sent the entire Tx packet in a fake event back to the host.
This feedback was immediate, no matter if the packet was really sent to CAN bus or not.
For a CAN FD packet with 8 data bytes the firmware sent a fake event of 80 bytes over USB back to the host.
These fake events produced a lot of useless USB traffic, could not be turned off and the timestamps were wrong.

CAN Tx Event Marker

The new firmware can receive an 8 bit marker with each transmit packet from the host application.
When the packet has been sent successfully to CAN bus the processor fires a Tx Event that contains the marker.
The host application must store the last sent packets in an internal array (study the code of the Demo Application).
The maximum count of packets that can be stored in the adapter is 64 + 3 = 67.
An 8 bit marker can have values from 0 to 255 which is more than enough to give each Tx packet a unique marker.

The advantage is that the user has a reliable feedback which packets have really been sent.
In One-Shot mode (no re-transmission) this is the only way to know if a packet has been acknowledged or not.
The user can also see the exact time when the packet has been dispatched to CAN bus.
By using markers only one byte is transferred back to the host, rather than the entire packet (See example).

Timestamps

I have seen Slcan firmware that sends timestamps over USB to the host application.
A 32 bit timestamp is sent as 8 ASCII characters with each received packet.
Using an ASCII protocol is already inefficient. See Comparison.
But making USB traffic even slower by inflating each packet with 8 additional bytes is a bad idea.

The CANable 2.5 firmware is speed optimized to the maximum that is possible.
Therefore timestamps are not implemented for Slcan, by purpose.

The Candlelight 2.5 firmware maintains 1 µs timestamps for backward compatibility.
These occupy only 4 bytes and can be turned off.

However, I recommend to use timestamps created by the performance counter in the computer CPU.
This 64 bit counter has a precision of nanoseconds.
When a packet arrives over USB you attach a timestamp to it.
The C++ Demo Application shows both: How to use timestamps from firmware and from performance counter.

Enter DFU mode

The new Slcan and the new Candlelight firmware have a new command to enter DFU mode.
The boot mode jumper will not be required anymore.

Before entering boot mode the firmware enables the pin BOOT0 if it was disabled.
If the pin BOOT0 was disabled the processor will not enter boot mode before it receives a hardware reset.
This means the user must reconnect the USB cable. This is only required if the pin BOOT0 was disabled before.

Other than the legacy firmware, the new firmware waits a delay of 300 ms before entering boot mode.
This guarantees that always a feedback is sent back to the host telling if the command was successful or not.

Bugfixes

I fixed several bugs in the legacy firmware. The top worst bugs were:
  1. The Candlelight firmware could crash completely after a buffer overflow.
  2. Candlelight had a misdesign: it used only one buffer for CAN Rx and Tx.
    The consequence was that after a CAN buffer overflow it could not even send the error status to the host.
  3. Candlelight did not send USB traffic correctly. USB Packets with exactly 64 bytes arrived wrong.

Bus Load

The new firmware can calculate the bus load. It is displayed in percent in an interval that the user can define.
HUD ECU Hacker shows the bus load every 5 seconds in the Trace pane, if it is not zero.
The calculation of the bus load is quite complex. It may have a deviation of +/- 10%.

Transceiver Delay

The delay of the CAN bus transceiver chip is relevant for baudrates above 1 Mega baud.
The processor automatically measures the delay and the firmware reports it.
You see a debug message after the first CAN FD packet that you send with the BRS flag set:

23:32:21.06919858A01: 0C 00 00 00 F0 18 51 0E (FDF, BRS)
23:32:21.073Measured transceiver chip delay: 131 ns
23:32:21.07319858A01: 0C 00 00 00 F0 18 51 0E (FDF, BRS)

Normally transceiver chips have a delay around 50 ns.
But the isolated chip in the MKS Makerbase that you see here is slower. (Datasheet).

 

2.) Application Developer Manual - Slcan

This manual is for software developers who want to communicate with the CANable 2.5 from a computer.
In Slcan all commands and responses are sent as ASCII strings which is slow. See Comparison.
For professional applications use Candlelight and not Slcan.

The first character is the command to execute. The last character is always a Carriage Return.

Slcan Commands

CommandConditionVersionMeaningComment
"A1\r"ClosedlegacyEnable Auto RetransmissionRetransmit packets until they are acknowledged
"A0\r"ClosedlegacyDisable Auto RetransmissionEnable one shot mode
"C\r"Open/ClosedlegacyClose the adapterShut down CAN connection, reset to default settings
"L7\r"Open/Closed100Enable Bus Load reports every 700 ms
L1: Report interval= 100 ms, L50: Interval= 5 seconds
Valid range of interval: 0 ... 100 (max 10 seconds)
"L0\r"Open/Closed100Disable Bus Load report
"O\r"ClosedlegacyOpen adapterConnect to CAN bus with the mode set by M0 / M1
"ON\r"Closed100Open in normal modeIgnore settings with M0 / M1
"OS\r"Closed100Open in silent modeIgnore settings with M0 / M1
"OI\r"Closed100Open in internal loopback modeIgnore settings with M0 / M1
"OE\r"Closed100Open in external loopback modeIgnore settings with M0 / M1
"V\r"Open/ClosedlegacyReturn detailed info: Version/Board/MCU/LimitsReturns seven key/value pairs. See Version Info
Set ModesConditionVersionMeaningComment
"M1\r"ClosedlegacyEnable silent modeThe next command "O\r" will open in bus monitoring mode
"M0\r"ClosedlegacyDisable silent modeThe next command "O\r" will open in normal mode
"MA\r"Closed100Enable Auto Retransmission mode (same as A1)Retransmit packets until they are acknowledged
"Ma\r"Closed100Disable Auto Retransmission mode (same as A0)Enable one-shot mode
"MD\r"Open/Closed100Enable Debug MessagesFirmware sends string messages to the host
"Md\r"Open/Closed100Disable Debug MessagesDo not send debug messages
"ME\r"Open/Closed100Enable CAN Error reportsCAN errors are sent to the host
"Me\r"Open/Closed100Disable CAN Error reportsCAN error reporting is off (deprecated!)
"MF\r"Open/Closed100Enable Feedback modeFor each command a success/error feedback is sent
"Mf\r"Open/Closed100Disable Feedback modeCommand Feedback mode is off (deprecated!)
"MI\r"Open/Closed100Enable Identify modeThe green/blue LED's start blinking
"Mi\r"Open/Closed100Disable Identify modeThe LED's stop blinking
"MM\r"Open/Closed100Enable Tx echo report markerReport all successfully sent packets with a marker
"Mm\r"Open/Closed100Disable Tx echo report markerNo Tx Echo report
"MR\r"Open/Closed100Enable 120 Ω Termination ResistorSupported only by few boards
"Mr\r"Open/Closed100Disable 120 Ω Termination Resistor
"MS\r"Open/Closed100Enable ESI reportReport the ESI flag of received CAN FD messages
"Ms\r"Open/Closed100Disable ESI reportNo ESI report
"MDEFMS\r"Open/Closed100Enable Debug, Error, Feedback, Echo, ESI reportsYou can set all modes at once in one command
Set BaudratesConditionVersionMeaningComment
"S0\r"ClosedlegacySet nominal baudrate 10 kbaudSamplepoint 87.5%
"S1\r"ClosedlegacySet nominal baudrate 20 kbaudSamplepoint 87.5%
"S2\r"ClosedlegacySet nominal baudrate 50 kbaudSamplepoint 87.5%
"S3\r"ClosedlegacySet nominal baudrate 100 kbaudSamplepoint 87.5%
"S4\r"ClosedlegacySet nominal baudrate 125 kbaudSamplepoint 87.5%
"S5\r"ClosedlegacySet nominal baudrate 250 kbaudSamplepoint 87.5%
"S6\r"ClosedlegacySet nominal baudrate 500 kbaudSamplepoint 87.5%
"S7\r"ClosedlegacySet nominal baudrate 800 kbaudSamplepoint 87.5%
"S8\r"ClosedlegacySet nominal baudrate 1 MbaudSamplepoint 87.5%
"S9\r"ClosedlegacySet nominal baudrate 83.333 kbaudSamplepoint 87.5%
"Y0\r"Closed100Set CAN FD data baudrate 500 kbaudSamplepoint 75%
"Y1\r"Closed100Set CAN FD data baudrate 1 MbaudSamplepoint 75%
"Y2\r"ClosedlegacySet CAN FD data baudrate 2 MbaudSamplepoint 75%
"Y4\r"Closed100Set CAN FD data baudrate 4 MbaudSamplepoint 75%
"Y5\r"ClosedlegacySet CAN FD data baudrate 5 MbaudSamplepoint 75%
"Y8\r"Closed100Set CAN FD data baudrate 8 MbaudSamplepoint 50%   (75% does not work on STM32G431)
"s4,69,10,7\r"Closed100Set nominal bitrate: Prescaler=4,
Seg1=69, Seg2=10, Synchr. Jump Width=7
Set 500 kbaud, Samplepoint 87.5%
See Samplepoint
"y4,9,10,7\r"Closed100Set data bitrate: Prescaler=4,
Seg1=9, Seg2=10, Synchr. Jump Width=7
Set 2 Mbaud, Samplepoint 50%
See Samplepoint
Set FiltersConditionVersionMeaningComment
"F7E8,7FF\r"Closed100Set a mask filter for only one ID: 7E8 (11 bit)
You can set up to 8 mask filters separated by semicolons.
11 bit and 29 bit filters can be mixed.
See CAN Filters.
"F18DA00F1,1FFF00FF\r"Closed100Set a mask filter for 256 IDs: 18DAXXF1 (29 bit)
"F7E0,7F0;720,7F0;730,7F0\r"Closed100Set 3 filters for 16 ID's each: 7EX, 72X and 73X
"f\r"Closed100Clear all filtersRemove all filters
Boot ModeConditionVersionMeaningComment
"*Boot0:Off\r"Closed100Disable pin BOOT0See Hardware Misdesign
"*Boot0:?\r"Open/Closed100Request status of pin BOOT0returns "+1\r" if enabled or "+0\r" if disabled
"*DFU\r"Open/Closed100Enable pin BOOT0 and enter DFU modeIf feedback = FBK_ResetRequired: Reconnect USB cable!
Transmit PacketsConditionVersionMeaningComment
"Txxxxxxxxx\r"OpenlegacySend classic packet with 29 bit IDBits: IDE     See Slcan Packets
"txxxxxxxxx\r"OpenlegacySend classic packet with 11 bit IDBits: None
"Rxxxxxxxxx\r"OpenlegacySend Remote Transmission Request with 29 bit IDBits: RTR + IDE
"rxxxxxxxxx\r"OpenlegacySend Remote Transmission Request with 11 bit IDBits: RTR
"Dxxxxxxxxx\r"OpenlegacySend CAN FD packet, 29 bit, no baudrate switchBits: FDF + IDE
"dxxxxxxxxx\r"OpenlegacySend CAN FD packet, 11 bit, no baudrate switchBits: FDF
"Bxxxxxxxxx\r"OpenlegacySend CAN FD packet, 29 bit with baudrate switchBits: FDF + BRS + IDE
"bxxxxxxxxx\r"OpenlegacySend CAN FD packet, 11 bit with baudrate switchBits: FDF + BRS

Slcan Responses and Events

FeedbackVersionMeaningComment
"#\r"100The command has executed successfullyRequires Feedback mode to be enabled
"#1\r"100The command is invalidRequires Feedback mode to be enabled
"#2\r"100A parameter of the command is invalidRequires Feedback mode to be enabled
"#3\r"100The command reqires the adapter to be openRequires Feedback mode to be enabled
"#4\r"100The command reqires the adapter to be closedRequires Feedback mode to be enabled
"#5\r"100The HAL from ST Microelectronics reported an errorRequires Feedback mode to be enabled
"#6\r"100The feature is not supported by the board / not implementedRequires Feedback mode to be enabled
"#7\r"100The CAN Tx Buffer is full (no ACK received, 67 packets waiting)Requires Feedback mode to be enabled
"#8\r"100CAN bus is off (a severe CAN error has occurred)Requires Feedback mode to be enabled
"#9\r"100Sending packets is not possible in silent modeRequires Feedback mode to be enabled
"#:\r"100The required baudrate has not been setRequires Feedback mode to be enabled
"#;\r"100Programming the Option Bytes in flash memory failedRequires Feedback mode to be enabled
"#<\r"100Please reconnect the USB cable, a hardware reset is requiredRequires Feedback mode to be enabled
ResponseVersionMeaningComment
"+Text\r"100The firmware sends a text response to a commandUsed by commands "*Boot0:?\r" and "V\r"
EventVersionMeaningComment
">Message\r"100The firmware sends a debug message (plain text)Requires Debug Messages to be enabled
"Exxxxxxxx\r"100The firmware reports the CAN Error Status (See Slcan Errors)Requires CAN Error Reports to be enabled
"L27\r"100The firmware has calculated a bus load of 27%.
If the bus load is zero, no report is sent.
Requires Bus Load Reports to be enabled
"M3C\r"100The firmware reports the Tx echo marker 0x3C (See Slcan Packets)Requires Tx Echo Report markers to be enabled
Rx PacketsVersionMeaningComment
"Txxxxxxxxx\r"legacyReceived classic packet with 29 bit IDBits: IDE   (See Slcan Packets)
"txxxxxxxxx\r"legacyReceived classic packet with 11 bit IDBits: None
"Rxxxxxxxxx\r"legacyReceived Remote Transmission Request with 29 bit IDBits: RTR + IDE
"rxxxxxxxxx\r"legacyReceived Remote Transmission Request with 11 bit IDBits: RTR
"Dxxxxxxxxx\r"legacyReceived CAN FD packet, 29 bit, no baudrate switchBits: FDF + IDE
"dxxxxxxxxx\r"legacyReceived CAN FD packet, 11 bit, no baudrate switchBits: FDF
"Bxxxxxxxxx\r"legacyReceived CAN FD packet, 29 bit with baudrate switchBits: FDF + BRS + IDE
"bxxxxxxxxx\r"legacyReceived CAN FD packet, 11 bit with baudrate switchBits: FDF + BRS

Slcan Version Info

In the new firmware the command "V\r" returns one string with seven key/value pairs separatad by tab characters.
It starts with a plus character that indicates a command response with text content, rather than a feedback response (#).

+Board: MksMakerbase\t
MCU: STM32G431\t
DevID: 1128\t
Firmware: 25.09.14\t
Slcan: 100\t
Clock: 160\t
Limits: 512,256,128,128,32,32,16,16\r

Split this string at each tab character ('\t') and then each part at the colon. You get 7 key/value pairs:
KeyValueComment
BoardMksMakerbase
This defines for which board the firmware was compiled.
It may not match the real hardware if the user has uploaded the wrong firmware.
See Firmware Versions
MCUSTM32G431
This defines for which processor the firmware was compiled.
It may not match the real processor if the user has uploaded the wrong firmware.
See Firmware Versions
DevID1128
This is the "Device ID" of the real processor. Convert 1128 to hex and you get 0x468.
Each processor serie is identified by a unique "Device ID".
In the Reference Manual from ST Microelectronics you find these identifiers:
0x468 = Category 2 devices (STM32G431, STM32G441)
0x469 = Category 3 devices (STM32G471, STM32G473, STM32G474, STM32G483, STM32G484)
0x479 = Category 4 devices (STM32G491, STM32G4A1)
Firmware25.09.14
The legacy firmware has returned completely meaningless version numbers like "ba6b1dd".
Here you get a version number that indicates the date when the firmware was created.
The version "25.09.14" means 14th september of 2025.
Slcan100
This is the version of the Slcan module that you see in the tables above in column 'Version'.
The first version created by ElmüSoft is version 100 which contains all the features described here.
Future versions will be 101, 102, etc and contain new commands which will be documented here.
Use this version number to detect which features are supported by the firmware.
Clock160The CAN clock is 160 MHz
Limits512,256,128,128,
32,32,16,16
These 8 values are the upper limits for the bitrate commands 's' and 'y'.
Each processor has different limits for Prescaler, Segment1, Segment2 and Synchr. Jump Width.
Nominal baudrate: max Prescaler= 512, max Seg1 = 256, max Seg2= 128, max SJW = 128
FD Data baudrate: max Prescaler= 32, max Seg1 = 32, max Seg2= 16, max SJW = 16
See Samplepoint

Slcan Packets

All packets are transmitted using this pattern:
DirectionPacketSlcanComment
Both18AABBCC: 11 22 33 44 55"T18AABBCC51122334455\r"Classic, 29 bit ID
Both7E0: 11 22 33 44 55 66 77 88 99 AA BB CC"d7E09112233445566778899AABBCC\r"CAN FD, 11 bit, FDF
Receive7E0: 11 22 33 44 55 66 77 88"b7E081122334455667788S\r"FDF, BRS, ESI
Transmit7E0: 11 22 33 44 55 66"t7E061122334455663F\r"Marker = 3F
Example:
Tx: "t7E061122334455663F\r" <—— send packet with marker 3F
Rx: "#\r"                   <—— receive command feedback (Success)
Rx: "M3F\r"                 <—— receive echo marker 3F

Slcan Error Reports

When CAN Error Reports are enabled you get an error report only if at least one error is present.
Errors are sent immediately, after 100 ms or after 3 seconds as explained above.
An error report is always of the form "Exxxxxxxx\r" and consists of 5 parts:
DigitMeaningValue
1Bus Status
'0' = Bus Active
'1' = Warning Level
'2' = Bus Passive
'3' = Bus Off
2Last Protocol Error
'0' = None
'1' = Bit stuffing error
'2' = Frame format error
'3' = No ACK received
'4' = Recessive bit error
'5' = Dominant bit error
'6' = CRC error
3 + 4Firmware Error Flags
0x00 = None
0x01 = Rx Failed
0x02 = Tx Failed
0x04 = CAN Tx buffer overflow
0x08 = USB IN buffer overflow
0x10 = Tx Timeout
Multiple flags may be combined
5 + 6Tx Error Count0 ... 255 errors
7 + 8Rx Error Count0 ... 255 errors
Example: "E2310800C\r" means:
Bus is passive, No ACK received, Tx Timeout, 128 Tx Errors, 12 Rx Errors

Slcan Initialization

When connecting to a CANable 2.5 adapter you should follow this sequence:
  1. Send command "C\r" to close the device if it is till open.
    But this command has also another purpose: It resets all internal variables in the firmware to their default.
    Baudrates and all modes are reset (back to legacy), reports turned off, filters removed, Rx/Tx buffers are emptied.
    ATTENTION: The command 'Close' is the only command that does not send a feedback, although feedbacks are enabled.
    The purpose is that you can always send this as the first command and don't have to wait for a feedback.
    When you connect to a CANable you don't know if the user has connected a legacy device or a CANable 2.5
    Additionally the firmware cannot know at this moment if you will enable feedback mode later or not.
    Therefore the command 'Close' behaves exactly as the legacy command: It never sends a feedback.
  2. Send command "V\r" to get the Version String.
    Split the response string at the tab characters.
    When you get 7 parts or more you are communicating with a CANable 2.5, otherwise it is a legacy firmware.
    If you don't support legacy devices show an error message, otherwise switch to legacy mode.
    If it is a CANable 2.5 use the Slcan Version Number (100 or higher) to check which features are available.
  3. Send command "MF\r" to enable feedback mode (or "MADEFMS\r" with all the other modes that you need)
    This will be the first command that sends a feedback.
    From now on you must wait for the feedback "#\r" and check for errors before sending the next command.
  4. Send command 'S' or 's' to set the nominal baudrate.
  5. If you also send command 'Y' or 'y' to set the data baudrate, the firmware will switch automatically into CAN FD mode.
  6. Now you can optionally set filters
  7. Finally execute command "ON\r" to open the device in normal mode.
RS232 Terminal
CANable 2.0 diagram
Show Full Size
 
Here you see the initialization sequence sent manually to the adapter.
Use the RS232 Terminal in HUD ECU Hacker.

The baudrate that you enter to open the COM port is irrelevant.
The port runs always with maximum USB speed (12 MBit).

 

3.) Application Developer Manual - Candlelight

The Candlelight 2.5 firmware can be used to build professional high speed CAN FD applications.
Controlling the Candlelight firmware is more complex than the Slcan firmware.
There are lots of structures and enums. Explaining them all here would explode this manual.

C++ Demo Application

Therefore I wrote a ready-to-use C++ Candlelight class that you can copy and paste into your project.
This robust and well tested class demonstrates all the features that the new firmware offers:
The source code is full of detailed comments so you can easily understand how it works.

The C++ demo also shows how to use WinUSB.dll correctly which is more complex than it seems at the first look.
For example in Cangaroo and in Candle.NET they use WinUSB wrongly which results in packet loss or wrong packet order.
WinUSB requires an unusal programming that is not documented by Microsoft.

Candlelight C++ demo project

The new ElmüSoft Protocol

The legacy Candlelight protocol had several design errors.
For example when a CAN FD packet was transmitted to the host they sent the timestamp behind a fix array of 64 data bytes.
Adding more unneccessary overhead resulted in sending always 80 bytes over USB, even for a packet with only 8 data bytes.

Additionally the legacy protocol was never designed to transmit anything else than CAN packets.
It was impossible to transfer other data to the host, like for example an ASCII debug string.

Therfore I had to design a new efficient protocol: The ElmüSoft protocol.
It adds only 2 additional bytes the CAN packet payload while transmitting over USB.
It uses a minimalistic data transfer and is additionally very easy to expand for any future requirements.

The new firmware 2.5 still implements the legacy Geschwister Schneider protocol, but can be switched to the new protocol.
The new protocol sends optimized structs for Tx and Rx packtes, Echo Markers, Debug Messages, Error reports, Busload events.
You can test all this in the demo application.

The screenshot above uses timestamps from the computer CPU. They are converted to local time with 1 µs precision.
When you set the flag GS_DevFlagTimestamp the demo switches to firmware timestamps generated in the adapter.
They have no advantage at all. They produce more USB traffic and you will see several lines with "No Timestamp".
The reason is that firmware timestamps are only available for events received from the firmware.
But when you send a packert to the firmware you don't get a timestamp.

Enter DFU mode

A SETUP request with DFU_Detach to interface 1 (DFU) enables boot mode.
Then immediately send a SETUP request with DFU_GetStatus to check if execution was successful.
If the state is DfuState_AppIdle the adapter will enter boot mode 300 ms later.
If the state is DfuState_AppDetach you must show a message to the user to reconnect the USB cable.
The USB reconnection is only required if the pin BOOT0 was disabled before.
The demo application shows the entire procedure.
See pages 17 and 22 in DFU Functional Descriptor 1.1.pdf in subfolder Documentation.

 

4.) Firmware Developer Manual

This is the first project that unites two firmware's, written by different persons, into one project.
The new CANable 2.5 firmware uses the same code base to compile Slcan and Candlelight.
The CAN interface, error handling, LED control, entering DFU mode, etc... use common code.
Only the USB interface and the command executer are implemented individually.
Each project has an own Make file that inculdes the corresponding subfolder: Slcan or Candlelight.

Caveat

The code in this project is not for beginners.
You need several years of embedded C programming experience and hardware knowledge.

Adding new boards

In the file settings.h you find the definitions for the boards.
Currently there are the pin defintions for the boards from MKS Makerbase and Openlight Labs.
The new board must be defined in a new Make file as TARGET_BOARD

Adding new processors

Also in settings.h are the includes of the HAL files (Hardware Abtraction Layer) from ST Microelectronics.
For another processor serie the required HAL files must be added into a new subfolder.
The new processor must be defined in a new Make file as TARGET_MCU

USB Interface

The USB interface is by far the most complicated code in the firmware.
ST Microelectronics gives us a HAL that is scatterd over eleven files calling from one file into another.
All the USB stuff is called from multiple interrupt handlers.

If you don't know what is a SETUP request, what is an OUT endpoint or what stalling an endpoint means,
I recommend that you read the exellent USB tutorial in subfolder Documentation.

Compiling STM32 code on Windows

You find a lot of instructions in internet how to compile the firmware on Linux.
But there is nothing for Windows developers, although it is quite simple.

Cube Programmer
If you think that you can install the STM32 Cube Programmer from ST Microelectronics
and you will get a comfortable developer environment, you are completely wrong!
After downloading this Gigabyte monster you will find a very badly designed user interface,
an extremely slow software and you notice that it is not able to compile a Make file.
Several menu items are greyed out without an understandable reason and the help file is no help.
So don't waste your time with this.
ST Microelectronics has only hardware engineers, they have nobody who is able to write desktop software.

Intallation
  1. Install STM32 Cube CLT (STM32 Command Line Compiler)
    From the drop down list on the ST website you can select the oldest version (300 MB).
    The newer the version, the bigger it gets. The latest version is 1 Gigabyte. You don't need that.
  2. Install MinGW (Minimalist GNU for Windows)
    The only files that you need from this installation are make.exe and mkdir.exe and their 6 DLLs:
    libgcc_s_dw2-1.dll, libiconv-2.dll, libintl-8.dll, msys-1.0.dll, msys-iconv-2.dll, msys-intl-8.dll
  3. Rename mkdir.exe into mmkdir.exe to avoid collision with the MKDIR command in the Windows console.
  4. In the Advanced System Settings search the PATH variable and add two folders separated by semicolon:
    The folder into which CubeCLT has installed the file arm-none-eabi-gcc.exe
    The folder into which MinGW has installed the file make.exe
    You can also copy make.exe and mmkdir.exe and their DLLs into the CubCLT directory and you need only one folder.
  5. Now double click the file Build_Slcan.cmd in my project and the compilation should start.
    This script copies the compiled BIN files automatically into the Firmware folder of HUD ECU Hacker.
  6. The Firmware Updater will convert the BIN files automatically into DFU files that you can upload.

Source Code

You find the source code on Github.

Version Numbers

When you add new features to the firmware don't forget to adapt FIRMWARE_VERSION_BCD in settings.h
After adding new Slcan commands you must increase SLCAN_VERSION and add the new commands to the documentation.


 

 
 
 

High Quality Software  from  ElmüSoft

Desktop Organizer & Event Calendar
My program PTBSync (in english + deutsch) has an event calendar / scheduler with lots of features, calculates the holidays of 70 countries, can display multiple gadgets on the desktop (current weather, birthdays, moon phase, menstruation calendar, world clocks,...) pins notes on the desktop, replaces the primitive Windows trayclock and adds a detailed tooltip, synchronizes with an atomic clock, and much more.
ECU Scanner, ECU Hacker, ECU Tuner for motorbikes, cars, trucks, vessels
connects to ECU's (Engine Control Units) from motorbikes, cars and trucks, shows parameters, clears DTC's, has tuning for a Delphi ECU, has an ECU emulator, can analyze the CAN bus using cheap adapters, supports many protocols, has a sniffer and manual data injection for K-Line and CAN Bus, allows you to write your own macro scripts that communicate over K-Line and CAN Bus.
Oscilloscope Waveform Logicanalyzer
displays oscilloscope waveforms and has A/D converters, noise suppression, precise time measurement, logic analyzer with decoders for UART, SPI, I²C, CAN bus (also CAN FD) and chip-specific decoders. Can split half-duplex communication. Transfers signals over USB (SCPI) from the oscilloscope to the computer and remote controls the oscilloscope. It is open-source and you can extend it with new features.
Subtitle Tuner
calculates the display duration of the subtitles based on the count of characters in the text. This avoids that badly created subtitles disappear before you could read them. Can remove deaf texts, lyrics, italic/bold. Can resynchronize a subtile to a movie with different framerate or change the subtitle offset.
Secure Doorlock with RFID Cards
is a project with an RFID antenna and a Teensy processor that opens a door with Mifare Desfire cards. The RFID cards of up to 64 users can be stored in the flash memory. It is extremely secure because it uses strong encryption. A big battery assures that the door can be opened during a power failure.
Remote Control your Computer with Infrared
An infrared receiver and a Teensy processor allow to remote control the music player on your computer with any old remote control that you have from a TV, amplifier, DVD player, SAT tuner or whatever. The Teensy simulates a keyboard and sends keystrokes to the music player.
3D Render and Editor Control in C#
A .NET control that can be easily implemented into System.Windows.Forms applications to display 3D graphs. The user can move and rotate the graph with the mouse and edit single points. Many display modes are available: 3D surface, 3D shapes, 3D lines, 3D objects, also animated 3D objects.
CAN FD adapter - CANable 2.5 Firmware Update - Candlelight & Slcan
I wrote two completely new firmwares for the CANable adapter with the STM32G431 processor (for example from MKS Makerbase). The official Slcan firmware has several issues and the official Candlelight firmware is complete crap. I fixed a ton of bugs and added several new features. HUD ECU Hacker fully supports these new features and comes with a firmware updater.
USB HID Touchscreen
A Teensy processor emulates keyboard, mouse and touchscreen at the same time to remote control a computer for automation purposes.
You can write me in english, oder auf deutsch, o en español.