Discussion:
[Sdcc-user] stm8flash compile fails under MacOS X
Georg Icking-Konert
2015-04-19 02:15:36 UTC
Permalink
hi all,

for the STM8 Discovery board I want to use Valentin's stm8flash tool (https://github.com/vdudouyt/stm8flash) for flashing via SWIM / ST-Link. This board has no UART<->USB connection and therefore cannot be programmed via UART boot loader —> need a SWIM tool

Unfortunately I wasn’t able to compile the tool on my Mac. Here's my steps with observations:

installed pkg-config and libusb via Homebrew --> worked
compile of stlink.c gave

many warning messages like (ignored):
stlink.c:37:71: warning: passing 'char [32]' to parameter of type 'unsigned char *' converts between pointers to integer types with different sign [-Wpointer-sign]
--> suppose this is not critical...? Disabled all warnings by CFLAGS += -w in Makefile

many error messages like (fixed):
/usr/local/Cellar/libusb/1.0.19/include/libusb-1.0/libusb.h:1696:10: error: use of undeclared identifier ‚NULL'
--> fixed by #include <stddef.h> in stlink.c before #include <libusb.h>

many error message like (open):
stlink.c:340:12: error: use of undeclared identifier ‚stderr'
fprintf(stderr, "Unknown status: %x\n", status);
In addition it warns that
declaration of built-in function 'fprintf' requires inclusion of the header <stdio.h>
--> it seems like the inclusion of <stdio.h> in line 4 of stlink.c has no effect... :-(

to make sure my toolchain is ok, I compiled a dummy program with fprintf(stderr,"test"); and it was ok
—> I played around a lot but can't get that stdio.h error fixed. Apparently the compiler "forgets“ the stdio.h declarations completely and I have no clue, why
 :-(


Hardware Setup:
iMac running MacOS X 10.10.3
"gcc -v“ yields:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
HW works under Windows on a VirtualPC, i.e. STVD could flash & debug the board on the same Mac and USB port
Anybody has idea what's going wrong, or maybe even succeeded in compiling the tool for MacOS X? For your help thanks a lot in advance!

Regards,
Georg Icking
Philipp Klaus Krause
2015-04-19 10:49:04 UTC
Permalink
Post by Georg Icking-Konert
hi all,
for the STM8 Discovery board I want to use Valentin's stm8flash tool
(https://github.com/vdudouyt/stm8flash) for flashing via SWIM / ST-Link.
This board has no UART<->USB connection and therefore cannot be
programmed via UART boot loader —> need a SWIM tool
Unfortunately I wasn’t able to compile the tool on my Mac. Here's my
* installed pkg-config and libusb via Homebrew --> worked
* compile of stlink.c gave
stlink.c:37:71: warning: passing 'char [32]' to parameter of
type 'unsigned char *' converts between pointers to integer
types with different sign [-Wpointer-sign]
--> suppose this is not critical...? Disabled all warnings
by CFLAGS += -w in Makefile
error: use of undeclared identifier ‚NULL'
--> fixed by #include <stddef.h> in stlink.c before #include <libusb.h>
stlink.c:340:12: error: use of undeclared identifier ‚stderr'
fprintf(stderr, "Unknown status: %x\n", status);
In addition it warns that
declaration of built-in function 'fprintf' requires inclusion of
the header <stdio.h>
--> it seems like the inclusion of <stdio.h> in line 4 of
stlink.c has no effect... :-(
* to make sure my toolchain is ok, I compiled a dummy program
with fprintf(stderr,"test"); and it was ok
—> I played around a lot but can't get that stdio.h error fixed.
Apparently the compiler "forgets“ the stdio.h declarations completely
and I have no clue, why… :-(
* iMac running MacOS X 10.10.3
--prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
* HW works under Windows on a VirtualPC, i.e. STVD could flash & debug
the board on the same Mac and USB port
Anybody has idea what's going wrong, or maybe even succeeded in
compiling the tool for MacOS X? For your help thanks a lot in advance!
Regards,
Georg Icking
Does the attached patch help?

Philipp
Georg Icking-Konert
2015-04-21 19:29:18 UTC
Permalink
Hi Philipp,

first of thanks a lot for the patch! However, I am new to paths and seem to be unable to apply it :-( Specifically:

I copied the patch from your mail and saved it as Unix textfile to root of folder stm8flash
command "patch -p1 < stm8flash.patch“ —> patch: **** malformed patch at line 6: .PHONY: all clean
command "git apply --stat stm8flash.patch“ —> fatal: corrupt patch at line 6

—>
where do I need to copy the patch to? I suppose it’s the root of folder stm8flash
?
what command do I need to call with what parameters?
anything else I have to consider?
maybe this is a stupid question, but is there a reason why this patch isn’t simply applied to Valentin’s repository?

For your help thanks a lot in advance!
Subject: Re: [Sdcc-user] stm8flash compile fails under MacOS X


Does the attached patch help?
Philipp
-------------- next part --------------
diff --git a/Makefile b/Makefile
index bac211b..c1951e2 100644


Philipp Klaus Krause
2015-04-21 20:00:02 UTC
Permalink
* maybe this is a stupid question, but is there a reason why this
patch isn’t simply applied to Valentin’s repository?
He applied it yesterday. I sent it to him at the same time as I sent it
to you. So you can just try his current version now.

Philipp

Loading...