Batch files to simplify s1fwx usage

Topics unrelated to a specific category.

Batch files to simplify s1fwx usage

Postby LKRaider » Fri Apr 14, 2006 11:43 pm

I've made some batch files that make it simple for me to work with the s1fwx tool, specially for unpacking a dumped firmware, creating the scripts and to repack it all together (after modification, for example).

I'll post the code here, since others may like to use it too.

To use them, copy the batch contents below to new text files and save them as I named below (important is to keep .bat extension).

Move both to a directory where you have a copy of the firmware you wish to work with, along with the s1fwx tool, and from a Command Prompt window, execute them by typing their names (eg. fwunpack or fwpack).
(Other idea is to put them on a folder that is in the system PATH, which allows you to call them from any directory then).

Also, typing /? after them (for example: fwunpack /?), will display a small help on general usage of the batch.

Here's the code:

fwunpack.bat
Code: Select all
@ECHO OFF
ECHO.

IF "%1"=="/?" GOTO HELP
IF "%1"=="" (
      IF EXIST dump.bin (SET FWDUMP=dump.bin) ELSE (
         ECHO Please specify a firmware file to use. && GOTO END
      )
)
IF EXIST %1 (SET FWDUMP=%1) ELSE (
      ECHO File not found. Check for typing errors. && GOTO END
)

ECHO Beggining extraction ...

IF NOT EXIST afi MD afi > NUL
IF NOT EXIST fwimage MD fwimage > NUL

CD afi
s1fwx x ..\%FWDUMP% > NUL
CD ..\fwimage
s1fwx x ..\afi\fwimage.fw > NUL
CD ..

ECHO.
ECHO Creating scripts ...
s1fwx s %FWDUMP% > %FWDUMP%_afi_script.txt
s1fwx s afi\fwimage.fw > %FWDUMP%_fw_script.txt

SET STRING1=PATH = ".\"
SET STRING2=PATH = ".\afi"
SET STRING3=%FWDUMP%_afi_script.txt
SET COUNT=1

:REPLACE
IF EXIST temp.txt DEL temp.txt > NUL
FOR /F "tokens=* delims=" %%L IN (%STRING3%) DO (
   IF "%%L"=="%STRING1%" (
      ECHO %STRING2%>>temp.txt
   ) ELSE (
      ECHO %%L>>temp.txt
   )
)
COPY /Y temp.txt %STRING3% > NUL && DEL temp.txt

SET STRING2=PATH = ".\fwimage"
SET STRING3=%FWDUMP%_fw_script.txt
IF "%COUNT%"=="1" SET COUNT=0 && GOTO REPLACE
GOTO END

:HELP
ECHO       --- fwUNPACK tool - by LKRaider ---
ECHO Automates unpacking a firmware file and generating the s1fwx scripts.
ECHO USAGE: fwunpack [ filename ]
ECHO If you don't specify a firmware filename, it will try to use 'dump.bin'

:END
SET FWDUMP=
@ECHO ON


And to pack:

fwpack.bat
Code: Select all
@ECHO OFF
ECHO.

IF "%1"=="/?" GOTO HELP
IF "%1"=="" (SET NEWFW=newfw.bin) ELSE (SET NEWFW=%1)

IF NOT EXIST *_script.txt ECHO No scripts found. Use the extract command first. && GOTO END
ECHO This will create a new Firware file from the scripts, and save it as '%NEWFW%'
ECHO Press a key to proceed or CTRL+C to quit
PAUSE > NUL
ECHO.

ECHO Creating new firmware file ...
FOR %%I IN (*_fw_script.txt) DO s1fwx a afi\fwimage.fw:fw < %%I > NUL
FOR %%I IN (*_afi_script.txt) DO s1fwx a %NEWFW%:afi < %%I > NUL
GOTO END

:HELP
ECHO       --- fwPACK tool - by LKRaider ---
ECHO Packs a firmware file based on the s1fwx scripts generated by fwunpack.
ECHO USAGE: fwpack [ filename ]
ECHO If you don't specify a filename, it will default to 'newfw.bin'

:END
SET NEWFW=
@ECHO ON

NOTE: if you add new files to your project, you'll have to edit the generated fw_script or afi_script to include them, as fwpack can't detect this by itself (yet ; ).

BTW, both are distributed under the LGPL, if anyone asks.

