daliansky / XiaoMi-Pro-Hackintosh

XiaoMi NoteBook Pro Hackintosh
BSD Zero Clause License
2.61k stars 472 forks source link

Internal SD-CardReader working - Please help to improve it #465

Open ManuGithubSteam opened 4 years ago

ManuGithubSteam commented 4 years ago

Hi guys,

I managed to get the SD-Card-Reader working with a Vm Solution just like @Menchen did with the bluetooth. The SD-Card is ready for use under 10 seconds. Its only like a 40 mb download so its easy on your nvme.

There are some areas to improve on but it is working and please try it out and give feedback and comments here. I wrote a short guide here: https://github.com/ManuGithubSteam/XiaoMi-Pro-2018-HackintoshOC/wiki/2.0-Setup-SD-Card-Reader

Please test and report back any bugs.

Many thanks to @stevezhengshiqi and @MarFre22 for helping me getting my feet wet.

MarFre22 commented 4 years ago

@ManuGithubSteam , Good job! Hope it's possible to make it better ;)

stevezhengshiqi commented 4 years ago

Duplication of https://github.com/daliansky/XiaoMi-Pro-Hackintosh/issues/36

stevezhengshiqi commented 4 years ago

Sorry for misread. It’s different from #36. BTW, I agree with what menchen says

The sdcard workaround with vm is technically possible but not really worth due to power usage

Great work though.

Menchen commented 4 years ago

@ManuGithubSteam One tips for your vm setup, folder sharing is built-in VMware so you won't need sshfs and avoid ip/ssh password problem. You need to install open-vm-tools in your guest and add a folder in VMware sharing add to fstab: .host:/<host folder name> /mnt/hgfs fuse.vmhgfs-fuse allow_other 0 0 See more info here: https://askubuntu.com/questions/580319/enabling-shared-folders-with-open-vm-tools https://gist.github.com/darrenpmeyer/b69242a45197901f17bfe06e78f4dee3

One of the reasons I didn't do it is because mounting/unmounting is not "easy" for the normal user(finding a USB reader is faster for me or boot to Linux)... But I guess you can just shut down VM so Linux automounts for you...

Also, how is the performance compared to windows?

ManuGithubSteam commented 4 years ago

@ManuGithubSteam One tips for your vm setup, folder sharing is built-in VMware so you won't need sshfs and avoid ip/ssh password problem.

I did not want use folder shareing as in Linux it is just a folder (not sure about mac) and so it would not reflect as device in Finder. Also the vmware tools are quite "large" and would bloat the vm wich leads to more boot time.

You need to install open-vm-tools in your guest and add a folder in VMware sharing add to fstab: .host:/<host folder name> /mnt/hgfs fuse.vmhgfs-fuse allow_other 0 0 See more info here: https://askubuntu.com/questions/580319/enabling-shared-folders-with-open-vm-tools https://gist.github.com/darrenpmeyer/b69242a45197901f17bfe06e78f4dee3

I know but afaik a shared folder it not "mounted" so it would not feel like a SD-Card, Just like a folder. Also i would need a comand to unmount if im done writing to it. This is avoided with the sshfs solution.

One of the reasons I didn't do it is because mounting/unmounting is not "easy" for the normal user(finding a USB reader is faster for me or boot to Linux)... But I guess you can just shut down VM so Linux automounts for you...

For the easyness: If you can execute a script and unmount in finder you are done. Also the installation of a Hackintosh is also not "trivial" so the install i think is doable. Well i doubt it is faster to shutdown mac with all your windows. wait for the reboot in Windows or Linux, enter your password and then do the sd card stuff. For me at least this is way faster... Also till i find my usb-reader its easier to use the script. I also like integrated solutions if possible...

I plan to make a menulet for easy mounting later but would like some help in booting the vm faster and some specific mac problems with the mac umount command. etc.

Also, how is the performance compared to windows?

I did not do much testing and did not test the performance yet. Please try it out and test it.

