STM32F103C8 BluePill VGA Project

What are you developing?
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

STM32F103C8 BluePill VGA Project

Post 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 12561 times
src2.gif
src2.gif (50.84 KiB) Viewed 12561 times
SpaceInvaders.png
SpaceInvaders.png (13.45 KiB) Viewed 7613 times

As this project moves forward I'll keep you all posted.
Last edited by feluga on Wed Dec 23, 2020 1:40 am, edited 8 times in total.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: STM32F103C8 BluePill VGA Project

Post by stevestrong »

+10
That's cool!
Do you consider sharing your code? Maybe on Github?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32F103C8 BluePill VGA Project

Post by fpiSTM »

WOW nice :shock:
User avatar
Bakisha
Posts: 139
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 5
Contact:

Re: STM32F103C8 BluePill VGA Project

Post 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.
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

Re: STM32F103C8 BluePill VGA Project

Post 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...
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

Re: STM32F103C8 BluePill VGA Project

Post 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.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: STM32F103C8 BluePill VGA Project

Post 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.
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

Re: STM32F103C8 BluePill VGA Project

Post 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.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: STM32F103C8 BluePill VGA Project

Post 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.
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

Re: STM32F103C8 BluePill VGA Project

Post 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!
Post Reply

Return to “Projects”