cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L431 Flashing fails if there is CAN bus activity

DHase.1
Associate III

I find that flashing a program using openocd, STLink (using a Nucleo F446, or L474), to our custom board frequently fails when there is CAN bus activity. What is causing this?

Our board has BOOT0 tied to ground. The SWD is gnd, data, clock, and connects to pins STLlink on the Nucleo board. For a while the flashing would "usually" work, occasionally there would be a failure to erase a blocks, or range of blocks, or a failure to write. With more units on the CAN bus, it always fails. For a while I thought the processor flash had gone bad until I stumbled on it working "better" when some of the other units were taken off the bus. That led to determining that flashing works 100% if the unit being flashed is the only unit on the bus (i.e. it is powered from the CAN cable as that carries power as well as the CAN signals).

 

The docs talk about the built-in routine for flashing where the standard peripheral pins are checked for data, etc. That suggests that somehow that is involved the above. If so, maybe there is a way to avoid it.

 

Further up-the-chain, is a program update over CAN scheme that I have in place. A load-over-CAN program is located low address flash, and upon boot waits for a short time for msgs to start an interactive loader sequence with a PC connected with a CAN gateway. Some failures to correctly complete the loading have "feel" that the above issue may be involved. The first step is to understand why CAN activity is causing the openocd,STLink flashing failures.

 

1 REPLY 1

I'd say, ground issues. 

Try to connect all devices on the CAN bus and others sharing the same ground - including/starting with the PC to which the STLink is connected - using short and thick wires to one common ground point in star fashion.

Also generally make sure that you have adequate return (ground or other DC) in your reasonably short SWD cable (15cm or so), ground separating SWDIO and SWCLK. "Occassionally failing programming" is not OK.

JW