OHh!!! Looking at the startup file it has the vector table with name
.section .isr_vector,"a",%progbits
.type g_pfnVectors, %object
.size g_pfnVectors, .-g_pfnVectors
g_pfnVectors:
.word _estack /* Top of Stack */
but in your file framework-arduinogd32 (2022-09-08)\variants\GD32F470ZK_EVAL your write
SECTIONS
{
__stack_size = DEFINED(__stack_size) ? __stack_size : 2K;
/* ISR vectors */
.vectors :
{
. = ALIGN(4);
KEEP(*(.vectors))
. = ALIGN(4);
/* __Vectors_End = .;
__Vectors_Size = __Vectors_End - __gVectors;*/
} >FLASH
so the vectors don’t get placed at the right address due to referencing a different name!!
Change this to say
SECTIONS
{
__stack_size = DEFINED(__stack_size) ? __stack_size : 2K;
/* ISR vectors */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector))
. = ALIGN(4);
/* __Vectors_End = .;
__Vectors_Size = __Vectors_End - __gVectors;*/
} >FLASH
and remove and ldscript.ld that you might have in your project directory and referenced in the platformio.ini. The builder script should pick up the one in the variant’s directory.
Now I also remember why platform-gd32/misc/scripts/startup_files_converted_arduino at main · CommunityGD32Cores/platform-gd32 · GitHub exists, these startup files in there have the correct .vector name in the startup file that is compatible with the linker file. But I haven’t yet regenerated those for F470.
I modified .vector to .isr_vector in ldscript.ld file.
(C:\Users\JJS.platformio\packages\framework-arduinogd32\variants\GD32F470ZK_EVAL\ldscript.ld)
unfortunately it still doesn’t work.
“remove and ldscript.ld that you might have in your project directory and referenced in the platformio.ini . The builder script should pick up the one in the variant’s directory.”
I didn’t understand it exactly. which one do you want me to remove? Could you explain again how to set it up?
Is it okay to leave the platformio.ini setting?
[env]
platform = https://github.com/CommunityGD32Cores/platform-gd32.git
platform_packages =
framework-arduinogd32@https://github.com/CommunityGD32Cores/ArduinoCore-GD32.git
monitor_speed = 115200
[env:genericGD32F470ZK]
board = genericGD32F470ZK
framework = arduino
build_flags =
-D GD32F470
-D GD32F4xx
board_build.ldscript = C:/Users/JJS/.platformio/packages/framework-arduinogd32/variants/GD32F470ZK_EVAL/ldscript.ld
board_build.variant = GD32F470ZK_EVAL
debug_tool = jlink
This line shouldn’t be needed. (But keep the .ld file of course).
After that change, what output does the command
x/16x 0x8000000
give in the “Debug console”?
platformio.ini
ldscript.ld
result of ‘x/16x 0x8000000’
x/16x 0x8000000
Read 4 bytes @ address 0x08000000 (Data = 0xF8134603)
Read 4 bytes @ address 0x08000004 (Data = 0x2A002B01)
Read 4 bytes @ address 0x08000008 (Data = 0x1A18D1FB)
Read 4 bytes @ address 0x0800000C (Data = 0x47703801)
0x8000000 <strlen>: 0xf8134603 0x2a002b01 0x1a18d1fb 0x47703801
Read 4 bytes @ address 0x08000010 (Data = 0x4C05B510)
Read 4 bytes @ address 0x08000014 (Data = 0xB9337823)
Read 4 bytes @ address 0x08000018 (Data = 0xB1134B04)
Read 4 bytes @ address 0x0800001C (Data = 0xF3AF4804)
0x8000010 <__do_global_dtors_aux>: 0x4c05b510 0xb9337823 0xb1134b04 0xf3af4804
Read 4 bytes @ address 0x08000020 (Data = 0x23018000)
Read 4 bytes @ address 0x08000024 (Data = 0xBD107023)
Read 4 bytes @ address 0x08000028 (Data = 0x20000068)
Read 4 bytes @ address 0x0800002C (Data = 0x00000000)
0x8000020 <__do_global_dtors_aux+16>: 0x23018000 0xbd107023 0x20000068 0x00000000
Read 4 bytes @ address 0x08000030 (Data = 0x080015F4)
Read 4 bytes @ address 0x08000034 (Data = 0x4B03B508)
Read 4 bytes @ address 0x08000038 (Data = 0x4903B11B)
Read 4 bytes @ address 0x0800003C (Data = 0xF3AF4803)
0x8000030 <__do_global_dtors_aux+32>: 0x080015f4 0x4b03b508 0x4903b11b 0xf3af4803
{"token":363,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
How in the world can the strlen function be placed there. Something is terribly out of sync with the startup .S file and the linker script.