Coder Social home page Coder Social logo

Comments (50)

r-pv avatar r-pv commented on May 27, 2024

Hi, I use STLink, since IMO it's the most convenient way to upload sketchs to the STM32/STM8 MCU's, you don't have to mess with boot pins nor bootloaders and you can find clones very cheap on aliexpress/ebay.

If you have an spare bluepill you may want to try to convert it into a stlink

On the datasheet says this:

3.3 Boot modes
At startup, the boot pin and boot selector option bit are used to select one of the three boot
options:
• Boot from User Flash
• Boot from System Memory
• Boot from embedded SRAM
The boot loader is located in System Memory. It is used to reprogram the Flash memory by
using USART on pins PA14/PA15 or PA9/PA10.

Pins PA9 and PA10 are the default for the USART so it should work, if not give a try to the PA14 (TX) / PA15 (RX)

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

I have used platformio IDE a few times, but I haven't idea how to create variants for this IDE, the variant on this repo it's for arduino IDE but the new version of this core (ST Core v2.0, that was released a few days) already has support for most of the F030XX series, so if you're using using arduino IDE upgrade the core to the newer 2.0 version or you'll have to install this variant manually (instructions are on the readme/main of this repo). Maybe that's why you can't program correctly the MCU, the USART interface it's the same as the bluepill (F103), the F030C just has one boot pin).

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Hi, sorry for the delay, I was using my F030C8 and can't use for this test until I finish a project.

So I didn't tried before to upload using the usart but I just tried and it works fine, here's how I did it:

  1. Put the boot pin to HIGH (1).
  2. Connect your USB-TTL to the board using the pinout: PA9->RX, PA10->TX, GND and 3v3 equals. Also, some USB-TTL are dodgy, even when you select 3v3 as the desired working voltage they outputs >4v on their RX/TX pins, so if you can check this before connect it will be great.
  3. Select the correct board on the arduino IDE and if there is an option "upload method>STM32CubeProgrammer"* pick the "serial" option.
  4. Compile and upload the code once arduino IDE says that it's finished, change the boot pin to LOW (0) and press the reset button on the board.

*This may be required to have it installed, it's a free (of charge) software that you can download on the ST site.

I tested this with the blink sketch and was working.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

The STM32CubeProgrammer, the stlink requires this software in order to be able of make uploads, but I'm not sure if it's required for ttl uploads, the error message makes me think that probably be the case but it's weird that you can do uploads on the blue pill and not on this board.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

But just to be sure you have installed software for the st-link?
Yes, for stlink uploads the STM32CubeProgrammer is mandatory, that's why I wasn't sure if this will be available on your menus.

But still, using stlink you just connect it, hit the compile/upload button and that's it, not messing with boot pins, bootloaders, no matter what stm32 flavor nor sequences.

There are some bootloaders that you can load into the bluepill (F3XXXX series, F4XXXX series, MCUs with considerable flash and USB capabilities) that allow you to do uploads through the USB port, that can be really convenient too.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Hi, sorry for the late reply.

This boards have 2 usart and the stcore has the software serial library, all works, I can't remember if I've tested the usart 2, but it should work. And I always use the PXX pin nomenclature (PA0, PB1, ..., ), but yes, there is a bit of mess regarding to the pin naming, I think that is inherited from the arduino API.

Regarding the tft, the SPI/I2C and most of the peripherals works fine and on most cases you can use all standard libraries like it was the atmega328p. The problem with the TFT/color libraries it's that are super-optimized for the avr-atmel mcu's and have very basic support for the stm32 mcu's, so when I tested the speed of the displays it's not what you'll expect for a mcu way faster that the avr-atmel. The TFT_eSPI works really well, has support for the stm32 (real support), but the config was a bit different, you have to edit the files of this library, on the User_Setup.h you have to:

  • un-comment: #define STM32
  • select the display driver that you are using.
  • when I tested this library, that version includes all the fonts by default, causing a lot of flash usage, so comment in all the fonts that you aren't using.

