TFT_eSPI example compile fail

First time using an stm32F103C8T6, hopefully driving a ili9488 display. Blink sample downloads and runs OK.
Problem is TFT_eSPI compiling Graph_2 (or any) Example.

Generic STM32F103C series board selected.
User_Setup.h has :
#define TFT_BL PA0 // LED back-light control pin
#define TFT_BACKLIGHT_ON HIGH // Level to turn ON back-light (HIGH or LOW)
#define TOUCH_CS PA2 // Chip select pin (T_CS) of touch screen
#define TFT_SPI_PORT 1 // SPI port 1 maximum clock rate is 55MHz
#define TFT_MOSI PA7
#define TFT_MISO PA6
#define TFT_SCLK PA5
#define TFT_CS PA3 // Nucleo-F767ZI equivalent of D5
#define TFT_DC PA4 // Nucleo-F767ZI equivalent of D6
#define SPI_FREQUENCY 27000000
#define SPI_TOUCH_FREQUENCY 1000000
(fonts ignored for brevity)

Compile result :

Arduino: 1.8.12 (Windows 10), Board: "Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), STM32duino bootloader, 72Mhz (Normal), Smallest (default)"

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino: In function 'void setup()':

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:294:93: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

   Graph(tft, x, y, 1, 60, 290, 390, 260, 0, 6.5, 1, -1, 1, .25, "", "", "", display1, YELLOW);

                                                                                             ^

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:294:93: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:294:93: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:301:106: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     Trace(tft, x, y, 1, 60, 290, 390, 260, 0, 6.5, 1, -1, 1, .25, "Sin(x)", "x", "fn(x)", update1, YELLOW);

                                                                                                          ^

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:301:106: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:301:106: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:309:118: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     Trace(tft, x, y, 1, 60, 290, 390, 260, 0, 6.5, 1, -1, 1, .25, "Sin(x) + Cos(x)", " x", "fn(x)", update1, TFT_PINK);

                                                                                                                      ^

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:309:118: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:309:118: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:317:123: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     Trace(tft, x, y, 1, 60, 290, 390, 260, 0, 6.5, 1, -1, 1, .25, "Sin(x) + Cos(x) + Tan(x)", " x", "fn(x)", update1, CYAN);

                                                                                                                           ^

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:317:123: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

D:\Arduino Sketches\libraries\TFT_eSPI\examples\480 x 320\Graph_2\Graph_2.ino:317:123: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

D:\Arduino Sketches\libraries\TFT_eSPI\TFT_eSPI.cpp: In member function 'void TFT_eSPI::begin_tft_read()':

D:\Arduino Sketches\libraries\TFT_eSPI\TFT_eSPI.cpp:110:9: error: 'class SPIClass' has no member named 'setFrequency'

     spi.setFrequency(SPI_READ_FREQUENCY);

         ^

D:\Arduino Sketches\libraries\TFT_eSPI\TFT_eSPI.cpp: In member function 'void TFT_eSPI::end_tft_read()':

D:\Arduino Sketches\libraries\TFT_eSPI\TFT_eSPI.cpp:343:9: error: 'class SPIClass' has no member named 'setFrequency'

     spi.setFrequency(SPI_FREQUENCY);

         ^

D:\Arduino Sketches\libraries\TFT_eSPI\TFT_eSPI.cpp: In member function 'int16_t TFT_eSPI::drawNumber(long int, int32_t, int32_t)':

D:\Arduino Sketches\libraries\TFT_eSPI\TFT_eSPI.cpp:4658:25: error: 'ltoa' was not declared in this scope

   ltoa(long_num, str, 10);

                         ^

D:\Arduino Sketches\libraries\TFT_eSPI\TFT_eSPI.cpp: In member function 'int16_t TFT_eSPI::drawNumber(long int, int32_t, int32_t, uint8_t)':

D:\Arduino Sketches\libraries\TFT_eSPI\TFT_eSPI.cpp:4666:25: error: 'ltoa' was not declared in this scope

   ltoa(long_num, str, 10);

                         ^

D:\Arduino Sketches\libraries\TFT_eSPI\TFT_eSPI.cpp: In member function 'int16_t TFT_eSPI::drawFloat(float, uint8_t, int32_t, int32_t, uint8_t)':

