Page 1 of 3

Linux native flashing

Posted: Sun Jan 12, 2020 3:38 am
by jedix
Hello,

Sometime in 2018/07 I purchased a bluray drive WH16NS40 svc code: NS50 from Amazon which arrived with firmware 1.03 pre-installed. At the time of my research I believed (not sure if I was right or not) that I needed to have 1.02 for makemkv to be able to use this drive for reading my media. As someone who chooses the less easy paths, I run only Linux and so my search for a way to flash the drive only returned windows boot media. After researching what happens to create the firmware prior to uploading, I came up with this bash script which uses dd to create my own firmware modifier (the comments are from whatever literature I used):

Code: Select all

#!/bin/bash

#On the backup firmware (the dumped one) select hex range starting from 0x1E8000 offset to 0x1E84FF and copy it in the same range of the new firmware. (**)

#Do the same as point 3. but starting now from 0x1E9000 to the end of the file. (***)

#Save the new firmware (for example as TEST.BIN).

#You are now ready for flashing (or crossflashing) the new firmware (or a downgrade version).

BACKUP=$1
CLEAN=$2


BLOCK=256
SIG_CNT=$((0x500/$BLOCK))
SIG_POS=$((0x1E8000/$BLOCK))
CAL_POS=$((0x1E9000/$BLOCK))

DD=`which dd`
NEW_FW="new_fw.bin"

CMD="$DD status=progress conv=notrunc if=$BACKUP of=$NEW_FW bs=$BLOCK"

for i in $BACKUP $CLEAN; do
        if [ ! -f $i ]; then
                echo file $i Does not exist.
                exit
        fi
done

echo "Creating new file."
cp $CLEAN $NEW_FW

echo "Copying signature."
$CMD count=$SIG_CNT seek=$SIG_POS skip=$SIG_POS

echo "Copying calibration."
$CMD seek=$CAL_POS skip=$CAL_POS

echo "Done."
I then used the https://github.com/devilsclaw/flasher to both dump and upload my firmware.
My drive was successfully downgraded to 1.02 and I've had success reading my discs with makemkv.

I thought I'd post this but please note that my testing is a single drive on a single run quite a while back so if you want try this, you do so at your own risk and your drive may become a brick.

Re: Linux native flashing

Posted: Fri Jan 17, 2020 9:16 pm
by Jimminy
Hi!

Thanks for the posting! I'm a little new to Linux. Would you mind please posting a detailed how to for this subject? I'd greatly appreciate it!

Re: Linux native flashing

Posted: Sun Jan 26, 2020 8:37 pm
by mike admin
MakeMKV has builtin (non-advertized) flashing capability. It is yet not exactly one-click user-friendly, but if you are OK with using command-line and not doing something stupid just in case, it is a lot more safer and user-friendlier than devilsclaw flasher. Please (anyone) PM me for details if you would like to use and test it.

Re: Linux native flashing

Posted: Sun Jan 26, 2020 9:41 pm
by Coopervid
Interesting, mike. Does that also work with the Windows version and how would be the command line syntax to flash a drive? Can this be an option to flash besides the patched ASUS / LG flasher maybe as a batch file? I guess if -it only works with LG / ASUS drives. Let us know....

Re: Linux native flashing

Posted: Mon Jan 27, 2020 10:07 am
by mike admin
This works on all platforms via so-called "universal flash tool", also known as "sdftool". In a not so distant future this tool will be released as a standalone open-source tool, but for now it shares an executable with makemkv. Current makemkvcon has a "secret" command line argument - if the first command-line argument is "f" then istead of makemkv a sdftool is executed and the rest of command line is interpreted as a command line for sdftool. Just make a shell script named sdftool that calls "makemkvcon f $1 $2 $3 etc...", or just call "makemkvcon f arg1 arg2 arg3 etc..." directly

Note to everyone - if you do understand this concept, then read on. Otherwise this tool might be too unfriendly for you :)

Also, please read this post to understand the tool architecture and importance of SDF.bin - https://www.makemkv.com/forum/viewtopic ... 856#p72110

In order for the sdftool to work, you need the latest SDF.bin . The easiest way to get one - run MakeMKV and open any disc. Another way is to download the sdf.bin manually. Unlike MakeMKV, sdftool can not download anything - it only uses the SDF.bin that is already available. There are command line options to specify path and/or version of sdf.bin to use.

Having said all this, the usage is sort of obvious:

Code: Select all

sdftool --help
sdftool --list
sdftool -d /dev/sr0 help all
sdftool -d /dev/sr0 flash -i blabla.bin
sdftool -d /dev/sr0 --info

Re: Linux native flashing

Posted: Mon Jan 27, 2020 1:15 pm
by SamuriHL
Brilliant. I may have to give that a try later just to play with it. Thanks!

Sent from my SM-G975U using Tapatalk


Re: Linux native flashing

Posted: Mon Jan 27, 2020 4:30 pm
by Ikkeetnavn
This is great news. sdftool worked like a charm for me.

Re: Linux native flashing

Posted: Mon Jan 27, 2020 11:48 pm
by stigger
Tried, but it didn't work, unfortunately. Not sure why.

