Patching a file in resulting rootfs - buildroot

I am using buildroot to create an OS for the Raspberry PI.
How do I apply a patch to a file in the resulting rootfs?
For example adding the lines
auto eth0
iface eth0 inet dhcp
to /etc/network/interfaces on the resulting rootfs.
I realize that this can be done with a script after unpacking the rootfs on my target, but I am wondering if it can be automated using buildroot.

First of all take a look at BR2_EXTERNAL mechanism. This way you can manage your project/configurations/package independent from Buildroot tree.
Then look at "Root filesystem overlays (BR2_ROOTFS_OVERLAY)" and "Post-build scripts (BR2_ROOTFS_POST_BUILD_SCRIPT)" in Customizing the generated target filesystem section. They describe both ways, i.e supply your custom file via fs-overlay or run a post-build script and alter the file within this script.

Related

Change sh scripts from CLI - Truenas Scale

I have added a script that changes the routing of the network for the Truenas Scale server which made the GUI unaccessable.
The custom scripts were added in the init/shutdown scripts. And the scripts run as Command and Post Init.
Im able to access CLI and trying to disable, remove or change the script.
*The server is for testing and learning
This is the script added
NAT rule 4 - Command - nft 'add rule nat postrouting iifname openvpn-server oifname enp3s0 ip saddr 10.20.0.0/24 masquerade'
I have tried to look for all .sh files in etc/Init.d folder but got either stuck or lost.
Question: where is the Post Init shell scripts located on Truenas Scale?

tftp booting my raspberry pi, but initramfs file is not requested by the raspberrypi

I am using custom Linux Kernel built through Yocto. I generated sdimg and try to boot it using an SDCARD and it boots perfectly fine. Here along with the Kernel I also use INITRAMFS files. Using config.txt and cmdline.txt file in partition 1, I tell the kernel to load my INITRAMFS file. This procedure is working fine.
Now, I am trying to net boot my Raspberrypi. For this I have another PC which has DNSMASQ installed and it acts as DNS server. I have all the required files in my /tftpboot directory. When I turn on the client RPI, it gets all the files from the server except my INITRAMFS file. I have added the initramfs file name as shown below in the config.txt, but still it is not being requested by my PI. How to make the RPI request for the INITRAMFS file? It just boots up the kernel7.img and thats it !
//appended the following lines to config.txt
ramfsfile=myramfs.cpio.gz
initramfs myramfs.cpio.gz followkernel
Please note that I am not using u-boot.
I was able to resolve the issue. When we do TFTP booting, the first file requested by Raspberry pi(Rpi) is startx.elf, this will be run on the GPU core. Next file that is requested is config.txt. For some reason, if I append the above 2 lines it doesn't work. I read in one of the raspberry pi forums that if the config.txt file is above some size limit, it will be ignored. So I cleared the config.txt file and added just these lines, and voila! Now my initramfs file is requested by the PI and boots successfully :)

Raspberry Pi script boot order

There're three forms about running a script on the boot of the Raspberry, that are modifying /etc/rc.local, modifying the cron daemon and making a script that automatically run on boot in /etc/init.d
I want to know which of the methods listed about executed first.
The point of the question is that I'm trying to run wvdial with an Alcatel X600D at boot, that is as simple as modify the /etc/network/interfaces with these lines:
auto ppp0
iface ppp0 inet wvdial
But the problem is that the modem needs to receive the PIN before the wvdial is called. For that, I need to pass the PIN to the modem before the system raises the ppp0 connection.
Regards.
Script in /etc/init.d
Whatever is in /etc/rc.local
Your cron daemon command
Proof:
Scripts in /etc/init.d are ran according to their priority and dependencies (look within the files in /etc/init.d and in the runlevel directories /etc/rc*.d)
cat /etc/rc.local
get
# This script is executed at the end of each multiuser runlevel.
Cron scripts are executed whenever the timing pattern specified in them is reached which is independent from the boot order. So a script in cron probably would not make much sense.
Also have a look at https://wiki.debian.org/Modem/3G, it might be possible to do what you're trying to achieve without coding your own script.

OpenOCD debugging multiple devices at once

I am trying to debug multiple devices at once with openocd on eclipse. I have 2x STM32F303 discovery borards, I have set the hla_serial flag to a proper board, but still no luck.
Separate boards are doing ok, but when trying to debug it's Eclipse saying it'came to error in last sequence.
So if anyone had experience with that. Thanks
We can use hla_serial option within openocd 0.9+ ONLY. I'd recommend to download from
GNU ARM Eclipse project or compile yourself.
To obtain hla_serial, the easiest way found after reading the patch that included this option (http://openocd.zylin.com/#/c/2198/), more specific function "string_descriptor_equal", was to provide a wrong serial, so it would print the correct one.
The command below will create file log_with_correct_serial.txt. Switch board config file for the one currently being used.
openocd.exe -d3 -f board/stm32f4discovery.cfg -c "hla_serial wrong_serial" 2>log_with_correct_serial.txt
Opening log_with_correct_serial.txt you will find correct serial in line containing something like
Debug: 229 23 libusb1_common.c:67 string_descriptor_equal(): Device serial number 'xxxxxxxxxxx' doesn't match requested serial 'wrong_serial'
So create a derived config (for example stm32f4discovery-mydevice1.cfg, assuming stm32f4discovery is used) inside folder board on openocd root directory. Use something like Notepad++ to copy serial as it is hex numbers.
# This is an STM32F4 discovery board with a single STM32F407VGT6 chip.
# http://www.st.com/internet/evalboard/product/252419.jsp
# hla_serial thanks to http://wunderkis.de/stlink-serialno/index.html
source [find board/stm32f4discovery.cfg]
hla_serial V?nIpSU)?
Now to open your device you can use the command below to start debugging using ST-Link adapter.
openocd.exe -f board/stm32f4discovery-mydevice1.cfg
In each eclipse project provides a different board config for each project and you are good to go.

Running sdbinst on a .sdb in a network share location

I want to run the sdbinst command on a .sdb database file as well as open it in the compatibility administrator. I have no problem doing this locally when the .sdb is stored on the machine i'm using, but i'd like to be able to open and run sdbinst on it when the file is stored in a network store location.
Is this possible?
Yes, according to the MS Help files within the MS Compatibility Toolkit.
See: "Mitigating Issues by using Compatibility Fixes". There is an example of a network deployment workflow: "Deploying the Contoso.sdb Database to your environment".
The basic pattern is to place the sdb on a network Share. Create a one line deployment script that references a path to that share.(sdbinst "\\SomePath\Ex.sdb" -q) Either push or execute the deployment script to/on each target computer in your environment.