Micro SD Card not able to format - filesystems

I have a Micro SD Card. I had used it in Samsung J5 Prime.
Once, I had rooted the Samsung device using TWRP and I had formatted this SD Card to get access to all files on it. The SD Card worked fine and still works fine in my Samsung J5 Prime, but other devices are not able to read/write it. Although my Laptop can access it (through a Card Reader 2.0), but it is write-protected, meaning that whenever I tried to create, modify, or even delete a file, it will restore back to the same state when I refresh the Windows Explorer.
Here is my SD Card Information:
FileSystem (as shown in the Properties menu): FAT32
Hardware Id: SCSI\DiskHGST_____HTS545050A7E680GR2O
Label: F:\
Image:
I tried Windows Format tools (chkdsk, diskpart, format option in context menu, in Computer Management), also tried 3rdParty Softwares (EaseUS Partition Master), but it didn't work.
No matter how many times I clean this SD card, all files reappear again.
Even I tried to format the SD Card on Samsung J5 Prime itself, but that too didn't work.
I need help to fix this. Any suggestions are much much appreciated!

If the SD-Card adapter (From microSD to SD) has the Lock protection enabled , please disable it.
This seems the solution, as you said
The SD Card worked fine and still works fine in my Samsung J5 Prime, but other devices are not able to read/write it. Although my Laptop can access it, but it is write-protected, meaning that whenever I tried to create, modify, or even delete a file, it will restore back to the same state when I refresh the Windows Explorer.

Related

Any hope for turning on phone Nokia 7.1 using adb

My power button died on my phone. Or got less and less responsive. Last time I was lucky that trying a long time I managed to start up my phone. Since then I kept my phone on perpetually or restarting it if that was required. However, now my phone just suddenly turned off out of nowhere. I tried to turn it on again but had no luck. I had previously turned on USB debugging since I thought that was enough to turn it on from the pc if it ever got turned off. Now it seems that was not enough as it shows up as unauthorized in adb (I never tried actually connecting, very stupid on my part). Is there any hope for turning my device on through adb.
Phone: Nokia 7.1
There are some questions on problems with unauthorized devices (ADB Android Device Unauthorized) but those seem to assume I can still turn on my phone to change settings. Is it impossible otherwise?
tldr; Here is a detailed list of instructions if you want to try your luck with fastboot. Your touchscreen and volume buttons must be functional for this to work.
Make sure the phone is turned off.
Press and hold the Volume Down button. Don't release it.
Plug in a USB charging cable
When the screen turns on and shows a message saying "Download" or "Fastboot" mode, release the Volume Down button.
Charge your phone like this for 2 minutes, to make sure it has enough charge.
Move your phone's USB cable and connect it to a PC.
Download the binary for fastboot.
Run fastboot continue.

Emulator for FAT32 mass storage with device file

