Two Qs sparked by sorting several hands full of SD890 and SD990 - page 2 - General Discussion and Assistance - CHDK Forum supplierdeeply

Two Qs sparked by sorting several hands full of SD890 and SD990

  • 28 Replies
  • 3781 Views
*

Offline koshy

  • *****
  • 1096
Re: Two Qs sparked by sorting several hands full of SD890 and SD990
« Reply #10 on: 12 / April / 2022, 13:21:40 »
Advertisements
Use any binary compare to find the offset of the first difference [...] I usually use HxD to compare, but only because I downloaded it a long time ago and it lets you compare and jump to the first difference.

I don't have a specific recipe for the "inspect" part, but generally, normal variation will be near the end of the file, and likely preceded by a large chunk of 0xFF values, and likely aligned to some fairly large value.
Great, thanks a lot, that was exactly the kind of detail needed. HxD will be just fine.

The CHDK CRC check should also catch corruption in a large fraction of the ROM.
Or the opposite, a broken FW dump in the repo as we once saw  8), which reminds me that I wanted to go through the whole lot with CHDK 1.5 to see if any flags get raised due to the new CRC. If I do that is there anything else currently to do automatedly with 'em all?

Also say I wanted to dump all FWs while I'm at it and suppose I'm lazy, can the script be generalized so that it works for the few existing sizes and does not dump to "PRIMAY.bin" but rather "SOME_UNIQUECAMERA_STR_PLUS_FW_VERSION.bin" with effort that would be LESS than me renaming like 140 files so it would need to be trivial or fun? I mean I'd need to exchange CHDKs anyway, so that wouldn't be a big deal, just tedious...
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)

*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: Two Qs sparked by sorting several hands full of SD890 and SD990
« Reply #11 on: 12 / April / 2022, 13:35:15 »
not dump to "PRIMAY.bin" but rather "SOME_UNIQUECAMERA_STR_PLUS_FW_VERSION.bin" with effort that would be LESS than me renaming like 140 files so it would need to be trivial or fun? I mean I'd need to exchange CHDKs anyway, so that wouldn't be a big deal, just tedious...
Maybe a script to combine...  :)
« Last Edit: 12 / April / 2022, 14:04:09 by Caefix »
All lifetime is a loan from eternity.

*

Offline koshy

  • *****
  • 1096
Re: Two Qs sparked by sorting several hands full of SD890 and SD990
« Reply #12 on: 12 / April / 2022, 14:22:10 »
Maybe a script to combine...  :)
Thank you very much, how nice of you.

So fil needs to be come "A/?PRIMARY.bin"
Code: [Select]
fil="A/?romlog.log"
while m needs to be 1, or I can just take out parts.
Code: [Select]
@param    m Test | os.rename | Batchfile
 @default m 2

This is pretty well on target. Great.
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)

*

Offline koshy

  • *****
  • 1096
Re: Two Qs sparked by sorting several hands full of SD890 and SD990
« Reply #13 on: 12 / April / 2022, 14:26:01 »
So that leaves the second half of the thought. Is it possible to detect the couple of versions
Code: [Select]
DUMPFILE="A/PRIMARY.BIN"
addr=0xFF810000
size=0x007EFFFC
can have, or does that need to get hard coded, now that the unique identifier is available by autodetection per camera?
 I mean writing down the like 140 cases once and for all would be a last resort wouldn't it.
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)


*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: Two Qs sparked by sorting several hands full of SD890 and SD990
« Reply #14 on: 12 / April / 2022, 16:05:12 »

while m needs to be 1, or I can just take out parts.
Code: [Select]
@param    m Test | os.rename | Batchfile
 @default m 2
When os.rename writes sfn~ the Batchfile option is better.
Then Explorer & mouse renames.  :)
« Last Edit: 13 / April / 2022, 10:13:09 by Caefix »
All lifetime is a loan from eternity.

*

Offline reyalp

  • ******
  • 14080
Re: Two Qs sparked by sorting several hands full of SD890 and SD990
« Reply #15 on: 12 / April / 2022, 17:04:02 »
So that leaves the second half of the thought. Is it possible to detect the couple of versions
Code: [Select]
DUMPFILE="A/PRIMARY.BIN"
addr=0xFF810000
size=0x007EFFFC
can have, or does that need to get hard coded, now that the unique identifier is available by autodetection per camera?
 I mean writing down the like 140 cases once and for all would be a last resort wouldn't it.
camera_info.csv in CHDK source includes the ROMBASEADDR values. I don't think there's a way to get this from script, and it doesn't exactly correspond 1:1 to digic number. Except for digic 6 and later, the ROM usually goes to the end of address space.

Alternately, you could follow the logic of canon basic dumper looking for the "gaonisoy" and "Copyrigh" strings with peek in Lua: https://chdk.fandom.com/wiki/Canon_Basic/Scripts/Dumper

