wosk / stm32-vserprog-lpc

flashrom serprog LPC programmer based on STM32 MCU
GNU General Public License v3.0
11 stars 4 forks source link

Compile errors: "arm-none-eabigcc: Command not found", "loop initial declarations are only allowed in C99 or C11 mode" #2

Open tosiara opened 5 years ago

tosiara commented 5 years ago

Ubuntu 16

ubuntu@ubuntu:~/stm32-vserprog-lpc$ make BOARD=stm32f103-ugly
make[1]: Entering directory '/home/ubuntu/stm32-vserprog-lpc'
git submodule init
git submodule update --remote
CFLAGS="-O3 -fno-common -ffunction-sections -fdata-sections -funit-at-a-time  -fgcse-sm -fgcse-las -fgcse-after-reload -funswitch-loops -DSTM32F1 -mthumb -mcpu=cortex-m3 -msoft-float -mfix-cortex-m3-ldrd -Ilibopencm3/include/ " PREFIX="arm-none-eabi" make -C libopencm3 lib/stm32/f1 V=1
make[2]: Entering directory '/home/ubuntu/stm32-vserprog-lpc/libopencm3'
  GENHDR  include/libopencm3/stm32/f0/irq.json
./scripts/irq2nvic_h ./include/libopencm3/stm32/f0/irq.json;
  GENHDR  include/libopencm3/stm32/f1/irq.json
./scripts/irq2nvic_h ./include/libopencm3/stm32/f1/irq.json;
  GENHDR  include/libopencm3/stm32/f2/irq.json
./scripts/irq2nvic_h ./include/libopencm3/stm32/f2/irq.json;
  GENHDR  include/libopencm3/stm32/f3/irq.json
./scripts/irq2nvic_h ./include/libopencm3/stm32/f3/irq.json;
  GENHDR  include/libopencm3/stm32/f4/irq.json
./scripts/irq2nvic_h ./include/libopencm3/stm32/f4/irq.json;
  GENHDR  include/libopencm3/stm32/f7/irq.json
./scripts/irq2nvic_h ./include/libopencm3/stm32/f7/irq.json;
  GENHDR  include/libopencm3/stm32/l0/irq.json
./scripts/irq2nvic_h ./include/libopencm3/stm32/l0/irq.json;
  GENHDR  include/libopencm3/stm32/l1/irq.json
./scripts/irq2nvic_h ./include/libopencm3/stm32/l1/irq.json;
  GENHDR  include/libopencm3/stm32/l4/irq.json
./scripts/irq2nvic_h ./include/libopencm3/stm32/l4/irq.json;
  GENHDR  include/libopencm3/stm32/g0/irq.json
./scripts/irq2nvic_h ./include/libopencm3/stm32/g0/irq.json;
  GENHDR  include/libopencm3/gd32/f1x0/irq.json
./scripts/irq2nvic_h ./include/libopencm3/gd32/f1x0/irq.json;
  GENHDR  include/libopencm3/lpc13xx/irq.json
./scripts/irq2nvic_h ./include/libopencm3/lpc13xx/irq.json;
  GENHDR  include/libopencm3/lpc17xx/irq.json
./scripts/irq2nvic_h ./include/libopencm3/lpc17xx/irq.json;
  GENHDR  include/libopencm3/lpc43xx/m4/irq.json
./scripts/irq2nvic_h ./include/libopencm3/lpc43xx/m4/irq.json;
  GENHDR  include/libopencm3/lpc43xx/m0/irq.json
./scripts/irq2nvic_h ./include/libopencm3/lpc43xx/m0/irq.json;
  GENHDR  include/libopencm3/lm3s/irq.json
./scripts/irq2nvic_h ./include/libopencm3/lm3s/irq.json;
  GENHDR  include/libopencm3/msp432/e4/irq.json
./scripts/irq2nvic_h ./include/libopencm3/msp432/e4/irq.json;
  GENHDR  include/libopencm3/efm32/tg/irq.json
./scripts/irq2nvic_h ./include/libopencm3/efm32/tg/irq.json;
  GENHDR  include/libopencm3/efm32/g/irq.json
./scripts/irq2nvic_h ./include/libopencm3/efm32/g/irq.json;
  GENHDR  include/libopencm3/efm32/lg/irq.json
./scripts/irq2nvic_h ./include/libopencm3/efm32/lg/irq.json;
  GENHDR  include/libopencm3/efm32/gg/irq.json
./scripts/irq2nvic_h ./include/libopencm3/efm32/gg/irq.json;
  GENHDR  include/libopencm3/efm32/hg/irq.json
./scripts/irq2nvic_h ./include/libopencm3/efm32/hg/irq.json;
  GENHDR  include/libopencm3/efm32/wg/irq.json
./scripts/irq2nvic_h ./include/libopencm3/efm32/wg/irq.json;
  GENHDR  include/libopencm3/efm32/ezr32wg/irq.json
./scripts/irq2nvic_h ./include/libopencm3/efm32/ezr32wg/irq.json;
  GENHDR  include/libopencm3/sam/3a/irq.json
