prof7bit / bare_metal_stm32f401xe Goto Github PK
View Code? Open in Web Editor NEWminimum gcc blinky with makefile for STM32F401RE (on NUCLEO-F401RE demo board)
minimum gcc blinky with makefile for STM32F401RE (on NUCLEO-F401RE demo board)
Hi, I am on arch linux and I have a Nucleo STM32F401RE
The compilation work and transfert too.
What is the difference with stm32f401xe and stm32f401re?
Thanks
make install
[CC] src/main.c:
arm-none-eabi-gcc -MMD -c -o build/src/main.o -Isrc/STM32F401XE -ffunction-sections -mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=gnu11 -ggdb -Os -flto -Wall -Wextra -Wstrict-prototypes -Werror -Wno-error=unused-function -Wno-error=unused-variable -Wfatal-errors -Warray-bounds -Wno-unused-parameter src/main.c[LD] build/hello_world.elf:
arm-none-eabi-gcc -o build/hello_world.elf build/src/STM32F401XE/gcc_startup_system.o build/src/main.o -ffunction-sections -mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=gnu11 -ggdb -Os -flto --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections -Tsrc/STM32F401XE/gcc_linker.ld -lm -Wl,-Map=build/hello_world.map[objcopy] build/hello_world.hex:
arm-none-eabi-objcopy -O ihex -S build/hello_world.elf build/hello_world.hex[OpenOCD] program build/hello_world.hex:
openocd -d0
-f board/st_nucleo_f4.cfg
-c "program build/hello_world.hex"
-c "reset run"
-c "shutdown"
Open On-Chip Debugger 0.9.0 (2016-04-27-23:18)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080001bc msp: 0x20018000
** Programming Started **
auto erase enabled
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x20000042 msp: 0x20018000
wrote 16384 bytes from file build/hello_world.hex in 0.687820s (23.262 KiB/s)
** Programming Finished **
shutdown command invoked
Hello,
I'd love to use this project as a base for my development. You clearly put work into doing a clean implementation to keep licensing issues to a minimum, but you have not declared any license for the code you have written. Could you add a comment stating what license the code is under?
Thanks!
Hi,
I tried to compile and run the bare metal example which I adopted to the Nucleo F411 with GCC 6.3.0 and landed in the default handler instead of main, while everything works perfectly fine with GCC 4.9.3. It simply crashes when calling __main__();
.
Changing the call of the main function to a simple main();
and marking the function with __attribute__((noinline))
did the trick, keeping it non-inlined. Interestingly I only got it to compile as a release build (with -0s and -flto) because a make DEBUG=1
leads to the following error.
src/STM32F411XE/gcc_startup_system.c: In function 'Reset_Handler': src/STM32F411XE/gcc_startup_system.c:197:20: error: cannot allocate stack for variable '__main__', naked function. int(* volatile __main__)(void) = main;
I wonder why the compiler does not complain for a release build but instead generates complete bogus, e.g. ldr R3, [sp, #4]
which should point somewhere beyond the end of RAM (see screenshot below). The value of the __main__
pointer also seems way off.
This is probably the same issue that lead to #2 because he is also using Arch Linux and probably had GCC 6 installed.
Anyhow I do not really understand why one should worry about the compiler inling the main function at all. Can you give me a hint why I should avoid that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.