Undefined Reference Error and Other Questions

yellowtiger
Posts: 15
Joined: Sun Oct 28, 2012 6:42 pm

Undefined Reference Error and Other Questions

Postby yellowtiger » Sun Oct 28, 2012 7:36 pm

Hi, I just registered to ask a few questions about Chibios/GFX driver.

First of all I want to thank you guys for your great work on the LCD drivers.

I am a mechnical engineer and don't have much background in electronics. But I'm interested in MCU programming. Recently I purchased a STM32F4Discovery card and an LCD with touchpad off ebay. I was able to setup the toolchain in Unbuntu and compiled and ran a few simple programs on the STM32F4Discovery board. Among these simple programs there was one that used Chibios/GFX drivers and drew a few simple shapes on the LCD screen. The ebay description of the LCD panel (http://www.ebay.com/itm/170912654535) stated that it had an SSD1963 controller. However, I couldn't drive it using the SSD1963 driver. Instead I was able to drive it using the SSD1289 driver.

Yesterday I was trying the new Graph example from the GFX driver. When I tried to compile the program I got an error saying "undefined reference to gdisp_llc_control_ssd1289" as well as "undefined refernce to sin". My initial thoughts were I must have missed some header files but I have included "gidsp.h", "graph.h", "math.h" in my main.c. I found out that the first error ("undefined reference to gdisp_llc_control_ssd1289") was caused by function gdispSetOrientation() (I have also got this exact error when trying the notdpad example). The second error message is obviously caused by un-defined sine function. So I was wondering if anyone had seen this error before. Could this be caused by an incorrectly setup toolchain?

As a newbie, I also have a few other questions. Firstly I want to check with you guys if my hardware connection between the STM32F4Discovery and LCD is correct. I'm trying to use FSMC on the STM32F4Discovery board to control the LCD. I followed this post on element14.com (http://www.element14.com/community/groups/development-tools/blog/2012/05/26/stm32f4-discovery-hy32d-tft-lcd) to connect the data pins and control pins. I didn't connect the touchpad pins as I was not ready to try that yet. I used a 1k-ohm resistor between the LCD reset pin and the +3V MCU board pin. Also I used a 33ohm resistor between the LCD backlight pin and the +3V MCU board pin. I don't have resistors between the LCD +3.3V/LCD Ground pins and the MCU board +3V/Ground pins. Does this connection look OK to you guys?

Secondly, I noticed that every time I disconnect and reconnect the power to the STM32F4Discovery board, I have to wait for quite some time (~ 5min) and pressed the board reset button once for the graphics to show up on the LCD screen. Sometimes I have to power off and power on the STM32F4Discovery board a few times before anything shows up on the LCD screen. I'm confused why this happens. I don't think the board needs that long to initialize. So I was wondering if you guys could give me some comments/hints on how to troubleshoot the problem.

Lastly, could you recommend any good beginner books on MCU programming?

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Undefined Reference Error and Other Questions

Postby Tectu » Sun Oct 28, 2012 8:03 pm

Hello yellowtiger and welcome to ChibiOS :)

The LCD module you got does definitley use SSD1289 and NOT the SSD1963 as on the description page. Maybe you want to notice the ebay seller about this issue.

You are getting the undefined reference error because you need to add the following to your halconf.h: #define GDISP_NEED_CONTROLL TRUE
The error about undefined reference to sin() is because you need to link with the math library. you can do this by adding -lm to you Makefile, somewhere near line 206:

Code: Select all

# List all user libraries here
ULIBS = -lm


I am sorry that this wasn't documented yet. I updated the documentation now: http://chibios-gfx.com/documentation/graph

The way how you connected your LCD seems good! You wouldn't even need the resistor between the 3.3V and the backlight. If you want to be able to dim the backlight, you can use a simple potentiometer between 3.3V and GND or you can generate a PWM signal with your MCU.

I am not very sure about the issue with the long startup sequence. Can you post your code?

Feel free to ask any further questions!


~ Tectu

yellowtiger
Posts: 15
Joined: Sun Oct 28, 2012 6:42 pm

Re: Undefined Reference Error and Other Questions

Postby yellowtiger » Sun Oct 28, 2012 8:19 pm

Hi Tectu,

Thanks for your quick reply. I knew it was something that newbies like me would miss! Anyway, after adding two things you mentioned to my halconf.h and Make file I was able to compile the program. And I was able to show the sine curves on the screen after flashing the .bin file to the MCU board.

I'm still getting two warnings as shown below.

Code: Select all

