GithubHelp home page GithubHelp logo

libopencm3-template's Issues

Template not working in OSX (Monterey)

Hi. If somebody could help/provide some guidance on this issue it would be greatly appreciated.

I've been trying to deploy/use this template in a Mac environment and it doesn't work due to problems with the makefile.

When executing the 1st command (from the README.md file): make -C libopencm3
it errors out with: GENHDR include/libopencm3/stm32/f0/irq.json
env: python: No such file or directory

and the file actually does exist at ~/myproject/libopencm3/include/libopencm3/stm32/f0

I followed the README.md instructions and entered this command in my home (~) directory:
git clone --recurse-submodules https://github.com/libopencm3/libopencm3-template.git myproject

I could really use some help here.

Thanks!

Initial make fails with error about Python

Following the build instructions in the README I get the following error:

make: Entering directory '/home/brian/projects/libopencm3_test/libopencm3'
  GENHDR  include/libopencm3/stm32/f0/irq.json
/usr/bin/env: ‘python’: No such file or directory
make: *** [Makefile:59: include/libopencm3/stm32/f0/irq.json.genhdr] Error 127
make: Leaving directory '/home/brian/projects/libopencm3_test/libopencm3'

I wonder whether this is due to the build process depending on Python2 which is now obsolute. Python3 executables tend to be called python3 whereas Python2 were just called python. (It is a shame that distros haven't yet changed the default name / alias for python=>python3.)

I see there are many scripts that have #!/usr/bin/env python. Updating each of these to use python3 advances the build but still failures:

make[1]: arm-none-eabi-gcc: No such file or directory

It looks like the cross compiler installed on my system differs (in location?) from that expected by the build system. Maybe the README should describe this dependancy?

clone and go fails at step 5

The clone and go instruction work fine for steps 1 - 4.
On step 5 I get the following :

mpe@ubuntu:~/mpe$ make -C my-project
make: Entering directory '/home/mpe/mpe/my-project'
CC my-project.c
my-project.c:2:10: fatal error: api-asm.h: No such file or directory
#include "api-asm.h"
^~~~~~~~~~~
compilation terminated.
../rules.mk:126: recipe for target 'bin/my-project.o' failed
make: *** [bin/my-project.o] Error 1
make: Leaving directory '/home/mpe/mpe/my-project'

The OS is Ubuntu 16.04.2
The ARM tools are installed, and libopencm3 build without any problems.
From just looking at the directories, everything looks to be right.
The directories specified in the Makefile look correct too.

Build error when building from template

Hello,

I have cloned this repository as a submodule of my own repository to have a setup customized to my board.

The problem is that whenever I try to build this using make I get this message:

$ make
CC main.c
In file included from ../libopencm3/include/libopencm3/stm32/f1/rcc.h:705,
from main.c:3:
../libopencm3/include/libopencm3/stm32/common/rcc_common_all.h:39:12: error: expected ';' before 'void'
39 | BEGIN_DECLS
| ^
| ;
40 |
41 | void rcc_peripheral_enable_clock(volatile uint32_t *reg, uint32_t en);
| ~~~~
../libopencm3/include/libopencm3/stm32/common/rcc_common_all.h:77:10: error: expected ';' before 'enum'
77 | END_DECLS
| ^
| ;
../libopencm3/include/libopencm3/stm32/f1/rcc.h:746:12: error: expected ';' before 'void'
746 | BEGIN_DECLS
| ^
| ;
747 |
748 | void rcc_osc_ready_int_clear(enum rcc_osc osc);
| ~~~~
../libopencm3/include/libopencm3/stm32/f1/rcc.h:776:6: warning: no previous prototype for 'rcc_clock_setup_in_hsi_
out_64mhz' [-Wmissing-prototypes]
776 | void rcc_clock_setup_in_hsi_out_64mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hsi_config
s[RCC_CLOCK_HSI_64MHZ])");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libopencm3/include/libopencm3/stm32/f1/rcc.h: In function 'rcc_clock_setup_in_hsi_out_64mhz':
../libopencm3/include/libopencm3/stm32/f1/rcc.h:776:45: error: expected declaration specifiers before 'LIBOPENCM3_
DEPRECATED'
776 | void rcc_clock_setup_in_hsi_out_64mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hsi_config
s[RCC_CLOCK_HSI_64MHZ])");
| ^~~~~~~~~~~~~~~~~~~~~
../libopencm3/include/libopencm3/stm32/f1/rcc.h:777:45: error: expected '=', ',', ';', 'asm' or 'attribute' be
fore 'LIBOPENCM3_DEPRECATED'
777 | void rcc_clock_setup_in_hsi_out_48mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hsi_config
s[RCC_CLOCK_HSI_48MHZ])");
| ^~~~~~~~~~~~~~~~~~~~~
../libopencm3/include/libopencm3/stm32/f1/rcc.h:778:45: error: expected '=', ',', ';', 'asm' or 'attribute' be
fore 'LIBOPENCM3_DEPRECATED'
778 | void rcc_clock_setup_in_hsi_out_24mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hsi_config
s[RCC_CLOCK_HSI_24MHZ])");
| ^~~~~~~~~~~~~~~~~~~~~
../libopencm3/include/libopencm3/stm32/f1/rcc.h:779:50: error: expected '=', ',', ';', 'asm' or 'attribute' be
fore 'LIBOPENCM3_DEPRECATED'
779 | void rcc_clock_setup_in_hse_8mhz_out_24mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hse_c
onfigs[RCC_CLOCK_HSE8_24MHZ])");
| ^~~~~~~~~~~~~~~~~~~~~
../libopencm3/include/libopencm3/stm32/f1/rcc.h:780:50: error: expected '=', ',', ';', 'asm' or 'attribute' be
fore 'LIBOPENCM3_DEPRECATED'
780 | void rcc_clock_setup_in_hse_8mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hse_c
onfigs[RCC_CLOCK_HSE8_72MHZ])");
| ^~~~~~~~~~~~~~~~~~~~~
../libopencm3/include/libopencm3/stm32/f1/rcc.h:781:51: error: expected '=', ',', ';', 'asm' or 'attribute' be
fore 'LIBOPENCM3_DEPRECATED'
781 | void rcc_clock_setup_in_hse_12mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hse_
configs[RCC_CLOCK_HSE12_72MHZ])");
| ^~~~~~~~~~~~~~~~~~~~~
../libopencm3/include/libopencm3/stm32/f1/rcc.h:782:51: error: expected '=', ',', ';', 'asm' or 'attribute' be
fore 'LIBOPENCM3_DEPRECATED'
782 | void rcc_clock_setup_in_hse_16mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hse_
configs[RCC_CLOCK_HSE16_72MHZ])");
| ^~~~~~~~~~~~~~~~~~~~~
../libopencm3/include/libopencm3/stm32/f1/rcc.h:783:51: error: expected '=', ',', ';', 'asm' or 'attribute' be
fore 'LIBOPENCM3_DEPRECATED'
783 | void rcc_clock_setup_in_hse_25mhz_out_72mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hse_
configs[RCC_CLOCK_HSE25_72MHZ])");
| ^~~~~~~~~~~~~~~~~~~~~
../libopencm3/include/libopencm3/stm32/f1/rcc.h:797:1: error: expected declaration specifiers before 'END_DECLS'
797 | END_DECLS
| ^~~~~~~~~
main.c:6:28: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
6 | static void rcc_setup(void){
| ^
main.c:11:29: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
11 | static void gpio_setup(void){
| ^
main.c:15:16: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
15 | int main(void) {
| ^
../libopencm3/include/libopencm3/stm32/f1/rcc.h:776:6: error: old-style parameter declarations in prototyped funct
ion definition
776 | void rcc_clock_setup_in_hsi_out_64mhz(void) LIBOPENCM3_DEPRECATED("use rcc_clock_setup_pll(&rcc_hsi_config
s[RCC_CLOCK_HSI_64MHZ])");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:27: error: expected '{' at end of input
make: *** [../rules.mk:131: bin/main.o] Error 1

However, I have tried running the examples from the example repo without trouble.

The only change I made was renaming the my-project.c file to main.c and updating the Makefile accordingly

I hope you can point me in the right direction.

Additional Problem with Template

KARLP: (I added this to the closed issue....but added it here also since I wasn't sure if a closed issue would be 'seeable' by you and others).

Thanks much. That helped get me past the 1st step (make -C libopencm3)
Now, however, it's failing on the 2nd step (make -C my-project)

Here are the error messages (and I think it's still a python vs python3 issue);

JR-iMac5K :: ~/myproject ‹master*› » make -C my-project
env: python: No such file or directory
env: python: No such file or directory
env: python: No such file or directory
env: python: No such file or directory
env: python: No such file or directory
../libopencm3/mk/genlink-config.mk:47: No match for the FPU flags
../libopencm3/mk/genlink-config.mk:52: stm32f407vgt6 not found in ../libopencm3/ld/devices.data
../libopencm3/mk/genlink-config.mk:63: ../libopencm3/lib/libopencm3_.a library variant for the selected device does not exist.
CC my-project.c
arm-none-eabi-gcc: error: missing argument to '-mcpu='
make: *** [bin/my-project.o] Error 1

Again - any help would be greatly appreciated!

Provide an easier way to specify custom linker script.

Issue: Currently in the Makefile both DEVICE and LDSCRIPT cannot be specified at the same time. This makes it difficult to have different linker script while keep all the other flags same.

This is especially true for bootloader projects and/or projects that will have to work with a custom bootloader.

It will be nice to have a way to use a custom linker script while keeping all the other settings as is.

Add flash option using st-flash

When running make flash I get this error:

  FLASH	awesomesauce.elf
make: *** [../rules.mk:159: awesomesauce.flash] Error 1

From what I understand, there's probably something related to openocd. However, I use st-flash:
st-flash write $(PROJECT).bin 0x8000000

It would be nice to have this option in the makefile.

flashing of a template project without verbose option fails

There's a superfluous silencer $(Q) placed in the makefile

$(Q)$(OOCD) -f $(OOCD_FILE) \

that causes an @ character to be placed in front of the openocd command

$ make -n flash
printf " FLASH\tyour-project.elf\n"
(echo "halt; program /home/dem/Code/your-project/my-project/your-project.elf verify reset" | nc -4 localhost 4444 2>/dev/null) ||
@openocd -f ../board/bluepill.cfg
-c "program /home/dem/Code/your-project/my-project/your-project.elf verify reset exit"
2>/dev/null

which makes make flash fail unless the verbose option is added.

$ make flash
CC my-project.c
CC ../my-common-code/api.c
GENLNK stm32f103c8t6
LD your-project.elf
FLASH your-project.elf
../rules.mk:147: recipe for target 'your-project.flash' failed
make: *** [your-project.flash] Error 127

$ make V=1 flash
CC my-project.c
arm-none-eabi-gcc -Os -std=c99 -ggdb3 -mcpu=cortex-m3 -mthumb -msoft-float -fno-common -ffunction-sections -fdata-sections -Wextra -Wshadow -Wno-unused-variable -Wimplicit-function-declaration -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -MD -Wall -Wundef -I. -I../my-common-code -I. -I../libopencm3/include -I. -I../my-common-code -I. -I../libopencm3/include -DSTM32F1 -DSTM32F103C8T6 -I../libopencm3/include -o bin/my-project.o -c my-project.c
CC ../my-common-code/api.c
arm-none-eabi-gcc -Os -std=c99 -ggdb3 -mcpu=cortex-m3 -mthumb -msoft-float -fno-common -ffunction-sections -fdata-sections -Wextra -Wshadow -Wno-unused-variable -Wimplicit-function-declaration -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -MD -Wall -Wundef -I. -I../my-common-code -I. -I../libopencm3/include -I. -I../my-common-code -I. -I../libopencm3/include -DSTM32F1 -DSTM32F103C8T6 -I../libopencm3/include -o bin/api.o -c ../my-common-code/api.c
GENLNK stm32f103c8t6
arm-none-eabi-gcc -E -mcpu=cortex-m3 -mthumb -msoft-float -DSTM32F1 -DSTM32F103C8T6 -D_ROM=64K -D_RAM=20K -D_ROM_OFF=0x08000000 -D_RAM_OFF=0x20000000 -P -E ../libopencm3/ld/linker.ld.S > generated.stm32f103c8t6.ld
LD your-project.elf
arm-none-eabi-gcc -Tgenerated.stm32f103c8t6.ld -L../libopencm3/lib -nostartfiles -mcpu=cortex-m3 -mthumb -msoft-float -specs=nano.specs -Wl,--gc-sections -L../libopencm3/lib bin/my-project.o bin/api.o -lopencm3_stm32f1 -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group -o your-project.elf
FLASH your-project.elf
(echo "halt; program /home/dem/Code/your-project/my-project/your-project.elf verify reset" | nc -4 localhost 4444 2>/dev/null) ||
openocd -f ../board/bluepill.cfg
-c "program /home/dem/Code/your-project/my-project/your-project.elf verify reset exit" \

Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
0x2000
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.229062
Info : STM32F103C8T6.cpu: hardware has 6 breakpoints, 4 watchpoints
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000430 msp: 0x20005000
** Programming Started **
auto erase enabled
Info : device id = 0x20036410
Info : flash size = 128kbytes
wrote 2048 bytes from file /home/dem/Code/your-project/my-project/your-project.elf in 0.548013s (3.650 KiB/s)
** Programming Finished **
** Verify Started **
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20005000
verified 1232 bytes in 0.380016s (3.166 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked

No rule to make target '.bin'

Got an error after cleaning some of code.
What I did:

  1. git clone and update submodules
  2. removed my-common-files/ dir
  3. rewrote main.c to only contain empty main function.
  4. rewrote Makefile, changing basic things.
  5. Build lib in libopencm3/ with make.
  6. Build in stm/ (old my-project) and got an error.

  CC	main.c
  GENLNK  stm32f103c8t6
  LD	stm32
  LD	.elf
make: *** No rule to make target '.bin', needed by 'all'.  Stop.


Here is how my Makefile looks like:


PROJECT = stm32
BUILD_DIR = bin

CFILES = main.c

# TODO - you will need to edit these two lines!
DEVICE=stm32f103c8t6
OOCD_FILE = board/stm32f103c8t6discovery.cfg

# You shouldn't have to edit anything below here.
VPATH += $(SHARED_DIR)
INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR))
OPENCM3_DIR=../libopencm3

include $(OPENCM3_DIR)/mk/genlink-config.mk
include ../rules.mk
include $(OPENCM3_DIR)/mk/genlink-rules.mk

Can suppose I'm not the only one getting this error. Getting this error on multiple devices and OS. Hope I'm just missing some basic knowledge and it is not a bug.

How to enable printf with float argument?

In the libopencm3-examples repository there is a usart_printf example. When compiling the examples this printf("float: %f", 3.21f); works as expected.

Using this repository (libopencm3-template), the printf("float: %f", 3.21f); doesn't do anything (skips the line). Some searching did reveal you should add LDFLAGS += -u _printf_float to the make file. This didn't
work for me. Any pointers on how to make this work?

update:
Got it working, added LDFLAGS += -u _printf_float to the Makefile. Not sure what went wrong the first time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.