Building firmware with gcc

I have done some great progress. Since the display was not coming up, and I have no JTAG or serial connection, I explored the possibilities of the 1-bit debug facility that is the function generator output :slight_smile: I hooked up a voltmeter to the output, and modified the code to not control the pin from a timer, but as a normal output pin I could toggle manually.

With this I could confirm that the LIB starts up fine, and if I disabled the USB_Init, it would go through the whole main() and jump to the APP. So why didn’t the LCD come up then? I studied the disassembly in LCD_Initial(), and here the elf file from Antonio gave me a nice opportunity to compare with the IAR-generated code. It turns of that some “cowboy” macros in HW_V1_Config.h gives quite different code in gcc versus IAR:

#define LCD_nWR_ACT()   GPIOD_BSRR = GPIOD_BRR  = GPIO_Pin_5

The intention here (which happens to work in IAR) is that GPIO_Pin_5 (which is just one bit) should be written to GPIOD_BRR first, then be written to GPIOD_BSRR, in order to create a 1-0-1 pulse. Although these variables are volatile (and directly mapped to the peripherals registers) it is easy to imagine that the compilers might do things slightly differently. And effectively, changing this and similar constructs to:

#define LCD_nWR_ACT()   GPIOD_BRR  = GPIO_Pin_5 ; GPIOD_BSRR = GPIO_Pin_5

made the LCD came up!

Now if we have hundreds more of these small things to fix, this is going to be fun :slight_smile:

EDIT: I pushed the fixes to my gcc branch, but you will have to disable USB_Init yourself, since the gcc branch should stay in working state for IAR as well.