Page 1 of 5

STM32F103C8 BluePill VGA Project

Posted: Thu Apr 23, 2020 7:27 pm
by feluga
Hi Guys!

I'm working on a minimalist VGA driver for the Bluepill (STM32F103C8T6) that uses smallest possible portion of RAM and Flash.
It also uses PC13, PC14 and PC15 for colors (8 possible colors) in order to leave most valuable pins free for other use (considering it uses pins PA9 and PB6 for sync).

It's ready and published as an Arduino Library.

These are the project millestones:
- VGA pins used are PC15, PC14 and PC13 for Red, Green and Blue signal
- It also uses PA9 and PB6 for HSync and VSync.
- It works with Roger's Core and STM32 Official Core.
- At this point a "Simple Demo" example for VGA uses 4.4K RAM and 19.5 K Flash, using Roger's Core.
- Using STM32 Official Core, this same example uses 2.4K RAM and 12.7 K Flash (lowest footprint). Which is very good for adding VGA to your project.

- It supports Arduino Print Class and it works the same way as Serial.print() and Serial.println(), but the output is the VGA monitor.
more information on viewtopic.php?p=3918#p3918

- It produces 8 colors
- Resolution is 224 x 240 pixels
- It works with Tiles and each tile can have only two colors (foreground and background colors)
- Its screen has 28x30 tiles - each tile has 8x8 pixels and it is in flash memory space using 8 bytes / tile
- Each tile has its own pair of colors.
- A tile is like a character bitmap, but it can be used for anything else, including graphical characters - font bitmap is user defined in code.
- There is a graphical mode to display pixels or bitmaps in the screen.

It's fully Arduino IDE compatible by the way!

Update: A new version is now released. The library BlueVGA 1.0 works transparently for both cores (STM32 and Roger's).
The library and source code can be found in https://github.com/RoCorbera/BlueVGA

Video of one of the examples coded within the library: http://www.youtube.com/watch?v=nNWkdR4P_UA

Some Screenshots:
scr1.gif
scr1.gif (43.37 KiB) Viewed 12567 times
src2.gif
src2.gif (50.84 KiB) Viewed 12567 times
SpaceInvaders.png
SpaceInvaders.png (13.45 KiB) Viewed 7619 times

As this project moves forward I'll keep you all posted.

Re: STM32F103C8 BluePill VGA Project

Posted: Thu Apr 23, 2020 7:42 pm
by stevestrong
+10
That's cool!
Do you consider sharing your code? Maybe on Github?

Re: STM32F103C8 BluePill VGA Project

Posted: Thu Apr 23, 2020 9:04 pm
by fpiSTM
WOW nice :shock:

Re: STM32F103C8 BluePill VGA Project

Posted: Fri Apr 24, 2020 6:18 am
by Bakisha
+1
Intresting choise of pins PA9/PB6. Is that without timers for hsync/vsync? And such small memory footprint. Recalculating every (second) line based on chars, not as bitmap. And probably streaming that data with dma to portC?
Can't wait to see the code.

Re: STM32F103C8 BluePill VGA Project

Posted: Fri Apr 24, 2020 3:46 pm
by feluga
Bakisha wrote: Fri Apr 24, 2020 6:18 am +1
Intresting choise of pins PA9/PB6. Is that without timers for hsync/vsync? And such small memory footprint. Recalculating every (second) line based on chars, not as bitmap. And probably streaming that data with dma to portC?
Can't wait to see the code.
I used a lot of coding resources. In order to achieve such low footprint, I used assembly, C, C++ and direct bare metal programming.
It was not easy...

Re: STM32F103C8 BluePill VGA Project

Posted: Fri Apr 24, 2020 3:50 pm
by feluga
stevestrong wrote: Thu Apr 23, 2020 7:42 pm +10
That's cool!
Do you consider sharing your code? Maybe on Github?
I'm considering it... It's still a WIP.
I'll work on an Arduino Library Version and share it on GitHub and Arduino environments.

Re: STM32F103C8 BluePill VGA Project

Posted: Fri Apr 24, 2020 5:29 pm
by mrburnette
feluga wrote: Thu Apr 23, 2020 7:27 pm ...
- It is currently based on Roger's Core that already uses about 2,700 bytes of RAM and 12K of flash just to run a blink.
- At this point a "Hello World" example for VGA uses 4.5K RAM and 18.5 K Flash, including Roger's Core Code.

It's fully Arduino IDE compatible by the way!
...
It has been years since I poked around in the re-born LeafLabs core known as Roger's core. But I seem to recall opportunities for reducing the binary size at the expense of Arduino syntax compatibility.

+1
Nice effort.

Re: STM32F103C8 BluePill VGA Project

Posted: Fri Apr 24, 2020 7:21 pm
by feluga
mrburnette wrote: Fri Apr 24, 2020 5:29 pm It has been years since I poked around in the re-born LeafLabs core known as Roger's core.
LeafLabs / Roger's Core is an excellent Arduino framework. It's worthy continue using because it works seamsly and it is an exceptional tool for beginners.

mrburnette wrote: Fri Apr 24, 2020 5:29 pm But I seem to recall opportunities for reducing the binary size at the expense of Arduino syntax compatibility.
I used some internal C functions from LeafLabs Arduino framework, as well as some bare metal register manipulation. Combining that to some ASM code I managed to reduce the final footprint of the library I'll publish. It was a great opportunity to dive deeply into this framework and understand some of its internal details. I think it was worth it.

There is a significant detail for me.... arm-gcc version from Arduino Due, used in Roger's core. It sound like it can create a smaller and more efficient machine code. I tried using STM32 Core but I could not reach neither size nor performance... Not sure why, but I didn't dive on this other core yet. Maybe some of the options used with gcc.

Maybe someone else has come better information on the difference of way both do compile and link.

Re: STM32F103C8 BluePill VGA Project

Posted: Sat Apr 25, 2020 2:33 am
by mrburnette
feluga wrote: Fri Apr 24, 2020 7:21 pm ...
There is a significant detail for me.... arm-gcc version from Arduino Due, used in Roger's core. It sound like it can create a smaller and more efficient machine code. I tried using STM32 Core but I could not reach neither size nor performance... Not sure why, but I didn't dive on this other core yet. Maybe some of the options used with gcc.

Maybe someone else has come better information on the difference of way both do compile and link.
I do not know enough about your current work or long-term intentions to offer much advice, but compiler switches for gcc, as well linking methodologies often affect bin size. Additionally, the standard C library is not used with either STM32duino implementation; rather RedHat's newlib is used. My experience with newlib has generally been favorable. You may find this link of interest, too.

I will leave you with this one suggestion: read the Arduino.cc documentation for creating your binary using make.

Re: STM32F103C8 BluePill VGA Project

Posted: Sat Apr 25, 2020 5:19 pm
by feluga
I'm looking for some advice..... thinking about this arduino library for VGA.

Should I focus on Roger's Core or should I move directly to STM32 Core?
What is your view on that?

Is Roger's Core sort of dead?

Thanks in advance!