Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • Feb 24 22:14
    karlp commented #1317
  • Feb 23 21:43
    ventZl commented #1315
  • Feb 23 21:41
    ventZl opened #1317
  • Feb 23 09:28
    karlp closed #1316
  • Feb 23 09:28
    karlp commented #1316
  • Feb 23 09:27

    karlp on master

    stm32: rtc-v2: Fix ADD1S bit de… (compare)

  • Feb 23 01:14
    iqyx opened #1316
  • Feb 17 21:11
    karlp closed #1314
  • Feb 17 21:11
    karlp commented #1314
  • Feb 17 11:08
    ventZl opened #1315
  • Feb 17 10:44
    Azq2 edited #1312
  • Feb 17 10:17
    romanstingler commented #635
  • Feb 17 08:02
    EasyNetDev opened #1314
  • Feb 16 20:39
    ventZl closed #1313
  • Feb 16 20:35
    ventZl synchronize #1313
  • Feb 16 13:01
    ventZl opened #1313
  • Feb 15 20:00
    manuelbl commented #1256
  • Feb 15 18:34
    makerkitten commented #1256
  • Feb 15 15:35
    Azq2 commented #1312
  • Feb 15 12:39
    manuelbl commented #1256
Brian Viele
Premain should get called...
Anyway...that's all I got :-)
Hi @vielster Thanks for the quick reply :) That was it! I don't know why Premain is not getting called but after I enabled the FPU the segmentation fault disappeared.
Brian Viele
I just looked in the source, and it appears vector_chipset.o may not be in the makefile! That would do it! Maybe it got removed in a merge by mistake or something
Hi @vielster It may be worse than that... The vector_chipset.c file does not have an entry for the H7 in my copy of the staging code. I added it to the file and rebuilt the H7 library and now premain gets called and floating point is enabled properly.
Brian Viele
You should confirm this isn't an issue on the mainline branch, and if it is maybe submit a PR with a fix.
Hi @vielster The same problem appears in the mainline branch as well. I submitted PR #1217 indicating the problem as well as the code to fix it.
Hi @vielster, I have a problem that I don't know how to solve (yet). My H7 project has an LCD that I am using FMC to access. I wrote the code needed to drive the FMC for the H7 and initial tests appear to work. The FMC is setup to access the LCD using an 8080 parallel interface and the memory for the FMC is mapped to 0xC0000000 which is required to allow proper access to the LCD. The problem is that the FMC interface appears to somehow interfere with the SPI interface to my SD card. If I run the FMC or the SPI interfaces separately they both work as expected. However if I run them together the SPI fails. I am thinking about changing from SPI1 to SPI2 to move the base address and see if that makes any difference. I know without code to look at this might be a strange question but what do you think about making this change? It will require hacking some wiring on the PCB I made but...
Hi @vielster Never mind my above problem. I tracked it down to the power which I was getting from the USB connection. Apparently 500ma is not sufficient for my setup.
Hi all
Is this a proper place to ask license questions?
I want to use libopencm3 in some embedded project but not sure if it's ok with LGPL - it's STM32F1, no runtime dynamic linking possible.
It was discussed previously here: https://sourceforge.net/p/libopencm3/mailman/message/30574571/
- but I see no mentions of this in current libopencm3: "probably should include ... static linking against libopencm3 is allowed and treated the same way as dynamic linking".
The project I have is under EUPL, but let's treat it as closed-source just for example (LGPL is not fully compatible with EUPL as far as I know).
OK, I'll write to libopencm3-devel also
Hm, it has no activity since 2018 (?)
Chuck McManis
@ohhai The best place to talk to the devs is on IRC #libopencm3 the gateway between IRC and gitter seems to have become non-functional. You can also file a PR on github which will be responded too.
@ChuckM Got it, thank you.
Paul Ugolini
Hi all, I recently started a project to add support for the SAM4E. Is anyone else already working on it?
I am interested in developing an HID host on the STM32F4 chip. I would like to use libopencm3. Has anyone used the USB host stack for the F4 and if so is there any example code available?
@ChuckM , Do you have any example code using the libopencm3 USB HID host stack on any STM32 chips?
Victor Lamoine
Hi! Does anyone have an example on how to configure/enter sleep mode on a STM32 F1 ?
Any example would help me start :) sleep-on-exit or sleep-now does not matter for now
Hi everyone, I was developing using a STM32F1 and i recentlly buy a STM32F4, and notice that had different API for setting GPIO's mode... in F1 is gpio_set_mode(), but in others is gpio_mode_setup(). Why the F1 has that diff? Isn't it better to use the same name? (i prefer gpio_mode_setup(), btw)
3 replies
Victor Lamoine
After a little bit of reading I managed to but the STM32 to sleep mode !
    pwr_set_stop_mode(); // Stop mode
    PWR_CR |= PWR_CR_LPDS; // Enable deep sleep
    __asm volatile("wfi");