EDIT: Fixed fwunpack code.
Last edited by LKRaider on Tue Apr 18, 2006 1:21 am, edited 2 times in total.
My MP4 player specs:
[url=http://forum.s1mp3.org/viewtopic.php?t=648]Shuray Japan - 256 Mb Memory
HJT H85-20MTV - REV:0.2B - 2005.03-12-Z[/url]
User avatar
LKRaider
s3 poster
 
Posts: 71
Joined: Wed Nov 23, 2005 12:08 am
Location: Florianopolis, SC - Brasil

Postby wladston » Sat Apr 15, 2006 1:47 am

Nice very nice!!

Let's make a project for batch files for working with firmwares?

If anyone got any batch file, please, post it here!

I remember James once coded a few ... Also, DON'T forget to post the license you are applying to the code.

The more permissive the license you use the better.

LKRaider, is it possible to change the license to LGPL, at least ?
1GB Standard s1 mp3 player. (MP-482C MAIN V8)
1GB "mp4" s1mp3 player. Not remarked.
I DO __NOT__ reply to PM's. Send email instead. I won't be even notified for new PM's.
User avatar
wladston
Site Admin
Site Admin
 
Posts: 1721
Joined: Tue Aug 23, 2005 8:54 pm
Location: Belo Horizonte, MG - Brazil

Postby LKRaider » Sat Apr 15, 2006 2:53 am

wladston wrote:LKRaider, is it possible to change the license to LGPL, at least ?

Sure, don't see why not. Just changed it.
My MP4 player specs:
[url=http://forum.s1mp3.org/viewtopic.php?t=648]Shuray Japan - 256 Mb Memory
HJT H85-20MTV - REV:0.2B - 2005.03-12-Z[/url]
User avatar
LKRaider
s3 poster
 
Posts: 71
Joined: Wed Nov 23, 2005 12:08 am
Location: Florianopolis, SC - Brasil

Postby wladston » Sat Apr 15, 2006 3:38 am

oh - thanks very much! :)
1GB Standard s1 mp3 player. (MP-482C MAIN V8)
1GB "mp4" s1mp3 player. Not remarked.
I DO __NOT__ reply to PM's. Send email instead. I won't be even notified for new PM's.
User avatar
wladston
Site Admin
Site Admin
 
Posts: 1721
Joined: Tue Aug 23, 2005 8:54 pm
Location: Belo Horizonte, MG - Brazil

Postby wladston » Sat Apr 15, 2006 4:09 pm

guest11000,

cooll .. but, if they are LGPL, where are the sources?
1GB Standard s1 mp3 player. (MP-482C MAIN V8)
1GB "mp4" s1mp3 player. Not remarked.
I DO __NOT__ reply to PM's. Send email instead. I won't be even notified for new PM's.
User avatar
wladston
Site Admin
Site Admin
 
Posts: 1721
Joined: Tue Aug 23, 2005 8:54 pm
Location: Belo Horizonte, MG - Brazil

Postby wladston » Sat Apr 15, 2006 11:27 pm

oh - this is VERY nice! :)

how is it licensed ? I really hope it's opensource ....
1GB Standard s1 mp3 player. (MP-482C MAIN V8)
1GB "mp4" s1mp3 player. Not remarked.
I DO __NOT__ reply to PM's. Send email instead. I won't be even notified for new PM's.
User avatar
wladston
Site Admin
Site Admin
 
Posts: 1721
Joined: Tue Aug 23, 2005 8:54 pm
Location: Belo Horizonte, MG - Brazil

Postby wladston » Sat Apr 15, 2006 11:29 pm

I see you made it GNU, I hope you upload the sources soon ...
1GB Standard s1 mp3 player. (MP-482C MAIN V8)
1GB "mp4" s1mp3 player. Not remarked.
I DO __NOT__ reply to PM's. Send email instead. I won't be even notified for new PM's.
User avatar
wladston
Site Admin
Site Admin
 
Posts: 1721
Joined: Tue Aug 23, 2005 8:54 pm
Location: Belo Horizonte, MG - Brazil

Postby wladston » Sat Apr 15, 2006 11:34 pm

cool :)

if post the source I'm sure people will make LOTS of things with it! :)

Also ... I don't know if you mind, but ...

we plan to distribute this toguether with the s1fwx ... so .. maybe you could do a shorter and easier name ... Maybe only "Guest's Tools"
1GB Standard s1 mp3 player. (MP-482C MAIN V8)
1GB "mp4" s1mp3 player. Not remarked.
I DO __NOT__ reply to PM's. Send email instead. I won't be even notified for new PM's.
User avatar
wladston
Site Admin
Site Admin
 
Posts: 1721
Joined: Tue Aug 23, 2005 8:54 pm
Location: Belo Horizonte, MG - Brazil

Postby wladston » Sun Apr 16, 2006 8:26 pm

for sure, this is great!

A part of our users thought, will prefer batch files like LKRaider's one, that is easy to modofy and it's not an executable, people fear executables a bit ! :)

oh, and the installer still show the GPL license .. can you change that to LGPL?

And also, the anymaion is very cool, but ... can you provide a way to let uses sisable it ?

