libopencm3 | Open source ARM Cortex-M microcontroller library
kandi X-RAY | libopencm3 Summary
kandi X-RAY | libopencm3 Summary
The libopencm3 project aims to create an open-source firmware library for various ARM Cortex-M microcontrollers.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of libopencm3
libopencm3 Key Features
libopencm3 Examples and Code Snippets
Community Discussions
Trending Discussions on libopencm3
QUESTION
I've been trying for a couple of days now, to create a simple DMA program for the G4. But without HAL (using libopencm3). The goal is to configure DMA to read data (in circular mode) from buffer and send them to TIM17_CCR1. I've made the code work in HAL previously, but have no luck with libopencm3. I've managed to transfer data from buffer to the OCR in mem2mem mode (even though i need mem2perif) just to try. But I have no idea on how to start with mem2perif. Configuring DMA is no big deal, but I'm lost in the DMAMUX part.
Do you even have to configure it? How do you configure it the right way? I'm totally lost in ST's documentation and can't find any existing code using DMAMUX without HAL. Do any of you have any examples I could look at? Best would be some bare metal C so I could check out the registers. Anything that would help some documents (else than STs own)? It would be much appreciated.
Thanks a lot!
...ANSWER
Answered 2020-Oct-12 at 19:43I've got it working even with the library, just needed one more day of testing :(
Here is the code for anybody interesrted:
QUESTION
I want to compile a program with arm-none-eabi-gcc 9.2.1
using the libopencm3 project and run it on ARM Cortex-M4 processors. My program is composed of two files: main.c
ANSWER
Answered 2020-May-23 at 22:25typedef unsigned int uint32_t;
uint32_t test(uint32_t a, uint32_t b) {
uint32_t tmp0, tmp1;
uint32_t c;
for(int i = 0; i< 4096; i++) {
tmp0 = a & 0xff;
tmp1 = b & 0xff;
c = tmp0 ^ tmp1 ^ (a>>(i/512)) ^ (b >> (i/1024));
}
return c;
}
unsigned int hello ( void )
{
return(test(0x75,0x14));
}
QUESTION
I've successfully implemented a CAN bus bootloader for the STM32103C8T6 chip based on an example I found here (lbus) https://github.com/alphalove/stm32-projects/tree/master/lbus_bootloader.
I've used libopencm3.
I've had this working very well until I made a very small change to the bootloader code. Following that, the bootloader will no longer start the main firmware.
The bootloader starts at 0x08000000 and is 8k. The main firmware starts at 0x08002000.
Along with other things, the booloader checks the integrity of the main firmware and if ok, starts it by calling the run_firmware() function. This function shuts down all the chip peripherals used in the bootloader before setting the vector table address, initializing the master stack pointer, then jumping to the start of the main firmware. Example / snippet of the run_firmware() function is the following.
...ANSWER
Answered 2020-Apr-28 at 22:52Don't have enough points to comment, but just thought I'd add that there's github project (marcinbor85/can-prog) that supports bootloading via stm32's built-in (rom) bootloader.
Not sure if Alex is going to open-source his bootloader, but there's plenty of blue-pills that could benefit (including mine!)
QUESTION
I got into the book "Beginning STM32" - Warren Gay. I tried to build the sources under Cygwin, but even if the path to the required files is denoted in the makefile, the required files were not found.The file in the folders libopencm3/cm3/scb.h lays in the path: /home/root/STM32/stm32f103c8t6/libopencm3/include so the correct path should be /home/root/STM32/stm32f103c8t6/libopencm3/include/libopencm3/cm3/scb.h and I checked the presence of the files.
So I tried to change the #include into #include "file.h" with the required header file in the source folder - this worked, but there are a lot of cases in different source files.
Is there any suggestion to get this fixed or to find a way to get out of this?
Thanks a lot!
This is what I got from the terminal.
...ANSWER
Answered 2020-Apr-06 at 17:12So, I know what is the source of the problem. There are problems in Cygwin with the path format or rather between the interaction between the Windows and Linux path formats. I could solve the problem by changing the paths in the Makefile from the Linux /home/folder to the Windows D:\home\folder\ format.
QUESTION
I'm about to start my first STM32 project. (I have previously used atmega MCUs, and have decades of experience with C, mostly server-side.)
There seem to be three choices, given that I want to develop on the command-line in Linux, using make.
- an STM32CubeMX generated makefile project,
- an STM32CubeMX generated makefile project, including FreeRTOS, or
- a makefile project using libopencm3.
The application will process and send messages on 4 or more serial ports, using different protocols. Occasionally GPIOs will be set or cleared.
My questions are:
- Why does libopencm3 exist? Why would someone choose it over an STM32CubeMX-generated makefile project.
- Is learning FreeRTOS worthwhile for such a project?
ANSWER
Answered 2019-Dec-19 at 09:29There are no good free project generation tools that I know. I worked mostly with STM32CubeMX and I can tell you that it's surely useful (expecially for novices) but long from being something you can trust on. I found lots of bugs in it in the years, some has been fixed, others are still in there. IMHO, in general, you should use code generator tool with care better as a training instrument maybe taking snippets of code out of them.
I've used FreeRTOS a lot and I can tell you I feel good with it. Maybe it's not good as as a commercial grade product but surely it's well documented and easy to handle. Haven't had any problem with it.
QUESTION
I'm developing a mixed C/C++ program for an ARM STM32F4, but I have problems in accessing global variables defined in the C part. Here is a simple test code to reproduce the problem.
test.h:
...ANSWER
Answered 2017-Jan-24 at 13:15As Olaf said in a comment, you did not declare your string table as constant. So it is considered by the compiler/linker as initialized read/write data, instead of read only data.
Maybe your initialization code (executed before the main entry point) does not properly copy the initialized data from flash to RAM.
As a quick fix, try to make your string table as constant:
QUESTION
I have an open source micromouse robot project. For easier compilation, I use containers (both Podman and Docker should be fine):
...ANSWER
Answered 2019-Sep-18 at 13:26I do perfectly understand you want to use the latest and greatest toolchain from your prefered, mainstream Linux distribution, but this is not always going well.
In my humble opinion, you should:
- stick to Linaro or ARM gcc toolchains,
- in the case of your specific cortex-m related project, stick to a gcc toolchain more specifically targeting the cortex-m, i.e. the so called 'GNU Arm Embedded Toolchain'.
Some remarks:
- There are probably excellent reasons why ARM itself is providing two specifics toolchains for the two profiles,
- Latest GCC toolchain version available from Linaro is 7.4.1, but if they used to point to it by default on this page, they now pointing to version 7.2.1, which may (or not) ring a bell regarding 7.4.1 - there are no official 9.2 versions available yet.
- Latest GCC toolchain available from ARM is 8.3.1 for cortex-m, and 8.3 for cortex-a - there are no official 9.2 versions available yet.
Back to your specific issue now: I was able to compile your project using the following steps:
QUESTION
I'm working on a project using an stm32f030rc. I need to use PC15 as a GPIO input but it appears I'm unable to.
I understand the couple PC14/PC15 is shared with the LFE oscillator, but of course I'm not using that function. Moreover, I am able to read the correct pin level on the PC14 GPIO. In the datasheed regarding my model the PC15 pin is marked as a I/O with OSC32_OUT as additional function: can it be used as input at all?
For reference, this is the C code I'm using to test the functionality; I'm using libopencm3 for initialization.
...ANSWER
Answered 2019-Aug-06 at 19:00PC14 & PC15 have the same configuration properties. Of course, there are some limitations regarding using these pins as outputs (including PC13), but it should be okay to use them as inputs as long as you don't activate LSE functionality.
PC14 & PC15 are GPIO inputs after power-up and considering that LSE is disabled by default, you should be able to use them directly even without any configuration.
As you don't have any problems with PC14, I suspect 3 possible causes:
1) A bug in the GPIO code the library provides. Although it's very unlikely, it's easy to test. You can remove the configuration code for PC14 & PC15, as they are GPIO inputs after power-up by default. This eliminates the possibility of having a bug in gpio_mode_setup() function. To avoid using gpio_get() function, you can use the following code:
QUESTION
For the life of me, I cannot find a way to get the clock speed for STM32L0 chips in libopencm3. There's got to be a way, right?
- In STM32Cube, there's the
SystemCoreClock
variable. - In ChibiOs, there's the
STM32_SYSCLK
variable.
Is there no variable or function to get this value in libopencm3?
...ANSWER
Answered 2019-Nov-14 at 08:30So far the closest thing I've found to a solution is the rcc_ahb_frequency
variable, which is set to the Advanced High-performance Bus frequency. This is usually the same as the clock speed, but can be given a clock divider.
Also, it looks like this is only defined if the clock is configured via the rcc_clock_setup_pll
method.
QUESTION
I am reading this book and I have come across this code:
...ANSWER
Answered 2019-Sep-19 at 21:56In general when one does not use an function argument, the compiler is likely to warn you about it. After all if you aren't going to use it why put it there in the first place?
In effect it is an artificial use of the argument that does nothing useful other than telling the compiler you know what you are doing, so "Shatupalready with the warning!"
(void) args works on all of the platforms that I have seen. I believe the __attribute((unused)) is a gcc specific thing.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install libopencm3
FP_FLAGS - Control the floating-point ABI If the Cortex-M core supports a hard float ABI, it will be compiled with the best floating-point support by default. In cases where this is not desired, the behavior can be specified by setting `FP_FLAGS`. Currently, M4F cores default to `-mfloat-abi=hard -mfpu=fpv4-sp-d16`, and M7 cores defaults to double precision `-mfloat-abi=hard -mfpu=fpv5-d16` if available, and single precision `-mfloat-abi=hard -mfpu=fpv5-sp-d16` otherwise. Other architectures use no FP flags, in otherwords, traditional softfp. You may find which FP_FLAGS you can use in a particular architecture in the readme.txt file shipped with the gcc-arm-embedded package. Examples: $ FP_FLAGS="-mfloat-abi=soft" make # No hardfloat $ FP_FLAGS="-mfloat-abi=hard -mfpu=magic" make # New FPU we don't know of
CFLAGS - Add to or supersede compiler flags If the library needs to be compiled with additional flags, they can be passed to the build system via the environment variable `CFLAGS`. The contents of `CFLAGS` will be placed after all flags defined by the build system, giving the user a way to override any default if necessary. Examples: $ CFLAGS="-fshort-wchar" make # Compile lib with 2 byte wide wchar_t
Simply pass -I and -L flags to your own project. See the [libopencm3-template](https://github.com/libopencm3/libopencm3-template) repository for a template repository using this library as a Git submodule, the most popular method of use. The libopencm3-examples is another example of this. It is strongly advised that you do not attempt to install this library to any path inside your toolchain itself. While this means you don’t have to include any -I or -L flags in your projects, it is very easy to confuse a multi-library linker from picking the right versions of libraries. Common symptoms are hardfaults caused by branches into ARM code. You can use arm-none-eabi-objdump to check for this in your final ELF file. You have been warned.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page