Code: Select all

[Identification SDF] Drive autodetect string:
mtk:19:59:JBC6:ASUS    :BC-12D2HT       3.01:WM00900:-

# ./makemkvcon  f -d /dev/sr0 -f /tmp/sdf_0000006a.bin -v flash -i /tmp/k/mk-firmware-pack-20191206/MK/ASUS/BC-12D2HT/ASUS-BC-12D2HT-3.11-WM00300-211902271319.bin
Loaded SDF.bin version 0x6a

Unknown command

Command produced error code 0x8fffffff

Re: Linux native flashing

Posted: Tue Jan 28, 2020 2:00 am
by SamuriHL
Yea I sent Mike a PM about this, but, when I tried just messing around with my BW-16D1HT earlier, I got the same error when trying to flash. Not sure what's going on with that.

EDIT: Actually looking much closer at your output, it's different than mine.

Re: Linux native flashing

Posted: Tue Jan 28, 2020 8:54 am
by Ikkeetnavn
stigger wrote:
Mon Jan 27, 2020 11:48 pm
Tried, but it didn't work, unfortunately. Not sure why.

Code: Select all

[Identification SDF] Drive autodetect string:
mtk:19:59:JBC6:ASUS    :BC-12D2HT       3.01:WM00900:-

# ./makemkvcon  f -d /dev/sr0 -f /tmp/sdf_0000006a.bin -v flash -i /tmp/k/mk-firmware-pack-20191206/MK/ASUS/BC-12D2HT/ASUS-BC-12D2HT-3.11-WM00300-211902271319.bin
Loaded SDF.bin version 0x6a

Unknown command

Command produced error code 0x8fffffff
I believe you just need to a minor adjustment to the command ­— "flash" is the command part which the console output describes as unknown. Calling it with "help all" will give the available commands and one small change was enough for my case.

Re: Linux native flashing

Posted: Tue Jan 28, 2020 10:47 pm
by stigger
Ikkeetnavn wrote:
Tue Jan 28, 2020 8:54 am
I believe you just need to a minor adjustment to the command ­— "flash" is the command part which the console output describes as unknown. Calling it with "help all" will give the available commands and one small change was enough for my case.
You are right, I got confused by mike's usage examples and the output of the "help" command. Thanks for the tip!

Re: Linux native flashing

Posted: Fri Jan 31, 2020 1:04 am
by robf2112
Linux user, trying to use sdftool functions, created this script:

Code: Select all

#!/bin/bash
exec makemkvcon f "$@"
Got these results... Expected? Should this work? Running as root.

Code: Select all

$ sdftool --version
LibDriveIo/SdfTool version: 2.01
$ sdftool -d /dev/sr0 --info | tail -3
[Identification SDF] Drive autodetect string:
mtk:19:59:JBC6:ASUS    :BC-12B1ST   b   3.01:W000900:-

$ sdftool -d /dev/sr0 flash -i ASUS-BC-12B1ST_b-3.11-WM00300-211902271321.bin

Unknown command

Command produced error code 0x8fffffff
$

Re: Linux native flashing

Posted: Fri Jan 31, 2020 3:29 pm
by mike admin
robf2112 wrote:
Fri Jan 31, 2020 1:04 am
Linux user, trying to use sdftool functions, created this script:
See earlier responses.
Some time, in a great wonderful future, sdftool (or, specifically MTK and pioneer modules) will have a "flash" command.
That command would accept flash image in any format, check it for correctness, and even fix the most obvious user mistakes. This time has not yet come. So for now you are stuck with another (more low-level) command, that just sends the raw firmware image to the drive. Use "help all" to get the details.

Re: Linux native flashing

Posted: Fri Jan 31, 2020 4:16 pm
by robf2112
mike admin wrote:
Fri Jan 31, 2020 3:29 pm
See earlier responses.
Some time, in a great wonderful future, sdftool (or, specifically MTK and pioneer modules) will have a "flash" command.
That command would accept flash image in any format, check it for correctness, and even fix the most obvious user mistakes. This time has not yet come. So for now you are stuck with another (more low-level) command, that just sends the raw firmware image to the drive. Use "help all" to get the details.
The "help all" was only showing a couple of dump variations.

Ok, carefully re-read, and checked...

Discovered that since I was doing this as root, and normally run makemkvcon as non-root, I did NOT have the latest SDF.bin available (different user, different home directory, therefore different config directory).

With latest SDF.bin (in _private_data.tar) copied from regular user's config dir, I get additional commands listed with "help all". Seems to have made the difference. Will give it a try...

Thanks, Mike!

Re: Linux native flashing

Posted: Sat Feb 01, 2020 4:12 pm
by SamuriHL
Just an FYI, I resolved my issues with Mike's help. Turns out trying to run it from a remote powershell prompt is not the best of ideas. LOL It will prompt you to type in yes or no before it flashes and in my case it wasn't waiting for the prompt before exiting with an error code. Once I resolved that issue the flash was flawless. I flashed the NS55 1.04 MK firmware and then flashed back to my BW-16D1HT 3.10 MK firmware with no issues. Very nice tool!