And regarding the variant: there is documentation about variants, but that info and my variants are for the st core <2.0, it seems that the stcore v2.0 changes the way that variants are made, but it doesn't matter, because the stcore v2.0 includes support for most the F030XX series, so if you're using the stcore v2.0, please use the included variant instead of mine.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Hi!

So... this board has 2 hardware usart ports, they should work fine even if you use one as the ttl-upload since this port will be used when the board runs on the bootloader and when will be running on flash (your program) the port should be free. There is also 2 extra possibilities:

  • You can use the SoftwareSerial library, this will create a virtual serial on any of 2 free pins you choose.
  • You can remap some of the pins of the usart/i2c/spi, the ST core has this as option check the documentation So you can use the normal pins for the ttl-upload and the remap pins for your normal program operations. But this has limitations: 1. there are just 2 (normally) set of pins, 2. ports are in sets so those pins aren't interchangeable, you has to choose between a pair/set or the other.

There are some nice sample sketches for this core: check

Displaytest program of the tft_eSPI is to large, some 49kb.

Yes!, I complain about this a lot, for some reason this series, F030XX, the flash usage it's insane (even compared with other stm32 flavors), a simple clock that uses serial, an i2c library and a led-segmented display can easily take above 16kb!, one solution it's disabling peripherals that you aren't using: read this part.

Also, the v2.0 may have make things worst on this regard, I saw a message on the stm32duino.com forum (or maybe on the github repo) that someone was complaining about the sketch getting 20% bigger on the new core :| I'm still using the 1.9 since I'm working on something and I don't want to add tons of extra variables with a new core :P

With the lib of cmb80amiga

So, here's other part of the stm32duino, the support for stm32 on arduino it's divided into "cores", you may have heard of this...long story short: there are basically 2 types of core:

-ST core, the core that ST themselves are developing.
-Libmapple-based cores (most known it's the Roger's Core, but there are a few other flavors of this core).

The libmapple cores starting all of this, but there are not compatible with the STcore and they only support a few boards/mcu's (F103XX line and the F4XXXX line).

So in some cases you'll find libraries for the libmapple-type cores (like the cmb80amiga) and others for the stcore (like the tft_eSPI), that's why you'll get a lot of errors when you try to compile libraries for a different core.

So yes, the tft_eSPI works fine on the stcore but the cmb80amiga won't work on this core.

Now, I use the tft_eSPI on a project that includes 2 MAX6675, 1 MAX44009 and a SD card for logging, the flash consumption was under 55kb, using a F030C8. This without disabling anything, so your problem with the huge flash usage may be related to the new core, but I cant investigate until a few days...

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

I use the F030F4 as the stm32 attiny, it's a tssop20 package with 16kb of flash, but depending on what peripherals you use it feels like an atmega328p of 512b-1kb flash, sadly ST didn't have any mcu of a sot-23 o similar size package.

To me the sale point of the stm32 it's that you have like a hundred mcu's to choose with all the combinations possibles: low power/consumption, dacs, adc 16bits, crypto, dfu, giant flash sizes (up to 1mb), fast clocks (at least 480mhz), etc.

The stcore compatibility with the arduino api it's really great overall, you don't find a lot of problems with libraries, there is this particularly case with the tft library because it has to send a lot of data as fast as possible and due to the same compatibility most of the speeds are set by default at the avr-atmel values, the adc y pwm channels also are set by default at 10bit and 8bit respectively when this are at least 12bit and 16bit on all stm32 series (on the api documentation says how to change it).

But libraries, like the u8g2 runs fast and perfectly on the f030 and all the stm32 mcu's that I have tested on both hardware i2c and spi, I just don't have tested the software i2c but probably it's a nono anyways.

