[Verizon HTC One (M8)] Sethnelson1:
Below is the OP, however, I changed something at the end to re-lock the boot-loader, forgot what, but this method below followed to a T worked for me.

Hey guys... was looking to return my phone to as close to stock as possible. And, couldn't find a tutorial on it... SO.. without further ado, this was the method I used (NONE of these tools were written or compiled by me, they were just FOUND and the method put together by me (or maybe someone else first... but I couldn't find a tut on it):

1) Flashed over my red developer warning and changed all flags to look like stock from (Not sure if there is a legit hboot floating around, I couldn't find one... And i didn't want to be left with a RE-LOCKED flag):

http://xdaforums.com/show....php?t=2710503

2) (THIS STEP IS UNNECESSARY)!!! Flashed Stock ROOTED ODEXed rom from (Mostly to make sure I had a stock boot look...not sure I needed to do this as I think the step 3 solves the boot image...but, wasn't sure):

http://xdaforums.com/show....php?t=2731893

3) Flashed RUU from: (I used Method 2 as my USB port is a little wonky on this phone... and Im sure there's a stock recovery floating around.. but I couldn't find it.. and to be honest, not entirely sure how to flash a recovery outside of fastboot... so, went with this method... )

http://xdaforums.com/show....php?t=2727831

(To note: On step 7 and 8 I got Bypass-S (I THINK, because I am S-OFF it skips the security patches there.. but not ENTIRELY positive)

This left me with my hboot showing UNLOCKED and S-OFF again...

SO, (again, as I didn't want it showing RE-LOCKED): re-flashed the nag:

http://xdaforums.com/show....php?t=2710503

This has left me essentially with what LOOKS like a stock phone...

To test.. I DID try to write my secureflag... ( fastboot oem writesecureflag 3) but, it returns with error:

roberts-mbp:~ robert$ fastboot oem writesecureflag 3

...

(bootloader) TZ_HTC_SVC_VERIFY_BOOTLOADER ret = 0

(bootloader) TZ_HTC_SVC_VERIFY_BOOTLOADER ret = 0

(bootloader) partition hboot signature error

(bootloader) writesecureflag: partitions siganture failed

OKAY [ 0.779s]

finished. total time: 0.779s

...could it be because HTC spelled signature "siganture" j/k...

anyway, this is as close to stock as I can get it post S-Off... hope this helps, anything else added or recommendations would be GREATLY appreciated...

Sending the phone back tomorrow (Friday, May 9).. so, if anyone jumps in before then, ill be happy to try things.

SWA2K4 suggested THIS fix to gain the ability to write the secure flag (I have not tested it as I no longer have the phone being returned. Feel free to comment and add suggestions if needed)

:

Your steps 1-2-3 are great but at the end ...You must first RE LOCK the bootloader before doing "fastboot oem writesecureflag 3" to put S-On

this is done by this method:

to LOCK your bootloader,enter the following:

adb devices

adb shell

su (if needed to get a # prompt)

echo -ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p2 bs=1 seek=33796

(i would very strongly recomend you copy/paste this)

exit

(exit a second time if you need to to get back to a normal > prompt)

adb reboot bootloader

verify you are now locked

Now! Reboot and unroot SU. Reboot to verify SU has been removed.

Reboot into fastboot.

Then you may do "fastboot oem writesecureflag 3" to put S-On

AND THERE YOU HAVE IT LOCKED BOOTLOADER AND S-ON! fully prepped to be returned or warranty exchanged!