./scripts/irq2nvic_h ./include/libopencm3/sam/3a/irq.json;
  GENHDR  include/libopencm3/sam/3n/irq.json
./scripts/irq2nvic_h ./include/libopencm3/sam/3n/irq.json;
  GENHDR  include/libopencm3/sam/3s/irq.json
./scripts/irq2nvic_h ./include/libopencm3/sam/3s/irq.json;
  GENHDR  include/libopencm3/sam/3u/irq.json
./scripts/irq2nvic_h ./include/libopencm3/sam/3u/irq.json;
  GENHDR  include/libopencm3/sam/3x/irq.json
./scripts/irq2nvic_h ./include/libopencm3/sam/3x/irq.json;
  GENHDR  include/libopencm3/sam/4l/irq.json
./scripts/irq2nvic_h ./include/libopencm3/sam/4l/irq.json;
  GENHDR  include/libopencm3/sam/d/irq.json
./scripts/irq2nvic_h ./include/libopencm3/sam/d/irq.json;
  GENHDR  include/libopencm3/vf6xx/irq.json
./scripts/irq2nvic_h ./include/libopencm3/vf6xx/irq.json;
  GENHDR  include/libopencm3/swm050/irq.json
./scripts/irq2nvic_h ./include/libopencm3/swm050/irq.json;
rm -f .stamp_failure_lib_stm32_f1
  BUILD   lib/stm32/f1
make --directory=lib/stm32/f1 SRCLIBDIR="/home/ubuntu/stm32-vserprog-lpc/libopencm3/lib" PREFIX="arm-none-eabi" || \
        echo "Failure building: lib/stm32/f1: code: $?" > .stamp_failure_lib_stm32_f1
make[3]: Entering directory '/home/ubuntu/stm32-vserprog-lpc/libopencm3/lib/stm32/f1'
  CC      adc.c
arm-none-eabigcc -Os -Wall -Wextra -Wimplicit-function-declaration -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -Wundef -Wshadow -I../../../include -fno-common -mcpu=cortex-m3  -mthumb -Wstrict-prototypes -ffunction-sections -fdata-sections -MD -DSTM32F1 -ggdb3 -std=c99 -O3 -fno-common -ffunction-sections -fdata-sections -funit-at-a-time  -fgcse-sm -fgcse-las -fgcse-after-reload -funswitch-loops -DSTM32F1 -mthumb -mcpu=cortex-m3 -msoft-float -mfix-cortex-m3-ldrd -Ilibopencm3/include/  -o adc.o -c adc.c
make[3]: arm-none-eabigcc: Command not found
../../Makefile.include:40: recipe for target 'adc.o' failed
make[3]: *** [adc.o] Error 127
make[3]: Leaving directory '/home/ubuntu/stm32-vserprog-lpc/libopencm3/lib/stm32/f1'
make[2]: Leaving directory '/home/ubuntu/stm32-vserprog-lpc/libopencm3'
arm-none-eabi-gcc -O3 -fno-common -ffunction-sections -fdata-sections -funit-at-a-time  -fgcse-sm -fgcse-las -fgcse-after-reload -funswitch-loops -DSTM32F1 -mthumb -mcpu=cortex-m3 -msoft-float -mfix-cortex-m3-ldrd -Ilibopencm3/include/  -c lpc.c -o lpc.o
lpc.c: In function 'lpc_send_addr':
lpc.c:152:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
  for (int i=4; i <= sizeof(addr)*8; i+=4){
  ^
lpc.c:152:2: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
Makefile:109: recipe for target 'lpc.o' failed
make[1]: *** [lpc.o] Error 1
make[1]: Leaving directory '/home/ubuntu/stm32-vserprog-lpc'
Makefile:56: recipe for target 'all' failed
make: *** [all] Error 2

Please suggest steps to troubleshoot Thanks!

tosiara commented 5 years ago

Workaround for the issue with prefix:

diff --git a/Makefile b/Makefile
index 332ef05..5f0f5be 100644
--- a/Makefile
+++ b/Makefile
@@ -113,7 +113,7 @@ $(DMP): $(ELF)
 $(LIBOPENCM3):
        git submodule init
        git submodule update --remote
-       CFLAGS="$(CFLAGS)" PREFIX="$(CROSS:-=)" make -C libopencm3 $(OPENCM3_MK) V=1
+       CFLAGS="$(CFLAGS)" PREFIX="$(CROSS)" make -C libopencm3 $(OPENCM3_MK) V=1

 .PHONY: clean distclean flash reboot size
tosiara commented 5 years ago

The second workaround is to add -std=gnu99:

diff --git a/Makefile b/Makefile
index 332ef05..d5fa431 100644
--- a/Makefile
+++ b/Makefile
@@ -74,7 +74,7 @@ ifeq ($(DEBUG),DEBUG_ENABLE_SEMIHOST)
 OBJS += semihosting.o
 endif
 else
-CFLAGS += -O3
+CFLAGS += -O3 -std=gnu99
 endif

 CFLAGS  += -fno-common -ffunction-sections -fdata-sections -funit-at-a-time