gicking / STM8-SPL_SDCC_patch

Patch for STM8 Standard Peripherals Libraries
Apache License 2.0
88 stars 13 forks source link

how to use example #9

Closed gicking closed 5 years ago

gicking commented 5 years ago

Hello,

I came across your patch file for STM8L SPL, which is very neat, i successfully patched the SPL and i can see the generated template and project for SDCC, how do i use the provided makefile to build a project? i am usually using IDE (for example SW4STM32) so i am not used to makefiles at all. Should i drop the makefile in the STM8L10x_StdPeriph_test folder and issue « make » in the terminal after cd to the directory?

The platform is STM8L101x3 and the environment is OS X, i have SDCC installed and working, i can compile single file firmwares, i also have stm8flash installed and working. Ideally i would like to use this in Eclipse (which has the ddcc plugin installed) however the attempt (make new project from existing makefile) fails to compile, so if i could already compile from terminal it is fine for now.

Thank you in advance. Hoel

gicking commented 5 years ago

hi Hoel,

nice to hear that you like the patches :-)

Unfortunately I cannot comment on how to use an IDE. Also I have no STM8L101x3 board available, so I can only check the build step using 'make' or shell scripts, not the upload. Sorry!

Anyway, building programs is quite easy and should works the same way under MacOSX - or so I expect... You can either use make - or the provided shell script. But before you start please assert that:

To build e.g. example Project/STM8L10x_StdPeriph_Examples/GPIO/GPIO_IOToggle perform the following steps:

  1. copy folder Project/STM8L10x_StdPeriph_test e.g. to Project/test
  2. copy all files from Project/STM8L10x_StdPeriph_Examples/GPIO/GPIO_IOToggle to Project/test
  3. in test/SDCC/Makefile
    • set the device type (this is n/a for STM8L10x, but required e.g. for STM8S)
    • add required SPL modules to SPL_SOURCE (is dummy for GPIO_IOToggle)
  4. build and upload either:
    • manual:
      • open a console in test/SDCC
      • type make -> creates folder test/SDCC/STM8L10x which contains hexfile STM8L10x.hex
      • type stm8flash -c stlink -w ./STM8L10x/STM8L10x.hex -p stm8l101?3 -> uploads hexfile
    • double-click:
      • under MacOSX change _UX_compile_run.sh to _UX_compile_run.command (see here)
      • in _UX_compile_run.sh set location of stm8flash for SWIM_LOADER (or omit if in $PATH)
      • double-click _UX_compile_run.* or type in console (for debug) -> builds code and uploads

PS: just for completeness: for STM8 devices with serial bootloader you can also upload the code via UART, see e.g. here