I am trying to add few checks in watchdog.c file in below package, but getting patch failure error as below, manual patch works fine without any issue, also patch is created from the file of this pkg only so there is no issue with version mismatch or older version.
https://sourceforge.net/projects/watchdog/files/watchdog/5.13/
ERROR: Command Error: exit status: 1 Output:
Applying patch watchdog.patch
patching file src/watchdog.c
Hunk #2 succeeded at 948 with fuzz 1.
Hunk #3 FAILED at 1057.
1 out of 3 hunks FAILED -- rejects in file src/watchdog.c
Patch watchdog.patch does not apply (enforce with -f)
ERROR: Function failed: patch_do_patch
Tried to search the answers, but
Bitbake recipe not applying patch as expected
Why does this patch applied with a fuzz of 1, and fail with fuzz of 0?
Hunk #1 FAILED at 1. What's that mean?
Above posts mention about pkg or improper patch issue, which doesnt look to be for my pkg, requesting for help on this.
diff --git a/src/watchdog.c b/src/watchdog.c
index 8a09632..bb4a189 100644
--- a/src/watchdog.c
+++ b/src/watchdog.c
## -570,6 +570,7 ##
struct stat s;
struct icmp_filter filt;
filt.data = ~(1<<ICMP_ECHOREPLY);
+ int check = FALSE;
#if USE_SYSLOG
char *opts = "d:i:n:Ffsvbql:p:t:c:r:m:a:";
## -947,6 +948,11 ##
(void) fclose(fp);
}
+ check = check_product();
+ if(check == TRUE)
+ {
+ setup_files();
+ }
/* set signal term to set our run flag to 0 so that */
/* we make sure watchdog device is closed when receiving SIGTERM */
signal(SIGTERM, sigterm_handler);
## -1051,6 +1057,11 ##
do_check2(check_bin(act->name, timeout, 1), act->name, rbinary, NULL);
#endif
+ if(check == TRUE)
+ {
+ do_check(test_files(), repair_bin, NULL);
+ }
+
/* finally sleep some seconds */
usleep(tint * 500000); /* this should make watchdog sleep tint seconds alltogther */
/* sleep(tint); */
.bbappend file
# changes for patching the disk IO check
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
FILESEXTRAPATHS_append := "${THISDIR}/files"
SRC_URI += " \
file://watchdog.patch \
"
Above "SRC_URI" & "SRC_URI_machineoverride" tried one-by-one and did not work
SRC_URI_machineoverride += "file://watchdog.patch"
The problem may be that you have file://watchdog.patch twice in your SRC_URI, and bitbake attempts to apply it twice. Thus the second fails.
Try removing the SRC_URI_machineoverride line.
your current patch file is mismatching with the source found in https://sourceforge.net/projects/watchdog/files/watchdog/5.13/
I have added changes manually to file from https://sourceforge.net/projects/watchdog/files/watchdog/5.13/ and patch is as below,
--- a/src/watchdog.c 2020-07-02 13:57:45.771971643 +0200
+++ b/src/watchdog.c 2020-07-02 13:57:55.979985941 +0200
## -567,6 +567,7 ##
pid_t child_pid;
int oom_adjusted = 0;
struct stat s;
+ int check = FALSE
#if USE_SYSLOG
char *opts = "d:i:n:Ffsvbql:p:t:c:r:m:a:";
## -1053,6 +1054,10 ##
do_check2(check_bin(act->name, timeout, 1), act->name, rbinary, NULL);
#endif
+ if(check == TRUE)
+ {
+ do_check(test_files(), repair_bin, NULL);
+ }
/* finally sleep some seconds */
usleep(tint * 500000); /* this should make watchdog sleep tint seconds alltogther */
/* sleep(tint); */
Related
I have currently build a Yocto core-minimal-images (with meta-sunxi) for an orange pi zero board(a cheap chinese board that i use for my studies)
https://github.com/linux-sunxi/meta-sunxi
And it succesfully boot on my board,but in the /dev directory i didnt have acces to the SPI NOR memory. After some search on the orange pi wiki i find that i need some line to my device tree : https://linux-sunxi.org/Orange_Pi_Zero#Installing_from_linux
&spi0 {
status = "okay";
flash: m25p80#0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "winbond,w25q128";
reg = <0>;
spi-max-frequency = <40000000>;
};
};
But i dont really understand how to proceed...because i don't find which files i need to edit ? and maybe this not a good idee ? i think its better to create a .bbappend recipes no ?
the information that i have gather by searching in the meta-sunxi directories:
in conf/orange-pi-zero/KERNEL_DEVICETREE = "sun8i-h2-plus-orangepi-zero.dtb"
but there is no "sun8i-h2-plus-orangepi-zero.dts" file in the meta-sunxi directories ?
"sun8i-h2-plus-orangepi-zero.dtb"file is present in /build/tmp/deploy/images/orange-pi-zero/ so i don't really know how it is generated ? is it only download by yocto ? ( no device tree compilation ? )
by serachin on the net i was able to find sun8i-h2-plus-orangepi-zero.dts
at: https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
and it contains theses interesting lines :
&spi0 {
/* Disable SPI NOR by default: it optional on Orange Pi Zero boards */
status = "disabled";
flash#0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "mxicy,mx25l1606e", "winbond,w25q128";
reg = <0>;
spi-max-frequency = <40000000>;
};
};
So maybe someone is able to give some advice to add SPI NOR support on my board ? what is the best way ? make some .bbappend ? or create my own meta by copying "meta-sunxi" and edit it ? and then which files i need to edit ?
thanks in advance for your time
Pierre.
Compiling the image with Yocto with the meta BSP layer pulls the kernel (checksout into tmp/work-shared/<MACHINE>/kernel-source/) and compiles it and you get the final output image which you can flash from tmp/deploy/images/<MACHINE>/. But in your case the mainline kernel doesn't enabled the SPI by default, so you need to enable it in the Linux Kernel source code.
If you have the Yocto build setup already, then you can edit the Device Tree and prepare the patch. You can move into tmp/work-shared/orange-pi-zero/kernel-source/ and edit the kernel source code and change
status = "okay";
and prepare the git patch using usually sequence,
git add arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
git commit -s -m "Enable SPI by default"
git format-patch HEAD~
Then you append this patch in two ways.
Edit the recipes-kernel/linux/linux-mainline_git.bb and add your patch file into SRC_URI. Copy the patch file into recipes-kernel/linux/linux-mainline
If you don't want to edit the meta-sunxi layer, create linux-mainline_%.bbappend in your meta layer and do the same.
The below patch can be directly applied to meta-sunxi to fix this case. You can find the same here.
From 3a1a3515d33facdf8ec9ab9735fb9244c65521be Mon Sep 17 00:00:00 2001
From: Parthiban Nallathambi <parthiban#linumiz.com>
Date: Sat, 10 Nov 2018 12:20:41 +0100
Subject: [PATCH] orange pi zero: Add SPI support by default
Signed-off-by: Parthiban Nallathambi <parthiban#linumiz.com>
---
...rm-dts-enable-SPI-for-orange-pi-zero.patch | 26 +++++++++++++++++++
recipes-kernel/linux/linux-mainline_git.bb | 1 +
2 files changed, 27 insertions(+)
create mode 100644 recipes-kernel/linux/linux-mainline/0001-arm-dts-enable-SPI-for-orange-pi-zero.patch
diff --git a/recipes-kernel/linux/linux-mainline/0001-arm-dts-enable-SPI-for-orange-pi-zero.patch b/recipes-kernel/linux/linux-mainline/0001-arm-dts-enable-SPI-for-orange-pi-zero.patch
new file mode 100644
index 0000000..e6d7933
--- /dev/null
+++ b/recipes-kernel/linux/linux-mainline/0001-arm-dts-enable-SPI-for-orange-pi-zero.patch
## -0,0 +1,26 ##
+From 1676d9767686404211c769de40e6aa55642b63d5 Mon Sep 17 00:00:00 2001
+From: Parthiban Nallathambi <parthiban#linumiz.com>
+Date: Sat, 10 Nov 2018 12:16:36 +0100
+Subject: [PATCH] arm: dts: enable SPI for orange pi zero
+
+Signed-off-by: Parthiban Nallathambi <parthiban#linumiz.com>
+---
+ arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
+index 0bc031fe4c56..0036065da81c 100644
+--- a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
++++ b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
+## -144,7 +144,7 ##
+
+ &spi0 {
+ /* Disable SPI NOR by default: it optional on Orange Pi Zero boards */
+- status = "disabled";
++ status = "okay";
+
+ flash#0 {
+ #address-cells = <1>;
+--
+2.17.2
+
diff --git a/recipes-kernel/linux/linux-mainline_git.bb b/recipes-kernel/linux/linux-mainline_git.bb
index 5b8e321..9b2bcbe 100644
--- a/recipes-kernel/linux/linux-mainline_git.bb
+++ b/recipes-kernel/linux/linux-mainline_git.bb
## -27,5 +27,6 ## SRCREV_pn-${PN} = "b04e217704b7f879c6b91222b066983a44a7a09f"
SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git;protocol=git;branch=master \
file://defconfig \
+ file://0001-arm-dts-enable-SPI-for-orange-pi-zero.patch \
"
S = "${WORKDIR}/git"
--
2.17.2
I'm trying to get a unified diff between many pairs of directories so I can ensure the comparison between pairs is consistent, and I want to know if there's a way to get diff to format the output with relative rather than absolute paths.
Right now if I use diff -r -u PATH1 PATH2 then I get this kind of output:
diff -r -u PATH1/some/subfile.txt PATH2/some/subfile.txt
--- PATH1/some/subfile.txt Tue Feb 07 09:16:31 2017
+++ PATH2/some/subfile.txt Tue Feb 07 09:16:32 2017
## -70,7 +70,7 ##
*
* some stuff
*
- * I am Tweedledee and you are not
+ * I am Tweedledum and you are not
*/
void twiddle(void)
{
## -88,7 +88,7 ##
* check whether we should destroy everything
* and then destroy everything in either case
*/
-inline static void Tweedledee(void)
+inline static void Tweedledum(void)
{
if (should_destroy_everything())
{
I would rather get just the relative paths... is there any way to get diff to do this? example:
diff -r -u PATH1/some/subfile.txt PATH2/some/subfile.txt
--- some/subfile.txt
+++ some/subfile.txt
## -70,7 +70,7 ##
*
* some stuff
*
- * I am Tweedledee and you are not
+ * I am Tweedledum and you are not
*/
void twiddle(void)
{
## -88,7 +88,7 ##
* check whether we should destroy everything
* and then destroy everything in either case
*/
-inline static void Tweedledee(void)
+inline static void Tweedledum(void)
{
if (should_destroy_everything())
{
This would make it easier to compare diff reports which are expected to be the same. (in my case PATH1 and PATH2 differ in each case, whereas the relative paths to files, and the exact content differences are the same)
Otherwise I have to filter this information out (either manually or with a script)
I would pipe the output of your diff command to a sed script something like this:
$ diff -r -u PATH1/some/subfile.txt PATH2/some/subfile.txt | sed '1s/PATH1\///' | sed '2s/PATH2\///'
The script says": on line 1, replace "PATH1", followed by a single forward slash, by nothing, then, on line 2, replace "PATH2", followed by a single forward slash, by nothing. I'd have to create some content to test it, so I haven't tested it.
I bit the bullet and did this parsing in Python; it removes the diff blah blah blah statements and relativizes the paths to a pair of specified root directories, also removing timestamps:
udiff_re = re.compile(r'^## -(\d+),(\d+) \+(\d+),(\d+) ##$')
diffitem_re = re.compile(r'^(\+\+\+|---) (.*)\s+.{7} \d\d \d\d:\d\d:\d\d \d{4}$')
def process_diff_output(output, dir1, dir2):
state = 0
lines_pending = [0,0]
result = []
for line in output.splitlines():
if state == 0:
if line.startswith('##'):
m = udiff_re.search(line)
if m:
nums = [int(n) for n in m.groups()]
else:
raise ValueError('Huh?\n' + line)
result.append(line)
lines_pending = [nums[1],nums[3]]
state = 1
elif line.startswith('--- ') or line.startswith('+++ '):
m = diffitem_re.search(line)
whichone = m.group(1)
filename = m.group(2)
dirx = dir1 if whichone == '---' else dir2
result.append('%s %s' % (whichone, os.path.relpath(filename, dirx)))
elif line.startswith('diff '):
pass # leave the diff cmd out
else:
raise ValueError('unknown header line\n'+line)
elif state == 1:
result.append(line)
if line.startswith('+'):
lines_pending[1] -= 1
elif line.startswith('-'):
lines_pending[0] -= 1
else:
lines_pending[0] -= 1
lines_pending[1] -= 1
if lines_pending == [0,0]:
state = 0
return '\n'.join(result)
I'm trying to find a way to parse a file in Rexx. Each line has two words and an IP address.
Example
Location Name 10.0.0.1
I have looked over a lot of documentation and i can get it to print all the lines in the file but i cannot figure out how to search an entire file and print a specific line by using a match operator.
For Regina Rexx this is a program should be close to what you want:
Call A000_init
Call R000_ReadFile
do while MoreData
parse var line pt1 pt2
if (pt1 == whatever) then do
/* Do some thing */
end
Call R000_ReadFile
end
A000_init:
Yes = 1
No = 0
MoreData = yes
filename = .....
return
R000_ReadFile:
if lines(filename,'N') then do
Line= LineIn(filename)
end; else do
line = ''
MoreData = no
end
Return
This is a pretty easy task for a Rexx program.
ExpectedLocation = 'Living Room' /* What location are we searching for? */
Signal on NotReady /* Jump to "NotReady:" at end-of-file. */
Do Forever /* ... or at least until EOF or Exit! */
Parse LineIn Word1 Word2 IPAddress . /* Pull apart the three tokens on the line */
Location = Word1 Word2 /* Put the two words of the location back together. */
If Location = ExpectedLocation then Do /* Did we find it? */
Say "Found it :-)" /* Yay! */
Exit /* We're done, stop the program. */
End
End
NotReady: /* We come here at end-of-file. */
Say "Didn't find it :-(" /* Darn! */
Regina is Open Source, the project is on SourceForge at http://regina-rexx.sourceforge.net, and the documentation for the version you're using can be downloaded from http://sourceforge.net/projects/regina-rexx/files/regina-documentation/3.4/
Input file : XXXXXX.XXXX.XXXX
***************************** Top of Data
Location1 Name1 11.11.11.11
Location2 Name2 22.22.22.22
Location3 Name3 33.33.33.33
**************************** Bottom of Data
Code:
/* REXX */
/* Author : Ebin Paulose */
/*=============================================================================*/
YourWord = Location2 /*Word which we need to find, here i m giving "Location2"*/
Your_PS = 'XXXXXX.XXXX.XXXX' /*File name where we need to search */
"ALLOC DA('"Your_PS"') F(FILEDD) SHR REUSE" /* Allocate the file */
DO FOREVER
"EXECIO 1 DISKR FILEDD"
IF RC>0 THEN LEAVE
PULL Record /* pull one record from file */
PARSE VAR Record Location " " Name " " IPAddress
/* parse record into 3 parts Location, Name and IPAddress */
IF Location = YourWord THEN do /* check for matching */
SAY 'Found : ' Location
Found = 'Y'
END
END
IF Found ¬= 'Y' THEN DO
SAY 'Sorry Search item Not found'
END
"EXECIO 0 DISKR FILEDD (FINIS"
"FREE F(FILEDD)"
Output 1 (item found) :
Found : LOCATION2
Output 2 (item not found) :
Sorry Search item Not found
filename = 'MY.DATA.SET'
if sysdsn(''''filename'''') <> 'OK' then exit
address 'TSO'
"ALLOCATE FILE(INDD) DATASET('"filename"') SHR REUSE"
"EXECIO DISKR * INDD(STEM file. FINIS)"
"CLOSE FILE(INDD)"
target = 'My Location'
found = 1==0 /* false */
do i = 1 to file.0
card = file.i
parse var card loc1 loc2 ip_address .
found = loc1' 'loc2 == target
if found then leave
end i
if found then
say 'IP address of 'target' is 'ip_address
else
say 'No IP address found for 'target
exit
My tests are in SystemC env and for all my tests i run a common routine(basically its my init sequence which doesn't vary much based on seed). This common routine is followed by my actual test.
It looks something like this:
Test_MAIN
init_seq();
my_test();;
Here init_seq() is that common routine and my_test() is my actual test that have actual test sequence which initiate multiple SC threads, for initiating various kind of traffic.
Now, my problem is that i want a way to avoid init_seq() for every run. The entire test should run for one time and the next time i should have a mechanism to directly run from my_test()(which is basically skipping/preloading init_seq() part to the simulator).
VCS save and restore can't be used directly as in this case we also will have to restore the SystemC variables.
Could you please direct me on this..!!
Thanks
ByreddyNaresh
I tried with a SystemC test with init() and run() routine, and use VCS save/restart to restore the test. It seems OK to me that a member variable 'cnt' in test is restored successfully.
This is my test:
// test.h
#ifndef TEST_H
#define TEST_H
#include <systemc.h>
class test: public sc_module{
public:
sc_in<bool> init_start;
sc_in<bool> run_start;
void init();
void run();
int cnt;
SC_CTOR(test){
SC_THREAD(init);
sensitive_pos << init_start;
dont_initialize();
SC_THREAD(run);
sensitive_pos << run_start;
dont_initialize();
}
};
#endif
and
// test.cpp
#include "test.h"
void test::init(){
printf("test init:\n");
while(1){
cnt = 10;
printf("init cnt to %d\n", cnt);
wait();
}
}
void test::run(){
printf("test run:\n");
while(1){
cnt++;
printf("cnt = %d\n", cnt);
wait();
}
}
and the top:
// tb.v
module tb;
reg init_start;
reg run_start;
initial begin
init_start = 0;
run_start = 0;
#100
init_start = 1;
#100
$save("save.chk");
#100
run_start = 1;
#100
$finish;
end
test u_test(
.init_start(init_start),
.run_start(run_start)
);
endmodule
After 'save.chk' is generated, I run it directly and the output is:
$ save.chk
Chronologic VCS simulator copyright 1991-2012
Contains Synopsys proprietary information.
Compiler version G-2012.09; Runtime version G-2012.09; Mar 5 18:01 2014
test run:
cnt = 11
$finish called from file "tb.v", line 17.
$finish at simulation time 1300
V C S S i m u l a t i o n R e p o r t
Time: 1300 ps
CPU Time: 0.260 seconds; Data structure size: 0.0Mb
Wed Mar 5 18:01:08 2014
It seems variable 'cnt' is restored from '10', as is done in init() routine.
Don't know if this is the case you met?
I'm trying to install the re::engine::RE2 module with cpan.
When building, the compiler emits the error message:
re2_xs.cc:254:25: error: variable length array of non-POD element type
're2::StringPiece'
re2::StringPiece res[re->nparens + 1];
^
What does that mean? How can I fix that? I'm using a 2011 Macbook Air and Perl 5.12.
re::engine::RE2 was never successfully tested on darwin/Perl 5.12.
Googling for the error message suggests that this is a flaw in old clang that ships with Xcode, and not present in newer versions.
Upgrade your software, you're out of support, perhaps use Macports to get a fresh gcc.
True, re::engine::RE2 never compiled on OS X. But you can get it to compile. Locate the cpan directory. For me it is ~/.cpan/build/re-engine-RE2-0.13-BY20k3/. Then within there, you change two C++ source files.
$ diff -p re2_xs.cc.old re2_xs.cc
*** re2_xs.cc.old 2015-04-20 20:20:15.000000000 +0200
--- re2_xs.cc 2015-04-20 20:22:24.000000000 +0200
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 229,236 ****
RE2 * ri = (RE2*) SvANY(rx)->pprivate;
regexp * re = SvANY(rx);
- re2::StringPiece res[re->nparens + 1];
-
#ifdef RE2_DEBUG
Perl_warner(aTHX_ packWARN(WARN_MISC), "RE2: Matching '%s' (%p, %p) against '%s'", stringarg, strbeg, stringarg, RX_WRAPPED(rx));
#endif
--- 229,234 ----
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 241,246 ****
--- 239,246 ----
return 0;
}
+ re2::StringPiece *res = new re2::StringPiece[re->nparens + 1];
+
bool ok = ri->Match(
re2::StringPiece(strbeg, strend - strbeg),
stringarg - strbeg,
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 250,255 ****
--- 250,256 ----
/* Matching failed */
if (!ok) {
+ delete [] res;
return 0;
}
*************** RE2_exec(pTHX_ REGEXP * const rx, char *
*** 266,271 ****
--- 267,274 ----
}
}
+ delete [] res;
+
return 1;
}
Attempting to compile after that will get you to a tr1 issue.
/usr/bin/clang -o obj/util/arena.o -xc++ -O3 -DHAVE_PTHREAD -pthread -Wno-sign-compare -c -I. -DNDEBUG util/arena.cc
In file included from util/arena.cc:5:
./util/util.h:45:10: fatal error: 'tr1/unordered_set' file not found
I'm sure there are simpler -D fixes for the Makefile but I changed the code.
# diff -p re2/util/util.h.old re2/util/util.h
*** re2/util/util.h.old 2015-04-20 20:29:01.000000000 +0200
--- re2/util/util.h 2015-04-20 20:29:26.000000000 +0200
*************** using std::make_pair;
*** 42,49 ****
#if defined(__GNUC__) && !defined(USE_CXX0X)
! #include <tr1/unordered_set>
! using std::tr1::unordered_set;
#else
--- 42,51 ----
#if defined(__GNUC__) && !defined(USE_CXX0X)
! //#include <tr1/unordered_set>
! //using std::tr1::unordered_set;
! #include <unordered_set>
! using std::unordered_set;
#else
Now just
make && make install
and you now have re::engine::RE2 available for OS X.
The answer by Douglas Scofield is correct, but one additional change is needed. In re2_xs.cc you also must change line 244 as follows:
bool ok = ri->Match(
re2::StringPiece(strbeg, strend - strbeg),
stringarg - strbeg,
strend - strbeg,
RE2::UNANCHORED,
! res, re->nparens + 1);
Douglas Scofield's answer changes the array res to pointer *res to avoid the compiler error of variable length array. However, after this change the line
sizeof res / sizeof *res
does not work because you would be taking the size of the pointer and dividing by the size of the array. Therefore, you have to make the change above to
re->nparens + 1
to get the size of the array pointed to by *res, which is what was desired in the original code.
If you don't make the change then capture groups will not work in re2. You will get errors that your capture groups like $1, $2, etc. are uninitialized.
So great answer above, just needs one addendum.