main.c: In function 'main':
main.c:50:5: warning: missing initializer [-Wmissing-field-initializers]
main.c:50:5: warning: (near initialization for 'G1.x0') [-Wmissing-field-initializers]
Compiling ../../ext/gfx/src/gdisp.c
Compiling ../../ext/gfx/src/gdisp_fonts.c
Compiling ../../ext/gfx/src/touchpad.c
Compiling ../../ext/gfx/src/console.c
Compiling ../../ext/gfx/src/graph.c
../../ext/gfx/src/graph.c: In function 'graphDrawSystem':
../../ext/gfx/src/graph.c:52:2: warning: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
Compiling ../../ext/gfx/drivers/gdisp/SSD1289/gdisp_lld.c


The first warning occurs at the end of the definition of Graph G1 = {...};
I added "#include "math.h" at the begining of graph.c as an effort to fix the second warning but the warning remained. Could you tell me how to fix it?

Thanks again.
Last edited by Tectu on Sun Oct 28, 2012 8:38 pm, edited 1 time in total.
Reason: Removed quote

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Undefined Reference Error and Other Questions

Postby Tectu » Sun Oct 28, 2012 8:40 pm

Hey yellowtiger,

Good to hear that you got it running! Did it still take like 5 minutes until it worked?
Thank you for pointing out the warning. I fixed the warning. Make a git pull.
As you can get from the manual of abs, we need to include stdlib.h, and not math.h ;-)

P.S.: I already updated the docs about the graph demo: http://chibios-gfx.com/documentation/graph


~ Tectu

yellowtiger
Posts: 15
Joined: Sun Oct 28, 2012 6:42 pm

Re: Undefined Reference Error and Other Questions

Postby yellowtiger » Sun Oct 28, 2012 9:06 pm

Hi Tectu,

Thanks for the update. Including stdlib.h eliminated the warning.

Yes, it still takes like 5 minutes untill it works. This is a puzzle to me and very annoying -:(

BTW, I already wrote to the ebay seller letting him know the wrong description of the LCD controller.
Last edited by Tectu on Sun Oct 28, 2012 9:24 pm, edited 1 time in total.
Reason: Removed quote

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Undefined Reference Error and Other Questions

Postby Tectu » Sun Oct 28, 2012 9:27 pm

Hey yellowtiger,

I don't know where's the problem... Do you use the correct board files of ChibiOS? Does this also happen with the demo located under chibios/demos/ARMC4-STM32F407-DISCOVERY ?
Maybe somebody else has an idea...

P.S. Please use the PostReply button on the very bottom of the page to write a reply, and don't use the "quote" button :)


~ Tectu

mobyfab
Posts: 446
Joined: Sat Nov 19, 2011 6:47 pm
Location: Versailles, France
Has thanked: 8 times
Been thanked: 17 times

Re: Undefined Reference Error and Other Questions

Postby mobyfab » Sun Oct 28, 2012 9:28 pm

Can you paste the full code on pastebin?

You should check the examples as well: https://github.com/mobyfab/ChibiOS-Examples/tree/master/STM32F4-LCD

yellowtiger
Posts: 15
Joined: Sun Oct 28, 2012 6:42 pm

Re: Undefined Reference Error and Other Questions

Postby yellowtiger » Sun Oct 28, 2012 10:39 pm

@Tectu:
I think I used the correct board files of ChibiOS but I'll double check.

@mobyfab:
I'll check the examples and let you know how they work. What do you mean by pastebin (sorry for the newbie question)? Do you mean paste the full code in the post?

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Undefined Reference Error and Other Questions

Postby Tectu » Sun Oct 28, 2012 11:17 pm

Hello yellowtiger,

It would be the best if you'd check if the examples work first.
Then do what mobyfab suggested and show us the entire sourcecode. You could simply zip your project folder and attach it to a post in this thread. This would be the easiest for us to check :)


~ Tectu

yellowtiger
Posts: 15
Joined: Sun Oct 28, 2012 6:42 pm

Re: Undefined Reference Error and Other Questions

Postby yellowtiger » Mon Oct 29, 2012 12:03 am

Hi Tectu and mobyfab, here is a quick update:

I went back and tried the example code in chibios/demos/ARMC4-STM32F407-DISCOVERY. The code compiled OK and I successfully flashed it to the board. I don't have the required RS232 level translator or SPI analyzer so I'm not able to check the data transmisson on the board. What I can see is that three LEDs (green, blue, and orange) are flashing about once per second.

I also tried one of mobyfab's exmaples (STM32F4-LCD). At first the compilation failed with error "GPIOC_PIN6 undeclared" in main.c. So I went ahead and commentted two palClearPad(GPIOC, GPIOC_PIN6) lines out. Then the code compiled OK. After flashing the code to the board, the LCD seemed doing what it was supposed to do (some text first, then some curves, then flashing rectangles, then repeat). I'll need to find how to change the orientation of the LCD though (I tried gdispSetOrientation() in main.c but that froze my screen).


Return to “LCD Driver and Graphic Framework”

Who is online

Users browsing this forum: No registered users and 1 guest