Linux native flashing

Discussion of LibreDrive mode, compatible drives and firmwares
jedix
Posts: 1
Joined: Sun Jan 12, 2020 3:25 am

Linux native flashing

Post 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.
Jimminy
Posts: 1
Joined: Fri Jan 17, 2020 9:14 pm

Re: Linux native flashing

Post 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!
mike admin
Posts: 4075
Joined: Wed Nov 26, 2008 2:26 am
Contact:

Re: Linux native flashing

Post 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.
Coopervid
Posts: 1902
Joined: Tue Feb 19, 2019 10:32 pm

Re: Linux native flashing

Post 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....
mike admin
Posts: 4075
Joined: Wed Nov 26, 2008 2:26 am
Contact:

Re: Linux native flashing

Post 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
SamuriHL
Posts: 2324
Joined: Mon Jun 14, 2010 5:32 pm

Re: Linux native flashing

Post 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

Ikkeetnavn
Posts: 2
Joined: Mon Jan 27, 2020 4:24 pm

Re: Linux native flashing

Post by Ikkeetnavn »

This is great news. sdftool worked like a charm for me.
stigger
Posts: 4
Joined: Fri Oct 18, 2019 8:35 am

Re: Linux native flashing

Post 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
SamuriHL
Posts: 2324
Joined: Mon Jun 14, 2010 5:32 pm

Re: Linux native flashing

Post 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.
Ikkeetnavn
Posts: 2
Joined: Mon Jan 27, 2020 4:24 pm

Re: Linux native flashing

Post 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.
stigger
Posts: 4
Joined: Fri Oct 18, 2019 8:35 am

Re: Linux native flashing

Post 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!
robf2112
Posts: 4
Joined: Fri Jan 31, 2020 12:58 am

Re: Linux native flashing

Post 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
$
mike admin
Posts: 4075
Joined: Wed Nov 26, 2008 2:26 am
Contact:

Re: Linux native flashing

Post 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.
robf2112
Posts: 4
Joined: Fri Jan 31, 2020 12:58 am

Re: Linux native flashing

Post 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!
SamuriHL
Posts: 2324
Joined: Mon Jun 14, 2010 5:32 pm

Re: Linux native flashing

Post 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!
Post Reply