VESC, and B-G431B-ESC1 and stm32g4xx development progress...

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 12749
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 696 times
Been thanked: 573 times
Contact:

Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...

Postby Giovanni » Thu Mar 05, 2020 7:02 pm

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

rreignier
Posts: 21
Joined: Sat Apr 15, 2017 11:49 pm
Has thanked: 7 times
Been thanked: 4 times

Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...

Postby rreignier » Thu Mar 05, 2020 8:26 pm

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?

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

Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...

Postby Giovanni » Thu Mar 05, 2020 9:11 pm

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

rreignier
Posts: 21
Joined: Sat Apr 15, 2017 11:49 pm
Has thanked: 7 times
Been thanked: 4 times

Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...

Postby rreignier » Thu Mar 05, 2020 9:55 pm

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,

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

Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...

Postby Giovanni » Fri Mar 06, 2020 6:18 am

That looks like a bug... you are using trunk code right?

Giovanni

rreignier
Posts: 21
Joined: Sat Apr 15, 2017 11:49 pm
Has thanked: 7 times
Been thanked: 4 times

Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...

Postby rreignier » Fri Mar 06, 2020 12:06 pm

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.

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

Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...

Postby Giovanni » Fri Mar 06, 2020 1:06 pm

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

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

Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...

Postby Giovanni » Fri Mar 06, 2020 4:10 pm

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

rreignier
Posts: 21
Joined: Sat Apr 15, 2017 11:49 pm
Has thanked: 7 times
Been thanked: 4 times

Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...

Postby rreignier » Fri Mar 06, 2020 4:22 pm

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++;

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

Re: VESC, and B-G431B-ESC1 and stm32g4xx development progress...

Postby Giovanni » Fri Mar 06, 2020 4:43 pm

Fixed, it was for CH_CFG_ST_TIMEDELTA equal to zero.

Giovanni


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 1 guest