Arduino_core_stm32: STM32F103RET6

Created on 2 Jul 2019  ·  36Comments  ·  Source: stm32duino/Arduino_Core_STM32

Board description:

"STM32F103xE" define can be found in some places in the Arduino_Core_STM32 but currently there are no board definitions for it.

Help wanted New variant Request

Most helpful comment

I have started work on a 103RCT6 variant but need to figure out the pin mappings for the variant.x files. The only difference with the RET6 is the flash size. Hopefully I can finish it in the next week or so if that helps any.

All 36 comments

It should be fairly simple to add this by following the guide -> https://github.com/stm32duino/wiki/wiki/Add-a-new-variant-(board)

Best for someone who has the board to do it for ease of testing...

I am afraid we have completely different idea of what it means to be "simple". :) I doubt that i will be the "someone", it is way beyond my hardware knowledge, sorry.

I need to do a board definition for a 103ZET6 at some point too, I will eventually get round to it but if someone has time to look at the RET6, I would expect the ZET6 to be very similar too (hint hint ;-))

I have started work on a 103RCT6 variant but need to figure out the pin mappings for the variant.x files. The only difference with the RET6 is the flash size. Hopefully I can finish it in the next week or so if that helps any.

I believe I have the 103RCT6 variant working. My board has no need for Arduino pins as nothing is broken out. The Blue Button board has almost everything broken out. This simply affects the way Arduino pin designations are allocated in variant.c and variant.h. Does anyone care about a specific allocation or I'll simply define them based on left/righ headers and a zig-zag numbering scheme?

I am currently using Roger Clark's Core which simply numbers sequentially the pins from PA0=0,PA1=1 .. PD2=50
https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F1/variants/generic_stm32f103r/board/board.h
But as you wish. :)

Yup, that's what I did for my board. I'll start work in the STM32F103RET6 variant with that approach.

Ok, I believe this RET6 variant is good. I have attached a zip of the variant folder. Do not rename this folder. The following needs to be added to the boards.txt file under the Generic F1 section of the file:

# BLUEBUTTON_F103RET6 board
GenF1.menu.pnum.BLUEBUTTON_F103RET6=Blue Button F103RET6
GenF1.menu.pnum.BLUEBUTTON_F103RET6.upload.maximum_size=524288
GenF1.menu.pnum.BLUEBUTTON_F103RET6.upload.maximum_data_size=65536
GenF1.menu.pnum.BLUEBUTTON_F103RET6.build.board=NUCLEO_F103RB
GenF1.menu.pnum.BLUEBUTTON_F103RET6.build.product_line=STM32F103xE
GenF1.menu.pnum.BLUEBUTTON_F103RET6.build.variant=BLUEBUTTON_F103RET6

BLUEBUTTON_F103RET6.zip

Let me know how it goes!

Thanks, but when i tried to compile the Blink sample i got the following error:

