Adding USB Serial

The official STMicroelectronics Arduino core
User avatar
Vassilis
Posts: 294
Joined: Thu May 21, 2015 6:42 am
Location: Thessaloniki, Greece
Contact:

Re: Adding USB Serial

Post by Vassilis » Tue Oct 04, 2016 10:44 pm

RogerClark wrote:Thanks Vassilis.

Appologies for not investigating this myself, but I have been looking at problems on the L476 core.
No worries Roger
So far the USBSerial works fine but only on VECT_TAB_OFFSET=0x0
I have to to create a second static library core that has 0x2000 offset. I will see that tomorrow.

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

Re: Adding USB Serial

Post by RogerClark » Tue Oct 04, 2016 11:21 pm

OK

Lets hope it moves to 0x2000 OK ;-)

Actually...

I have thought about moving all the files from libstm32f103c into the variant folder, and perhaps change some include paths,

I know compiles will take longer, but its a more flexible approach.

However I don't know what will need to be changed to make this work e.g include paths etc

User avatar
Vassilis
Posts: 294
Joined: Thu May 21, 2015 6:42 am
Location: Thessaloniki, Greece
Contact:

Re: Adding USB Serial

Post by Vassilis » Wed Oct 05, 2016 5:10 am

RogerClark wrote:OK
I have thought about moving all the files from libstm32f103c into the variant folder, and perhaps change some include paths,

I know compiles will take longer, but its a more flexible approach.

However I don't know what will need to be changed to make this work e.g include paths etc
I have thought about that moving too but for now I choose to keep the initial file structure.

In my opinion, all files that uses each variant must be in the same variant folder. Every common variant file should be in a folder in the system folder (?)

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

Re: Adding USB Serial

Post by danieleff » Wed Oct 05, 2016 5:11 am

Vassilis wrote:
RogerClark wrote:Thanks Vassilis.

Appologies for not investigating this myself, but I have been looking at problems on the L476 core.
No worries Roger
So far the USBSerial works fine but only on VECT_TAB_OFFSET=0x0
I have to to create a second static library core that has 0x2000 offset. I will see that tomorrow.
You can just make the VECT_TAB_OFFSET as extern const, and declare in variant.cpp as extern const uint32_t VECT_TAB_OFFSET = VECT_TAB_OFFSET_VARIANT (and rename it in boards.txt to *_VARIANT), see attachment.
RogerClark wrote:OK

Lets hope it moves to 0x2000 OK ;-)

Actually...

I have thought about moving all the files from libstm32f103c into the variant folder, and perhaps change some include paths,

I know compiles will take longer, but its a more flexible approach.

However I don't know what will need to be changed to make this work e.g include paths etc
Please do this only when its really necessary. This would mean every small fix would have to be duplicated for every single board.
Attachments
vect_tab_offset_patch.txt
(6.6 KiB) Downloaded 14 times

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

Re: Adding USB Serial

Post by RogerClark » Wed Oct 05, 2016 6:32 am

Good idea

We could change it to a constant. Thats a solution to one of the issues.

With our existing libmaple repo each variant gets a lot more options e.g. upload via USB Serial or via STLink etc, which affect other parts of the build, e.g. how many USARTS are configured, but perhaps moving hw_config.c / .h to the variant folder is enough to handle that as well.

edogaldo
Posts: 250
Joined: Fri Jun 03, 2016 8:19 am

Re: Adding USB Serial

Post by edogaldo » Wed Oct 05, 2016 7:40 am

Hi there, please apologise me if my contribution is not useful, I have only occasional time to look at these topics..

As far as I know the position of the vector table shoud be the starting address of the sketch (i.e. 0x08002000 in case of using the v2 bootloader, 0x08005000 in case of using the original Maple bootloader, 0x08000000 in case of using no bootloader).
This address is generally specified in the compiler options through the board definition and set in the MCU's SCB_VTOR registry during the startup phase, so a question: what's the need to define a const for it?

Thakns in advance and best, E.

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

Re: Adding USB Serial

Post by RogerClark » Wed Oct 05, 2016 8:42 am

In this core we just specify the offset

So as most people are using the new bootloader, the offset will be 0x2000 - but in the future we will also need to support 0x5000 for the old bootloader as well

edogaldo
Posts: 250
Joined: Fri Jun 03, 2016 8:19 am

Re: Adding USB Serial

Post by edogaldo » Wed Oct 05, 2016 8:47 am

RogerClark wrote:In this core we just specify the offset

So as most people are using the new bootloader, the offset will be 0x2000 - but in the future we will also need to support 0x5000 for the old bootloader as well
Ok, but why not just putting a:

Code: Select all

#if !defined  (VECT_TAB_OFFSET) 
	#define VECT_TAB_OFFSET  0x0 /*!< Vector Table base offset field. 
#endif /* VECT_TAB_OFFSET */
in the "system_stm32f1xx.c" letting the compilation/linking process to define it?

edogaldo
Posts: 250
Joined: Fri Jun 03, 2016 8:19 am

Re: Adding USB Serial

Post by edogaldo » Wed Oct 05, 2016 10:06 am

edogaldo wrote: Ok, but why not just putting a:

Code: Select all

#if !defined  (VECT_TAB_OFFSET) 
	#define VECT_TAB_OFFSET  0x0 /*!< Vector Table base offset field. 
#endif /* VECT_TAB_OFFSET */
in the "system_stm32f1xx.c" letting the compilation/linking process to define it?
Ok maybe I found the answer myself: defining VECT_TAB_OFFSET as a macro it's resolved at compile time during the static library compilation, this hardcodes the resolved value within the static library itself; instead defining it as an external variable declared in "variant.cpp" it can be solved at linking time during the final sketch compilation.

User avatar
Vassilis
Posts: 294
Joined: Thu May 21, 2015 6:42 am
Location: Thessaloniki, Greece
Contact:

Re: Adding USB Serial

Post by Vassilis » Sat Oct 22, 2016 10:03 am

The USBSerial has been added to the new core https://github.com/Serasidis/cbp_HALMX_2

I decided to use the Code::Blocks for creating the static libraries instead of using the .mk files that includes the new ST repo.
The reason is that I am more familiar with Code::Blocks (thanks to Slammer !).

There are two static libraries:
- libstm32f103c_gcc_rel.a that works on 0x08000000 address for using the ST-Link, Serial and BMP upload methods
- libstm32f103c_gcc_rel_bl.a that works on 0x08002000 address for using the DFU upload method.

I used the BluePill board with generic_boot20_pc13.bin bootloader file.

Both versions (with bootloader and without bootloader) use the USBSerial. The bad thing is that the produced code is too big
21608 bytes FLASH, 9776 bytes RAM.

Anyway. To use it just copy the cbp_HALMX_2 folder into the arduino -> Hardware folder and choose the board you want from
Tools -> Board -> HALMX 2
The NUCLEO-F103RB variant is not supported yet.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest