[Android Software/Hacking General [Developers Only]] amirhtc:
Before starting about fetching Stock ROM of TWG10 , maybe you ask ,what is TWG10 ? which Tablet is it ? ,so you can know and Find it from here :

Introduction of Datamini TWG10

.

So , we pay attention some introduction and requirements in some steps then considering to the main .

Using of Ubuntu has far better features and advantage respect to Windows to fetch the Stock ROM of any Android devices , So we use Ubuntu too.

First Step is to Install ADB and Fastboot for Ubuntu from

here

using Terminal of Ubuntu.

Second step is to root your device , Rooting will be released so many privileges that make us to fetch the Stock ROM of any Android Devices .

One of the common and famous way of rooting Android devices is booting TWRP recovery from fastboot and Flashing SuperSu, but when there is no TWRP recovery for your device , you can port and compile it for your device :

Porting TWRP From Source .

But always there is a final and better way to root your device which is so easy too ->

UNIVERSAL GUIDE for Rooting Any Android Device Manually !

which has worked and been tested on Intel Atom based processor devices .

<<Fetching Factory Imgs>> :

After installing the SU ,now we can access to Android partition scheme of TWG10 , just connect your device through its cable to your PC (Ubuntu) , hoping you have already made USB debugging on in Developer options , just open a new terminal and write

adb devices

, you should see Baytrail000... in the last line , now command in the terminal ,

adb shell

and then when it starts , you will see your phone code name ,shell@inet_phone_32:/$ ,it means now you can get controlled fully of your tablet , just type

su

and press Enter , the information of Android partition scheme is located in /dev/block/platform/dw_mmc/by-name such that , the dw_mmc for TWG10 is 808060F14:00 let's use

ls -l /dev/block/platform/808060F14:00/by-name

to find locations of , boot.img , system.img, recovery.img and so on(Factory imgs) you will see such below photo : ( you can save this info in your internal storage ,

ls -la /dev/block/platform/808060F14:00/by-name > sdcard/your selective name.txt

)

also by commanding cat /proc/partition in terminal , you find some info about your tablet partition too

[IMG="partition of your android"]https://i.imgur.com/Jbw2InT.png[/IMG]​

As you see ,you can find location of each img file in your device for example : boot.img is in /dev/block/mmcblk0p5 now its time to fetch them using

dd if=Directory of source of=Directory of Destination

for example :

dd if=/dev/block/mmcblk0p5 of=/sdcard/boot.img

sdcard is absolute location of your Internal storage :/storage/emulated/legancy.(Notice : NEVER TOUCH basic_data_partition , its data of your windows OS , NEVER TOUCH ESP , its location of your UEFI bios insyde software , NEVER TOUCH Microsoft_reserve_partition , the only img files that you need to dd is boot.img. fastboot.img (bootloader) , system.img, recovery.img ,config.img ,factory.img, these two contains vendor.img and radio.img related connectivity and WIFI)

[IMG="fetch"]https://i.imgur.com/Q72gfjb.png[/IMG]​

after fetching all imgs of stock ROM (Factory imgs) of TWG10 , its the time to pull them to your PC .

Just type exit and enter , write in the terminal ,

adb pull /sdcard/"img File" /" your selective Directory in your PC"

for example :

adb pull /sdcard/boot.img /home/amir/twg10_imgs

.

[IMG="pulling"]https://i.imgur.com/nbMTnlV.png[/IMG]​

Do not worry , if you cant fetch all factory images , you can download them from here :

Factory imgs of TWG10

But the important question is : why we need those factory imgs ? because when the Android OS gets damaged and its not booted up or in boot looping condition, we can survive it in below instruction :

Reviving TWG10 Android OS by Flashing Factory imgs via Fastboot:

open a new terminal in the directory which those factory images are there and placed and then write in the terminal :

adb reboot -bootloader

(we will boot to fastboot)

after restarting :

sudo fastboot devices

now we need to unlock bootloader for flashing

sudo fastboot oem unlock
sudo fastboot flashing unlock
sudo fastboot reboot bootloader

after restarting to bootloader ,you should press volume up to enter to fastboot

now its the time for erasing necessary partition, as we saw , ls -l /dev/block/platform/808060F14:00/by-name , shows the portions by name for example /dev/block/mmcblk0p5 is called boot .

​

so we use this code sudo fastboot erase 'partition by name'

sudo fastboot erase boot
sudo fastboot erase cache
sudo fastboot erase recovery
sudo fastboot erase date (userdata)
sudo fastboot erase system

now flashing 'partition by name'

sudo fastboot flash 'partition by name' 'img file association'

sudo fastboot flash boot boot.img
sudo fastboot flash fastboot fastboot.img (flashing bootloader)
sudo fastboot reboot bootloader (reboot to fastboot)
sudo fastboot flash recovery recovery.img
sudo fastboot flash system system.img
sudo fastboot flash config config.img (this is radio.img)
sudo fastboot flash factory factory.img (this is vendor.img)
sudo fastboot reboot

Congratulation ! your stock Android revived !

you can also download and install any

Android X86

on your TWG10 , you can make bootable flash memory using

Rufus

but its important to say , you should use GPT Partition scheme for UEFI in partition scheme and target system type , another important notice is : when your bootable flash memory gets ready , you should open your flash memory and go to /boot/grub and open grub.cfg by gedit and modify it , after root=/dev/ram0 you should "space" and type nomodeset vga=5785 for live , debug and installation and then save , otherwise it wont be booted into TWG10!.

By pressing ESC before going to any OS ,you can select the bootable flash memory in boot manager and enter to boot menu of android X86 , if you did not modify the grub.cfg , you can press E in boot menu of Android X86 installation and modify it ( type and add nomodeset vga=5785 after root=/dev/ram0) and press F10 , but because of the orientation of tablet is in horizontal , maybe its difficult to modify , so its better to modify it before booting the flash memory and its better to install Android X86 on a SD card or another flash memory , because 32 GB is not enough for 3 OSs!

Another notice is you should pay attention to above partition scheme in the time of Android X86 installation.

​

but when you booted up the Android X86 , nothing works , touch , rotation ,sound and ......

this is because of no one of Android Drivers is installed for TWG10 , so we pay attention to ->

<<Introduction of Android Device Drivers >>

lets your TWG10 is connected to your PC.

Android Device Drivers (modules) are C program in fact , they are kind of modules which will be added to kernel of Android OS and they load and unload in the time of demand , these C program files after compiling ,they convert to the files with extension .ko , these .ko Files are located in /lib/modules .

these ko files are taking care of Device functionality (how they perform and operate) and files of hardware devices( such HDMI , hard disk , sound , touchscreen , WIFI...) are located in /dev

you can see the files of hardware devices using these codes in a terminal :

adb shell
ls -l /dev/i2c-1

you will see

crw------- root root 89, 1 2017-11-11 01:02 i2c-1

if the first letter is C its character device , 89 is major number using for identify the driver (which module or .ko file is used for this device file) , after 89 , there is a ',' and then 1 its a minor number which is used to distinguish between devices with same driver ,

for example if we write

adb shell
ls -l /dev/i2c-2

you will see

crw------- root root 89, 2 2017-11-11 01:02 i2c-2

i2c-2 used same driver file (major number is same) but another device file (minor number different)

we have two type devices , block devices and character devices.

block devices have a buffer for a request so they can have best response , block devices takes input and gives output only , but character devices can takes so many inputs and give so many outputs .

to see blocks and character devices on your TWG10 , you can use below codes :

adb shell
cat proc/devices

to create a device file ,using this code :

open a terminal :

mknod dev/'device name' 'major number' 'minor number'

for example :

adb shell
mknod dev/i2c 89 3

In fact modules (device drivers ) and devices file (hardware) are connect to each other by major number .

You can pull modules which are control the functionality of devices (hardware) in your PC from the stock Android using ADB and Ubuntu Terminal :

just open a new Terminal , type :

adb devices
adb pull /lib/modules 'A directory in your PC"

​

now if you want to see these .ko files are about which Device Driver , just open a terminal in the directory that .ko files are type :

modinfo 'name of the ko file'

for example

modinfo 8723bs.ko

​

We can also see Device Drivers which are activated by using lsmod or cat /proc/modules :

open a new terminal and type :

adb shell
lsmode or cat/proc/modules

For adding a driver or module to the kernel ,

open a terminal in the directory of .ko file where you pulled them into your PC

adb push 'directory of modules(drivers) in the PC' /lib/modules
adb shell
modprobe 'the pushed file name'

for example :

adb push /home/amir/twg10_imgs/drivers /lib/modules
adb shell
modprobe 8723bs

also with insmod command , we can add a driver to the kernel , but its dependencies command , we should add other related driver(module) too.

for example

adb shell
insmod ./8723bs.ko

the story still has not be started , it will be continued !