Busybox Bitbake Config does not save - embedded-linux

I am trying to add devmem to my yocto image. I do this I run the command
bitbake -c menuconfig busybox
I go to Miscellaneous Utilities and place a * in the devmem menu. Exit and save the config then perform a
bitbake busybox
Followed by
bitbake core-image-full-cmdline
When I boot my device the devmem program is not there, when I re-run the menuconfig for busybox the devmem option is no longer selected! What can I do to fix this?

Busybox is like other projects that are using a .config to define the features needed to be compiled into the final output, just like the Linux kernel and U-boot, etc.
So, here how to deal with them in Yocto:
When you run:
bitbake busybox -c menuconfig
it will run make menuconfig into its working directory and opens the configuration menu for you.
Now, if you save and exit, only the .config in the working directory will be changed, meaning that if the recipe get unpacked again your modification will be lost.
In addition, when you change the .config via menuconfig you need to force the compilation of the busybox recipe, because for bitbake it is already built:
bitbake busybox -c compile -f
But, for the best practices, here what I suggest to you if you want your modification to be a feature that you can easily enable or disable from a recipe:
Run: bitbake busybox -c menuconfig
Edit and save your modification
Run: bitbake busybox -c diffconfig
The diffconfig command will give you a fragment.cfg file that contains the modifications you just did.
The file should contain:
CONFIG_DEVMEM=y
A quick explaination about the fragment:
When you opened menuconfig it backed up .config to .config.old, and then diffconfig will give you the difference between them after saving your modification into .config.
Now, Busybox like other recipes that are using configuration files, they understand that if a .cfg file exists in their working directory, they need to apply it to their main .config file before compilation.
So, what you need to do after getting the fragment.cfg is to create a .bbappend recipe to busybox in your custom recipe and specify your new fragment:
meta-custom/
| recipes-core/
| busybox/
| busybox_%.bbappend
| busybox/
| devmem.cfg
Now, busybox_%.bbappend contains:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://devmem.cfg"
Now, when you re-bitbake Busybox again, it will unpack the fragment and apply it.
To check if the fragment is applied after the bitbake completes, you can check the .config file:
First get the Build directory path of Busybox
bitbake -e busybox | grep ^B=
Grep for CONFIG_DEVMEM
grep CONFIG_DEVMEM <path_of_previous_command>/.config
You should see:
CONFIG_DEVMEM=y

Related

Make always build even when there is no file change

I'm writing a simple Makefile:
all: image
image: ./common ./source
docker build -t some-resource -f source/Dockerfile .
.PHONY: all image
I expect that image is only built when files under folders common or source have changes. But when I run make, it always run docker run even without any file change. What's the problem?
When you run make, it will try to make the first target, which is all. This causes make to make the target image. Because there is no actual file named image (you even told make that it is a phony target), it will always execute the docker command.
In this case, it is not possible for make to determine that "common and source have changes". Normally make does this by comparing the modification timestamps of the target and the dependencies but there is no actual target to check (image is not a file).

How to use GNU Makes dry run mode with CMake generated Makefile before actually performing the installation

Every now and then a new tarball or a new xyHub/Lab-repository needs to be built. They usually come with a Makfile or an Autotools/CMake/XY-Generator provides one on the fly. As the maintainers most likely use another operating system or distribution than the one I am currently running, the assumptions that went into their Makefiles usually do not fit my filesystem hierarchy (lib vs. lib64, bin vs. sbin, /usr/lib vs. /lib and so on). As the final command in the build sequence usually is
sudo make install
it is quite annoying to move thousands of files to the correct place. Or even worse determine which files of my distribution were overwritten. Here GNU Makes dry run mode comes in very handy. Running
sudo make -n install
first, saves me the trouble of cleaning up my file system, by just printing all the commands from all active GNU Make recepies without executing them. In case of a handwritten or Autotools-generated Makfile this works as intended. If the Makefile contains something like:
#PREFIX is environment variable, but if it is not set, then set default value
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
install: unixlib.a
install -d $(DESTDIR)$(PREFIX)/lib/
install -m 644 unixlib.a $(DESTDIR)$(PREFIX)/lib/
install -d $(DESTDIR)$(PREFIX)/include/
install -m 644 unixlib.h $(DESTDIR)$(PREFIX)/include/
I would see exactly what would happen. Every install/cp/mv-command with the full path information would be printed. If I made a mistake with the install prefix in the configure step I can see it there. If the default in the Makefile is weird because it comes from another OS, I would see it there.
Now in case of a CMake-generated Makefile this is different. Doing
mkdir build && cd build
cmake ..
make
sudo make -n install
only produces output that ends in
...
make -f CMakeFiles/Makefile2 preinstall
/usr/bin/cmake -E cmake_echo_color --switch= --cyan "Install the project..."
/usr/bin/cmake -P cmake_install.cmake
As these commands get not executed, just printed, I do not get all the cp/mv/mkdir/install/etc-commands that I would like to see first, before I let the Makefile touch the file system.
Is there a way to get the list of commands that would be executed from the install target in a CMake-generated Makefile as it is the case with handwritten or Autotools-generated ones?
Is there a way to get the list of commands that would be executed from the install target.
Actually, the core part of installation process is contained in the file cmake_install.cmake (which is created in the build directory). This file is processed as CMake script using cmake -P flow of the cmake executable.
The script cmake_install.cmake performes installation of files with install command. Semantic of the install command, used by the script, differs from the one described in documentation: internally, CMake uses some undocumented features of the command.
But it shouldn't be so hard to understand cmake_install.cmake script in general and deduce paths from it.

