MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.34k stars 19.26k forks source link

How to implement u8g ST7920 for STM32F4? #11955

Closed mr-miky closed 5 years ago

mr-miky commented 6 years ago

I'm trying to run the display (chipset st7920) directly with a spi hardware (STM32F405) without necessarily doing bitbangig of the pins.

From what I understand I have to define U8G_HAL_LINKS. I do not understand whether I should include the U8glib library, or U8glib-HAL / U8glib-HAL-dev.

I tried with the first one, the compilation is successful but the display is completely dead. With the other two the compilation fails with errors that at the moment I do not remember well.

I took a look at the HAL of the LPC1768 and there is u8g_com_HAL_LPC1768_st7920_hw_spi.cpp, I suppose I have to implement something equivalent for STM32F4.

Can someone give me some advice on what I have to actually implement in order not to become crazy?

Thank you

Marlin 2.0 .x bugfix update to head ...

thinkyhead commented 6 years ago

I took a look at the HAL of the LPC1768 and there is u8g_com_HAL_LPC1768_st7920_hw_spi.cpp, I suppose I have to implement something equivalent for STM32F4.

That's basically it. Start by duplicating the LPC1768 stuff over to the STM32F4 HAL and build on it. You may be able to ask @Bob-the-Kuhn for some additional guidance.

mr-miky commented 6 years ago

And again constructor of ug8lib tries to use spi with uninitialized hardware and enters an infinite while () loop after reset.

while(__HAL_SPI_GET_FLAG(&spiHandle, SPI_FLAG_RXNE) == RESET);

STM32GENERIC is becoming a nightmare ....

thinkyhead commented 6 years ago

Arduino STM32 is now an option.

xC0000005 commented 6 years ago

STM32 generic doesn't init systick before some constructors without a fix. If you insist on using that core (and my M200 V2 support is currently on it, since i haven't managed to make it work with the official core yet), clone STM32GENERIC from my repo, which at least has that fixed + a few others. The official core is coming along. You can build using the Arduino IDE and edit in PIO/whatever you like.

mr-miky commented 6 years ago

Thank you. I do not insist on using STM32Generic but at the moment when I use official STM32 I get some code that does not work on the board I designed. I added a bit of #ifdef to the marlin code since the serial changes name and something else. The build of the source ends correctly but then nothing works. I do not like the management of pin names in the official version. I have to edit variant.h and variant.cpp, so that PA0 is associated with D0 and then D0 is translated into PA_0 through enumerations and arrays. It seems to me only a waste of resources.

jmz52 commented 5 years ago

You might want to look at https://github.com/MarlinFirmware/U8glib-HAL/blob/dev/src/clib/u8g_com_stm32duino_hw_spi.cpp It is an implementation of communication function for MKS Mini 12864 using HW SPI interface (STM32F1/F4 HALs) It works without U8G_HAL_LINKS.

boelle commented 5 years ago

@mr-miky

This Issue Queue is for Marlin bug reports and development-related issues, and we prefer not to handle user-support questions here. (As noted on this page.) For best results getting help with configuration and troubleshooting, please use the following resources:

After seeking help from the community, if the consensus points to to a bug in Marlin, then you should post a bug report. Before posting a bug report please test with bugfix-2.0.x to check if problem is gone

boelle commented 5 years ago

@thinkyhead think we can close this one

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.