I2C transfer of large data (10kb +) crashes chibios Topic is solved

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

Nicolai86
Posts: 9
Joined: Sun Jul 12, 2020 5:43 pm
Has thanked: 1 time

Re: I2C transfer of large data (10kb +) crashes chibios

Postby Nicolai86 » Mon Aug 03, 2020 3:56 pm

Giovanni,

thank you so much for your help.

It turns out that the issue is inside my Makefile: I had

Code: Select all

USE_FPU=hard
set; once I disabled it it all started working.

I'm not 100% sure why the FPU would break an I2C transaction, but I'm glad that it works when I disable it.

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: I2C transfer of large data (10kb +) crashes chibios

Postby Giovanni » Mon Aug 03, 2020 6:27 pm

FPU increases stack usage.

Giovanni

Nicolai86
Posts: 9
Joined: Sun Jul 12, 2020 5:43 pm
Has thanked: 1 time

Re: I2C transfer of large data (10kb +) crashes chibios

Postby Nicolai86 » Mon Aug 03, 2020 7:45 pm

Giovanni,

I guess I was a little premature here - it works fine with -O0 only.
Once I enable either -O1 or -O2 it fails again with the unhandled exception, even with FPU disabled.

So back to the stacksize issue. I'll keep you posted if I find anything concrete. First time debugging issues when using chibios :)

For the sake of documenting this endavour; I've enabled idle threads again, and bumped up the thread default PORT_IDLE_THREAD_STACK_SIZE to 512.

Code: Select all

HardFault_Handler exceptionvectors.c:63
<signal handler called> 0x00000000ffffffed
_idle_thread chcore_v7m.h:774
<unknown> 0x0000000001000000


Code: Select all

isFaultPrecise = {_Bool} true
isFaultAddressValid = {_Bool} true


I guess this means it's an issue with addresses when switching threads, but I don't know.
LR points to where I call i2cStart, so this happens somewhere inside chibios when I want to ensure the i2c state machine is ready.

Oh, and if you have any advice on how to triage the issue, please let me know :)

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: I2C transfer of large data (10kb +) crashes chibios

Postby Giovanni » Mon Aug 03, 2020 8:22 pm

Which compiler are you using? chibios version? are you using chibios startup files?

Giovanni

Nicolai86
Posts: 9
Joined: Sun Jul 12, 2020 5:43 pm
Has thanked: 1 time

Re: I2C transfer of large data (10kb +) crashes chibios

Postby Nicolai86 » Mon Aug 03, 2020 9:21 pm

Code: Select all

❯ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Arm Embedded Toolchain 9-2020-q2-update) 9.3.1 20200408 (release)
❯ git st
## stable_20.3.x...origin/stable_20.3.x
❯ git rev-parse HEAD
5f523dc8e95d7ff6c6daf3bc41531cae7285cbdf


However it seems I fixed the issue entirely by following your suggestion:

both stm32_write_memory and stm32_write_data, one 256 and another one 258 bytes long.

I change the size to 128 and 130 bytes and all works. So it seems your comment about not allocating big arrays inside functions was on point, and indeed the source of this bug.

Thank you so much Giovanni! <3

It works now with all optimization levels without crash and with FPU enabled as well.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 13 guests