Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mcu committed Dec 13, 2023
1 parent 5d4eb29 commit a7c5ebc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ DIRS := $(shell ls -R components application -Icubemx | grep : | sed 's/://')
CBMXDIRS := $(shell ls -R $(CBMXDIR) | grep : | sed 's/://')
CBMXASRC := $(wildcard $(addsuffix /*.s, $(CBMXDIR)))
CBMXLD := $(wildcard $(addsuffix /*.ld, $(CBMXDIR)))
CBMXOBJS := $(wildcard $(addsuffix /*.o, $(CBMXDIR)/build))

APPLASRC := $(wildcard $(addsuffix /*.s, $(DIRS)))
APPLCSRC := $(wildcard $(addsuffix /*.c, $(DIRS)))
Expand Down Expand Up @@ -86,20 +87,17 @@ MAKEFLAGS += --no-print-directory -j
###############################################################################

all: build
build: application
application: $(OUTDIR)/$(PROJNAME).elf \
$(OUTDIR)/$(PROJNAME).bin \
build: cubemx application
cubemx:
@cd $(CBMXDIR) && $(MAKE) -j -s
application: $(OUTDIR)/$(PROJNAME).bin \
$(OUTDIR)/$(PROJNAME).siz

# Rebuild project if Makefile changed
$(APPLOBJS): $(firstword $(MAKEFILE_LIST))

cubemx:
@cd $(CBMXDIR) && $(MAKE) -j -s

$(OUTDIR)/$(PROJNAME).elf: cubemx $(APPLOBJS)
$(OUTDIR)/$(PROJNAME).elf: $(APPLOBJS)
@echo linker: $@
$(eval CBMXOBJS = $(wildcard $(addsuffix /*.o, $(CBMXDIR)/build)))
@$(CC) $(LDFLAGS) $(CBMXOBJS) $(APPLOBJS) $(LIBDIRS) $(LIBS) -o $@

$(OUTDIR)/$(PROJNAME).bin: $(OUTDIR)/$(PROJNAME).elf
Expand Down Expand Up @@ -132,6 +130,7 @@ clean:
rm -rf $(OUTDIR)

# Dependencies
-include $(CBMXOBJS:.o=.d)
-include $(APPLOBJS:.o=.d)

###############################################################################
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
This example provides the ability to configure components and application
using kconfig language
![](scripts/menu/menuconfig.png)
Originally created for STM32 microcontrollers but it can be used for any ARM
Originally created for STM32 Black Pill but it can be used for any ARM
based MCUs
<img src="scripts/menu/blackpill.jpeg" width="640" height="245">

Development environment consists of:
* Ubuntu OS
Expand All @@ -24,12 +25,13 @@ Development environment consists of:

```bash
sudo apt install gcc-arm-none-eabi

```
```bash
arm-none-eabi-gcc --version
```

Alternative way is to download GNU Arm Embedded Toolchain from the
website https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
Alternative way is to download
[Arm GNU Toolchain](https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain)
and setup path to compiler binaries by adding the following line
into ~/.profile with your path to toolchain folder:

Expand All @@ -43,30 +45,34 @@ Log out and log back in to update PATH variable

```bash
git clone https://github.com/mcu/kconfig.git

```
```bash
cd kconfig
make menuconfig
make
```bash
make clean
make -f scripts/Makefile clean
```

## How it works

At first, "make" utility use "ls" command recursively to create a list of all
folders in the "components", "application". Then "make" creates a list of all
*.s, *.c, *.ld and *.a files in the project (ASSOURCES, CSOURCES, LINKERS, LIBS).
After that "make" starts the process of compiling, linking and generating the
binary file. It's easy but more correctly is to build components separately into
libraries
At first, 'make' utility use 'ls' command recursively to create a list of all
folders in the 'components', 'application'. Then 'make' creates a list of all
*.s, *.c, *.ld and *.a files into variables CBMXASRC, CBMXLD, CBMXOBJS...
After that 'make' starts the process of compiling cubemx, components,
application sorce files in parallel, linking and generating binary file.
It's easy but more correctly is to build components separately into
libraries (for advanced developers https://github.com/mcu/kconfig-libs).
You can add *.h, *.c files and folders as you want into "components",
"application" folders. All source files will be compiled
You can change cubemx source files using STM32CubeMX program or replace cubemx
folder with your own, small changes need to be made to the Makefile.
## For advanced developers

https://github.com/mcu/kconfig-libs
You can also add *.h, *.c files and folders as you want into "components",
"application" folders. All source files will be compiled
## Comment
The implementation of makefile has its pros and cons. Since all header files
Implementation of makefile has its pros and cons. Since all header files
are visible to each source file during the build process it is not recommended
to use this example for large projects
Binary file added scripts/menu/blackpill.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a7c5ebc

Please sign in to comment.