D:\Arduino Sketches\libraries\TFT_eSPI\TFT_eSPI.cpp:4715:27: error: 'ltoa' was not declared in this scope

   ltoa(temp, str + ptr, 10);

                           ^

In file included from D:\Arduino Sketches\libraries\TFT_eSPI\TFT_eSPI.cpp:4973:0:

D:\Arduino Sketches\libraries\TFT_eSPI\Extensions/Touch.cpp: In member function 'void TFT_eSPI::begin_touch_read_write()':

D:\Arduino Sketches\libraries\TFT_eSPI\Extensions/Touch.cpp:24:9: error: 'class SPIClass' has no member named 'setFrequency'

     spi.setFrequency(SPI_TOUCH_FREQUENCY);

         ^

D:\Arduino Sketches\libraries\TFT_eSPI\Extensions/Touch.cpp: In member function 'void TFT_eSPI::end_touch_read_write()':

D:\Arduino Sketches\libraries\TFT_eSPI\Extensions/Touch.cpp:39:9: error: 'class SPIClass' has no member named 'setFrequency'

     spi.setFrequency(SPI_FREQUENCY);

         ^

exit status 1
Error compiling for board Generic STM32F103C series.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Any help VERY welcome, as I'm at my wits end on this.

Best Regards
picclock

I suggest that you start with a similar example e.g.
C:\Users\David Prentice\Documents\Arduino\libraries\TFT_eSPI\User_Setups\Setup32_ILI9341_STM32F103.h

Change the DRIVER and save as your custom User_Setup file with a suitable name.

// Define the TFT display driver
#define ILI9488_DRIVER

Wire up your Display to the BluePill.
I am happier with pin names like PA5 rather than A5.
But the important point is to use Bodmer's wiring scheme.

Run all of the examples.
Only change the wiring scheme if you really need to.

If you still have a problem I suggest that you report your IDE configuration lines. e.g. USB CDC Serial, Bootloader/STLink, ...

David.

Was this supposed to be an upload?

No. I was just showing the location of Setup32_ILI9341_STM32F103.h

Your file will be:
C:\Users\er_name_not_found\Documents\Arduino\libraries\TFT_eSPI\User_Setups\Setup32_ILI9341_STM32F103.h

However the reply was addressed to picclock whose file would be:
C:\Users\picclock\Documents\Arduino\libraries\TFT_eSPI\User_Setups\Setup32_ILI9341_STM32F103.h

It is always wise to start with library examples. After all, Bodmer has written and tested these specific "setups".

But most importantly, readers can access the exact file from their own TFT_eSPI installation.

David.

Excellent. Thanks for clarifying for me.
Hope it helps OP.

@ David_Prentice
Thanks for taking the time to assist. Your comments made me step back from the issue and take a deeper look.
The Example sketch(s) do not compile with the renamed example User_Setup.h files.
Clearly something has changed or become corrupted.
I will reinstall the library and start afresh.

Best Regards

picclock

I seem to have got rid of most of the errors, but am having issues with memory size.
An empty sketch compiles with :
Sketch uses 21344 bytes (32%) of program storage space. Maximum is 65536 bytes.
Global variables use 3532 bytes (17%) of dynamic memory, leaving 16948 bytes for local variables. Maximum is 20480 bytes.

When I try to compile an example I get:


c:/users/piccl/appdata/local/arduino15/packages/stmicroelectronics/tools/xpack-arm-none-eabi-gcc/9.3.1-1.3/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\piccl\AppData\Local\Temp\arduino_build_906735/TFT_Ellipse.ino.elf section `.rodata' will not fit in region `FLASH'
c:/users/piccl/appdata/local/arduino15/packages/stmicroelectronics/tools/xpack-arm-none-eabi-gcc/9.3.1-1.3/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 11764 bytes

