Serial communication not working when compiling with arm-none-eabi-gcc

mcufan wrote on Friday, February 21, 2014:


I have a small project for an LPC2138 MCU that uses FreeRTOS and reads/writes to UART0 and UART1. Everything was working fine when I compiled it on Windows with arm-elf-gcc. However I moved to a new computer that has Ubuntu. Now I am compiling with arm-none-eabi-gcc 4.8.3 20131129 ( precise/main amd64 Packages).

The problem is that it seems UART interrupts has stopped working. When I compile the very same code (I modified only the compiler in Makefile) with arm-elf-gcc, it works perfectly. Unfortunately there is no arm-elf-gcc package available for Ubuntu, so I could not try it with that.

Is there something else I should have modified or is this a compiler bug?

Best regards,

rtel wrote on Saturday, February 22, 2014:

Sorry - this is a FreeRTOS forum, not a LPC2138 or GCC forum, all I can suggest is you look at the output generated by the compiler in both cases to see what is different. It could be something is being optimised away by one compiler and not the other because there is a volatile missing or some such thing.


mcufan wrote on Saturday, February 22, 2014:

I compared the assembly code generated by the compilers and it seems that the arm-none-eabi-gcc 4.8.3 generated code subtracts 12 instead of 8 from the stack pointer when it enters the vUART_ISR_Handler called from vUART_ISR_Wrapper. Most probably this happens due to the __asm volatile (“bl vUART_ISR_Handler”) function call.
However since there are only two variables defined in vUART_ISR_Handler (char and portBASE_TYPE), there should really be 8 bytes on the stack.

I’ll file a bug report to gcc. Thank you for the help!

mcufan wrote on Monday, February 24, 2014:

As I learned this is not a bug in the compiler. The problem is that arm-elf and arm-none-eabi are different binary interfaces, so for example the function calls are different.
Unfortunately it seems that ARM7_LPC2106_GCC demo can be compiled only with arm-elf-gcc. Most probably ASM parts of the interrupt handlers are written in a way that it is compatible with only the arm-elf binary interface.

Is it possible to provide a similar example for the arm-none-eabi-gcc compiler in the FreeRTOS demo package? I am asking this because it seems arm-elf is deprecated and arm-none-eabi is used lately. For most distributions eg. 4.6.x arm-elf-gcc compiler is no longer available, only arm-none-eabi-gcc.


rtel wrote on Monday, February 24, 2014:

I’m not sure the asm itself would cause an issue as the asm is used to prevent the compiler inserting anything. Without looking at the code (which I can’t do right now) I can’t be sure though.

It is unlikely such an old demo would get an update as the majority of new users use the Cortex parts which don’t need any special interrupt entry code and we have to prioritise work there.


mcufan wrote on Monday, February 24, 2014:

You are right, it has nothing to do with the asm wrapper. The problem seems to be that vUART_ISR_Wrapper does not even get called. Unfortunately I do not have access to a debugger, I could just figure out from flashing leds and checking the generated asm code of xSerialPortInit that the VIC vector address is set correctly, divisor is ok, fifo is set, interrupts are enabled… But still the interrupt wrapper code never gets called when arm-none-eabi-gcc compiler is used.

hawk777 wrote on Wednesday, February 26, 2014:

This doesn’t seem really FreeRTOS related, but if the UART isn’t entered, perhaps it’s not the change of compilers but rather the change of libraries that causes the problem—have you verified that a pointer to your ISR is still being stored in the vector table? An objdump should let you check that easily enough.