I have a smart card-like miniSD card (it's a javacard as far as I know) and I'm trying to write an emulator for it that runs on Windows and Linux. The emulator will be used in software integration tests. I want to test my client without using the actual hardware for several reasons. One reason is that the actual hardware will change its state irreversibly and doesn't allow a complete reset.
The device implements a mass storage with FAT32 file system. It contains a special device file that is being used for controlling the device via simple file write/read operations.
My goal is that the virtual (emulated) device appears with drive letter in Windows explorer as soon as the emulator is started, similar as if someone would actually plug a real device.
I wonder if there is any open software project that I can base my program on? The biggest challenges are obviously
Providing/developing a "virtual" (USB/SD) mass storage device
Intercepting file I/O operations on the special device file.
According to Wikipedia, device files are a common way to simplify driver development. So I wondered if there are existing emulation solutions for driver developers. At least I couldn't find any.
Simulating the device file itself would be an important first step. My first idea was to use a normal file and to communicate with the client by actually reading/writing to this file while observing it. I.e. clear the file as soon as the client wrote to it and write the response into it. I don't know if this could work at all. One problem is that the client doesn't open the file with shared mode, so my simulator cannot access it at the same time.
Then I found out that QEMU can emulate mass storage, however it seems that it only supports image files and that probably doesn't allow device file.
Microsoft has some documentation about how to write USB device emulators and drivers but it seems to be very complex and I wondered if there is an exisiting solution that could be extended:
Finally there is the USB/IP Project, but I don't know if it is helpful as I still need to develop a driver and then I'm back at the complex MS documentation above.

Get system date/time via USB

Is there any way to query the system's date/time via USB without installing anything on the host computer (maybe just drivers)?
Background of the original problem
To avoid the XY problem, let me explain a bit what I'm trying to do.
To be able to calculate a TOTP token for 2FA (e.g. like Google Authenticator app does) you need a real-time clock to get the date and time.
There's this USB device called SC4-HSM that I would like to use to calculate the tokens, however it doesn't have a clock and according to the designer, adding one would be too expensive (needs a battery, etc).
Possible solution to the original problem
This device is going to be used with a computer which already has an RTC of course. Thus I had the idea of querying the system for a date/time which would solve the issue.
(Note: I know that a USB device can be connected to all sorts of hosts and not all hosts will have an RTC, but since this only needs to work with a computer, I thought this shouldn't be an issue)
My first thought was that there might be some USB device class that had date/time needs, so I could register the device as that type and then I would be able to query the values.
After going through the device class codes list (Internet Archive) nothing jumped at me as needing date/time. The closest ones I could think of were:
Content Security (PDF)
Personal Healthcare
Smart Card Class (PDF)
I skimmed the device class documents in the USB Implementers Forum but there's nothing in there even remotely related to date or time.
Current problem
Since the USB specs seemed like a dead-end I thought that maybe there was a way to write a very simple USB driver that can be auto-loaded when the device is plugged in to a computer and then we can use the driver to return the date/time when the device asks for it (unless I'm misunderstanding something).
I am now looking through USB development docs like Michael Opdenacker's Linux USB drivers course, I tried the Linux USB Project which seems dead. Skimmed through Driver Development for Windows NT just to get an idea, however I am still not able to figure out if this is possible or not, and how hard it would be.
I'm a complete beginner at this and maybe this is something out of my skill level, but I would like to figure out if will I need weird hacks and workarounds or is there a much more straightforward way to do this?
There seems to be little information about it or I'm just searching the wrong places.
Any ideas/or pointers on either solving the original problem or the current one?
system time is not necessarily the general time i.e. the 'atomic' time you get from a NTP server
the most obvious solution is to use autorun, this is also possible on linux but normally autorun is blocked so the user explicitely has to activate it
https://askubuntu.com/questions/642511/how-to-autorun-files-and-scripts-in-ubuntu-when-inserting-a-usb-stick-like-autor
the linux command to get the time is date or hwclock or if the computer is connected to the net it may be possible to contact a NTP server (if the firewall does not block this)
then your autorun program has to send the data to the SC4-HSM. i do not know what USB classes the SC4-HSM implements if it implements CDC ACM (virtual COM port) this is easy:
Unable to sync computer time to Arduino via USB
(something like echo "T$(($(date +%s)+60*60*$TZ_adjust))" >/dev/tty.usbmodemfa131)
maybe it is possible to access system time over the USB drivers, i do not know this right now

Waiting for all USB drives to load

I'm currently working with an application that has branching logic depending on whether a specific USB drive is inserted into the system. It does this by polling all drive letters looking for a path on the root of each drive.
This works for the majority of machines, but often, this application runs on startup with the USB drive inserted. In addition, some machines are especially slow and take a good minute to load the USB drive once Windows boots. In these machines, the code reaches the check of whether this drive exists, it can't find the drive, and the wrong branch is executed.
It could be possible to wait a minute before checking for drives. I'd prefer to have the application wait for all USB devices (or simply only mass storage devices) to load before checking for the drives, or something even more intelligent.
Unfortunately, I am unfamiliar with the methods needed to wait for all USB devices to finish loading, and with the DDK in general. I can see that it's possible to register a window for device notifications with GUID_DEVINTERFACE_USB_DEVICE, possibly receiving messages like DBT_DEVICEARRIVAL, DBT_DEVNODES_CHANGED, and WM_DEVICECHANGE, the distinctions of which I do not know.
However, the USB drive will likely be already inserted and detected (but not having a drive letter) into the system before the program executes. So, registering for all device change notifications would not make sense. If it's possible to identify devices which are inserted but not loaded (possibly with SetupDiEnumDeviceInterfaces) and then register for "loaded" notifications on all of those devices, it might work. I don't have familiarity with any this, so pointers (or sample code) would be extremely helpful.
I don't think you can.
The problem is that you're tyring to distinguish two cases which are not actually distinct, that of plugging in a USB device during boot and plugging it in later.
You have to know that USB is a protocol which requires a non-trivial amount of intelligence in the USB slave devices. They exchange multiple messages with the USB host (i.e. your OS). This exchange isn't instant. For instance, your USB harddrive will need to ask for permission to draw more than 100mA power. To answer that, the power drivers of Windows must be up and running. The phsyical disk can only spin up when the answer arrives.
So, there's a whole message sequence going on, and the drive letter shows up only fairly late. Windows must know how many partitions exist. So during this exchange, new devices are being created all the time.
When you enumerate devices while devices are actively being added, you're really asking for troubles. The SetupDiEnumDeviceInterfaces API doesn't operate on a snapshot (which we know because there's no Close method); you're asking for the N'th device until you get an "no more devices" error an you know N was to big. But when devices are still actively being added, N changes. And I don't see a guarantee that the list order is by age; devices might be added in the middle as well.
I don't think that getting notifications about drivers being installed for newly plugged-in devices would help you much. When you plug in the same device repeatedly, the drivers are usually installed only the first time.
Also, an USB flash drive, although physically looks like one compact device, is represented by at least three PnP devices by Windows: an USB mass storage device (represents the USB endpoint), a disk device (represents the physical disk inside the flash drive) and one or multiple Volume devices (each represents one volume = partition in your case). Drive letters may be assigned to the Volume devices.
What you can possibly do is monitoring the arrival and removal of Volume devices (RegisterDeviceNotification for GUID_DEVINTERFACE_VOLUME) and examining each volume device that arrives (I believe that Setup API allows you to track its "parents" to the USB stack).

HTC Evo 4G LTE not found in ADB

I am having a problem with adb not finding my evo 4g lte. I have USB debugging selected. The phone is updated to 3.17, so some of the options, like charge only/disk drive have changed (now i think my only options are HTC Sync and disk drive). I am using the most updated version of the Android SDK. I'm running a fully updated windows 7 box. I have tried all of my USB ports, adb kill-server/adb start-server. I even created an .ini file with the hex version of the device USB/VID id (based on the HTC Sync setting, the phone shows only as Android Phone in my windows device manager. I have not yet tried switching it to disk drive), and nothing has worked. The phone's bootloader is unlocked via htcdev, but is otherwise stock. And, oddly enough, my old evo 4g which is rooted and running CM9 can be found, so I think it's got to be something with the new phone, I am just not sure what. I've been researching this over the last few days and have tried everything I have found, all to no avail. Any advice would be greatly appreciated!
Internal port is faulty. Two terminals for charging ,two for data, the data one(s) may have fractured from.the board.

Resources