Have you any thoughts on this ? I am new to STM processors but 16k ram and 40k flash seems massive to me, likely because I dont understand `.rodata'.

Any help much appreciated.

Best Regards
picclock

First step is to identify your "BluePill".
I have three BluePills. Each board has 128kB Flash (but marked STM32F103C8).
Yes, I know that some BluePills have only got 32kB (F103C6) or 64kB Flash (F103C8).

Please list the options that you have selected in the IDE.

Meanwhile, I will dig out a BluePill and an ILI9488 display. And see for myself.

David.

I compiled on IDE 1.8.13 for F103C8 with USB CDC Serial and HID bootloader:

Using library SPI at version 1.0 in folder: C:\Users\David Prentice\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\SPI 
Using library TFT_eSPI at version 2.3.67 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\TFT_eSPI 
Using library SrcWrapper at version 1.0.1 in folder: C:\Users\David Prentice\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\SrcWrapper 
"C:\\Users\\David Prentice\\AppData\\Local\\Arduino15\\packages\\STM32\\tools\\xpack-arm-none-eabi-gcc\\9.2.1-1.1/bin/arm-none-eabi-size" -A "C:\\Users\\DAVIDP~1\\AppData\\Local\\Temp\\arduino_build_790868/TFT_Ellipse.ino.elf"
Sketch uses 48436 bytes (73%) of program storage space. Maximum is 65536 bytes.
Global variables use 4368 bytes (21%) of dynamic memory, leaving 16112 bytes for local variables. Maximum is 20480 bytes.

With CDC Serial and Maple DFU bootloader 2.0

Sketch uses 48356 bytes (73%) of program storage space. Maximum is 65536 bytes.
Global variables use 4368 bytes (21%) of dynamic memory, leaving 16112 bytes for local variables. Maximum is 20480 bytes.

Without CDC Serial and Maple DFU bootloader 2.0

Sketch uses 37460 bytes (57%) of program storage space. Maximum is 65536 bytes.
Global variables use 1408 bytes (6%) of dynamic memory, leaving 19072 bytes for local variables. Maximum is 20480 bytes.

David.

Hi David
Chip is marked STM32F103C8T6. Allegedly 64k flash and 20k Ram.
Board.

Many Thanks for your assistance

Best Regards

picclock

My earlier builds were for BluePill F103C8. STM32 Core 1.9.0

I copied your configuration as well as I could on IDE v1.8.13
generic F103C8 because there was no generic F103C8T6.
Sure enough, I get

Using library SPI at version 1.0 in folder: C:\Users\David Prentice\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\SPI 
Using library TFT_eSPI at version 2.3.67 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\TFT_eSPI 
Using library SrcWrapper at version 1.0.1 in folder: C:\Users\David Prentice\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\SrcWrapper 
exit status 1
Error compiling for board Generic STM32F1 series.

I get the same error if I select BluePill F103C8.
So the problem is down to the Maple DFU original Bootloader.

I suggest that you either use DFU v2.0 or the HID bootloader. Installation requires an STLink or a genuine USART-Serial.

There are so many historic "features" inherited from the "Roger Clark" Core. I suspect that you have just chosen a "larger" example that does not fit with the wasteful Maple "original" DFU.

Bear in mind that the official STM32 Core is supported by STMicroelectronics. Roger Clark did an excellent job of adapting Maple software but the STM32 manufacturers have more experience.

Oh, even small examples fail when built for Maple "original" DFU.

David.

The easiest thing is to select BluePill F103CB
Then just attempt the bootload and run.

If you have 128kB Flash the program will just work. And you know that you have 128kB.

I would still change the Bootloader.

David.

Thanks for the update. I'm not sure what the Core 1.9.0 referenced in you text means. Is this the board manager revision number, which is now 2.0.0 ?

Have changed the bootloader to the HID one which is really small. Flashed the binary supplied using ftdi adapter (hid_generic_pc13.bin), which is really small <2k !!.
Have now hit the snag that the HID programmer option says it cannot find COM Port 5. Its clearly one of those days :frowning:

Will definitely try the F103CB trick just on the offchance. I thought 64K would be ample, but with memory you can never have too much.

Best Regards

picclock

I'm having some success with HID bootloader but still have a few issues.

I'm putting the device into bootloader mode using jumper 1 set high (fast flashing led indicates bootloader running). Uploading modified Blink program (PC13, my board led, replacing LED_BUILTIN) with the following results :

Sketch uses 7572 bytes (11%) of program storage space. Maximum is 65536 bytes.
Global variables use 908 bytes (4%) of dynamic memory, leaving 19572 bytes for local variables. Maximum is 20480 bytes.

+-----------------------------------------------------------------------+
|         HID-Flash v2.2.1 - STM32 HID Bootloader Flash Tool            |
|     (c)      2018 - Bruno Freitas       http://www.brunofreitas.com   |
|     (c) 2018-2019 - Vassilis Serasidis  https://www.serasidis.gr      |
|   Customized for STM32duino ecosystem   https://www.stm32duino.com    |
+-----------------------------------------------------------------------+

> Trying to open the [COM4]...
> Unable to open the [COM4]
> Searching for [1209:BEBA] device...
#
> [1209:BEBA] device is found !
> Sending <reset pages> command...
> Flashing firmware...
. 1024 Bytes
. 2048 Bytes
. 3072 Bytes
. 4096 Bytes
. 5120 Bytes
. 6144 Bytes
. 7168 Bytes
. 8192 Bytes

> Done!
> Sending <reboot mcu> command...
> Error while sending <reboot mcu> command.
> Searching for [COM4] ...
> Finish
Invalid library found in D:\Arduino Sketches\libraries\libraries: no headers files (.h) found in D:\Arduino Sketches\libraries\libraries

Having done this I moved the boot1 link to the normal position and hit the board reset button. However the LED does not flash?

So I don't know if the code is actually written, I suspect not.

Many thanks for your assistance

Best Regards

picclock

yes, i was using Core v1.9.0. (which did not report that there was an update)
I updated my old Win7-32 laptop to v2.0.0 quite easily.
My Win10-64 Desktop PC was painful. The internet download kept failing.

Once you have installed the HID bootloader, you don't touch the jumpers again.
Just compile and upload sketches in the usual way.

From memory the HID finds your bootloader whether you have CDC Serial or not.
But I strongly advise you to select CDC anyway. Then you have Serial in your sketches.

David.

Good Morning
If I do not move the jumper the usb device is not recognised by windows, and not found when programming attempted.

tSketch uses 18096 bytes (13%) of program storage space. Maximum is 131072 bytes.
Global variables use 3624 bytes (17%) of dynamic memory, leaving 16856 bytes for local variables. Maximum is 20480 bytes.

+-----------------------------------------------------------------------+
|         HID-Flash v2.2.1 - STM32 HID Bootloader Flash Tool            |
|     (c)      2018 - Bruno Freitas       http://www.brunofreitas.com   |
|     (c) 2018-2019 - Vassilis Serasidis  https://www.serasidis.gr      |
|   Customized for STM32duino ecosystem   https://www.stm32duino.com    |
+-----------------------------------------------------------------------+

> Trying to open the [COM4]...
> Unable to open the [COM4]
> Searching for [1209:BEBA] device...
##########
Error - [1209:BEBA] device is not found :(> Searching for [COM4] ...
> Finish
the selected serial port > Finish
 does not exist or your board is not connected
Invalid library found in D:\Arduino Sketches\libraries\libraries: no headers files (.h) found in D:\Arduino Sketches\libraries\libraries
ype or paste code here

Hope you can assist.

Many thanks for your time and input.

Best Regards

picclock

I installed my HID bootloader via STLink. (SWD)

If you don't have an STLink you can use a genuine USART adapter with the Boot Jumpers. Obviously you restore the Boot jumpers to Application mode afterwards.

I presume that you found the instructions for installing HID bootloader. And followed them step by step.

Obviously you need to test your HID bootloader e.g. with a Blink sketch and with a Serial sketch like ASCIITable.
Note that your Blink sketch must use the correct port pin for the LED (PC13 on most BluePills)

David.

@david_prentice
I have programmed the bootloader at least a dozen times with different flavours, PC13 is correct. Ive been using an ftd232 adapter and programming with STMFlashLoader Demo, which verifies the code. I have set link0 to zero before power off. I have global erased the device most times just in case.

I think I've come to the end of the road with this one. I have three more on order from a different supplier which will hopefully allow me to sort it out or bin it.

I chose the STM32F part because its ADC is far better than the ESP32 parts which I have. Also I have no need of the WiFi/Blutooth capabilities which are just baggage, using power making noise.

Would have used a pro mini (328) but too slow for touch screen.

Thank you so much for your help and assistance in this fruitless endeavor.

Best Regards

picclock

Whether you install the Maple DFU 2.0 or the HID bootloader the process is the same.

I have always used a STLink. These are not expensive. https://www.ebay.co.uk/itm/184349508603
But I have also used the STLink built in to Nucleo and Discovery boards.

Of course you can use any make of SWD debugger but ST programs expect you to use ST style tools.

You can turn a BluePill into a STLink (I think)

My BluePill(s) seem to be built fine and work fine.
They have always been cheap but the downward price pressure may mean that the manufacturers are cutting corners.
The price seems to have shot up. Probably because of chip shortages, demand etc.

I am much happier with Nucleo boards. Many readers have used and still use BluePills.

David.

Previously, I had simply compiled and reported the libraries, memory.

I have installed Core 2.0.0 and uploaded to a real 128kB BluePill with a real ILI9488. Which is now running the TFT_Ellipse example just fine.
Please note that I am running it on my own custom wiring that uses SPI2.
My CDC Serial port appears as "STM Serial (COM16)" on Device Manager.


Using library SPI at version 1.0 in folder: C:\Users\David Prentice\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\libraries\SPI 
Using library TFT_eSPI at version 2.3.67 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\TFT_eSPI 
Using library SrcWrapper at version 1.0.1 in folder: C:\Users\David Prentice\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\libraries\SrcWrapper 
"C:\\Users\\David Prentice\\AppData\\Local\\Arduino15\\packages\\STMicroelectronics\\tools\\xpack-arm-none-eabi-gcc\\9.3.1-1.3/bin/arm-none-eabi-size" -A "C:\\Users\\DAVIDP~1\\AppData\\Local\\Temp\\arduino_build_927853/TFT_Ellipse.ino.elf"
Sketch uses 56540 bytes (43%) of program storage space. Maximum is 131072 bytes.
Global variables use 4372 bytes (21%) of dynamic memory, leaving 16108 bytes for local variables. Maximum is 20480 bytes.

+-----------------------------------------------------------------------+
|         HID-Flash v2.2.1 - STM32 HID Bootloader Flash Tool            |
|     (c)      2018 - Bruno Freitas       http://www.brunofreitas.com   |
|     (c) 2018-2019 - Vassilis Serasidis  https://www.serasidis.gr      |
|   Customized for STM32duino ecosystem   https://www.stm32duino.com    |
+-----------------------------------------------------------------------+

> Trying to open the [COM16]...
> Toggling DTR...
> Searching for [1209:BEBA] device...
##
> [1209:BEBA] device is found !
> Sending <reset pages> command...
> Flashing firmware...
. 1024 Bytes
. 2048 Bytes
. 3072 Bytes
. 4096 Bytes
. 5120 Bytes
. 6144 Bytes
. 7168 Bytes
. 8192 Bytes
. 9216 Bytes
. 10240 Bytes
. 11264 Bytes
. 12288 Bytes
. 13312 Bytes
. 14336 Bytes
. 15360 Bytes
. 16384 Bytes
. 17408 Bytes
. 18432 Bytes
. 19456 Bytes
. 20480 Bytes
. 21504 Bytes
. 22528 Bytes
. 23552 Bytes
. 24576 Bytes
. 25600 Bytes
. 26624 Bytes
. 27648 Bytes
. 28672 Bytes
. 29696 Bytes
. 30720 Bytes
. 31744 Bytes
. 32768 Bytes
. 33792 Bytes
. 34816 Bytes
. 35840 Bytes
. 36864 Bytes
. 37888 Bytes
. 38912 Bytes
. 39936 Bytes
. 40960 Bytes
. 41984 Bytes
. 43008 Bytes
. 44032 Bytes
. 45056 Bytes
. 46080 Bytes
. 47104 Bytes
. 48128 Bytes
. 49152 Bytes
. 50176 Bytes
. 51200 Bytes
. 52224 Bytes
. 53248 Bytes
. 54272 Bytes
. 55296 Bytes
. 56320 Bytes
. 57344 Bytes

> Done!
> Sending <reboot mcu> command...
> Error while sending <reboot mcu> command.
> Searching for [COM16] ...
> [COM16] is found !
> Finish