For the Power hungry-ness. im not sure what you are refering to. Its a small vm with no load. The only thing that is running additionally is vmware fusion. I get that this is additional power useage but it is only used when you need it. It is like heliport in my mind. Just a second tool. How could we prove the power craziness of vmware fusion ? Also for me this is like maybe 10 min running when i use it for photos transfer..... It there a power meter of some sort to quantify the lost battery due to fusion running ?

Also i would like to know if my install guide works because i kinda wrote that from memory and did not acutally try it myself. Thanks so far.

Menchen commented 4 years ago

@ManuGithubSteam

I did not want use folder shareing as in Linux it is just a folder (not sure about mac) and so it would not reflect as device in Finder. Also the vmware tools are quite "large" and would bloat the vm wich leads to more boot time.

open-vm-tools https://www.archlinux.org/packages/community/x86_64/open-vm-tools/ It's only 3.2Mb... But I guess using sshfs would be more safe for umount....

For the easyness: If you can execute a script and unmount in finder you are done. Also the installation of a Hackintosh is also not "trivial" so the install i think is doable. Well i doubt it is faster to shutdown mac with all your windows. wait for the reboot in Windows or Linux, enter your password and then do the sd card stuff. For me at least this is way faster... Also till i find my usb-reader its easier to use the script. I also like integrated solutions if possible...

Tbh the only thing I use sd card for is flashing iso for my raspberry pi.... so I need raw access to the device...

I plan to make a menulet for easy mounting later but would like some help in booting the vm faster and some specific mac problems with the mac umount command. etc.

You can boot faster by not booting it ;D, you could just do a snapshot of the VM and it should load under 7s(my test iso was a 700mb iso so your can be faster depending on your ram usage)..... The cons of this approach are large disk usage (same as your guest ram).... but

For the Power hungry-ness. im not sure what you are refering to. Its a small vm with no load. The only thing that is running additionally is vmware fusion. I get that this is additional power useage but it is only used when you need it. It is like heliport in my mind. Just a second tool. How could we prove the power craziness of vmware fusion ? Also for me this is like maybe 10 min running when i use it for photos transfer..... It there a power meter of some sort to quantify the lost battery due to fusion running ?

My guess for power usage would be 15~30m.... because last time I disabled an unused USB port in SSDT it saved me 20m... and headless vm should be efficient because of the lack of CPU usage...

It's just not worth for me because I rarely use sd card nowadays...

Also, I would like to point out that you can get VM IP using vmrun getGuestIPAddress ~/.docker/machine/machines/myvm.vmx Hardcoding an IP is bad practice because someone can have that subnet used and it's just not portable...

ManuGithubSteam commented 4 years ago

@Menchen

Thanks for replying these are valid points..

@ManuGithubSteam

I did not want use folder shareing as in Linux it is just a folder (not sure about mac) and so it would not reflect as device in Finder. Also the vmware tools are quite "large" and would bloat the vm wich leads to more boot time.

open-vm-tools https://www.archlinux.org/packages/community/x86_64/open-vm-tools/ It's only 3.2Mb... But I guess using sshfs would be more safe for umount....

For tiny Core linux 3 mb is huge the iso is just 9 mb.... Yes umount was my main goal here.

For the easyness: If you can execute a script and unmount in finder you are done. Also the installation of a Hackintosh is also not "trivial" so the install i think is doable. Well i doubt it is faster to shutdown mac with all your windows. wait for the reboot in Windows or Linux, enter your password and then do the sd card stuff. For me at least this is way faster... Also till i find my usb-reader its easier to use the script. I also like integrated solutions if possible...

Tbh the only thing I use sd card for is flashing iso for my raspberry pi.... so I need raw access to the device...

Ok i see that problem here we would need a menu for flashing direct or passtrough with the finder. Will put it on the list...

I plan to make a menulet for easy mounting later but would like some help in booting the vm faster and some specific mac problems with the mac umount command. etc.

