Bluepill F4 board, anyone still working on it?

If you made your own board, post here, unless you built a Maple or Maple mini clone etc
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Bluepill F4 board, anyone still working on it?

Post by ag123 »

Bingo600 wrote: Sun Jan 19, 2020 1:39 pm I got HW float enabled (i think) -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant

Beginning Whetstone benchmark at 84 MHz ...

Loops:10000, Iterations:1, Duration:29795.44 millisec
C Converted Single Precision Whetstones:33.56 Mflops

Wonder what FCPU i'm running
Can't be all wrong , as USB is workingBeginning Whetstone benchmark at 84 MHz ...

Previous was -oS now with -o3
Loops:10000, Iterations:1, Duration:22780.49 millisec
C Converted Single Precision Whetstones:43.90 Mflops


/Bingo

try -O3 :)
the other thing is make sure to check in your variant
https://github.com/stevstrong/Arduino_S ... f401.h#L39

Code: Select all

#define CYCLES_PER_MICROSECOND   84
is defined appropriately
it is used to select the clock initialization algorithm
https://github.com/stevstrong/Arduino_S ... cF4.c#L476

Code: Select all

void rcc_clk_init(void)
{
	SystemCoreClock = CYCLES_PER_MICROSECOND * 1000000;

#if CYCLES_PER_MICROSECOND == 168
	  SetupClock168MHz();
#elif CYCLES_PER_MICROSECOND == 120
	  SetupClock120MHz();
#elif CYCLES_PER_MICROSECOND == 96
	  SetupClock96MHz();
#elif CYCLES_PER_MICROSECOND == 84
	  SetupClock84MHz();
#elif CYCLES_PER_MICROSECOND == 72
	  SetupClock72MHz();
#else
	#error Wrong CYCLES_PER_MICROSECOND!
#endif
}
e.g. for 84 Mhz
https://github.com/stevstrong/Arduino_S ... cF4.c#L214

Code: Select all

