renode / renode

Renode - Antmicro's open source simulation and virtual development framework for complex embedded systems
https://renode.io
Other
1.45k stars 257 forks source link

Wrong behavior on STM32_ADC_Common when using FeedVoltageSampleToChannel #570

Open nandojve opened 5 months ago

nandojve commented 5 months ago

Description

After apply the fixes of https://github.com/renode/renode-infrastructure/pull/94 I tried to use the simulation to run robot to perform the ADC tests. I noted that when using FeedVoltageSampleToChannel the first read is always zero on all channels. It seems that after the second read the simulation consumes the loaded data.

Expected behavior

It is expected that when load a machine and then load data to ADCs when the simulation starts the first read consume the data loaded.

How to reproduce?

1- Apply the fixes of https://github.com/renode/renode-infrastructure/pull/94 2- Build https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/drivers/adc from https://github.com/nandojve/zephyr/tree/renode/fix_stm32_c0g0l0_adc branch west build -b nucleo_g071rb deps/zephyr/samples/drivers/adc -t run 3- Stop simulation 4- Use the command logged without the "--disable-xwt" and "s" option (note: some zephyr path could be different due to project configurations) <path>/renode --port -2 --pid-file renode.pid -e '$bin=@<path>/build/zephyr/zephyr.elf; include @<path>/deps/zephyr/boards/arm/nucleo_g071rb/support/nucleo_g071rb.resc;'

5- Feed ADC channels with 1 sample each, start and stop simulation

image

6- Repeat the process and confirm (second time) that simulation always read the first sample as 0 for each channel

image

7- Load more samples and test

image

Environment

Please, provide the following information:

Do you plan to address this issue and file a PR?

It is not clear to me why the first sample is not valid. I can send a patch with some help once we figure out the root of cause.