How to Run PC-Lint on only locally modified files(Not commited on Server of SVN)

I am trying to write script to run PC-Lint Static analyzer tool on only locally modified files by user and not on whole project.
For that I need to run Lint command on all locally modified files
using svn status
svn status -u | grep -w M
command I get list of locally modified files with its full path
For Example if locally modified file is asn1_common_elements.c, the above svn command will give output as
M 10014 \Implementations\asn1der\src\asn1_common_elements.c
now I need to take only filename asn1_common_elements.c and put it with LINT command as LINT asn1_common_elements.log (instead of .c need to change to .log)
How can I achieve this?
You could use a Makefile's ability to only let the compiler to compile only the changed files.
Do something like this in the Makefile:
# Create object from C source code
file.o: file.c
gcc -c $(CFLAGS) -o $#
wine lint-nt.exe file.c
Now the file.c will get analysed only when it is changed.

How to customize the docker gcc command and add own path instead of /usr/src

I'm trying to compile a C file named test.c using docker's gcc container.
I'm using the following command, I have put the test.c in my homein ubuntu.
sudo docker run -v /home/moomal/workspace/FypProject/WebContent/file/:/myapp.c:ro gcc:4.9 sh -c "gcc -o myapp /home/moomal/workspace/FypProject/WebContent/file/myapp.c; ./myapp"
It works cool, but, I want to change the folder from home to a folder inside my eclipse web project folder. I have an editor on a web page and then on compile it creates a test.c file inside a folder. I want to access that file.
I tried adding the path like /home/moomal/workspace/FypProject/WebContent/file but I get the error
gcc: error: /home/moomal/workspace/FypProject/WebContent/file/myapp.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
sh: 1: ./myapp: not found
You seem to be confused about several things here.
The -v HOST_PATH:CON_PATH argument can be used to mount files inside a container, as you seem to be attempting. The HOST_PATH can be a file or a directory. The CON_PATH determines where that file or directory will be in the container. In your case, I think you want:
-v /home/moomal/workspace/FypProject/WebContent/file/myapp.c:/myapp.c
Not just ...file/:/myapp.c. I'm not sure what you expected your version to do (how can a directory be mapped to a file?).
Also, in the shell command you give the path on the host, but as this is processed in the container, you need the path in the container i.e:
gcc -o myapp /myapp.c
Putting it together, I would expect to see something like:
sudo docker run -v /home/moomal/workspace/FypProject/WebContent/file/myapp.c:/myapp.c:ro gcc:4.9 sh -c "gcc -o myapp /myapp.c; ./myapp"

gcc -c option not giving execute file permission to the output file

i am using ubuntu 10.10
i am trying to compile simple helloworld file using
gcc -c option
the output file is created but it does not have execute permission
if i dont use -c option the output file has execute permission ..
Please help
The command gcc -c generates a non-executable object file. If you want the output to be executable, do not use the -c option.
I am not sure what you hoped -c was for, but it is exactly for not generating an executable, and your GCC is working as designed.
From the man gcc:
-c Compile or assemble the source files, but do not link. The linking
stage simply is not done. The ultimate output is in the form of an
object file for each source file.
It is not executable. It needs to undergo linking process to become an execution file.

Resources