Page 1 of 1

LUA code and EGT makes ECU to hang

Posted: Sun Jan 28, 2024 12:33 pm
by zed65
I'm having a weird problem with some LUA code and SPI EGT that makes the processor to hang.
Here is a guide to replicate my problem.

1. Flash the latest bundle to a F407 (black-board in my case).
2. Open console and write this into LUA:

Code: Select all

function onTick()
    adv = getOutput ("correctedIgnitionAdvance")
    print (adv)
end
3. Open Tunerstudio, create a new project.
4. Turn on EGT SPI, (tried with SPI1,2and3, same problem).
egtSpiHang.png
egtSpiHang.png (489.39 KiB) Viewed 1575 times

5. Reboot the processor.
6. It freezes in a couple of seconds (1-30sec).

The weird thing is that it seems to only affect the getOutput() command in LUA, everything else seems to work regarding LUA.

Re: LUA code and EGT makes ECU to hang

Posted: Sun Jan 28, 2024 5:13 pm
by AndreyB
zed65 wrote:
Sun Jan 28, 2024 12:33 pm
black-board in my case
Where does one get a black-board to test? is this reproducible on naked stm32f4discovery?

Re: LUA code and EGT makes ECU to hang

Posted: Sun Jan 28, 2024 5:35 pm
by zed65
Search STM32F407VGT6 on Aliexpress

I think it will produce the same on a stm32f4discovery but i'm not 100%

Re: LUA code and EGT makes ECU to hang

Posted: Sun Jan 28, 2024 5:38 pm
by AndreyB
zed65 wrote:
Sun Jan 28, 2024 5:35 pm
Search STM32F407VGT6 on Aliexpress

I think it will produce the same on a stm32f4discovery but i'm not 100%
Oh so that's without actual EGT chip present?

Please link your complete tune just in case.

Re: LUA code and EGT makes ECU to hang

Posted: Sun Jan 28, 2024 5:45 pm
by zed65
Yes, that's without the chip installed.
Let me get my actual ECU from my car (chip is present) and I check on that one.

Re: LUA code and EGT makes ECU to hang

Posted: Sun Jan 28, 2024 5:57 pm
by zed65
Sadly it don't work on that either.
I tried both with and without an actual K-type sensor connected.

Re: LUA code and EGT makes ECU to hang

Posted: Tue Jan 30, 2024 10:16 pm
by mck1117
andrey you should go look at the call to getMax31855EgtValue in status_loop.cpp and see if the things done in getMax31855EgtValue are a good idea to call from an arbitrary lua call stack

Re: LUA code and EGT makes ECU to hang

Posted: Tue Jan 30, 2024 10:42 pm
by AndreyB
mck1117 wrote:
Tue Jan 30, 2024 10:16 pm
andrey you should go look at the call to getMax31855EgtValue in status_loop.cpp and see if the things done in getMax31855EgtValue are a good idea to call from an arbitrary lua call stack
Thank you! I've changed things https://github.com/rusefi/rusefi/commit/324378f252b049a5f83f0f42a9f44e54741ee349