void SetupClock84MHz()
{
	/******************************************************************************/
	/*            PLL (clocked by HSE) used as System clock source                */
	/******************************************************************************/
	/************************* PLL Parameters *************************************/
	// PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N = 25[MHz]/25 * 336 = 336
	int PLL_M = 25;
	int PLL_N = 336;

	// SYSCLK = PLL_VCO / PLL_P = 336 / 4 = 84
	int PLL_P = 4;

	// USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ = 336 / 7 = 48
	int PLL_Q = 7;
^^ it would choose this set of clock configurations
this is the important part, for black pill the crystal runs at 25 Mhz
if you are using a board that has a different crystal speed say 8 Mhz, it may run too slow or too fast

next thing is you can now tweak the clocks if you want, the python script to search clock settings
viewtopic.php?p=393#p393

there are more examples in this thread, i.e. the PLL prescalers and multipliers m, n, p, q
viewtopic.php?f=7&t=92

but if you tweak clocksi.e. the PLL prescalers and multipliers m, n, p, q
https://github.com/stevstrong/Arduino_S ... f401.h#L39

Code: Select all

#define CYCLES_PER_MICROSECOND   84
^^ you would also need to update the cycles per microsecond manually in your variant,
this matters a lot, because it is used in various places, in particular to set the pre-scaler for systick so that systick counts every milliseconds.
and the timers use that same CYCLES_PER_MICROSECOND macro as well.

and you may need to temporary edit

Code: Select all

void rcc_clk_init(void)
so that it would always call the clock setting algorithm that you are changing e.g.

Code: Select all

void SetupClock84MHz()
Bingo600
Posts: 86
Joined: Sat Dec 21, 2019 3:56 pm

Re: Bluepill F4 board, anyone still working on it?

Post by Bingo600 »

If i'm using your binaries , i get the same speed as you.
So the HW is the same

This is something in my setup (or compiler choice)
From the build logs it seems like i use this GCC vers : .arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/
Came in w. the "Atmel Arduino ARM setup i think"

/Bingo
Last edited by Bingo600 on Sun Jan 19, 2020 2:38 pm, edited 1 time in total.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Bluepill F4 board, anyone still working on it?

Post by ag123 »

note that if you choose the clocks for 96mhz
e.g. by selecting a variant with

Code: Select all

CYCLES_PER_MICROSECOND == 96
it would choose this clock setting algorithm instead
https://github.com/stevstrong/Arduino_S ... cF4.c#L277

Code: Select all

void SetupClock96MHz()
{
	/******************************************************************************/
	/*            PLL (clocked by HSE) used as System clock source                */
	/******************************************************************************/
	/************************* PLL Parameters *************************************/
	// PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N = 8[MHz]/4 * 192 = 384
	int PLL_M = 4;
	int PLL_N = 192;

	// SYSCLK = PLL_VCO / PLL_P = 384 / 4 = 96
	int PLL_P = 4;

	// USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ = 384 / 8 = 48
	int PLL_Q = 8;

^^^ note in the comment that this set of pre-scalers is intended for a 8 mhz crystal

to check that use my python script
viewtopic.php?p=393#p393
and for 8mhz you would get this line

Code: Select all

FHSE: 8 m: 4 n: 192 p: 4 (RCC_PLLP_DIV4) q: 8 fusb: 48.0 fcpu: 96.0
look at that it matches

next step is go back to the python script
change the script to read

Code: Select all

#!/usr/bin/python3
#FHSE in mhz
FHSE = 25

#cpu search frequency range
fmin = 90
fmax = 110
run that python script again, you would get this set of clocks

Code: Select all

FHSE: 25 m: 25 n: 192 p: 2 (RCC_PLLP_DIV2) q: 4 fusb: 48.0 fcpu: 96.0
FHSE: 25 m: 25 n: 384 p: 4 (RCC_PLLP_DIV4) q: 8 fusb: 48.0 fcpu: 96.0
FHSE: 25 m: 25 n: 432 p: 4 (RCC_PLLP_DIV4) q: 9 fusb: 48.0 fcpu: 108.0
FHSE: 25 m: 50 n: 384 p: 2 (RCC_PLLP_DIV2) q: 4 fusb: 48.0 fcpu: 96.0
assuming that your variant has already defined

Code: Select all

CYCLES_PER_MICROSECOND == 96
go back in
https://github.com/stevstrong/Arduino_S ... cF4.c#L277

Code: Select all

void SetupClock96MHz() 
{
	/******************************************************************************/
	/*            PLL (clocked by HSE) used as System clock source                */
	/******************************************************************************/
	/************************* PLL Parameters *************************************/
	// PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N = 8[MHz]/4 * 192 = 384
	int PLL_M = 4;
	int PLL_N = 192;

	// SYSCLK = PLL_VCO / PLL_P = 384 / 4 = 96
	int PLL_P = 4;

	// USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ = 384 / 8 = 48
	int PLL_Q = 8;
and patch the clocks you prefer for the m, n, p, q values from the search suggestions from the python script
if you feel naughty you can patch that python script suggestion for 108 Mhz clocks settings instead, i.e. over clock :lol:
Last edited by ag123 on Sun Jan 19, 2020 2:49 pm, edited 1 time in total.
Bingo600
Posts: 86
Joined: Sat Dec 21, 2019 3:56 pm

Re: Bluepill F4 board, anyone still working on it?

Post by Bingo600 »

I'm just trying to get 84MHz to work for now , i'll leave 96MHz for a later excercise,

Here's my build log attached
build-bingo.txt.zip
(3.76 KiB) Downloaded 322 times
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Bluepill F4 board, anyone still working on it?

Post by ag123 »

the build log looks ok, fpu flags, -O3 all selected, so it is the rcc clocks settings that cause the difference ;)

if you are using the disco_f411 variant
https://github.com/stevstrong/Arduino_S ... f411.h#L41

Code: Select all

#define CYCLES_PER_MICROSECOND   96
^^ it would choose this cycles per us

so it goes back to that

Code: Select all

void SetupClock96MHz() { 
2 comments above, try patching the clocks settings (m, n, p, q) and u'd likely get better clocks
Bingo600
Posts: 86
Joined: Sat Dec 21, 2019 3:56 pm

Re: Bluepill F4 board, anyone still working on it?

Post by Bingo600 »

I'm using the blackpill_401 variant in Arduino (Steves) , and running on the F411 blackpill.
The strange thing is really that USB is working , so the RCC clock settings aren't totally FSCK'ed up ...

/Bingo
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Bluepill F4 board, anyone still working on it?

Post by ag123 »

well then you are running at 84 mhz, it would sound a little strange for the low mflops reading in this case
based on what i read so far, it seemed the m, n, p, q settings method is pretty much common in the F4* lines.
i'm not sure if i may be mistaken

one more thing, you should not define in your F401 pill variant
https://github.com/stevstrong/Arduino_S ... f401.h#L39

Code: Select all

#define CYCLES_PER_MICROSECOND   84
changing that clocks per us to 96 which is the normal run speed for F411
because changing that would use the

Code: Select all

void SetupClock96MHz() { 
clocks setting algorithm which is intended for 8mhz crystal.
nevertheless, if you do that, you could go back in the SetupClock96MHz() and update the m, n, p, q pll pre-scalers to match your crystal frequency like suggested. a few comments above

note that the python script as mentioned search clocks such that fusb = 48mhz
viewtopic.php?p=393#p393
i.e. it returns the clocks settings for which usb will continue to operate i.e. 48 mhz

playing with clocks is fun, try the clock settings > 100 mhz (i.e. overclock) and run that whetstone benchmark
those experiments are tedious and they look like this that i've one on f401 black pill
viewtopic.php?p=539#p539

in a recent commit steve made the ART accelerator go on steroids: prefetch + data cache + instruction cache on.
but steve is a little careful, the disableART() function disables only prefetch, which is deemed a power/battery consuming ops
so disableART() switch off prefetch, but still runs fast due to data cache + instruction cache enabled - that is a power saving recommendation
by st too
https://www.st.com/content/ccc/resource ... 096220.pdf
search for 'ART configuration'
Bingo600
Posts: 86
Joined: Sat Dec 21, 2019 3:56 pm

Re: Bluepill F4 board, anyone still working on it?

Post by Bingo600 »

Could you build this , and report the performance ??

I get w. HW FP enabled , and -03 - and -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant



Beginning Whetstone benchmark at 84 MHz ...

Loops:10000, Iterations:1, Duration:22665.84 millisec
C Converted Single Precision Whetstones:44.12 Mflops
Attachments
BP411-wheatstone-Steve.zip
(5.17 KiB) Downloaded 307 times
Last edited by Bingo600 on Sun Jan 19, 2020 4:34 pm, edited 1 time in total.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Bluepill F4 board, anyone still working on it?

Post by ag123 »

Code: Select all

Beginning Whetstone benchmark at 84 MHz ...-OS

Loops:10000, Iterations:1, Duration:74355.56 millisec
C Converted Single Precision Whetstones:13.45 Mflops

Code: Select all

Beginning Whetstone benchmark at 84 MHz ...-O3

Loops:10000, Iterations:1, Duration:42268.75 millisec
C Converted Single Precision Whetstones:23.66 Mflops
something is missing somewhere
:lol:
Last edited by ag123 on Sun Jan 19, 2020 4:46 pm, edited 1 time in total.
Bingo600
Posts: 86
Joined: Sat Dec 21, 2019 3:56 pm

Re: Bluepill F4 board, anyone still working on it?

Post by Bingo600 »

13Mflop

Was what i got on -OS wo HW float .. I think

Is that Steve's Core ??

Well at least we get the same ...

I have been chasing ghosts all day ... Thinking my build system was BORKED

/Bingo
Last edited by Bingo600 on Sun Jan 19, 2020 4:47 pm, edited 1 time in total.
Post Reply

Return to “Custom design boards”