You can boot faster by not booting it ;D, you could just do a snapshot of the VM and it should load under 7s(my test iso was a 700mb iso so your can be faster depending on your ram usage)..... The cons of this approach are large disk usage (same as your guest ram).... but

I tried that and sometimes i was not able to use the card reader because i would have to use the gui to pass it trough. So for my initial version i did not do that. Also as you wrote. It did not feel that much faster... If you have more insight when it would patch it through and when not this would be most welcomed....

For the Power hungry-ness. im not sure what you are refering to. Its a small vm with no load. The only thing that is running additionally is vmware fusion. I get that this is additional power useage but it is only used when you need it. It is like heliport in my mind. Just a second tool. How could we prove the power craziness of vmware fusion ? Also for me this is like maybe 10 min running when i use it for photos transfer..... It there a power meter of some sort to quantify the lost battery due to fusion running ?

My guess for power usage would be 15~30m.... because last time I disabled an unused USB port in SSDT it saved me 20m... and headless vm should be efficient because of the lack of CPU usage...

Ok i see you point. @stevezhengshiqi Is it possible to activate it just when needed ? Like a command to cut power to the sd-reader and only power it when there is a need ? Also if possible could we detect the putting in of a sd-card ? Like the bit flip even if there is no driver to read it ? Then it could be much more automated....

It's just not worth for me because I rarely use sd card nowadays...

Also, I would like to point out that you can get VM IP using vmrun getGuestIPAddress ~/.docker/machine/machines/myvm.vmx Oh this is real good to know. Thank you very much...

Hardcoding an IP is bad practice because someone can have that subnet used and it's just not portable...

I know, first version an all. Hoping for colaborators....

ManuGithubSteam commented 4 years ago

Duplication of #36

36 did not get it to work as far as i read. Is that correct ?

stevezhengshiqi commented 4 years ago

No, it didn’t. I explained in the below comment there https://github.com/daliansky/XiaoMi-Pro-Hackintosh/issues/465#issuecomment-707203792 @ManuGithubSteam

Is it possible to activate it just when needed ?

Not that possible. The power for the USB port is distributed when startup.

stevezhengshiqi commented 4 years ago

I prefer a cleaner solution like IntelBluetoothFirmware that uploads the firmware and register power control for the bluetooth. Same approach can be done for SD Card reader, but needs tremendous work.

ManuGithubSteam commented 4 years ago

Unfortunately im not a programmer...

Thanks for letting me know. I will keep working in this so far till there is a better solution. Please test and give feedback :-)

Menchen commented 4 years ago

@ManuGithubSteam

For tiny Core linux 3 mb is huge the iso is just 9 mb.... Yes umount was my main goal here.

I was going to use tiny linux for BTFirmUploader too... But I was too lazy to build it myself and finishing the main program was the main focus..

Ok i see that problem here we would need a menu for flashing direct or passtrough with the finder. Will put it on the list...

You would want to use dd to flash... So I would recommend ssh pipe the ISO...

I tried that and sometimes i was not able to use the card reader because i would have to use the gui to pass it trough. So for my initial version i did not do that. Also as you wrote. It did not feel that much faster... If you have more insight when it would patch it through and when not this would be most welcomed....

In your vmx file usb.autoConnect.device0 = "vid:0x0bda pid:0x0129 autoclean:0" Try to delete autoclean or set it to 1

autoclean:1 - autoconnect if a device matches the pattern, removed if the VM is powered on and no device matches the pattern, removed if disconnected through the UI.
autoclean:0, no autoclean - autoconnect if a device matches the pattern, not removed if the VM is powered on and no device matches the pattern, not removed if disconnected through UI. Although the autoconnect entries are not removed, the device will not autoconnect again after the user disconnects the device using the UI for that session of the VM. The same device will autoconnect when the VM is restarted or when the device is physically unplugged and replugged into the same port on the host.

https://kb.vmware.com/s/article/1648

Also your vmx have many unnecessary value usb.vbluetooth.startConnected = "TRUE" I can see this interfering Bluetooth...

