PDA

View Full Version : Modify flash in assembly



Bütyök
03-04-2004, 09:35 AM
Hi all!

Wich software can I write routines to Nokia flash file with?

The WinArm is read only, and I can modify flash by a hex editor. It is too complicated if I modify a relative jump.
Because of it I want to write any routines in assembly.
How can I do it?

Bütyök

danwood76
05-04-2004, 11:10 AM
The BLs are easy to edit in a hex editor
There are tools available but you can just as easily work them out for yourself :)

Devi = NAdr2 - NAdr1 - 4
THi = (Devi / 2) / &H800
TLo = (Devi - (THi * &H800 * 2)) / 2
THi = THi + 61440 'F000
TLo = TLo + 63488 'F800
TRes = (THi * &H10000) + TLo

(The above is thanks to nokdoc)

I did try to make a C prog for this but couldnt make a big enough variable to hold the answer!!
But it is just as easy to work it out ;)

regards,
Danny

Al
05-04-2004, 12:29 PM
@danwood76

void arm_bl( long from, long to, BYTE *data )
{
long offset;

offset = to - from - 4;
data[ 0 ] = (BYTE)( 0xF0 | (( offset >> 20 ) & 0x07 ));
data[ 1 ] = (BYTE)( offset >> 12 );
offset >>= 1;
data[ 2 ] = (BYTE)( 0xF8 | ( offset >> 8 ));
data[ 3 ] = (BYTE)offset;
}

danwood76
05-04-2004, 12:40 PM
Thanks!

But Im not sure how to use it :(
I am not very good with C and I thought it would be a nice challenge for me ;)

This is little source:


#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>

long add1, add2, thi, devi, tlo, thi2, tlo2, tres;

main()
{
main:
printf("Enter the Start Address: ");
scanf("%d", &add1);
printf("\nEnter the End address: ");
scanf("%d", &add2);
long int devi = add2 - add1 -4;
printf("\nDevi= %d", devi);
long int thi = devi /2 /0x800;
printf("\nThi= %d", thi);
long int tlo = (devi - (thi * 0x800 * 2)) / 2;
printf("\nTLo= %d", tlo);
unsigned long int thi2 = thi + 61440;
unsigned long int tlo2 = tlo + 63488;
printf("\nTHi= %d", thi2);
printf("\nTLo= %d", tlo2);
unsigned long int tres = (thi2 * 0x10000) + tlo2;
printf("\nDecimal Answer: %d", tres);
printf("\n");
system("PAUSE");
return 0;
}


thanks if you can sort out my problems
Danny :)

Al
05-04-2004, 01:57 PM
@danwood76

Try this code:


#include "stdio.h"

void arm_bl( long from, long to, unsigned char *data )
{
long offset;

offset = to - from - 4;
data[ 0 ] = (unsigned char)( 0xF0 | (( offset >> 20 ) & 0x07 ));
data[ 1 ] = (unsigned char)( offset >> 12 );
offset >>= 1;
data[ 2 ] = (unsigned char)( 0xF8 | ( offset >> 8 ));
data[ 3 ] = (unsigned char)offset;
}

int main( int argc, char* argv[] )
{
long int addr1, addr2, i;
unsigned char outdata[ 4 ];

printf( "Enter the Start Address (in HEX): 0x" );
scanf( "%x", &addr1 );
printf( "\nEnter the End address (in HEX): 0x" );
scanf( "%x", &addr2 );

arm_bl( addr1, addr2, outdata );

printf( "BL instruction (in HEX): " );
for( i = 0; i < 4; i++ )
printf( " %02X", outdata[ i ] );
printf( "\n" );

return 0;
}

danwood76
05-04-2004, 05:40 PM
Thanks Al

:):):)

That works perfectly

regards,
Danny

Bütyök
05-04-2004, 06:24 PM
Hi!

Thanx a lot!

By this method I made a little table in Excel. It works correctly. :-)

BR,
Bütyök



The BLs are easy to edit in a hex editor
There are tools available but you can just as easily work them out for yourself :)

Devi = NAdr2 - NAdr1 - 4
THi = (Devi / 2) / &H800
TLo = (Devi - (THi * &H800 * 2)) / 2
THi = THi + 61440 'F000
TLo = TLo + 63488 'F800
TRes = (THi * &H10000) + TLo

