Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use VECT_TAB_OFFSET from upload method #111

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ gd_generic_gd32f3x0.menu.upload_method.dfuUtilMethod.upload.options=
gd_generic_gd32f3x0.menu.upload_method.dfuUtilMethod.build.upload_flags=
gd_generic_gd32f3x0.menu.upload_method.dfuUtilMethod.upload.tool=dfu-util

gd_generic_gd32f3x0.menu.upload_method.dfuUtilMethod.build.flash_offset=0x0x2000
gd_generic_gd32f3x0.menu.upload_method.dfuUtilMethod.build.flash_offset=0x2000
gd_generic_gd32f3x0.menu.upload_method.dfuUtilMethod.upload.pid=0x004
gd_generic_gd32f3x0.menu.upload_method.dfuUtilMethod.upload.vid=0x1209

Expand Down Expand Up @@ -644,7 +644,7 @@ gd_generic_gd32f30x.menu.upload_method.dfuUtilMethod.upload.options=
gd_generic_gd32f30x.menu.upload_method.dfuUtilMethod.build.upload_flags=
gd_generic_gd32f30x.menu.upload_method.dfuUtilMethod.upload.tool=dfu-util

gd_generic_gd32f30x.menu.upload_method.dfuUtilMethod.build.flash_offset=0x0x2000
gd_generic_gd32f30x.menu.upload_method.dfuUtilMethod.build.flash_offset=0x2000
gd_generic_gd32f30x.menu.upload_method.dfuUtilMethod.upload.pid=0x004
gd_generic_gd32f30x.menu.upload_method.dfuUtilMethod.upload.vid=0x1209

Expand Down Expand Up @@ -854,7 +854,7 @@ gd_generic_gd32e23x.menu.upload_method.dfuUtilMethod.upload.options=
gd_generic_gd32e23x.menu.upload_method.dfuUtilMethod.build.upload_flags=
gd_generic_gd32e23x.menu.upload_method.dfuUtilMethod.upload.tool=dfu-util

gd_generic_gd32e23x.menu.upload_method.dfuUtilMethod.build.flash_offset=0x0x2000
gd_generic_gd32e23x.menu.upload_method.dfuUtilMethod.build.flash_offset=0x2000
gd_generic_gd32e23x.menu.upload_method.dfuUtilMethod.upload.pid=0x004
gd_generic_gd32e23x.menu.upload_method.dfuUtilMethod.upload.vid=0x1209

Expand Down Expand Up @@ -1248,7 +1248,7 @@ gd_generic_gd32f1x0.menu.upload_method.dfuUtilMethod.upload.options=
gd_generic_gd32f1x0.menu.upload_method.dfuUtilMethod.build.upload_flags=
gd_generic_gd32f1x0.menu.upload_method.dfuUtilMethod.upload.tool=dfu-util

gd_generic_gd32f1x0.menu.upload_method.dfuUtilMethod.build.flash_offset=0x0x2000
gd_generic_gd32f1x0.menu.upload_method.dfuUtilMethod.build.flash_offset=0x2000
gd_generic_gd32f1x0.menu.upload_method.dfuUtilMethod.upload.pid=0x004
gd_generic_gd32f1x0.menu.upload_method.dfuUtilMethod.upload.vid=0x1209

Expand Down
6 changes: 3 additions & 3 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} "-DUSB_MANUFACTURER=

# compile patterns
## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} {build.info.flags} {compiler.c.extra_flags} {build.extra_flags} {build.enable_usb} {includes} "{source_file}" -o "{object_file}"
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} {build.info.flags} {compiler.c.extra_flags} {build.extra_flags} {build.enable_usb} {build.bootloader_flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {build.info.flags} {compiler.cpp.extra_flags} {build.extra_flags} {build.enable_usb} {includes} "{source_file}" -o "{object_file}"
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {build.info.flags} {compiler.cpp.extra_flags} {build.extra_flags} {build.enable_usb} {build.bootloader_flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.info.flags} {compiler.S.extra_flags} {build.extra_flags} {build.enable_usb} {includes} "{source_file}" -o "{object_file}"
recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.info.flags} {compiler.S.extra_flags} {build.extra_flags} {build.enable_usb} {build.bootloader_flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Combine gc-sections, archives, and objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define __HXTAL (HXTAL_VALUE) /* high speed crystal oscillator frequency */
#define __SYS_OSC_CLK (__IRC8M) /* main oscillator frequency */

#define VECT_TAB_OFFSET (uint32_t)0x00 /* vector table base offset */
//#define VECT_TAB_OFFSET (uint32_t)0x00 /* vector table base offset */
Copy link
Member

@maxgerhardt maxgerhardt Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a

#ifndef VECT_TAB_OFFSET  
#define VECT_TAB_OFFSET ...
#endif 

here to allow a user-overridable value, would that not mean that this file tries to use a hardcoded vector table offset?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's pulled in from platform.txt. The variable build.bootloader_flags=-DVECT_TAB_OFFSET={build.flash_offset} wasn't being used anywhere. flash_offset is being used to inform the linker script through LD_FLASH_OFFSET={build.flash_offset}.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if -DVECT_TAB_OFFSET={build.flash_offset} is additionally set as global compiler settings, would that not cause a "VECT_TAB_OFFEST redefined" warning in GCC when compiling this file like in https://stackoverflow.com/a/73518725?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it would, so the correct way for the user to override it would be setting build.flash_offset.


/* select a system clock by uncommenting the following line */
//#define __SYSTEM_CLOCK_8M_HXTAL (__HXTAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define __HXTAL (HXTAL_VALUE) /* high speed crystal oscillator frequency */
#define __SYS_OSC_CLK (__IRC8M) /* main oscillator frequency */

#define VECT_TAB_OFFSET (uint32_t)0x00 /* vector table base offset */
//#define VECT_TAB_OFFSET (uint32_t)0x00 /* vector table base offset */

/* select a system clock by uncommenting the following line */
/* use IRC8M */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define __HXTAL (HXTAL_VALUE) /* high speed crystal oscillator frequency */
#define __SYS_OSC_CLK (__IRC8M) /* main oscillator frequency */

#define VECT_TAB_OFFSET (uint32_t)0x00 /* vector table base offset */
//#define VECT_TAB_OFFSET (uint32_t)0x00 /* vector table base offset */

/* select a system clock by uncommenting the following line */
//#define __SYSTEM_CLOCK_8M_HXTAL (__HXTAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define __HXTAL (HXTAL_VALUE) /* high speed crystal oscillator frequency */
#define __SYS_OSC_CLK (__IRC8M) /* main oscillator frequency */

#define VECT_TAB_OFFSET (uint32_t)0x00 /* vector table base offset */
//#define VECT_TAB_OFFSET (uint32_t)0x00 /* vector table base offset */

/* select a system clock by uncommenting the following line */
#if defined (GD32F330)
Expand Down