Also tbh I really think that a shared folder is the best because it fixes all your finder bugs...

Also i would need a comand to unmount if im done writing to it. This is avoided with the sshfs solution.

You just shutdown VM... systemctl does the umount for you...

ManuGithubSteam commented 4 years ago

@ManuGithubSteam

For tiny Core linux 3 mb is huge the iso is just 9 mb.... Yes umount was my main goal here.

I was going to use tiny linux for BTFirmUploader too... But I was too lazy to build it myself and finishing the main program was the main focus..

Feel free to use my tiny as a base :-)

Ok i see that problem here we would need a menu for flashing direct or passtrough with the finder. Will put it on the list...

You would want to use dd to flash... So I would recommend ssh pipe the ISO...

Yep thats exactly my thinking. I would need more RAM for that tho... Is RAM in Fusion prealocated ? Or uses it when it needs it ?

I tried that and sometimes i was not able to use the card reader because i would have to use the gui to pass it trough. So for my initial version i did not do that. Also as you wrote. It did not feel that much faster... If you have more insight when it would patch it through and when not this would be most welcomed....

In your vmx file usb.autoConnect.device0 = "vid:0x0bda pid:0x0129 autoclean:0" Try to delete autoclean or set it to 1

autoclean:1 - autoconnect if a device matches the pattern, removed if the VM is powered on and no device matches the pattern, removed if disconnected through the UI.
autoclean:0, no autoclean - autoconnect if a device matches the pattern, not removed if the VM is powered on and no device matches the pattern, not removed if disconnected through UI. Although the autoconnect entries are not removed, the device will not autoconnect again after the user disconnects the device using the UI for that session of the VM. The same device will autoconnect when the VM is restarted or when the device is physically unplugged and replugged into the same port on the host.

https://kb.vmware.com/s/article/1648

Not sure if this will work with resume as there is always talk from powerd on etc. Will have to test.

Also your vmx have many unnecessary value usb.vbluetooth.startConnected = "TRUE" I can see this interfering Bluetooth...

I see your point. Will look into it.

Also tbh I really think that a shared folder is the best because it fixes all your finder bugs...

Will have to test if it works as i want it.

Also i would need a comand to unmount if im done writing to it. This is avoided with the sshfs solution.

You just shutdown VM... systemctl does the umount for you...

Yes but you would need to issue a command in Mac to shutdown the vm or use the fusion gui for it. wich all means a action who is different than unmounting a SD-Card Volume.

I want to keep it as close as possible on the original workflow.

ManuGithubSteam commented 4 years ago

I just made an new release:

https://drive.google.com/u/0/uc?id=1H5wSauAWYqpnPqv4FChuZIoh7l3hS9Cd&export=download

Changes:

Challenges:

Please test :-)

ManuGithubSteam commented 4 years ago

New Version is out: https://drive.google.com/file/d/15fuFOqoqN30yRkp8eijphxtdUAoAyZ7I/view?usp=sharing

Changes: Bitbar has high quality icons Faster mounting due to remastering of tinycore linux boots now in 3 seconds. Whole process takes around 10 seconds

Challenges: Remaster TC kernel for even faster boot Start vmware with more niceness so it boots faster ?? start openssh sooner inside of tiny

Please test :-)

screenshots: https://github.com/ManuGithubSteam/XiaoMi-Pro-2018-HackintoshOC/blob/main/Screenshots/1.png https://github.com/ManuGithubSteam/XiaoMi-Pro-2018-HackintoshOC/blob/main/Screenshots/2.png https://github.com/ManuGithubSteam/XiaoMi-Pro-2018-HackintoshOC/blob/main/Screenshots/3.png

ManuGithubSteam commented 4 years ago

Even newer version is out: https://drive.google.com/file/d/1a5IsBR4m4FHzs80ZtFILHYJ3hsVvXcr2/view?usp=sharing

Changes:

Strange issue:

Comming soon to a SD-Card reader in your hackintosh: