Updated STM F1 core to support BluePill including USB Serial

Information on the latest releases
User avatar
RogerClark
Posts: 6123
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Updated STM F1 core to support BluePill including USB Serial

Post by RogerClark » Mon Nov 14, 2016 5:49 am

OK

Pushed a whole bunch of changes.

Replaced dashes in board names and variant folders with underscores, updated the makefiles etc etc accordingly.

Changed boards.txt so that STLink is the default for the VL Discovery F100, and changed Blue pill to default to Bootloader uploads


Note. Library for VL Discover still won't compile

User avatar
Rick Kimball
Posts: 892
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Updated STM F1 core to support BluePill including USB Serial

Post by Rick Kimball » Mon Nov 14, 2016 6:03 am

From the ld script:

_estack = 0x20005000; /* end of RAM */
...
the chip i have only has 8K of ram

■ STM32F100RBT6B microcontroller, 128 KB Flash, 8 KB RAM in 64-pin LQFP

* sorry I meant to mention that before

should be:

/* Highest address of the user mode stack */
_estack = 0x20002000; /* end of RAM */

... and the boards.txt is wrong also .. should be 8192

Code: Select all

$ git diff
diff --git a/boards.txt b/boards.txt
index 2f60161..89a69ea 100644
--- a/boards.txt
+++ b/boards.txt
@@ -39,7 +39,7 @@ STM32VLDISCOVERY.pid.0=0x374b
 STM32VLDISCOVERY.node=NODE_F103RB
 
 STM32VLDISCOVERY.upload.maximum_size=131071
-STM32VLDISCOVERY.upload.maximum_data_size=20479
+STM32VLDISCOVERY.upload.maximum_data_size=8192
 
 STM32VLDISCOVERY.build.mcu=cortex-m3
 STM32VLDISCOVERY.build.board=NUCLEO_F103RB
diff --git a/variants/STM32F100RB_STM32VLDISCOVERY/linker_scripts/gcc/STM32F100RB_FLASH.ld b/variants/STM32F100RB_STM32VLDISCOVERY/linker_scripts/gcc/STM32F100RB_FLASH.ld
index d8ea420..e13f5ee 100644
--- a/variants/STM32F100RB_STM32VLDISCOVERY/linker_scripts/gcc/STM32F100RB_FLASH.ld
+++ b/variants/STM32F100RB_STM32VLDISCOVERY/linker_scripts/gcc/STM32F100RB_FLASH.ld
@@ -46,7 +46,7 @@
   ENTRY(Reset_Handler)
 
   /* Highest address of the user mode stack */
-  _estack = 0x20005000;    /* end of RAM */
+  _estack = 0x20002000;    /* end of RAM */
   /* Generate a link error if heap and stack don't fit into RAM */
   _Min_Heap_Size = 0x200;      /* required amount of heap  */
   _Min_Stack_Size = 0x400; /* required amount of stack */
-rick

User avatar
RogerClark
Posts: 6123
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Updated STM F1 core to support BluePill including USB Serial

Post by RogerClark » Mon Nov 14, 2016 7:06 am

OK.

I updated those files

User avatar
RogerClark
Posts: 6123
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Updated STM F1 core to support BluePill including USB Serial

Post by RogerClark » Mon Nov 14, 2016 8:27 am

With the VL DIscovery F100 library build issue.

I think the way to fix is probably to have a different makefile .mk for that board, which can somehow exclude the usb files

danieleff
Posts: 301
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: Updated STM F1 core to support BluePill including USB Serial

Post by danieleff » Mon Nov 14, 2016 8:52 am

RogerClark wrote:With the VL DIscovery F100 library build issue.

I think the way to fix is probably to have a different makefile .mk for that board, which can somehow exclude the usb files
Try commenting out lines 110, 113, 114 in stm32f103c.mk when compiling for F100. right now those only contain USB code.

User avatar
RogerClark
Posts: 6123
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Updated STM F1 core to support BluePill including USB Serial

Post by RogerClark » Mon Nov 14, 2016 10:03 am

Thanks

I thought I'd tried that and it didnt work, but I just tried again and its OK

So I've duplicated stm32f103c.mk to make stm32f100.mk and modified the makefile

BTW.
Strangely, every time I make the lib it changes all the binaries.

I'm not sure whats causing this.

Possibly

system\Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_fsmc.h

lines like

Line 109: #define IS_FSMC_TCLR_TIME(__TIME__) ((__TIME__) <= 255)

User avatar
RogerClark
Posts: 6123
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Updated STM F1 core to support BluePill including USB Serial

Post by RogerClark » Mon Nov 14, 2016 10:05 am

Thanks

Git repo has been updated with the fix for the VL F103 lib compile issue

User avatar
Rick Kimball
Posts: 892
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Updated STM F1 core to support BluePill including USB Serial

Post by Rick Kimball » Mon Nov 14, 2016 2:39 pm

Thanks Roger, those changes seemed to have allowed me to compile and run successfully on the stm32f100rb value line.

This core really isn't effcient when it comes to optimal use of RAM. You can get away with that if you have a chip with 64K of ram and wafers of flash. For a "small" chip ( with 8k of ram ) a blink script uses more than 6000 bytes of ram leaving only about 2k for the app. Half of the RAM usage seems to be data structures that contain static data that could be compile time structures stored in flash. The biggest offender is the g_analog_config table, that alone is 2k
$ arm-none-eabi-nm -t d --print-size --size-sort BlinkWithoutDelay_vl103.ino.elf | grep -v -i '[TR] ' | tail -20
536874360 00000128 b g_UartHandle
536875372 00000140 B g_anInputPinConfigured
536873076 00000208 d g_timer_config
536874120 00000240 b g_TimerHandle
536873700 00000320 d gpio_irq_conf
536873284 00000416 d g_uart_config
536874932 00000440 B g_anOutputPinConfigured
536874488 00000440 B g_digPinConfigured
536870912 00002160 D g_analog_config
Another 1.5K is stolen for the stack and heap. Your code may not actually use that much but it is "reserved" anyways.

-rick
Last edited by Rick Kimball on Fri Nov 18, 2016 1:12 pm, edited 1 time in total.
-rick

User avatar
RogerClark
Posts: 6123
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Updated STM F1 core to support BluePill including USB Serial

Post by RogerClark » Mon Nov 14, 2016 8:25 pm

Thanks Rick

I think there is still a lot of work to be done on the new core to make it work well on processors with small amounts of RAM and flash.

Can you post an issue for the analog config structure

User avatar
RogerClark
Posts: 6123
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Updated STM F1 core to support BluePill including USB Serial

Post by RogerClark » Tue Nov 15, 2016 10:21 pm

I'll post an issue for this, but I don't think there is an easy fix.

Just out of interest, I tried declaring the the analog config as const, but it won't compile as parts of the struct get changed at runtime e.g. I think when analogRead etc is called

I tried packing the struct and changing some of the uint32_t to uint8_t where it looked like that was OK, but it only saved 60 bytes, so is not worth doing.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest