View Full Version : Using command line patching
This command reminds me of "poke" from 20 or 30 odd years ago. Is there a "peek" as well - where you can see what the value is that you are going to replace?
Can this be run on a "live" TiVo from a bash console?
Specifically, I am trying to undo the 30 second skip installed by NutKase's superpatch67-all-1.2. I don't like this feature nearly as much as I think I am supposed to. But, If I've got to pull the D-TiVo again, and disassemble it , and a PC to resolve this - I might could learn to live with it for a while.
I have this command (for a S2 D-TiVo running 6.2-01-2-151):
echo -ne "\x10\x40\x00\x1d" | dd conv=notrunc of=tivoapp bs=1 seek=6716760
PlainBill
06-08-2006, 12:33 PM
It can be run from a bash prompt. With proper syntax you can also 'peek' the locations, but a better option is to ftp the file to a pc and use a hex editor to view it.
PlainBill
Jamie
06-08-2006, 01:15 PM
IMHO, the easiest way to handle this without screwing up your tivoapp is to remove the unwanted patch from the superpatch, then apply the superpatch to a stock tivoapp. It's well marked, IIRC.
In all cases, you'll have to reboot before the change will be in effect. No need to pull the drive, unless you screw up.
With proper syntax you can also 'peek' the locations...I would be interested in that syntax if you (or anyone else) knows it.
...but a better option is to ftp the file to a pc and use a hex editor to view it.I'm not so sure that'd be better. My thoughts on this are that I would be able to verify the before/after values and the seek offset according to the information here (http://www.dealdatabase.com/forum/showthread.php?t=33946). That way, I have a way of knowing if I've got the numbers right before I blow it up.
I have this command (for a S2 D-TiVo running 6.2-01-2-151):
echo -ne "\x10\x40\x00\x1d" | dd conv=notrunc of=tivoapp bs=1 seek=6716760
BTW: I was hoping someone would actually look at these numbers and see if they were correct.
IMHO, the easiest way to handle this without screwing up your tivoapp is to remove the unwanted patch from the superpatch, then apply the superpatch to a stock tivoapp. It's well marked, IIRC...So, you're saying it would be easier to copy the original tivoapp into /tvbin, and then re-run the patch? Rather than what looks like a fairly straightforward, one-line command?? Uhggh!
Won't re-running the patch create double entries in /etc/rc.d/rc.sysinit and rc.sysinit.author?
In all cases, you'll have to reboot before the change will be in effect. No need to pull the drive, unless you screw up.Re-booting is not a problem. Disassembling half the entertainment center just to get to the DTiVo, then disassembling it and screwing with a old PC is. I'm glad to know I should be able to do this one way or the other without having to pull the drive.
Jamie
06-08-2006, 02:34 PM
...
So, you're saying it would be easier to copy the original tivoapp into /tvbin, and then re-run the patch? Rather than what looks like a fairly straightforward, one-line command?? Uhggh!
Won't re-running the patch create double entries in /etc/rc.d/rc.sysinit and rc.sysinit.author?
...Suit yourself. Don't expect help cross checking your vma/hex conversions or repairing things if you screw up your tivoapp.
You don't seem to have a clue about what the superpatch script does. It only modifies tivoapp; it doesn't touch anything else (including /etc/rc.sysinit*).
Have fun with echo/dd. This is an approach that few recommend anymore. One of the chief reasons is that it is "blind": you can't see/check what you are overwriting it before you clobber your tivoapp. The tcl approach used in the superpatch does check the old value before replacing it. Another advantage of the tcl approach is that it does all the hex/vma conversions for you.
Suit yourself. Don't expect help cross checking your vma/hex conversions or repairing things if you screw up your tivoapp.I'm trying to get that before I screw it up.
...It only modifies tivoapp; it doesn't touch anything else (including /etc/rc.sysinit*).My apologies, you are correct. I ran several scripts - both hurriedly and late. It all kinda ran together.
You don't seem to have a clue about what the superpatch script does.Well - I wouldn't say that. I'm no coder - but, I can read enough to see that it uses simple arrays and a build identifier to change certain insertion points on a temporary file. The code that makes the change is:
set fh [open "/tvbin/tivoapp.superpatch" r+]
foreach {off val} [array get $a] {
binary scan $val a8xa8 orig new
seek $fh [expr $off - 0x400000] start;
puts -nonewline $fh [binary format H8 $new]
}
close $fh
But, not being a coder, that particular part of the script is majik [sic] as far as I'm concerned. I have no idea how to apply this in a single change (command line) methodology. I would like to know, however.
Have fun with echo/dd. This is an approach that few recommend anymore. One of the chief reasons is that it is "blind"...I don't know how to use dd - but, I know what it is (which is essentially a very old, file system independent, "copy" program - deriving from early tape systems). Surely there is a way to easily read a segment before replacing it, verifying both location and data.
As per PlainBill's suggestion - I can easily hex edit the file and make the changes there - but, I'm intrigued with using dd to do the same.
Jamie
06-08-2006, 03:51 PM
Example of using dd/hexdump in "peek" mode (http://www.dealdatabase.com/forum/showthread.php?p=253092&highlight=dd#post253092)
dd man page (http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?dd)
echo man page (http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?echo)
The man pages on the web may not always completely match the versions of programs running on the tivo. In some cases, you might be using a "busybox" subset of the real command. "foo --help" or "foo -h" will often give you basic usage information for command foo.
I still stand by my assertion that the path least likely to require you to pull the disk is to simply edit the one line out of the superpatch and apply it to a stock tivoapp. A second choice would be PlainBill's suggestion of altering tivoapp with a hex editor on the pc side. Most likely to result in a disk pull: screwing around with dd/hexdump/echo without understanding them.
This (http://www.dealdatabase.com/forum/showthread.php?p=178198&highlight=hex+editor#post178198) is a good reference too.
fantmn
06-09-2006, 02:27 AM
Here is a link (http://www.dealdatabase.com/forum/showthread.php?t=42540&highlight=hexedit)to hexedit that runs on S2 Tivos. It will let you hex edit files on the Tivo without a transfer to the PC. I think you will need to rename the existing tivoapp because it is still locked by the running tivo OS and you will not be able to change it. You then copy the renamed tivoapp to the real name, hexedit the new copy, then reboot. If everything went well, your patch will work and life will be good. If not you will prob. get a reboot loop, end up having to pull the drive, restore stock tivoapp redo superpatch, etc.
Here is a link (http://www.dealdatabase.com/forum/showpost.php?p=251500&postcount=5)that has a pointer to a version of hexdump (part of the devbin-S2.tgz package) that supports the -C option unlike the busybox version. The -C option is useful because it displays both hex and ASCII. In this case it does not really matter, but for other things it may. I used hexdump and hexedit to find and change some titles like "Now Playing" and added the tivo name to the title to easily tell which one I was looking at.
FWIW, After I ran superpatch and got the 30 sec. skip, I did not find it too my liking either. I did exactly what Jamie says to do. I believe you will need to rename the existing tivoapp and then transfer the stock one back to the tivo as the original name.
Thanks Jamie.
That first link was exactly what I was looking for.
I already have html man pages bookmarked at mit & brown. Don't help much for concept, tho - just syntax.
FWIW, After I ran superpatch and got the 30 sec. skip, I did not find it too my liking either. I did exactly what Jamie says to do.Thanks for those links. I think apps of that sort would be handy to just have around anyway. I was not actually able to find "hexdump", unless it is contained in busybox-0.60.5-s2... but, the sourceforge page for tivoutils was worth the trip anyway.
I believe a lot of the issue surrounding this is no one seems to understand that I (now) know I have other means to do this. At this point, I simply want to do it via echo/dd. This is both a knowledge and a nostalgia desire. Many years ago, you made changes and hacks using a peek/poke command. Usage of dd for these types of changes is essentially the same thing. I just really want to know how to do it on a TiVo, as I did it a lot several decades ago.
I believe you will need to rename the existing tivoapp and then transfer the stock one back to the tivo as the original name.The "stock" tivoapp (providing you had an unhacked unit to start with) is already on board as /tvbin/tivoapp.original.
bash-2.02# dd if=/tvbin/tivoapp bs=1 count=4 skip=6716760 | hexdump
4+0 records in
4+0 records out
0000000 1440 001d
0000004
bash-2.02# dd if=/tvbin/tivoapp.original bs=1 count=4 skip=6716760 | hexdump
4+0 records in
4+0 records out
0000000 1040 001d
0000004
bash-2.02#
Edited for putting on eye-glasses...
Assuming skip = seek, and both are in dec., I'm good to go!
fantmn
06-09-2006, 09:06 AM
I was not actually able to find "hexdump", unless it is contained in busybox-0.60.5-s2...
I had to do a find in page with the browser. It is part of devbin-S2.tgz
The "stock" tivoapp (providing you had an unhacked unit to start with) is already on board as /tvbin/tivoapp.original.
Yep, I forgot. I copied one to my PC from an original clean drive for safe keeping. I think somewhere along the way the one on my Tivos "got cleaned up" and deleted.
Many years ago, you made changes and hacks using a peek/poke command. Usage of dd for these types of changes is essentially the same thing. I just really want to know how to do it on a TiVo, as I did it a lot several decades ago.
Many, many years we used 80 column cards and the superzap utility. Peek and poke sound like PC commands, and those PC things will NEVER catch on. :D
ocntscha
06-09-2006, 10:01 AM
[I]bash-2.02# dd if=/tvbin/tivoapp bs=1 count=4 skip=6716760 | hexdump
4+0 records in
4+0 records out
0000000 1440 001d
0000004
bash-2.02# dd if=/tvbin/tivoapp.original bs=1 count=4 skip=6716760 | hexdump
4+0 records in
4+0 records out
0000000 1040 001d
0000004
bash-2.02#
Cool. So, assuming you can modify the "live" tivoapp which contrary to popular opinion on here I would expect to work you ought to be able to combine the two above commands to do what you want..
dd if=/tvbin/tivoapp.original bs=1 count=4 skip=6716760 | dd of=/tvbin/tivoapp bs=1 count=4 skip=6716760
Reboot so tivoapp reloads and your good.
Jamie
06-09-2006, 11:41 AM
assuming you can modify the "live" tivoapp which contrary to popular opinion on here I would expect to workTry it. I believe you'll get: dd: /tvbin/tivoapp: Text file busy. Some rationale here (http://mail.nl.linux.org/kernelnewbies/2003-04/msg00137.html).dd if=/tvbin/tivoapp.original bs=1 count=4 skip=6716760 | dd of=/tvbin/tivoapp bs=1 count=4 skip=6716760
seek != skip. Time to revisit the man page. Hint: one is for input (reading), one is for output (writing). Also, you might want to look into conv=notrunc. You certainly don't want to truncate the output file after the last byte written, which may be what happens without notrunc.
I believe a lot of the issue surrounding this is no one seems to understand that I (now) know I have other means to do this. At this point, I simply want to do it via echo/dd. This is both a knowledge and a nostalgia desire. Many years ago, you made changes and hacks using a peek/poke command. Usage of dd for these types of changes is essentially the same thing. I just really want to know how to do it on a TiVo, as I did it a lot several decades ago.Sorry I got grumpy in this thread yesterday. After posting a "this is a good way to do this" message and getting back a seemingly argumentative "no, that's not a good way to do it" response, I got ticked off. Nothing wrong with trying to better understand all the tools at your disposal.
dd if=/tvbin/tivoapp.original bs=1 count=4 skip=6716760 | dd of=/tvbin/tivoapp bs=1 count=4 skip=6716760Intriguing thought. I wonder if it would actually parse the output from the "peek" into a form the "poke" would write correctly...
Jamie
06-09-2006, 12:12 PM
Intriguing thought. I wonder if it would actually parse the output from the "peek" into a form the "poke" would write correctly...It's raw binary data, so there is no parsing. Subject to my other observations/corrections above, it should work fine.
cheer
06-09-2006, 01:33 PM
Many, many years we used 80 column cards and the superzap utility. Peek and poke sound like PC commands, and those PC things will NEVER catch on. :D
Hah. I was doing peeks and pokes back on the TRS-80 Model I...
fantmn
06-09-2006, 02:38 PM
Hah. I was doing peeks and pokes back on the TRS-80 Model I...
Sorry I was not clear, I was using PC in the more generic meaning, so a trash-80 qualifies. The first "PC" I got to play with was one a friend of mine dad's built. It cam in a brown paper bag with baggies full of parts and circuit boards. A processor Technologies SOL-20. After the upgrade it had 16K of RAM. At first you had to type the program executable in using hex, then he got a surplus paper-tape / TTY device so we could load programs that way. I tell you it was a big day when he got the cassette tape interface working using the Kansas city tape format.
But boy did it play a mean game of star trek. It even could even get sound effects by putting an AM radio next to the computer and tuning in the "noise". The programing team had spent time figuring out what sounds different code loops would make. I think the code came from MIT but I'm not sure. Maybe called Trek-80 or something along those lines. We spent tons of time with it. I guess that was life before Tivo. :) (Edit: google is amazing, I found a PDF of the manual for it here (http://www.thebattles.net/sol20/manuals/trek80.pdf))
(sorry for the slightly off topic post, I guess it was the poke that did it).
Fant
ocntscha
06-09-2006, 02:42 PM
Try it. I believe you'll get: dd: /tvbin/tivoapp: Text file busy.
I did try it. As usual, you are right again on all counts. I thought it would've worked because I thought I'd used the fuser command on /tvbin/tivoapp at sometime in the past and unlike when I ran it at the end of this little exercise I thought it hadn't returned anything. Faulty memory on my part I guess.
root@tivo:~/tmp/blah bash# ls -ld /tvbin/tivoapp*
-rwxr-xr-x 1 0 0 23242024 May 10 15:21 /tvbin/tivoapp*
-rwxr-xr-x 1 0 0 23242024 Apr 13 20:48 /tvbin/tivoapp.original*
root@tivo:~/tmp/blah bash# dd if=/tvbin/tivoapp.original bs=1 count=4 skip=7231376 | hexdump
4+0 records in
4+0 records out
0000000 1440 002b
0000004
root@tivo:~/tmp/blah bash# dd if=/tvbin/tivoapp bs=1 count=4 skip=7231376 | hexdump
4+0 records in
4+0 records out
0000000 1040 002b
0000004
root@tivo:~/tmp/blah bash# dd if=/tvbin/tivoapp.original bs=1 count=4 skip=7231376 | dd of=/tvbin/tivoapp bs=1 count=4 seek=7231376 conv=notrunc
4+0 records in
4+0 records out
dd: /tvbin/tivoapp: Text file busy
root@tivo:~/tmp/blah bash# fuser /tvbin/tivoapp
/tvbin/tivoapp: 111e 112e 113e 114e 117e 121e 122e 123e 124e 125e 126e 154e 155e 156e 159e 160e 161e 162e 163e 165e 166e 167e 168e 174e 175e 176e 180e 181e 182e 205e 206e 207e 209e 217e 218e 219e 221e 225e 226e 230e 236e 242e 243e 244e 245e 247e 248e 249e 250e 251e 252e 253e 254e 259e 261e 262e 263e 267e 268e 271e 272e 274e 276e 277e 278e 288e 289e 290e 296e 302e 303e 304e 306e 322e 344e 345e 346e 2374e 3789e 5604e 20431e 20437e 22950e 23010e 23407e 24308e 24401e 24901e 24906e 24910e 24916e 24922e 24932e 24946e 24949e 24950e 24951e 24952e 24955e 24956e 24959e 24960e
All right Jamie, thanks to you pointing ought the the 3 flaws in my previous suggestion I'm going to ammend my idea for the original poster to the following. I'm sure you'll be quick to jump and point out any flaws, assuming he has disk space for another temporary copy of tivoapp on his root partition any reason this shouldn't work?...
mv /tvbin/tivoapp /tvbin/tivoapp.tmp
cp /tvbin/tivoapp.tmp /tvbin/tivoapp
dd if=/tvbin/tivoapp.original bs=1 count=4 skip=6716760 | dd of=/tvbin/tivoapp bs=1 count=4 seek=6716760 conv=notrunc
reboot
rm /tvbin/tivoapp.tmp
Jamie
06-09-2006, 02:57 PM
All right Jamie, thanks to you pointing ought the the 3 flaws in my previous suggestion I'm going to ammend my idea for the original poster to the following. I'm sure you'll be quick to jump and point out any flaws, assuming he has disk space for another temporary copy of tivoapp on his root partition any reason this shouldn't work?...Not a flaw, but a pedantic suggestion:
There is no need for two dd processes piped together. You can do this all with one dd command. dd copies from an input file to an output file. You don't have to use stdin/stdout for either one. This might give a clue why seek= and skip= are separate options.
Perhaps this was well understood and the two separate dd's (one for reading, one for writing) were thought to be a more readable solution.
ocntscha
06-09-2006, 03:14 PM
Perhaps this was well understood and the two separate dd's (one for reading, one for writing) were thought to be a more readable solution.Ahh yes, another excellent point. It was more a matter of not thinking enough than "thought to be a more readable solution". All right then as I tend to favor efficient over pedantic lets make it this..
dd if=/tvbin/tivoapp.original bs=1 count=4 skip=6716760 of=/tvbin/tivoapp seek=6716760 conv=notrunc
I had to do a find in page with the browser. It is part of devbin-S2.tgzThanks for the pointer. I'll go back and klep a copy.
Many, many years we used 80 column cards and the superzap utility.I had a little experience with those as well. Both on the Gould system and the Univac 1000 series - which was on a T1 into the internet, BTW. No trivial accomplishment for 1983.
...and those PC things will NEVER catch on.
Originally Posted by cheer
Hah. I was doing peeks and pokes back on the TRS-80 Model I...fantnm - just to let you know - I got it. :D
Of course my line was (and I quote):
"Who wants a computer made by IBM. They make typewriters."
This was in response to a question asked of me around 1980 when IBM was trying to offload the first couple of hundred thousand PCs that they had made for a contract. The deal blew out - and they were cheap (like $2500 for a PC with 256K of RAM). It was also before I knew that IBM made mainframes and minis - and had even produced large-scale tabulating machines (read: computers) before WWII.
The first "PC" I got to play with was one a friend of mine dad's built. It cam in a brown paper bag with baggies full of parts and circuit boards. A processor Technologies SOL-20. After the upgrade it had 16K of RAM. At first you had to type the program executable in using hex, then he got a surplus paper-tape / TTY device so we could load programs that way. I tell you it was a big day when he got the cassette tape interface working using the Kansas city tape format.My first was in 1976. An Attache 2K - with, you guessed it, 2K of RAM. Of course it did have ROM BASIC. My big day was the $200 octopus cable coming in. It connected it to a tabletop cassette recorder to save files. Something I could build with parts from Radio Shack for $25 (that's todays prices even, probably <$5 in 1977).
Maybe called Trek-80 or something along those lines... I had that, as well. Wasted many hours playing it. I have a current copy for Palm O/S if anyone wants....
BTW - Loved the manual for it. I never read it (if I had one). Most copies of S/W I had then were.... ahhh... of undetermined origin.
How little some things change.
All right then as I tend to favor efficient over pedantic lets make it this..
dd if=/tvbin/tivoapp.original bs=1 count=4 skip=6716760 of=/tvbin/tivoapp seek=6716760 conv=notrunc
Although most of the posts here go far beyond my original question, I - for one - am enjoying it. Every practical example deepens my understanding of how to use one of the most cryptically flexible tools for UNIX.
fantmn
06-11-2006, 12:11 AM
Hash, Please check your Personal Mail (PM).
Fant
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.