[LPC55xx, CAN] Config Tool generates non-compilable code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[LPC55xx, CAN] Config Tool generates non-compilable code

Jump to solution
1,744 Views
SynBilly
Contributor III

When I use the CONFIG TOOL to initialize the CAN bus, unfortunately code is generated that cannot be compiled/linked.

If my research is correct, then in "peripherals.c" a global array ("CAN0_RAM_BASE_ADDRESS") is created, which should be aligned to 0x10000.
But the linker can't do this successfully because at the beginning of the RAM is the "data" section and so the alignment fails.

What are possible workarounds?

Versions:
- Chip: LPC550x
- MCUXpresso V11.6.0 (integrated CONFIG TOOLS)
- (same failure with standalone "MCUXpresso Config Tools Rev 12.0")

 

Tags (3)
0 Kudos
1 Solution
1,709 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

I have been able to reproduce the issue in MCUXPresso IDE 11.6 using the LPC55S06. There is not enough memory in the default bss section. In this case, you can allocate the message buffer in your user code. In the MCAN component, uncheck "Allocate message RAM" settings:

marek_neuzil_0-1661246103734.png

The CAN0_RAM_BASE_ADDRESS buffer is not allocated in the peripheral.c file and you can use the following definition to use another RAM section to place the buffer and align it to the required size. See the following example:

uint32_t CAN0_RAM_BASE_ADDRESS[CAN0_MESSAGE_RAM_SIZE] __attribute__((section(".bss.$SRAMX"), aligned(CAN0_BASE_ADDRESS_ALIGN_SIZE)));

This global variable definition can be placed for example in the main program module where the peripherals.h file is included.

You can check that the CAN0_RAM_BASE_ADDRESS is placed in correct address in the map file:

.bss.$SRAMX 0x04000000 0x24 ./source/mcan_loopback.o
                        0x04000000 CAN0_RAM_BASE_ADDRESS

 

Best Regards,

Marek Neuzil

View solution in original post

3 Replies
1,710 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

I have been able to reproduce the issue in MCUXPresso IDE 11.6 using the LPC55S06. There is not enough memory in the default bss section. In this case, you can allocate the message buffer in your user code. In the MCAN component, uncheck "Allocate message RAM" settings:

marek_neuzil_0-1661246103734.png

The CAN0_RAM_BASE_ADDRESS buffer is not allocated in the peripheral.c file and you can use the following definition to use another RAM section to place the buffer and align it to the required size. See the following example:

uint32_t CAN0_RAM_BASE_ADDRESS[CAN0_MESSAGE_RAM_SIZE] __attribute__((section(".bss.$SRAMX"), aligned(CAN0_BASE_ADDRESS_ALIGN_SIZE)));

This global variable definition can be placed for example in the main program module where the peripherals.h file is included.

You can check that the CAN0_RAM_BASE_ADDRESS is placed in correct address in the map file:

.bss.$SRAMX 0x04000000 0x24 ./source/mcan_loopback.o
                        0x04000000 CAN0_RAM_BASE_ADDRESS

 

Best Regards,

Marek Neuzil

1,649 Views
SynBilly
Contributor III

@marek_neuzil 

Thanks a lot for your answer. This helped a lot.

I also had a "deep dive" into this issue:

As I'm working with the LPC5504, the linker was not able to link the array "CAN0_RAM_BASE_ADDRESS" to the forced alignment (CAN0_BASE_ADDRESS_ALIGN_SIZE).

The suggested workaround is fine for most cases, but it might fail, if "data"-section of RAMX will be filled with other variables (then the linker can not fulfill the alignment requirement for CAN0_RAM_BASE_ADDRESS).

So, a slighly "improved" version would be to link the array to the "data"-section of RAMX (data-section is linked to start of RAMX):

uint32_t CAN0_RAM_BASE_ADDRESS[CAN0_MESSAGE_RAM_SIZE] __attribute__((section(".data.$SRAMX"), aligned(CAN0_BASE_ADDRESS_ALIGN_SIZE)));

or simply:

SDK_ALIGN(uint32_t CAN0_RAM_BASE_ADDRESS[CAN0_MESSAGE_RAM_SIZE], CAN0_BASE_ADDRESS_ALIGN_SIZE) = {1};

-> this 'trick' (set first element of array to 1) will force the linker to link the CAN0_RAM_BASE_ADDRESS into 'data'-section of normal RAM. Works fine, too.

1,720 Views
PabloAvalos
NXP TechSupport
NXP TechSupport

Hi @SynBilly 

 

Thanks a lot for reaching our technical support. I really appreciate your patience.

 

Regarding your issue, I was trying to reproduce your issue, but I do not see any CAN module on the LPCXpresso55S06 SDK config tool, for example. I am wondering if you can attach some screenshots about how did you configure it and then some screenshots of the errors that appear to you on your MCUXpresso IDE, if it is possible.

 

I would really appreciate your help, so please let me know your comments or updates and be right back with you as soon as possible.

 

Thnaks in advance.
Best Regards.
Pablo Avalos.

0 Kudos