Now work with __attribute__

Sysprogs forums Forums VisualGDB Now work with __attribute__

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12430
    ilord
    Participant

    Hello.
    Chip STM32F030C8T6, code:

    volatile unsigned char __attribute__((section(".eeprom_data"))) EEPROM_NumberOfTable = 4;

    In STM32F030C8_flash.lds add strings (last 1K):

    MEMORY
    {
         FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 64K
         EEPROM_DATA (X) : ORIGIN = 0x0800FC00, LENGTH = 1K
         SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 8K
    }
    .....
     .eeprom_data :
     {
            *(.eeprom_data*);
     } > EEPROM_DATA

    GCC compiled, my byte placed at 0x0800FC00, it’s ok. ST-Link utility works and programm runs.

    But VisualGDB is not debugging and programm doesnt start wthout debugging 🙁

    GDB Log:

    C:\SysGCC\arm-eabi\bin\arm-eabi-gdb.exe --interpreter mi D:\table\table/Debug/table.elf
    -gdb-version
    =thread-group-added,id="i1"
    ~"GNU gdb (GDB) 7.12\n"
    ~"Copyright (C) 2016 Free Software Foundation, Inc.\n"
    ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
    ~"This GDB was configured as \"--host=i686-pc-mingw32 --target=arm-eabi\".\nType \"show configuration\" for configuration details."
    ~"\nFor bug reporting instructions, please see:\n"
    ~"<http://www.gnu.org/software/gdb/bugs/>.\n"
    ~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
    ~"For help, type \"help\".\n"
    ~"Type \"apropos word\" to search for commands related to \"word\"...\n"
    ~"Reading symbols from D:\\table\\table/Debug/table.elf..."
    ~"done.\n"
    ~"GNU gdb (GDB) 7.12\n"
    ~"Copyright (C) 2016 Free Software Foundation, Inc.\n"
    ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
    ~"This GDB was configured as \"--host=i686-pc-mingw32 --target=arm-eabi\".\nType \"show configuration\" for configuration details."
    ~"\nFor bug reporting instructions, please see:\n"
    ~"<http://www.gnu.org/software/gdb/bugs/>.\n"
    ~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
    ~"For help, type \"help\".\n"
    ~"Type \"apropos word\" to search for commands related to \"word\".\n"
    ^done
    -list-features
    ^done,features=["frozen-varobjs","pending-breakpoints","thread-info","data-read-memory-bytes","breakpoint-notifications","ada-task-info","language-option","info-gdb-mi-command","undefined-command-error-code","exec-run-start-option"]
    -gdb-set disassembly-flavor intel
    ^error,msg="No symbol \"disassembly\" in current context."
    -gdb-set print demangle off
    ^done
    -break-insert -f main
    ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x08000790",func="main",file="Src/main.c",fullname="D:\\table\\table\\Src\\main.c",line="56",thread-groups=["i1"],times="0",original-location="main"}
    set remotetimeout 60
    &"set remotetimeout 60\n"
    =cmd-param-changed,param="remotetimeout",value="60"
    ^done
    target remote :59431
    &"target remote :59431\n"
    ~"Remote debugging using :59431\n"
    =thread-group-started,id="i1",pid="42000"
    =thread-created,id="1",group-id="i1"
    ~"0xfffffffe in ?? ()\n"
    *stopped,frame={addr="0xfffffffe",func="??",args=[]},thread-id="1",stopped-threads="all"
    ^done
    mon halt
    &"mon halt\n"
    ^done
    info shared
    &"info shared\n"
    ~"No shared libraries loaded at this time.\n"
    ^done
    mon reset init
    &"mon reset init\n"
    @"adapter speed: 1000 kHz\n"
    @"target halted due to debug-request, current mode: Thread \n"
    @"xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc\n"
    @"adapter speed: 8000 kHz\n"
    ^done
    load
    &"load\n"
    &"Error erasing flash with vFlashErase packet\n"
    ^error,msg="Error erasing flash with vFlashErase packet"
    compare-sections
    &"compare-sections\n"
    ~"Section .isr_vector, range 0x8000000 -- 0x80000c0: MIS-MATCHED!\n"
    ~"Section .text, range 0x80000c0 -- 0x8001d78: MIS-MATCHED!\n"
    ~"Section .init_array, range 0x8001d78 -- 0x8001d7c: MIS-MATCHED!\n"
    ~"Section .fini_array, range 0x8001d7c -- 0x8001d80: MIS-MATCHED!\n"
    ~"Section .data, range 0x8001d80 -- 0x8001d84: MIS-MATCHED!\n"
    ~"Section .eeprom_data, range 0x8006c00 -- 0x8006c01: matched.\n"
    &"warning: One or more sections of the target image does not match\nthe loaded file\n"
    &"\n"
    ^done

    GDB Server log:

    C:\Users\admin\AppData\Local\VisualGDB\EmbeddedDebugPackages\com.sysprogs.arm.openocd\bin\openocd.exe -f interface/stlink-v2.cfg -f target/stm32f0x.cfg -c "gdb_port 59431" -c "telnet_port 59430" -c init -c "reset init" -c "echo VisualGDB_OpenOCD_Ready"
    Open On-Chip Debugger 0.10.0 (2017-06-09) [https://github.com/sysprogs/openocd]
    Licensed under GNU GPL v2
    For bug reports, read
    	http://openocd.org/doc/doxygen/bugs.html
    Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
    Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
    adapter speed: 1000 kHz
    adapter_nsrst_delay: 100
    none separate
    Info : Unable to match requested speed 1000 kHz, using 950 kHz
    Info : Unable to match requested speed 1000 kHz, using 950 kHz
    Info : clock speed 950 kHz
    Info : STLINK v2 JTAG v16 API v2 SWIM v4 VID 0x0483 PID 0x3748
    Info : using stlink api v2
    Info : Target voltage: 3.226877
    Info : stm32f0x.cpu: hardware has 4 breakpoints, 2 watchpoints
    adapter speed: 1000 kHz
    target halted due to debug-request, current mode: Thread 
    xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
    adapter speed: 8000 kHz
    VisualGDB_OpenOCD_Ready
    Info : accepting 'gdb' connection on tcp/59431
    Info : device id = 0x20006440
    Info : flash size = 64kbytes
    Error: address + size wrapped (0xfffffffe, 0x00000004)
    adapter speed: 1000 kHz
    target halted due to debug-request, current mode: Thread 
    xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
    adapter speed: 8000 kHz
    adapter speed: 1000 kHz
    target halted due to debug-request, current mode: Thread 
    xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
    adapter speed: 8000 kHz
    adapter speed: 1000 kHz
    target halted due to debug-request, current mode: Thread 
    xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
    adapter speed: 8000 kHz
    Error: Whole bank access must start at beginning of bank.
    Error: flash_erase returned -904
    target halted due to breakpoint, current mode: Thread 
    xPSR: 0x61000000 pc: 0x2000002e msp: 0xfffffffc
    
    #12431
    ilord
    Participant

    Update.

    I googled :

    Problem adding section to linker script

    EEPROM – Flash

    but I dont understend how write the linker script. My script:

    /* Generated by LinkerScriptGenerator [http://visualgdb.com/tools/LinkerScriptGenerator]
     * Target: STM32F030C8
     * The file is provided under the BSD license.
     */
    
    ENTRY(Reset_Handler)
    
    MEMORY
    {
    	FLASH (RX)       : ORIGIN = 0x08000000, LENGTH = 63K
    	EEPROM_DATA (X)  : ORIGIN = 0x0800FC00, LENGTH = 1K
    	SRAM (RWX)       : ORIGIN = 0x20000000, LENGTH = 8K
    }
    
    _estack = 0x20002000;
    
    SECTIONS
    {
    	.isr_vector :
    	{
    		. = ALIGN(4);
    		KEEP(*(.isr_vector))
    		. = ALIGN(4);
    	} > FLASH
    
    	.text :
    	{
    		. = ALIGN(4);
    		_stext = .;
    
    		*(.text)
    		*(.text*)
    		*(.rodata)
    		*(.rodata*)
    		*(.glue_7)
    		*(.glue_7t)
    		KEEP(*(.init))
    		KEEP(*(.fini))
    		. = ALIGN(4);
    		_etext = .;
    
    	} > FLASH
    
    	.ARM.extab :
    	{
    		. = ALIGN(4);
    		*(.ARM.extab)
    		*(.gnu.linkonce.armextab.*)
    		. = ALIGN(4);
    	} > FLASH
    
    	.exidx :
    	{
    		. = ALIGN(4);
    		PROVIDE(__exidx_start = .);
    		*(.ARM.exidx*)
    		. = ALIGN(4);
    		PROVIDE(__exidx_end = .);
    	} > FLASH
    
    	.ARM.attributes :
    	{
    		*(.ARM.attributes)
    	} > FLASH
    
    	.preinit_array :
    	{
    		PROVIDE(__preinit_array_start = .);
    		KEEP(*(.preinit_array*))
    		PROVIDE(__preinit_array_end = .);
    	} > FLASH
    
    	.init_array :
    	{
    		PROVIDE(__init_array_start = .);
    		KEEP(*(SORT(.init_array.*)))
    		KEEP(*(.init_array*))
    		PROVIDE(__init_array_end = .);
    	} > FLASH
    
    	.fini_array :
    	{
    		PROVIDE(__fini_array_start = .);
    		KEEP(*(.fini_array*))
    		KEEP(*(SORT(.fini_array.*)))
    		PROVIDE(__fini_array_end = .);
    	} > FLASH
    
    	. = ALIGN(4);
    	_sidata = .;
    
    	.data : AT(_sidata)
    	{
    		. = ALIGN(4);
    		_sdata = .;
    
    		PROVIDE(__data_start__ = _sdata);
    		*(.data)
    		*(.data*)
    		. = ALIGN(4);
    		_edata = .;
    
    		PROVIDE(__data_end__ = _edata);
    	} > SRAM
    
    	.eeprom_data :
    	{
    		*(.eeprom_data*);
    	} > EEPROM_DATA
    
    	.bss :
    	{
    		. = ALIGN(4);
    		_sbss = .;
    
    		PROVIDE(__bss_start__ = _sbss);
    		*(.bss)
    		*(.bss*)
    		*(COMMON)
    		. = ALIGN(4);
    		_ebss = .;
    
    		PROVIDE(__bss_end__ = _ebss);
    	} > SRAM
    
    	PROVIDE(end = .);
    
    	.heap (NOLOAD) :
    	{
    		. = ALIGN(4);
    		PROVIDE(__heap_start__ = .);
    		KEEP(*(.heap))
    		. = ALIGN(4);
    		PROVIDE(__heap_end__ = .);
    	} > SRAM
    
    	.reserved_for_stack (NOLOAD) :
    	{
    		. = ALIGN(4);
    		PROVIDE(__reserved_for_stack_start__ = .);
    		KEEP(*(.reserved_for_stack))
    		. = ALIGN(4);
    		PROVIDE(__reserved_for_stack_end__ = .);
    	} > SRAM
    
    }
    
    #12433
    support
    Keymaster

    Hi,

    This happens because OpenOCD does not know how to program the EEPROM memory. You can try tagging the new section with the NOLOAD attribute to prevent it from being loaded, or try developing a custom FLASH programming plugin to load EEPROM automatically.

    #12455
    ilord
    Participant

    Thank you.

    I have another solution. This is a work sample.
    My variables:
    __attribute__((section(“.strdata”))) volatile unsigned char EEPROM_txt1[16] = “some text”;
    __attribute__((section(“.strdata”))) volatile unsigned char EEPROM_txt2[16] = “asdasdsad”;

    __attribute__((section(“.eeprom”))) volatile unsigned char EEPROM_NumberOfTable = 3;

    are placed at 0x0800E000 and 0x0800FC00

    
    
    /* Generated by LinkerScriptGenerator [http://visualgdb.com/tools/LinkerScriptGenerator]
     * Target: STM32F030C8
     * The file is provided under the BSD license.
     */
    
    ENTRY(Reset_Handler)
    
    MEMORY
    {
    	FLASH (RX)   : ORIGIN = 0x08000000, LENGTH = 64K
    	SRAM (RWX)   : ORIGIN = 0x20000000, LENGTH = 8K
    }
    
    _estack = 0x20002000;
    
    SECTIONS
    {
    	.isr_vector :
    	{
    		. = ALIGN(4);
    		KEEP(*(.isr_vector))
    		. = ALIGN(4);
    	} > FLASH
    
    	.text :
    	{
    		. = ALIGN(4);
    		_stext = .;
    
    		*(.text)
    		*(.text*)
    		*(.rodata)
    		*(.rodata*)
    		*(.glue_7)
    		*(.glue_7t)
    
    		KEEP(*(.init))
    		KEEP(*(.fini))
    		. = ALIGN(4);
    		_etext = .;
    
    	} > FLASH
    
    	.ARM.extab :
    	{
    		. = ALIGN(4);
    		*(.ARM.extab)
    		*(.gnu.linkonce.armextab.*)
    		. = ALIGN(4);
    	} > FLASH
    
    	.exidx :
    	{
    		. = ALIGN(4);
    		PROVIDE(__exidx_start = .);
    		*(.ARM.exidx*)
    		. = ALIGN(4);
    		PROVIDE(__exidx_end = .);
    	} > FLASH
    
    	.ARM.attributes :
    	{
    		*(.ARM.attributes)
    	} > FLASH
    
    	.preinit_array :
    	{
    		PROVIDE(__preinit_array_start = .);
    		KEEP(*(.preinit_array*))
    		PROVIDE(__preinit_array_end = .);
    	} > FLASH
    
    	.init_array :
    	{
    		PROVIDE(__init_array_start = .);
    		KEEP(*(SORT(.init_array.*)))
    		KEEP(*(.init_array*))
    		PROVIDE(__init_array_end = .);
    	} > FLASH
    
    	.fini_array :
    	{
    		PROVIDE(__fini_array_start = .);
    		KEEP(*(.fini_array*))
    		KEEP(*(SORT(.fini_array.*)))
    		PROVIDE(__fini_array_end = .);
    	} > FLASH
    
    	_offset = .;
     
        .strdata :
        {
            . = . + 0x0800E000 - _offset;
            *(.strdata*)
        } > FLASH	
    		
    	_offset = .;
        
    	.eeprom :
        {
            . = . + 0x0800FC00 - _offset;
            *(.eeprom*)
        } > FLASH
    
    	. = ALIGN(4);
    	_sidata = .;
    	
    	.data : AT(_sidata)
    	{
    		. = ALIGN(4);
    		_sdata = .;
    
    		PROVIDE(__data_start__ = _sdata);
    		*(.data)
    		*(.data*)
    		. = ALIGN(4);
    		_edata = .;
    
    		PROVIDE(__data_end__ = _edata);
    	} > SRAM
    
    	.bss :
    	{
    		. = ALIGN(4);
    		_sbss = .;
    
    		PROVIDE(__bss_start__ = _sbss);
    		*(.bss)
    		*(.bss*)
    		*(COMMON)
    		. = ALIGN(4);
    		_ebss = .;
    
    		PROVIDE(__bss_end__ = _ebss);
    	} > SRAM
    
    	PROVIDE(end = .);
    
    	.heap (NOLOAD) :
    	{
    		. = ALIGN(4);
    		PROVIDE(__heap_start__ = .);
    		KEEP(*(.heap))
    		. = ALIGN(4);
    		PROVIDE(__heap_end__ = .);
    	} > SRAM
    
    	.reserved_for_stack (NOLOAD) :
    	{
    		. = ALIGN(4);
    		PROVIDE(__reserved_for_stack_start__ = .);
    		KEEP(*(.reserved_for_stack))
    		. = ALIGN(4);
    		PROVIDE(__reserved_for_stack_end__ = .);
    	} > SRAM
    }
    
    
    
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.