/home/enes/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32/timer.c: In function 'TIM8_UP_IRQHandler':
/home/enes/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32/timer.c:1328:21: error: 'TIMER13_INDEX' undeclared (first use in this function); did you mean 'TIMER3_INDEX'?
   if (timer_handles[TIMER13_INDEX] != NULL) {
                     ^~~~~~~~~~~~~
                     TIMER3_INDEX

Yup. There is a bug in one of the Core files. See this issue https://github.com/stm32duino/Arduino_Core_STM32/issues/585 for the fix.

OK, now the Blink example compiles without error.
But after i've uploaded the sketch to the device through Maple DFU Bootloader 2.0, neither the LED blinking starts, nor the DFU port appears. I guess i have to reupload the bootloader to it with a serial bootloader again.

I don't use a bootloader so that's as far as I can help.

I've uploaded the compiled Blink sketch and uploaded directly to F103RET6 through serial, but it did not do anything: blinking do not start and there are no data coming from serial... this is the most basic sketch i know, do you have any suggestions for testing?
(I've compiled the same sketch with Roger Clark's core and the same sketch works on the same device through serial upload.)

Did you make sure to assign the correct pin for the built-in LED in the varian.h file?

Honestly i never use built in LED definition, i know that my LED is located on PB11 so i am using this:

void setup() {
  Serial.begin(115200);
  pinMode(PB11, OUTPUT);
  Serial.print(F("\nSetup"));
}

void loop() {
  Serial.print(F("\nLoop"));
  digitalWrite(PB11, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(PB11, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

This code is working on the other core, led is blinking and "Loop" string arrives from serial, but on this official core, there are nothing happens after uploading&restart. I thought that at least the serial comm has to be working, but nope.

OK, now the Blink example compiles without error.
But after i've uploaded the sketch to the device through Maple DFU Bootloader 2.0, neither the LED blinking starts, nor the DFU port appears. I guess i have to reupload the bootloader to it with a serial bootloader again.

I did not checked the variant provided by @pkourany but if the ldscript does not take in account the BL_SIZE then after a flash the bootloader is simply overwritten as it is wrote @0x8000000

@fpistm, that is most likely the cause as I am not using a bootloader in my scenario.

That's why the ldscript is preprocessed then this is automatically handled.
https://github.com/stm32duino/Arduino_Core_STM32/blob/6d9575ec6a4452d52a2b0d73656c3a060dd0e2c6/variants/PILL_F103XX/ldscript.ld#L55

https://github.com/stm32duino/Arduino_Core_STM32/blob/6d9575ec6a4452d52a2b0d73656c3a060dd0e2c6/variants/PILL_F103XX/ldscript.ld#L63-L64

In platform.txt:
-Wl,--defsym=LD_FLASH_OFFSET={build.flash_offset} -Wl,--defsym=LD_MAX_SIZE={upload.maximum_size} -Wl,--defsym=LD_MAX_DATA_SIZE={upload.maximum_data_size}

Depending of the upload method the proper definitions are used:
https://github.com/stm32duino/Arduino_Core_STM32/blob/6d9575ec6a4452d52a2b0d73656c3a060dd0e2c6/boards.txt#L779-L780

Could you provide a PR for this then I could review it/help.

@pkourany, any update for this issue?

Note link that could be used to reference it in the README.md thanks @ThomasGravekamp work.
https://stm32-base.org/boards/STM32F103RET6-Generic-Board

@fpistm are you looking to me to do the PR as I had not planned to do so?

@fpistm are you looking to me to do the PR as I had not planned to do so?

In fact I thought you will provide it, as I understood you've made the variant ❓

@fpistm, I did provide it (see earlier post attachment BLUEBUTTON_F103RET6.zip) but it seems it did not perfectly suit the OP's requirements. I am not sure what the final ldscript.ld and board.txt files look like since the OP has not provided feedback on your latest recommendations. I can do a PR once he does.

what recommandations?
i doubt that the provided bootloader fix will solve my issue as i wrote previously, i've tried to upload with nature serial (without bootloader), and i am unable to get any proof that the sketch is running - neither LED activity nor serial communications.

@fpistm maybe it is a good time to provide some generic mcu variants, with more menu options like for esp8266 etc. , it will resolve lots of issues

@fpistm maybe it is a good time to provide some generic mcu variants, with more menu options like for esp8266 etc. , it will resolve lots of issues

any PR's are welcome 😄

I've made a PR based on @pkourany variant.
I've fixed some issues and provided 4 boards support:

  • STM32F103R8T6
  • STM32F103RBT6
  • STM32F103RCT6
  • STM32F103RET6

Thank you I've made some tests, it looks like almost perfect, only the HID upload method is failing.
Blink sketch with

  • Serial upload: Upload OK, after restart Serial print works, LED blinking OK
  • HID 2.2.1 upload: Upload OK, after restart nor serial, neither blinking works
  • DFU 2.0 upload: Upload OK, after restart Serial print works, LED blinking OK

@enesbcs thanks for the test.

  • HID 2.2.1 upload: Upload OK, after restart nor serial, neither blinking works

The bootloader is for a C8 or CB so this is normal, I guess. @Serasidis do you confirm?

* HID 2.2.1 upload: Upload OK, after restart nor serial, neither blinking works

Burn again the HID bootloader and then, select from Arduino IDE:
Tools > USB Support (if available) > CDC (generic 'Serial' supersede U(S)ART)

Upload your Blink sketch through HID Bootloader 2.2

arduino_ide

I did a successful test on my STM32F103RBT6 by using the hid_generic_pc13.bin file
https://github.com/Serasidis/STM32_HID_Bootloader/releases/download/2.2.1/stm32_binaries.zip

Thanks @Serasidis

After a second glance, I noticed that @enesbcs uses the F103RET MCU that is a high density device.
The F103RET has 2k flash sectors instead of 1k flash sectors that have the F103C8T6 and F103RBT6
That means that the high density F103 devices need different handling during programming.

I will fix that

@enesbcs Could you please test this bootloader file ?

hid_bootloader_f103rct.zip

STM32 HID Bootloader v2.2.2 (Support for High Density F103 Devices)
https://github.com/Serasidis/STM32_HID_Bootloader/commit/161fb7db0ce93ca7eda6d9f0dfc3024bcc143dc0#diff-04c6e90faac2675aa89e2176d2eec7d8

@enesbcs Could you please test this bootloader file ?

Sure, i will try it tonight.

Thank you @Serasidis it works flawlessly! All RET owner owe you a coffee! :)
Thanks also to @pkourany and @fpistm for expanding the core with new board support!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fivdi picture fivdi  ·  6Comments

Hoel picture Hoel  ·  4Comments

Pararera picture Pararera  ·  5Comments

romainreignier picture romainreignier  ·  7Comments

mcer12 picture mcer12  ·  3Comments