Skip to content

Support for SDCC and stm8flash in Eclipse C/C++

Summary

(Summarize the bug encountered concisely)

I'm using Makefile to compile with SDCC, but I couldn't adapt the Makefile file generated automatically by the Eclipse project. Apparently I didn't find variable names like project name etc.

I created a project for C with CDT's support, but disabled them. (Hello world ANSI C project)

W1209-firmware-modified-timer_bkp1.zip

Properties

Launch_config

Images from: https://github.com/rtek1000/W1209-firmware-modified/tree/master/W1209-firmware-Eclipse/Doc

Makefile:

##
## Edited manually by RTEK1000 (Mar/31/2023)
## Based in: https://github.com/mister-grumbler/w1209-firmware/blob/master/Makefile
##

BuildDirectory         :=Release
IncludeDirectory       :=Core/Inc
IncludeSwitch          :=-I
LibrarySwitch          :=-l stm8
LibraryPathSwitch      :=-L
LinkerName             :=/usr/bin/sdcc
LinkOptions            :=--out-fmt-ihx -mstm8
MakeDirCommand         :=mkdir -p
mkfile_path            :=$(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir             :=$(dir $(mkfile_path))
ObjectSuffix           :=.rel
OutputSwitch           :=-o
ObjectSwitch           :=-o
ProjectName            :=$(project_name)
OutputFile             :=$(BuildDirectory)/$(ProjectName).ihx
OutputFileBin          :=$(BuildDirectory)/$(ProjectName).bin
SourceDirectory        :=Core/Src
SourceDirectoryRule    :=$(SourceDirectory)/
GccSourceDirectory     :=$(SourceDirectory)
IncludePath            :=$(IncludeSwitch)$(SourceDirectory) $(IncludeSwitch)$(IncludeDirectory)
SourceSwitch           :=-c
SOURCES                :=$(call rwildcard,$(SourceDirectory),*.c)

##
## Common variables
## CC and CFLAGS can be overriden using an environment variables
##
CC                     := /usr/bin/sdcc
CFLAGS                 := $(LibrarySwitch) -mstm8


##
## User defined environment variables
##
list_files_c           := $(notdir $(wildcard $(SourceDirectory)/*.c))
list_files_rel         := $(addprefix $(BuildDirectory)/,$(patsubst %,%.rel,$(list_files_c)))
		
##
## Main Build Targets 
##
.PHONY: clean makeBuildDirectory all

all:
	@echo Compiling files:;
	@for i in $(list_files_c); do \
		echo Compiling: $$i to $$i.rel; \
		$(CC) \
		$(SourceSwitch) $(SourceDirectoryRule)"$$i" \
		$(CFLAGS) \
		$(ObjectSwitch)$(BuildDirectory)/$$i$(ObjectSuffix) \
		$(IncludePath); \
	done
	@echo Done.;
	@echo Linking all *.rel files. Generating $(project_name).ihx file:;
	$(LinkerName) $(OutputSwitch)$(OutputFile) $(list_files_rel) $(LinkOptions)
	@echo Done.;
	@echo Generating $(project_name).bin file:;
	objcopy -Iihex -Obinary $(OutputFile) $(OutputFileBin)
	@echo Done.;

##
## Make Build Directory
##

makeBuildDirectory:
	@echo Checking build directory.
	@test -d $(BuildDirectory) || $(MakeDirCommand) $(BuildDirectory)

$(BuildDirectory)/.d:
	@test -d $(BuildDirectory) || $(MakeDirCommand) $(BuildDirectory)
	@echo Done.;

##
## Clean
##
clean:
	@echo Cleaning up build directory...
	$(RM) $(BuildDirectory)/*.*
	@echo Done.;

compile.sh:

#! /bin/sh

##
## Edited manually by RTEK1000 (Mar/31/2023)
## Based in: https://github.com/mister-grumbler/w1209-firmware/blob/master/Makefile
##

## remove files before compile, to get errors
make clean

## https://unix.stackexchange.com/questions/31414/how-can-i-pass-a-command-line-argument-into-a-shell-script
## ./myscript myargument
## myargument becomes $1 inside myscript.

make project_name=$1

## Instructions for Empty C Project
## Add compiler Make for Makefile
## Select the Project in Project Explorer
## Project-Properties (Alt+Enter)
## - Go to Builders
## - Uncheck all native builders (CDT or Scanner etc)
## - Click in New
## - - Click in OK (Program)
## - - Put a name ("Make"???)
## - - In Location put: /usr/bin/sh
## - - In Working directory put: ${project_loc}
## - - In Arguments put: compile.sh ${project_name}
## - - Click in OK
## - - Click in Apply and Close
##
## Instructions for STM8S003?3
## - - Add programmer STM8SFLASH
## Select the Project in Project Explorer
## Project-Properties (Alt+Enter)
## - Go to Builders
## - Uncheck all native builders (CDT or Scanner etc)
## - Click in New
## - - Click in OK (Program)
## - - Put a name ("STM8SFLASH"???)
## - - In Location put: /usr/local/bin/stm8flash
## - - In Working directory put: ${project_loc}/Release
## - - In Arguments put: -c stlinkv2 -p stm8s003?3 -w ${project_name}.ihx
## - - Click in OK
## - - Click in Apply and Close

Steps to reproduce

(How one can reproduce the issue - this is very important)

What is the current bug behavior?

(What actually happens)

What is the expected correct behavior?

(What you should see instead)

Relevant logs and/or screenshots

(Add a link to or paste any relevant logs - please use code blocks (```) to format console output, logs, and code, as it's very hard to read otherwise.)

Priority

  • Urgent
  • High
  • Medium
  • Low

Severity

  • Blocker
  • Major
  • Normal
  • Low

Impact

(What is the impact of this issue? Is it blocking a release? Are there any time constraints?, for example: "We have a release tomorrow")