Also, I still can't see the source ...

if it's to become a real GUI, then we migh add a "root folder" option, a "path to s1fwx" option, and more complec taskes, such as "loading a firmware and showing it's info", "merge 2 firmwares" and so on ...

anyways, congratulations for the good work!

Also, I think you could place the buttons Inline, with a detailed description, such as "Extract Firmware image (FWIMAGE.FW) file" insread of "EX Fwimage"
1GB Standard s1 mp3 player. (MP-482C MAIN V8)
1GB "mp4" s1mp3 player. Not remarked.
I DO __NOT__ reply to PM's. Send email instead. I won't be even notified for new PM's.
User avatar
wladston
Site Admin
Site Admin
 
Posts: 1721
Joined: Tue Aug 23, 2005 8:54 pm
Location: Belo Horizonte, MG - Brazil

Postby LKRaider » Tue Apr 18, 2006 1:24 am

It looks great guest11000!

What language are you using for the programs?

Hmm, and where is the source?! You know, GPL requires it or we can sue you! :wink:


BTW, I just fixed my fwunpack batch code, it was missing an important line. If anyone is using it, please update.
My MP4 player specs:
[url=http://forum.s1mp3.org/viewtopic.php?t=648]Shuray Japan - 256 Mb Memory
HJT H85-20MTV - REV:0.2B - 2005.03-12-Z[/url]
User avatar
LKRaider
s3 poster
 
Posts: 71
Joined: Wed Nov 23, 2005 12:08 am
Location: Florianopolis, SC - Brasil

Postby JJ Fugazi » Tue Apr 18, 2006 7:13 am

I have made simple batch file
extract.bat
echo off

echo make script file
s1fwx s %1 >afi.jj

echo extract %1
s1fwx x %1

echo Generate script file
s1fwx s fwimage.fw >fw.jj

echo extract %1
s1fwx x fwimage.fw
------------------------------------

example : extract mp4-512.bin

make.bat

echo off

echo make fwimage.fw
s1fwx a fwimage.fw:fw < fw.jj

echo Make %1
s1fwx a %1:afi < afi.jj
---------------------------------------
example make mp4-512.bin
User avatar
JJ Fugazi
s3 poster
 
Posts: 54
Joined: Thu Feb 23, 2006 4:06 pm
Location: Balikpapan, Indonesia

Postby jerry77 » Thu Apr 20, 2006 7:23 am

I cant' download your tools. When I click "Click here to download" I back to top of site and nothing happen. I do something wrong?
User avatar
jerry77
s2 poster
 
Posts: 105
Joined: Thu Feb 09, 2006 9:51 pm
Location: Poland

Postby LKRaider » Thu Apr 20, 2006 6:54 pm

I really like the AutoIt thingie!

I'm developing a wizard tool to help on the process of using s1fwx, with the AutoIt script. Expect something soon. :)
My MP4 player specs:
[url=http://forum.s1mp3.org/viewtopic.php?t=648]Shuray Japan - 256 Mb Memory
HJT H85-20MTV - REV:0.2B - 2005.03-12-Z[/url]
User avatar
LKRaider
s3 poster
 
Posts: 71
Joined: Wed Nov 23, 2005 12:08 am
Location: Florianopolis, SC - Brasil

Postby LKRaider » Fri Apr 21, 2006 7:57 am

S1mp3 Tools v. 1.0 !

Screenies:
Image Image

It serves as a GUI for the main funtions of s1fwx. Try it and see how you like it!
Thanks goes to guest11000 for introducing the AutoIt GUI idea.

Download: S1mp3 Tools program [ sources ]


This program is released under the LGPL, as usual.
My MP4 player specs:
[url=http://forum.s1mp3.org/viewtopic.php?t=648]Shuray Japan - 256 Mb Memory
HJT H85-20MTV - REV:0.2B - 2005.03-12-Z[/url]
User avatar
LKRaider
s3 poster
 
Posts: 71
Joined: Wed Nov 23, 2005 12:08 am
Location: Florianopolis, SC - Brasil

Postby wladston » Fri Apr 21, 2006 7:24 pm

LKRaider,

Great program!

Congratulations for the efforts ... :)
1GB Standard s1 mp3 player. (MP-482C MAIN V8)
1GB "mp4" s1mp3 player. Not remarked.
I DO __NOT__ reply to PM's. Send email instead. I won't be even notified for new PM's.
User avatar
wladston
Site Admin
Site Admin
 
Posts: 1721
Joined: Tue Aug 23, 2005 8:54 pm
Location: Belo Horizonte, MG - Brazil

Next

Return to Miscellaneous Problems

Who is online

Users browsing this forum: No registered users and 1 guest



cron