Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

h2obrain
Copy link

@h2obrain h2obrain commented May 25, 2019

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 mk/genlink-config: provide LIBNAME in devices autogeneration 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

LIBNAME = opencm3_stm32l4
DEFS += -DSTM32L4

FP_FLAGS ?= -mfloat-abi=hard -mfpu=fpv5-sp-d16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where di you get that it's v5?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right though, I have this as an unchecked in file locally, never committed when the "basics" example was added.

@karlp
Copy link
Member

karlp commented May 25, 2019

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.

$(foreach S,$(call DIR,$(OPENCM3_DIR)/lib/$(M)), \
$(if $(subst opencm3_$M$S,,$(LIBNAME)),,$M/$S)), \
$M)))
# exceptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely not interested in this one. I've had enough rpoblems with people trying to pick and choose things, and reportings bugs when all they really needed to do was just run "make" once in the top and everythign would have been fine. This relies far too much on knowledge of the build system and file structure within the library, which should be treated as a simple .a dependency. It's a submodule for exactly that reason, just build it once, move on.

@@ -186,7 +186,7 @@ endif
# Build libopencm3-lib if it does exists
$(OPENCM3_DIR)/lib/lib$(LIBNAME).a:
$(warning $(LIBNAME).a not found, attempting to rebuild in $(OPENCM3_DIR))
$(MAKE) -C $(OPENCM3_DIR) $(LIBFOLDER)
$(MAKE) -C $(OPENCM3_DIR) $(LIBFOLDER) $(if $(CFLAGS),CFLAGS="$(CFLAGS)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what sort of usecase is this meant to support?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess it makes no sense having this in the examples

@karlp
Copy link
Member

karlp commented May 25, 2019

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

@h2obrain
Copy link
Author

"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?

@karlp
Copy link
Member

karlp commented May 27, 2019

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
Copy link
Member

karlp commented May 27, 2019

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: libopencm3/libopencm3-miniblink@199faa9

@h2obrain
Copy link
Author

h2obrain commented May 27, 2019

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants