libopencm3-examples icon indicating copy to clipboard operation
libopencm3-examples copied to clipboard

Examples stuff: fix examples/rules, extend rules and add f7 examples

Open h2obrain opened this issue 6 years ago • 6 comments

This PR requires the newest libopencm3 master..

Fixes:

  • lpc43xx: Fixed lpc43xx examples (untested) and reenabled compilation
    • alternatively remove the whole lpx43-tree
  • stm32l4: added missing l4 target to Makefile and added stm32/l4/Makefile.include
    • this is also untested, as i have no stm32l476g-disco board
  • rules.mk: define missing LIBDEPS for old style compilation and rules.mk: fix build dependencies
    • adds missing LIBDEPS for old style compilation
    • works best together with PR libopencm3/libopencm3#1053
    • adds $(LIBDEPS) dependency to %.o targets, so libopencm3 gets rebuilt before the c-files (fix for non-existing autogenerated headers)
    • also adds a recipe for the autogenerated headers located in the locm3/include folder to get rid of "no recipe found for header" errors

rules.mk extensions

  • Nice to have for me, but i understand they add unnecessary weight
  • rules.mk: pass CFLAGS variable to libopencm3
  • rules.mk: avoid double slashes in paths
  • rules.mk: build only for the required libopencm3 target
    • alternatively there could be some phony targets in the main Makefile of libopencm3 for the libs like libopencm3_stm32f4.a: lib/stm32/f4;, but this also looks like overkill..

f7-examples for gpio, exti and fmc

  • stm32f7: added demo Makefiles
  • stm32f769i-disco: added blinkled demo
  • stm32f769i-disco: added sdram demo

h2obrain avatar May 25 '19 17:05 h2obrain

I'm not adding more blinkers here. https://github.com/libopencm3/libopencm3-miniblink has them now, it avoids the sort of arbitraty styel differences and gives a common base.

karlp avatar May 25 '19 21:05 karlp

Tell me more about this ""no recipe found for header" problem, I'm not sure what you're reporting here.

karlp avatar May 25 '19 21:05 karlp

"no recipe found for header" when you build everything, then run 'make clean' in the libopencm3-folder, then run 'make clean all' from the examples folder, the makefile picks up header dependencies from the old .d files in the example folder. this is a very specific fix, i know. maybe we could remove the $(MAKE) -C $(OPENCM3_DIR) completely?

h2obrain avatar May 27 '19 10:05 h2obrain

Are you talking about these warnings on the clean?

...
  CLEAN   examples/stm32/f4/nucleo-f411re/usart/
  CLEAN   examples/stm32/f4/other/crypto-basic/
  CLEAN   examples/stm32/f4/stm32f4-discovery/adc-dac-printf/
/home/karlp/src/libopencm3-examples/libopencm3/mk/genlink-config.mk:63: /home/karlp/src/libopencm3-examples/libopencm3/lib/libopencm3_stm32f4.a library variant for the selected device does not exist.
  CLEAN   examples/stm32/f4/stm32f4-discovery/button/
  CLEAN   examples/stm32/f4/stm32f4-discovery/dac-dma/
  CLEAN   examples/stm32/f4/stm32f4-discovery/fancyblink/
  CLEAN   examples/stm32/f4/stm32f4-discovery/mandelbrot/
  CLEAN   examples/stm32/f4/stm32f4-discovery/miniblink/
/home/karlp/src/libopencm3-examples/libopencm3/mk/genlink-config.mk:63: /home/karlp/src/libopencm3-examples/libopencm3/lib/libopencm3_stm32f4.a library variant for the selected device does not exist.
  CLEAN   examples/stm32/f4/stm32f4-discovery/random/
  CLEAN   examples/stm32/f4/stm32f4-discovery/tick_blink/

I can't reproduce any "no recipe found for header" problem.

I tried with

libopencm3-examples $ make clean all
libopencm3-examples $ make -C libopencm3 clean
libopencm3-examples $ make clean all

Is there some other step you needed to make this trigger?

karlp avatar May 27 '19 11:05 karlp

I've added my local files that I hadn't committed. (it's v4 for the fpu, v5 is for cortex-m7 parts) I've also taken the led definitions from your f769i blink and added it to the miniblink repo: https://github.com/libopencm3/libopencm3-miniblink/commit/199faa9da4caf72b606e8ec928c45c5936f28572

karlp avatar May 27 '19 11:05 karlp

yeah sorry about the v5 fpu. i should have been more careful there.

my motivation to change the makefile-system of the examples was, to simplify writing the dsi and other stuff from within the examples project. i should probably just do the development stuff in a standalone project.

LIBNAME is not defined in New Style Makefiles if libopencm3 is not built so the recipe:

$(OPENCM3_DIR)/lib/lib$(LIBNAME).a:
	$(warning $(LIBNAME).a not found, attempting to rebuild in $(OPENCM3_DIR))
	$(MAKE) -C $(OPENCM3_DIR)

becomes:

$(OPENCM3_DIR)/lib/lib.a:
	$(warning .a not found, attempting to rebuild in $(OPENCM3_DIR))
	$(MAKE) -C $(OPENCM3_DIR)

also LDLIBS and LIBDEPS have garbage values in them

LDLIBS += -l
LIBDEPS += $(OPENCM3_DIR)/lib/lib.a

for the examples, this probably only means i have to recompile and everything works. but if I want to use the genlink script to setup the ARCH flags for the device, i either have to backup/restore the LDLIBS/LIBDEPS before/after including genlink-config or just copy/adapt it.

i can trigger the undefined header rule stuff with this (and i know that this is not the intended usage)

libopencm3-examples $ make
...
libopencm3-examples $ make -C libopencm3 clean
...
libopencm3-examples $ make -C examples/stm32/f7/stm32f769i-discovery/sdram clean all
...
make[1]: Leaving directory '.../libopencm3-examples/libopencm3'
make: *** No rule to make target '../../../../../libopencm3/include/libopencm3/stm32/f4/nvic.h', needed by 'console.o'.  Stop.
make: Leaving directory '.../libopencm3-examples/examples/stm32/f4/stm32f429i-discovery/sdram'

h2obrain avatar May 27 '19 15:05 h2obrain