Menu

STM8S103 working, cfg file included

2017-08-24
2017-08-24
  • simon greaves

    simon greaves - 2017-08-24

    Just a small hack on an existing config, tested with one of the multitude of super cheap dev boards fro mChina with this mcu:

    #config script for STM8S103
    
    set FLASHEND 0x9FFF
    set EEPROMEND 0x427F
    set OPTIONEND 0x480A
    set BLOCKSIZE 0x40
    
    proc stm8_reset_rop {} {
       mwb 0x4800 0x00
       reset halt
    }
    
    source [find target/stm8.cfg]
    

    The only issue I have so far i srelated to libraries. I compiled the ST StdPeriph library and then used ar to make it into a library. Then I compiled my test app in a separate dir and linked against the library. This works fine and the code loads and executes however single stepping through with gdb throws an error when it tries to step into a library call - eg:

    GPIO_Init (GPIOx=<error reading="" variable:="" Could="" not="" find="" the="" frame="" base="" for="" "GPIO_Init".="">,
    GPIO_Pin=<error reading="" variable:="" Could="" not="" find="" the="" frame="" base="" for="" "GPIO_Init".="">,
    GPIO_Mode=<error reading="" variable:="" Could="" not="" find="" the="" frame="" base="" for="" "GPIO_Init".="">) at stm8s_gpio.c:71

    The library was compiled with the '--debug --out-fmt-elf' and single stepping still works, just doesn't show the source in the TUI window. Any suggestions?

    S.

     
  • simon greaves

    simon greaves - 2017-08-24

    Bah.. magled the formatting... tyring again:

    GPIO_Init (GPIOx=<error reading variable: Could not find the frame base for "GPIO_Init".>,
        GPIO_Pin=<error reading variable: Could not find the frame base for "GPIO_Init".>,
        GPIO_Mode=<error reading variable: Could not find the frame base for "GPIO_Init".>) at stm8s_gpio.c:71
    

    Compile flags are: -mstm8 --std-sdcc99 --Werror --nostdlib -DSTM8S103 --out-fmt-elf --all-callee-saves --debug --stack-auto --fverbose-asm --float-reent --no-peep

     
    • akre

      akre - 2017-08-24

      Hello and thanks for your interest in the stm8 binutils project.

      I will include the cfg file in the next release.

      Are you sure the library still contain debugging info like .debug_line section? (stm8-objdump <file.elf> -h)

      Anyway, the way it should work is, for any function call without debug info should simply be stepped over regardless of stepping or nexting unless forcibly stepped into with 'si'.

      You could post the library here with your source code if you want me to have a look.

       
      • akre

        akre - 2017-08-24

        The file is of course <libfile.lib>.

         
        • akre

          akre - 2017-08-24

          I don't know if it makes any difference but don't you want to run the archiver with stm8-ar ?

          Although I'm not sure if it is supposed to work with sdcc link?

           

          Last edit: akre 2017-08-24
          • akre

            akre - 2017-08-24

            Hmm, I made a small test with a library and I get the same result.

            dummyx (x=<error reading variable: Could not find the frame base for "dummyx".>) at dummyx.c:8
            dummyx (x=-60798456842731264) at dummyx.c:10
            
             
            • akre

              akre - 2017-08-25

              I have to revise my previous statement. It DOES work as excpected with my small test. I how ever discovered a couple of problems.

              1) There is a bug in the startup code, the sp register is not initialized correctly. A freshly resetted system should work though.

              2) If there is a function returning long long type makes gdb confused somehow showing argments wrongly.

              Single stepping machine instructions will show the above <error reading="" variable=""> during the prolouge. This is normal. Line stepping will however stop on the first line in the function.

              Find the attached test code.

              $ stm8-gdb.exe testdummy.elf
              GNU gdb (GDB) 7.12.1
              Copyright (C) 2017 Free Software Foundation, Inc.
              License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
              This is free software: you are free to change and redistribute it.
              There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
              and "show warranty" for details.
              This GDB was configured as "--host=x86_64-unknown-cygwin --target=stm8-none-elf32".
              Type "show configuration" for configuration details.
              For bug reporting instructions, please see:
              <http://www.gnu.org/software/gdb/bugs/>.
              Find the GDB manual and other documentation resources online at:
              <http://www.gnu.org/software/gdb/documentation/>.
              For help, type "help".
              Type "apropos word" to search for commands related to "word"...
              /cygdrive/c/Users/ARE/.gdbinit:1: Error in sourced command file:
              No symbol table is loaded.  Use the "file" command.
              Reading symbols from testdummy.elf...done.
              (gdb) start
              Temporary breakpoint 1 at 0x80c9
              Starting program: /cygdrive/c/akre/stm8/testdummy/testdummy.elf
              Remote debugging using localhost:3333
              dummyz (z=3) at testdummy.c:8
              8               return z+3;
              Loading section DATA, size 0x5 lma 0x1
              Loading section SSEG, size 0x3 lma 0x6
              Loading section HOME, size 0x83 lma 0x8000
              Loading section GSINIT, size 0x1e lma 0x8083
              Loading section GSFINAL, size 0x3 lma 0x80a1
              Loading section CODE, size 0x97 lma 0x80a4
              Start address 0x8083, load size 323
              Transfer rate: 1 KB/sec, 53 bytes/write.
              (gdb)
              Temporary breakpoint 1, main () at testdummy.c:15
              15              y = dummyy(1);
              s
              dummyy (y=1) at dummyy.c:6
              6         return y-1;
              (gdb) s
              8       }
              (gdb) s
              main () at testdummy.c:16
              16              x = dummyx(2);
              (gdb) s
              dummyx (x=2) at dummyx.c:12
              12        return x + 1;
              (gdb) s
              14      }
              (gdb) s
              main () at testdummy.c:17
              17              z = dummyz(3);
              (gdb) s
              dummyz (z=3) at testdummy.c:8
              8               return z+3;
              (gdb) s
              9       }
              (gdb) s
              main () at testdummy.c:18
              18              return x+y+z;
              (gdb) s
              19      }
              (gdb) s
              
              Program stopped.
              0x00006000 in ?? ()
              (gdb)
              
               

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.