There's other library that gave me a lot of problems and I didn't make it work on the f030's, was the IR remote library, so timer-related libraries may also be an issue, I haven't tried again though.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Yes, but to change default stuff on the stcore isn't complicated:

analogReadResolution(12);//changes the adc resolution to 12 bits
analogWriteFrequency(1000);//changes the pwm frequency to 1000...1khz
//I haven't tested this, but it should work:
analogWriteResolution(12);//changes the pwm resolution to 12bit (and up to 16bit)

changing the speed of serial it's the standard way, the i2c it's:

Wire.setClock(1000000);//set the speed at 1mhz, default it's at 100khz
Wire.begin();

the spi speed on the stm32 can go up to 50% of the clock speed, the f030 clock can go up to 48mhz so 24mhz it's the max speed of the spi, on the f103 the max clock it's 72mhz so max 36mhz spi.

all the free pins can be used as input/outputs and as interrupts.

You mentioned the different core for cmb80amiga libs. Is there an easy way to integrate this core in arduino, too? If these basics are not set up properly, I don't think I would have any success.

Yes, the installation it's the same as the stcore, here it's the Roger's Core repo but I think that you can't have both cores installed at the same time, also remember that the libmapple cores doesn't support the f030 series, you'll have to use a bluepill (f103 cc/c8/ve/ze series), there's also support for some mcu's of the f4xxxx series, but I don't have idea which ones, probably the black pill (f411ce). Also, be aware of the libmapple core may not be compatible with the previous info, as example: it's a while now since I don't use Roger's Core, but back then using the pwm output was using:

pwmWrite(PB1,128);

while the stcore it's the standar way:

analogWrite(PB1,128);

So using libmapple cores may take a bit more work.

Don't think I can make it again with stmnerd_face

Yes, I feel you, changing platform can be really exhaustive and sometimes ended not been useful or not something that you'll like. So you really have to evaluate this according to your needs.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Hi!,

White screen means faulty connection and/or wrong display driver.
If I remember correctly, when I use this library you can't choose freely the pins, for some reason you've to use a set of pins, I don't know if this has changed, maybe not. I attached an schematic of the pins I used, the contructor I used it's:

TFT_eSPI _s=TFT_eSPI();

rMeterST_kc.pdf

Use this pinout and let's see if it works.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Hi!

Glad it worked out!. I remember that one or two examples also didn't ran but since my sketch was working I didn't investigated any further 😏

And yes, to me stlink it's the way to go with stm32 uploads, it's just the easiest way: no messing with boot pins, bootloaders or sequences, but sadly stlink doesn't create a serial protocol (like for debugging), stlink supports real debugging but arduino IDE won't, on stm32cubeide (the stm32 kind of official IDE) you can use stlink for debugging, you can see the values of your variables on real time!, maybe one day this will be ported to arduino IDE...

BTW, when I mention the timers I was referring to libraries that are using the hardware timers directly may give you problems, libraries that are using timer-based functions (like delay(), delaymicroseconds, millis(), etc. ) all those should work fine.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Sorry to hear that.