You could take the size logic from there too.

If I were going to do this, I'd probably use a chdkptp script so I could just run one command and get a nicely named file on the PC.

To check CRCs, you could use tools/make-fw-crc.py and compare with what's currently in the source. But assuming you do a fresh CHDK install, each camera should do a CRC check on boot anyway.
Don't forget what the H stands for.

*

Offline koshy

  • *****
  • 1096
Re: Two Qs sparked by sorting several hands full of SD890 and SD990
« Reply #16 on: 12 / April / 2022, 17:33:39 »
@reyalp Thank you.

You could take the size logic from there too.
I have coded little lua, does this look plausible?

Code: [Select]
local startaddr,os,lcdmsg,msgstr,romsize,whatThePeek

startaddr=0
os="unk"
lcdmsg=0
msgstr=0
romsize=0

whatThePeek=peek(0xFFC00004, 8)
if (whatThePeek=="gaonisoy") then
startaddr = 0xFFC00000
os = "dry"
end
whatThePeek=peek(0xFFC00008, 8)
if (whatThePeek=="Copyrigh") then
startaddr = 0xFFC00000
os = "vx"
end
whatThePeek=peek(0xFF810004, 8)
if (whatThePeek=="gaonisoy") then
startaddr = 0xFF810000
os = "dry"
end
whatThePeek=peek(0xFF820004, 8)
if (whatThePeek=="gaonisoy") then
startaddr = 0xFF810000
os = "dry"
end
whatThePeek=peek(0xFF810008, 8)
if (whatThePeek=="Copyrigh") then
startaddr = 0xFF810000
os = "vx"
end
whatThePeek=peek(0xFF000004, 8)
if (whatThePeek=="gaonisoy") then
startaddr = 0xFF000000
os = "dry"
end
whatThePeek=peek(0xFF020004, 8)
if (whatThePeek=="gaonisoy") then
startaddr = 0xFF010000
os = "dry"
end
whatThePeek=peek(0xFC020004, 8)
if (whatThePeek=="gaonisoy") then
startaddr = 0xFC000000
os = "dry"
romsize = 0x2000000
end
whatThePeek=peek(0xE0020004, 8)
if (whatThePeek=="gaonisoy") then
startaddr = 0xE0000000
os = "dry"
romsize = 0x2000000
end

if (romsize==0) then
romsize = 0xFFFFFFFC - startaddr
end

I wasn't sure if I could just do it inline like:
Code: [Select]
if (peek(0xFFC00004, 8)=="gaonisoy") then
...
« Last Edit: 12 / April / 2022, 17:36:27 by koshy »
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)

*

Offline koshy

  • *****
  • 1096
Re: Two Qs sparked by sorting several hands full of SD890 and SD990
« Reply #17 on: 12 / April / 2022, 17:47:40 »
But assuming you do a fresh CHDK install, each camera should do a CRC check on boot anyway.
Do I get this right: I need to delete CHDK each time rather than putting a base CHDK into an existing Full CHDK? The CRC check is performed once upon installation, not on every boot? Can that be altered to on every boot by means of the CHDK menu?
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)


*

Offline reyalp

  • ******
  • 14080
Re: Two Qs sparked by sorting several hands full of SD890 and SD990
« Reply #18 on: 12 / April / 2022, 17:57:31 »
I have coded little lua, does this look plausible?
Mostly, but peek returns a integer, not a string. You could use a function like this to get the 8 bytes as a string:
Code: [Select]
binstr=require'binstr'

function getsig(addr)
 return binstr.pack({peek(addr),peek(addr+4)})
end
Then use getsig where you had peek.

Do I get this right: I need to delete CHDK each time rather than putting a base CHDK into an existing Full CHDK?
The CRC check setting is stored in the in CCHDK4.CFG (config name check_firmware_crc) The initial value is "next" (1), which causes the CRC to be checked on boot, and the setting changed to "never" (0). You can set it "always" (2) in the menu.

This config is not reset when the platform changes, so if you are re-using the same card, you could just set it to "always". Or, if you delete the CFG file between installs, it will be checked on the first boot.

Quote
I wasn't sure if I could just do it inline like:
You can (but with getsig not peek)
« Last Edit: 12 / April / 2022, 17:59:47 by reyalp »
Don't forget what the H stands for.

*

Offline koshy

  • *****
  • 1096
Re: Two Qs sparked by sorting several hands full of SD890 and SD990
« Reply #19 on: 12 / April / 2022, 18:06:02 »
You can (but with getsig not peek)
Thanks a lot for looking at it and the function.

You can set it "always" (2) in the menu.
Perfect, I'll need to remember doing that as I prefer setting it all up once and just replacing CHDK base files. Can't do that with the latest cameras supported as it's all different with them but that will just be a second CHDK to configure...
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)

 

Related Topics