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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
2,048件の閲覧回数
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")

 

タグ(3)
0 件の賞賛
返信
1 解決策
2,013件の閲覧回数
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

元の投稿で解決策を見る

3 返答(返信)
2,014件の閲覧回数
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,953件の閲覧回数
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.

2,024件の閲覧回数
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 件の賞賛
返信