New tool for porting. - page 3 - General Discussion and Assistance - CHDK Forum

New tool for porting.

  • 40 Replies
  • 10543 Views
*

Offline nafraf

  • *****
  • 1308
Re: New tool for porting.
« Reply #20 on: 13 / June / 2013, 20:59:27 »
Advertisements
philmoz, maybe it is better to use your original idea. Detection is not working right.  Tested with sx160is
Code: [Select]
code_gen 0xFF810000 gen_capt_seq.c PRIMARY.BIN  > correct.c
code_gen 0xFF810000 gen_capt_seq_add1.c PRIMARY.BIN  > add1.c      => only to show next instruction
code_gen 0xFF810000 gen_capt_seq_noend.c PRIMARY.BIN  > noend.c    => show error
Thanks
« Last Edit: 13 / June / 2013, 21:01:22 by nafraf »

*

Offline philmoz

  • *****
  • 3325
    • Photos
Re: New tool for porting.
« Reply #21 on: 13 / June / 2013, 21:10:35 »
philmoz, maybe it is better to use your original idea. Detection is not working right.  Tested with sx160is
Code: [Select]
code_gen 0xFF810000 gen_capt_seq.c PRIMARY.BIN  > correct.c
code_gen 0xFF810000 gen_capt_seq_add1.c PRIMARY.BIN  > add1.c      => only to show next instruction
code_gen 0xFF810000 gen_capt_seq_noend.c PRIMARY.BIN  > noend.c    => show error
Thanks

You still need the 'FW $' instructions to tell it to disassemble and output the rest of the function (up to the supplied or calculated length).

The only time you would not use this is if you have 'FW n' instructions that exactly match the length, or you end with '->FW'.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline philmoz

  • *****
  • 3325
    • Photos
Re: New tool for porting.
« Reply #22 on: 14 / June / 2013, 18:17:47 »
Updated source.
This version supports cameras with ALT_ROMBASEADDR (S110), and cameras that copy code to RAM (G15, S110 & SX50).

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline philmoz

  • *****
  • 3325
    • Photos
Re: New tool for porting.
« Reply #23 on: 15 / June / 2013, 19:46:44 »
New version attached.

This version follows unnecessary branches in sub_XXXXXXXX references to get to the actual code.

For example, if the firmware code is
Code: [Select]
    BL sub_AAAAAAAA        // instruction to disassemble
    ...
sub_AAAAAAAA:
    B  sub_BBBBBBBB
    ...
sub_BBBBBBBB:
the output is
Code: [Select]
    BL  sub_BBBBBBBB

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)


*

Offline srsa_4c

  • ******
  • 4416
Re: New tool for porting.
« Reply #24 on: 22 / June / 2013, 07:33:39 »
@philmoz

I'm still unable to make code_gen work on vx dumps (it does work on dryos ones). If it makes a difference, I'm still on 32bit linux, and I'm trying to run it in platform/{camera}/sub/{fw}. Previously it crashed with a segfault, now it exits with this message: Invalid firmware offset 0.. Guess this means something mandatory was not found. Can you give some hints about what's required to make it run (other than a dryos dump ;) )?

*

Offline philmoz

  • *****
  • 3325
    • Photos
Re: New tool for porting.
« Reply #25 on: 22 / June / 2013, 07:38:19 »
@philmoz

I'm still unable to make code_gen work on vx dumps (it does work on dryos ones). If it makes a difference, I'm still on 32bit linux, and I'm trying to run it in platform/{camera}/sub/{fw}. Previously it crashed with a segfault, now it exits with this message: Invalid firmware offset 0.. Guess this means something mandatory was not found. Can you give some hints about what's required to make it run (other than a dryos dump ;) )?

Sorry; but it's based on the finsig_dryos code - so it's not surprising it won't work.

Post the instructions files and which camera/firmware and I'll take a look.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4416
Re: New tool for porting.
« Reply #26 on: 22 / June / 2013, 07:47:40 »
Sorry; but it's based on the finsig_dryos code - so it's not surprising it won't work.

Post the instructions files and which camera/firmware and I'll take a look.
I used the s80 100g port with its dump, the instruction file to test was:
#FUNC start=0xFF88000C length=86 name=boot
FUNC sig=malloc length=86 name=something
ASM
FW $
ENDASM
ENDFUNC
I tried both FUNC lines, the address is a random one, just for test.

Command line was code_gen 0xff810000 test.txt PRIMARY.BIN
finsig_dryos has no such problems btw. Thx for looking into this.

*

Offline philmoz

  • *****
  • 3325
    • Photos
Re: New tool for porting.
« Reply #27 on: 22 / June / 2013, 09:06:52 »
Sorry; but it's based on the finsig_dryos code - so it's not surprising it won't work.

Post the instructions files and which camera/firmware and I'll take a look.
I used the s80 100g port with its dump, the instruction file to test was:
#FUNC start=0xFF88000C length=86 name=boot
FUNC sig=malloc length=86 name=something
ASM
FW $
ENDASM
ENDFUNC
I tried both FUNC lines, the address is a random one, just for test.

Command line was code_gen 0xff810000 test.txt PRIMARY.BIN
finsig_dryos has no such problems btw. Thx for looking into this.

0xFF88000C is in the middle of the copyright string - which it will try and disassemble and fail.

0xFF880054 works for me, as does the 'sig=malloc' version.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)


*

Offline srsa_4c

  • ******
  • 4416
Re: New tool for porting.
« Reply #28 on: 22 / June / 2013, 09:29:50 »
0xFF880054 works for me
And it happened again ...  :-[
I originally used another copy (directory tree) of the CHDK trunk, with symlinked dumps, but switched to a different one with a 0 sized .BIN, and I have not noticed the difference...
So yes, it does work, sorry about that...
In addition, it looks like I have to polish my chdk_dasm change a bit, as it produces wrong lines sometimes...

*

Online reyalp

  • ******
  • 13288
Re: New tool for porting.
« Reply #29 on: 12 / October / 2013, 20:59:26 »
I'm trying to use codegen on a long function that has a chunk of data in the middle (elph130 FF17D650 task_ComWireless). Since it's a task loop, I need the whole thing.

It seems like SKIP should skip over the data, but looking at the code, it looks like it still tries to disassemble it. If I've understood correctly, some of the data disassembles to a valid instruction with an invalid offset. With

edit: oops, there original code below had some arithmetic errors, :(  but they don't affect the result. Correct below.

Code: [Select]
FUNC sig=task_ComWireless name=task_ComWireless_my
ASM
FW 10
>>>
"LDR     R0, [SP,#4]\n"
"BL log_wireless_msg\n"
<<<
FW 135
SKIP 28
I get

Invalid firmware offset 2007437.
Source --> FUNC sig=task_ComWireless name=task_ComWireless_my

If I reduce skip to 6, it runs correctly. (edit, offset from old wrong values...)

I don't see any simple way to fix this in the codegen code.
« Last Edit: 12 / October / 2013, 22:34:46 by reyalp »
Don't forget what the H stands for.

 

Related Topics