Victor Lamoine
A full example can be found here for the stop mode + wake up: libopencm3/libopencm3-examples#211
Anhad Sawhney
Is there no function to enable flash prefetch for STM32F4?
I cannot find it in the docs, although enable/disable for Datacache and instruction cache all exist
Hmm, flash_prefetch_enable() exists but is not in the docs
Fabio Pugliese Ornellas
Hi there! The main page sais "it is very easy to confuse a multi-library linker from picking the right versions of libraries" regarding installing libopencm3. I was wondering if this still applies. We currently have lib/libopencm3_$TARGET.a built for each case, linking those wold mean using eg: -lopencm3_stm32f4, shouldn't this work for all cases? As an example, avr-libc is distributed by Ubuntu at /usr/lib/avr/lib/$TARGET/libc.a and it seems to work just fine. Couldn't / wouldn't the same be true for libopencm3?
Context: I'm working on a fairly complete & portable display driver library https://fornellas.github.io/eglib/ and am considering how to better distribute it.
Santiago Piccinini
Hi! Does anybody know why is needed the buf[len] = 0; in the cdcacm_data_rx_cb in the usb examples ? I was about to open a PR because that buf is only 64 bytes long and that added zero is causing a hardfault. I don't know if it is better to remove the buf[len] = 0 in the examples or to enlarge the buffer.
I am guessing that the added zero is for debuging purposes only? I am just starting with libopencm3 :)
Anhad Sawhney
I dont think buf[len] = 0;serves any purpose
Also, is there no function to set GPIO pins using a mask? I don't want to change all of portb, I just want to set PB0-PB5
It seems the only way to do this is to manipulate the ODR directly
Chuck McManis
you can set GPIO pins as follows gpio_mode_setup(GPIO_B, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO0 | GPIO3 | GPIO4);
This workds on the F4 version of the GPIO code but the older F0 version is difference because ST changed GPIOs around
Anhad Sawhney
Thats not what I mean. I already have portB set to output. I want GPIOB->ODR = xxx11011 where x does not change the state of that gpio pin, but the last 5 get changed
This can be done by directly changing the register like this: GPIOB->ODR = (GPIOB->ODR & ~(pin_mask)) | pin_states; but I was wondering if there is a function for that
1 reply
Adriana Schepers
Hi all, i use libopencm3 with the stm32f429iDiscovery and i am trying to use DMA to get values from ADC1:I have a question about this funtion: "dma_set_peripheral_address(DMA2,DMA_STREAM0,(uint32_t) &ADC1_DR);" Is the last Argument correct? Normally it looks like this : ADC1->DR but that makes an error.
7 replies
Adriana Schepers
When i want to convert the two Potentiometers With ADC and at the same time use DMA: Do I need to configure two ADCs?
manthan shah
hello, I'm trying to make libopencm3, I downloaded and used Msys shell
I have python 3.9, I'm getting the following error :
GENHDR stm32/f0
/usr/bin/env: python3: No such file or directory
make: * [include/libopencm3/stm32/f0/nvic.h] Error 127
manthan shah
[UPDATE]: never mind, the issue was trivial AF!, the issue arose because the python executable was named python.exe and not python3.exe :/
Adriana Schepers
Hello everybody, I am trying to convert values from the two potis with ADC1 and put them into memory via DMA (DMA2). i want to print them on the display afterwards . For some reason it doesnt work.


  • AD-Wandlung für beide Potis mit DMA und Verwendung des libopencm3 Beispiels
  • Potis: PortA Pin 6,Pin7
  • ADC1
  • DMA2, Stream0, channel 0, da DMA2 auf channel0 stream0 den ADC1 belauscht.
  • This file is part of the libopencm3 project.
    @author: Adriana