Yes, you can disable stuff to gain some flash, I'll disable the serial (this will give you like 1-2kb) and if you aren't using the hardware timers directly or pwm channels you can disable the timer module (#define HAL_TIM_MODULE_DISABLED this will give you like 5kb-10kb). After this you can try to optimize your code, but overall yes, the flash usage on this particular line (F030) it's insane, this may be exaggerating by the new core, your code or both.

For voltage, there is an example on the documentation on how to use the internal voltage reference as well other of the internal channels, like the internal temperature.

Can you compile the blink example to see if we get similar flash/ram usage?, I got this:

Sketch uses 10548 bytes (16%) of program storage space. Maximum is 65536 bytes.
Global variables use 928 bytes (11%) of dynamic memory, leaving 7264 bytes for local variables. Maximum is 8192 bytes.

on Arduino IDE 1.8.12 and STcore 1.9 with all initial values and without disabling anything.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Hi

Don't I need the timer at least for delay? I read about interrupt handler with use

For delay() and other timer-based functions, no, you won't need the timer module, for interrupts I haven't tried.

So do you think a bluepill will be less resource hungry?

You can test it, just change the board on arduino IDE and compile it, but yes, it should be a smaller flash usage, the thing will be to see how much small will be.

Flash is 11136 byte.

so isn't considerable bigger usage.

#define HAL_TIM_MODULE_DISABLED has no effect .

Just to be sure, you did put that line on a separate hal_conf_extra.h file, right?, I remember that changing/creating this file may require an arduino IDE restart.

There are other ways to optimize code, like avoiding to use INT (int range it's way bigger on 32bit platforms than on 8bit) so using byte, short or unsigned short instead of int can give you a few kb (or using their C++ AKAs: int8_t,uint8_t,int16_t,uint16_t). Using float/double also have a way bigger impact on the f030 line.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Well, seems that you already hit the ceiling, I think that you should go for the BlackPill:

blackpill_0

The 401 blackpill will have 256kb and the 411 512kb, sadly the prices went crazy since covid times.

Moving from the f030 to the f4XX it's easy.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

the blink example, disabling everything should be under 4kb.

When you use the hal_conf_extra.h file you need to restart arduino ide when you do changes otherwise the flash usage seems unaffected.

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

I got this values:

settings

F030F4:

Sketch uses 3716 bytes (22%) of program storage space. Maximum is 16384 bytes.
Global variables use 64 bytes (1%) of dynamic memory, leaving 4032 bytes for local variables. Maximum is 4096 bytes.

F030K6:

Sketch uses 3660 bytes (11%) of program storage space. Maximum is 32768 bytes.
Global variables use 64 bytes (1%) of dynamic memory, leaving 4032 bytes for local variables. Maximum is 4096 bytes.

F030C8:

Sketch uses 4028 bytes (6%) of program storage space. Maximum is 65536 bytes.
Global variables use 64 bytes (0%) of dynamic memory, leaving 8128 bytes for local variables. Maximum is 8192 bytes.

BluePill:

Sketch uses 4200 bytes (3%) of program storage space. Maximum is 131072 bytes.
Global variables use 64 bytes (0%) of dynamic memory, leaving 20416 bytes for local variables. Maximum is 20480 bytes.

F411CE:

Sketch uses 4440 bytes (0%) of program storage space. Maximum is 524288 bytes.
Global variables use 68 bytes (0%) of dynamic memory, leaving 131004 bytes for local variables. Maximum is 131072 bytes.

F405RG:

Sketch uses 4488 bytes (0%) of program storage space. Maximum is 1048576 bytes.
Global variables use 80 bytes (0%) of dynamic memory, leaving 196528 bytes for local variables. Maximum is 196608 bytes.

blink.zip

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Hi

I agree, the extra usage must be related to the new core 2.0.

BTW, when I first saw this problem, the insane flash usage, first thing that I tried was to use stm32cubeide to program the f030 mcu's, but the result on flash usage was pretty similar to arduino ide (but with a lot of extra work needed), the peripheral libraries are the same on both ide's and are heavy, what you can try it's to disable the hardware peripherals (like i2c) and using software emulation (when be possible), I think it's called "bitbanging", on most sensors won't make a difference, using this method I was able to use an OLED display on the F030F4 (16kb), by "using" it was just printing a few text and that's about it, but using standard peripheral libraries it's just not possible.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Yes, there also a few other models on the F103 line with more flash:

STM32F103 - STMicroelectronics

But I don't think that would be cheaper than a blackpill.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

r-pv avatar r-pv commented on May 27, 2024

Hi, so I'm closing this issue if you have more questions or any other issue please feel free to open a new issue. Cheers.

from rstm32f030c8t6_prominiplus.

KKuKK avatar KKuKK commented on May 27, 2024

from rstm32f030c8t6_prominiplus.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.