Explanation of PAL_NEW_INIT

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.
avrhack
Posts: 140
Joined: Tue Dec 24, 2013 1:42 pm
Has thanked: 17 times
Been thanked: 3 times

Explanation of PAL_NEW_INIT

Postby avrhack » Sun Apr 18, 2021 4:27 pm

I'm really struggling in trying to set up my board.h, board.c etc. etc. with conditional compilation so it can handle being compiled for F103 and L433/L443 processors. The current 'mess' I'm in seems to stem from massive changes to the PAL definitions which are tied to PAL_NEW_INIT but I can't figure out how this is meant to work so I'm blundering around in a complete nightmare.

Is there any documentation on this as it seems the F103 still uses the 'old' setup but the L4xx uses the new setup and it's far from obvious (to me anyway) how this is all meant to work.......

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

Re: Explanation of PAL_NEW_INIT

Postby Giovanni » Sun Apr 18, 2021 5:15 pm

Hi,

Probably your problem is that F1 uses GPIOv1 while L4 uses GPIOv2 or GPIOv3 depending on the model. Aren't you using makefiles? this should be pretty much transparent.

Giovanni

avrhack
Posts: 140
Joined: Tue Dec 24, 2013 1:42 pm
Has thanked: 17 times
Been thanked: 3 times

Re: Explanation of PAL_NEW_INIT

Postby avrhack » Sun Apr 18, 2021 5:18 pm

Giovanni wrote:Hi,

Probably your problem is that F1 uses GPIOv1 while L4 uses GPIOv2 or GPIOv3 depending on the model. Aren't you using makefiles? this should be pretty much transparent.

Giovanni


Yes I'm using Makefiles - copied from the examples. That's not the issue; it's that the configuration of the board.h and board.c files and the associated type definitions seems to be completely different between GPIOv1 and GPIOv3 ie the F103 and the L4xx, coupled with the PAL_NEW_INIT is just causing me a total nightmare to figure out. I don't know whether the PAL_NEW_INIT is something you'll be bringing to the F103 in due course - as some of the source comments imply, or whether it will never change. But for example in my source code I have to use GPIO_Typedef * for the type of F103 ports and stm32_gpio_t * for the type of the L4xx which I can't see makes any sense - surely the type should be the same across the board and just the definition changes between the types if necessary?

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

Re: Explanation of PAL_NEW_INIT

Postby Giovanni » Sun Apr 18, 2021 5:24 pm

Hi,

Board files are totally different, you should not assume those are the same. You need a board file for the F1 and a different one for the L4.

PAL_NEW_INIT should not even be visible to the end user, it is a macro internal to the driver.

Giovanni

avrhack
Posts: 140
Joined: Tue Dec 24, 2013 1:42 pm
Has thanked: 17 times
Been thanked: 3 times

Re: Explanation of PAL_NEW_INIT

Postby avrhack » Sun Apr 18, 2021 5:29 pm

Giovanni wrote:Hi,

Board files are totally different, you should not assume those are the same. You need a board file for the F1 and a different one for the L4.

PAL_NEW_INIT should not even be visible to the end user, it is a macro internal to the driver.

Giovanni


As the F103 and L433/L443 are compatible, they can both go in the same board hence the need for a single board file with a conditional compilation depending on which one the firmware is compiled for. But that's not the issue here - whether I do it with different board files or conditional compilation in a single board file, the GPIO definitions that I would have expected to be non-specific to the MCU type seem to be totally different for the F103 and the L4xx series.

I don't understand why that is and what the differences are, rationale, what needs to change etc. etc. Figuring it out from the source code is proving very time consuming, hence my ask whether there was any documentation to explain why things are so different.

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

Re: Explanation of PAL_NEW_INIT

Postby Giovanni » Sun Apr 18, 2021 5:38 pm

Sorry, but your documentation is called "STM32 Reference Manual", GPIO registers and structures are different thus board files are different, you may ask ST the reason behind the changes.

Giovanni

steved
Posts: 823
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: Explanation of PAL_NEW_INIT

Postby steved » Mon Apr 19, 2021 8:41 am

avrhack wrote:As the F103 and L433/L443 are compatible, they can both go in the same board hence the need for a single board file with a conditional compilation depending on which one the firmware is compiled for. But that's not the issue here - whether I do it with different board files or conditional compilation in a single board file, the GPIO definitions that I would have expected to be non-specific to the MCU type seem to be totally different for the F103 and the L4xx series.

If you have a separate board file for each board, it doesn't matter at all how they are created. Then use conditionals in the makefile to select the right file (often you need different scatter files, and maybe other files, as well, so its the logical place to put everything). I've found that approach is simple and pretty easy to understand.

avrhack
Posts: 140
Joined: Tue Dec 24, 2013 1:42 pm
Has thanked: 17 times
Been thanked: 3 times

Re: Explanation of PAL_NEW_INIT

Postby avrhack » Mon Apr 19, 2021 9:26 am

steved wrote:If you have a separate board file for each board, it doesn't matter at all how they are created. Then use conditionals in the makefile to select the right file (often you need different scatter files, and maybe other files, as well, so its the logical place to put everything). I've found that approach is simple and pretty easy to understand.


Exactly. That’s the approach I’ve taken too and it works well. The issue I think is unrelated but is due to the massive differences in how the GPIOs are handled between the CPUs. Giovanni’s post above points at ST and it’s absolutely correct that the way the IO registers and particular alternate mode works is very different between F103 and L4xx but my issue is more related to PAL_NEW_INIT which I’m struggling to reverse document / understand from the source code......


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 24 guests