(The above is thanks to nokdoc)

I did try to make a C prog for this but couldnt make a big enough variable to hold the answer!!
But it is just as easy to work it out ;)

regards,
Danny

danwood76
05-04-2004, 06:42 PM
Here is my finnished SW with source code ;)

It is a little easier than the spreadsheet
Out of interest you are putting in decimal values or hex?

regards,
Danny

Thanks again to Al

Bütyök
05-04-2004, 06:54 PM
"Out of interest you are putting in decimal values or hex?"


In excel?

danwood76
05-04-2004, 07:02 PM
Yeah in excel

Otherwise you need to convert the values to decimal from hex?

Bütyök
05-04-2004, 08:33 PM
Yeah in excel

Otherwise you need to convert the values to decimal from hex?


Ah! Yes, of course.

In excel there is a converter called HEX2DEC, DEC2HEX.
I put datas in hex, it converts to dec, calculate result, and converts back to hex.
You have to use Analisys ToolPak.

BR,
Bütyök

mazon
06-04-2004, 05:52 AM
The above is for Bls to your own routines. Wat then do u guys used to write ur own routines?
Does this work ? ->writing code in assembly, compiling it to arm binary, then copy the binary with hex editor n inject into the flash. inside the flash use a BL to tat routine.

Or are there software will help you to do tat? ARMada ?

danwood76
06-04-2004, 11:40 AM
Ah! Yes, of course.

In excel there is a converter called HEX2DEC, DEC2HEX.
I put datas in hex, it converts to dec, calculate result, and converts back to hex.
You have to use Analisys ToolPak.

BR,
Bütyök

Cool :)

Did you try my tool?

regards,
Danny

danwood76
08-04-2004, 04:58 PM
This is my final version of the tool!
I got a little bit tired of having to type out the BL so I added in a little logger

It now creates a file called bl.txt it then stores the start address end address and the BL in a table style format :)

I found it easier than typing int the addresses in again if I lost the BL

regards,
Danny

hud_nash
10-04-2004, 06:02 AM
here some software from philippines

just download --> armtoolsV2 by th3_3lob at

http://groups.yahoo.com/group/hud_nash/
...
to moderator i cant upload the file..

Bütyök
13-04-2004, 07:06 PM
Did you try my tool?



Yes, I did.
It is very good!

I could modify some BL jumps in a 6110 flash with it.
It works fine!

BR,
Bütyök

danwood76
14-04-2004, 10:34 AM
to moderator i cant upload the file..

This could be for many reasons:
1 the file is too big
2 the file is the wrong type

although some users just cant upload

This is not the right place for this q
Post in 'report server problems' section of the forum

regards,
Danny

yak
14-04-2004, 10:46 PM
you can easily write directly into flash with assembly using ARMada by g3gg0.

Bütyök
20-04-2004, 07:02 PM
you can easily write directly into flash with assembly using ARMada by g3gg0.

How?
How can I use the ARMada?
Can you write an users manual?
:rolleyes:

danwood76
20-04-2004, 07:41 PM
If you have problems with armada click the help

but basically you can write a bit of code like:

PUSH { R1, R2, R3 }
MOV R1, R2
ADD R1, #6

etc

and ARMada will compile
if you put .hex at the start it will compile in hex and .gsc will do it in GSC :)

play around with it you will soon learn it ;)

regards,
Danny

Bütyök
20-04-2004, 08:10 PM
If you have problems with armada click the help

but basically you can write a bit of code like:

PUSH { R1, R2, R3 }
MOV R1, R2
ADD R1, #6

etc

and ARMada will compile
if you put .hex at the start it will compile in hex and .gsc will do it in GSC :)

play around with it you will soon learn it ;)

regards,
Danny


Thanx
Bütyök

NokDoc
20-04-2004, 08:27 PM
Hi,

Ps, it's not exact the same style as winarm.

PUSH R1, R2, R3, LR
MOV R1, R2
ADD R1, 6
POP R1, R2, R3, LR

NokDoc

danwood76
21-04-2004, 11:56 AM
Thanks Nokdoc :D

regards,
Danny