include <libopencm3/stm32/rcc.h>

include <libopencm3/stm32/gpio.h>

include <libopencm3/stm32/adc.h>

include <libopencm3/stm32/dma.h>

include <stdint.h>

include <stdio.h>

include <unistd.h>

include "adc-potis.h"

include "clock.h"

include "console.h"

include "sdram.h"

include "lcd-spi.h"

include "gfx.h"


uint8_t potis_vals[ARRAY_PLACES];

static void rcc_setup(void){

/* ADC1  */

/*ADC1 on APB2*/
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_ADC1EN);

/* Potis*/

/*Clock for DMA2*/


void dma_setup(void);
void dma_setup(void){

//dma_stream_reset(DMA2,DMA_STREAM0);  /*The specified stream is disabled and configuration registers are cleared.*/
dma_disable_stream(DMA2, DMA_STREAM0);
dma_channel_select(DMA2,DMA_STREAM0,DMA_SxCR_CHSEL_0); /*DMA2, Stream0,Channel0, for ADC1 .*/
dma_set_peripheral_address(DMA2,DMA_STREAM0,(uint32_t) &ADC_DR(ADC1)); 
dma_set_memory_address(DMA2, DMA_STREAM0, (uint32_t) potis_vals); 
dma_enable_direct_mode(DMA2,DMA_STREAM0); /*No FIFO*/


static void adc_setup(void)

/*Pins for Potis*/



adc_enable_scan_mode(ADC1); /* 2 channels*/

/*allow DMA to continue to operate after the last conversion in the DMA sequence. 
This allows DMA to be used in continuous circular mode.*/


/*ADC1-channels for the 2 potentiometer*/
uint8_t channel_array[2];
adc_set_regular_sequence(ADC1, 2, channel_array);


  /* Wait for ADC starting up. */
int i;
for (i = 0; i < 800000; i++)



int main(void)

char  val1[32],val2[32]; /*put voltage-values of the potis in val1 and val2 */
float poti_proportion1, poti_proportion2;
int i;

gfx_init(lcd_draw_pixel, 240, 320);

while (1) {

    for (i = 0; i < 1000000; i++) { /* Wait a bit. */

    poti_proportion1 = potis_vals[0] / POTIS_ADC_MAX_VALUE; 
    poti_proportion2 = potis_vals[1] / POTIS_ADC_MAX_VALUE;
    sprintf(val1, "%.2f V", 3.3 * poti_pro
is something wrong with the config? I just cant find the reason.
I am sorry the message looks terrible
Valentin Ochs

Hey. Just asked this over on IRC as well, but it seems there's more people here as well, so I hope nobody minds if I repeat myself for a bit.

According to https://github.com/libopencm3/libopencm3/blame/master/include/libopencm3/usb/usbstd.h#L157 we shouldn't instantiate struct usb_interface... but every example I've seen (gadget zero, and a whole bunch in libopencm3-examples) /does/.

What are we actually supposed to do?

This is apparently written to by build_config_descriptor, which only gets it from usbd_device *usbd_dev... as a const
Adriana Schepers

hello folks,

it's about the code that I posted. After a few days I have now looked at it again and found out that the "circular mode" is disabled when I let the DMA flow determined by the periphery.

The NDT register of the DMA is set to the maximum value by the hardware (0xFFFF).
But since I want to transfer 2 values (in circular mode) into an array with 2 places in my code, this has triggered a SegFault.
What can I say? I should have just read the Reference Manual more carefully.
(Maybe this is interesting for one or the other here)