Page 2 of 3
Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...
Posted: Thu Mar 05, 2020 7:02 pm
by Giovanni
Hi,
You can set any value, it is rounded to a multiple of 8 internally. Enable stack checking and MPU guard pages in port layer, this way you will get clear halts for overflows, also verify the exceptions stack, the size is in the makefile, the default is very generous.
Giovanni
Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...
Posted: Thu Mar 05, 2020 8:26 pm
by rreignier
Thanks for the advises.
But I am not sure, what do you mean by "MPU guard pages"? Is there any example how to use that feature?
Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...
Posted: Thu Mar 05, 2020 9:11 pm
by Giovanni
Just add -DPORT_ENABLE_GUARD_PAGES=1 to your makefile and enable stack checks in chconf.h.
It uses MPU for stack overflow detection, much more reliable than the normal SW stack check.
Giovanni
Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...
Posted: Thu Mar 05, 2020 9:55 pm
by rreignier
Ok, thanks but PORT_USE_MPU_REGION need to be defined.
Code: Select all
ChibiOS/os/common/ports/ARMCMx/chcore_v7m.c:278:24: error: 'PORT_USE_MPU_REGION' undeclared (first use in this function)
mpuConfigureRegion(PORT_USE_MPU_REGION,
Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...
Posted: Fri Mar 06, 2020 6:18 am
by Giovanni
That looks like a bug... you are using trunk code right?
Giovanni
Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...
Posted: Fri Mar 06, 2020 12:06 pm
by rreignier
Yes, I am using trunk from last month.
Even without MPU, I was able to reduce RAM usage to 15 kB!
But the stack checker did not help me, do I need to enable another option to use it?
As I understand, a stack overflow should be detected and the OS halted? Instead, the application was just working with some errors.
So I have stopped reducing the stacks size when the application stopped working normally.
With NIL, I was able to reduce RAM by about 6 kB and FLASH 7 kB.
So there is some hope but a lot of changes are needed from stock VESC firmware to disable most features that are not just BLDC and FOC.
For now, the issue is on FLASH side, my minimal version is still using 150 kB and the G431 has only 128 kB. But should be doable.
While trying to build with NIL, I noticed that NIL cannot be built with semaphores support disabled (not so surprising because what is the point to use an RTOS without any lock mechanism, but maybe the option to disable semaphores should be removed?).
And the time_msecs_t typedef is missing in NIL's ch.h, preventing the use of TIME_I2MS.
Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...
Posted: Fri Mar 06, 2020 1:06 pm
by Giovanni
You need to enable both the stack check in chconf.h and those MPU-related options. It places a non-accessible page below stack areas so it is strange it is not detecting anything.
I will look into those issues in NIL, it is a new version not yet released.
Giovanni
Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...
Posted: Fri Mar 06, 2020 4:10 pm
by Giovanni
Fixed the problem with the MPU option, about NIL, it does build with semaphores disable but you need to disable all those modules that depends on semaphores too, there are #error catching this.
Giovanni
Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...
Posted: Fri Mar 06, 2020 4:22 pm
by rreignier
Ok, great for MPU, I will make sure to test it soon!
NIL without semaphores and CH_CFG_ST_TIMEDELTA not 0 does not build:
Code: Select all
ChibiOS/os/nil/src/ch.c: In function 'chSysTimerHandlerI':
ChibiOS/os/nil/src/ch.c:373:17: error: 'union <anonymous>' has no member named 'semp'
tp->u1.semp->cnt++;
Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...
Posted: Fri Mar 06, 2020 4:43 pm
by Giovanni
Fixed, it was for CH_CFG_ST_TIMEDELTA equal to zero.
Giovanni