Download all debug symbols for Win10

Download app symbols,

1
2
3
4
set SYMURL=SRV*C:\MySymbols\*http://msdl.microsoft.com/download/symbols
#symchk /om c:\MySymbols\app_manifest.txt /ie explorer.exe
#symchk /im c:\MySymbols\app_manifest.txt /s %SYMURL%
symchk /r /ie explorer.exe /s %SYMURL%

Download kernel symbols,

1
symchk /r c:\windows\system32\ntoskrnl.exe /s %SYMURL%

Setup symbols path for WinDbg and IDA in console with Administrator privilege,

1
2
setx /m _NT_SYMBOL_PATH SRV*c:\\MySymbols*http://msdl.microsoft.com/download/symbols/
#.

ps. SymChk is in WinDbg tools.

refer to:
https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/using-a-manifest-file-with-symchk
https://blog.csdn.net/ziwei960319/article/details/122212998
https://www.cnblogs.com/antigao/p/4584034.html

Recover Fedora after EFI partition is deleted by shaking hand

Make a Fedora live USB stick, plug it in the pc and power up, when grub menu appears, type ctrl + e, using tab key find the real path when editing,

linux (hd2,gpt3)/boot/vmlinuz-5.16.12-200.fc35.x86_64 root=/dev/sda3 ro rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1
initrd (hd2,gpt3)/boot/initramfs-5.16.12-200.fc35.x86_64.img

press ctrl + x to boot.

If encounter

Cannot open access to console, the root account is locked.

It means the password of root is not set so far,

Reboot to Fedora live environment,

# /dev/sda3 is the root partition.
mkdir /tmp/sda3
mount /dev/sda3 /tmp/sda3
cd /tmp/sda3
mount -o bind /dev ./dev
mount -t proc proc ./proc
mount -t sysfs sys ./sys
chroot .
passwd root

Now we have set up root password, then retry previous step to boot in local Fedora.

sudo su

# For security, Fedora coder disables directly building loader files in EFI partition.
# we can not invoke like this: grub2-install /dev/sda

dnf reinstall grub2-efi-x64 shim-x64
dnf install grub2-efi-x64-modules

# for how to register startup item in EFI NVRAM, get it from
#grep efibootmgr /var/log/anaconda/storage.log

# we make /dev/sda1 as EFI partition.
# -c = create
# -d = disk
# -p = EFI partition number, start from 1
# -l = loader path
efibootmgr -c -w -L Fedora -d /dev/sda -p 1 -l \EFI\fedora\shimx64.efi

refer to:
https://bugzilla.redhat.com/show_bug.cgi?id=1917213

Burn iso to USB stick for Windows installation

  • Rufus, released only in Windows.

    https://rufus.ie/en/
    https://github.com/pbatard/rufus

  • WoeUSB, can run in Linux.

    1
    2
    3
    
    dnf install WoeUSB
    # /dev/sdd is the u-disk
    woeusb --device /path/to/cn_windows_10_enterprise_ltsc_2019_x64_dvd_9c09ff24.iso /dev/sdd

Install VMWare Player in Fedora

After

1
dnf install kernel-headers kernel-devel

we still failed building kernel modules for VMWare Player in fedora,

1
vm_basic_defs.h:54:12: fatal error: stddef.h: No such file or directory

A solution is

1
2
3
4
# e.g. current kernel version is 5.16.12-200.fc35.x86_64
cd /usr/src/kernel/5.16.12-200.fc35.x86_64/include
ln -s linux/stddef.h stddef.h
ln -s linux/stdarg.h stdarg.h

refer to:
https://stackoverflow.com/questions/54480765/how-can-i-solve-stdarg-h-no-such-file-or-directory-while-compiling-out-of-tree-l

Change grub2 default startup item in Fedora

Confirm our OS is in BIOS or EFI,

1
2
3
4
# in BIOS system
GRUB_CFG=/boot/grub2/grub.cfg
# in EFI system
GRUB_CFG=/boot/efi/EFI/fedora/grub.cfg

Then lookup the booting item id we want to set as default.

If we only want to switch default between Linux kernels,

1
grubby --info ALL

Else if we want to change default booting item to Windows,

1
cat $GRUB_CFG | grep Windows

Read the output, we will find the item, e.g. corresponding to the name, the id is "e528434f2b3e4d7c97d97aa4aabb976e-5.16.7", write it in /etc/default/grub

1
2
#GRUB_DEFAULT=saved
GRUB_DEFAULT=e528434f2b3e4d7c97d97aa4aabb976e-5.16.7

Finally update grub,

1
2
grub2-mkconfig -o $GRUB_CFG
#.

Reboot to see the change.

And in Ubuntu, how to make grub2 remember last choice?

sudo vi /etc/default/grub
	GRUB_DEFAULT=saved
	GRUB_SAVEDEFAULT=true
sudo update-grub

refer to:
https://docs.fedoraproject.org/en-US/fedora/f35/system-administrators-guide/kernel-module-driver-configuration/Working_with_the_GRUB_2_Boot_Loader/

Fedora 21 改变启动顺序以及grub2 配置技巧


https://askubuntu.com/questions/148662/how-to-get-grub2-to-remember-last-choice

Directories in Win10

Not only one Startup directory,

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
C:\Users\euhat\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Themes downloaded from Windows Store,

C:\Users\euhat\AppData\Local\Microsoft\Windows\Themes

Linux subsystem Ubuntu,

C:\Users\euhat\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_xxxx\LocalState\rootfs

Need to clean,

C:\ProgramData\Package Cache
Control Panel\All Control Panel Items\Administrative Tools\Task Scheduler\Task Scheduler Library\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser

refer to:
https://blog.csdn.net/weixin_48160438/article/details/113413048

CreateTexture2D E_INVALIDARG

  1. Ensure "Graphics Tools" installed.

    Go to the Settings panel, under System, Apps & features, Manage optional Features, Add a feature, and then look for "Graphics Tools".

  2. Enable the debug layer by code,

    1
    2
    3
    4
    5
    6
    
    D3D11CreateDevice(
    	nullptr,
    	D3D_DRIVER_TYPE_HARDWARE,
    	nullptr,
    	XXX | D3D11_CREATE_DEVICE_DEBUG, // add here!
    	...);

    or in Visual Studio, on the main menu, choose Debug, Graphics, setup in DirectX Control Panel.

  3. Restart debug session. And after CreateTexture2D returns E_INVALIDARG, there will be debug informations in VS IDE Output Panel, each one of which begins with like "D3D11 ERROR".

refer to:
https://docs.microsoft.com/en-us/visualstudio/debugger/graphics/getting-started-with-visual-studio-graphics-diagnostics
https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-layers
https://stackoverflow.com/questions/53569263/directx-11-id3ddevicecreatetexture2d-with-initial-data-fail
https://blog.rthand.com/capture-directx-10-11-debug-output-to-visual-studio/
https://article.itxueyuan.com/dwlpL
https://walbourn.github.io/

Spi protocol memo

drivers/spi/spi.c

1
2
3
4
5
6
7
8
9
spi_write_then_read
 __spi_sync
 
spi_transfer_one_message
 spi_set_cs
 stm32_spi_transfer_one
 
 rspi_dma_transfer
 rspi_pio_transfer

SPI: Serial Peripheral Interface
CS(SS): Chip Select
SCLK: Serial Clock
PTP: Precise Time Protocol

refer to:
https://blog.csdn.net/faihung/article/details/81839825

Minimize memory usage in win10

Remove all apps,

1
#Get-AppxPackage -AllUsers | Remove-AppxPackage

To restore,

dism.exe /online /cleanup-image /scanhealth
dism.exe /online /cleanup-image /restorehealth
dism.exe /online /cleanup-image /startcomponentcleanup
sfc /scannow
 
Get-AppXPackage WindowsStore -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}

Strip off HyperV,

bcdedit /set hypervisorlaunchtype off

Disable realtime protection of Windows Defender, or completely shut it down,

gpedit.msc
	Computer Configuration
		Administrative Templates
			Windows Components
				Microsoft Defender Antivirus
					Turn off Microsoft Defender Antivirus
						Enabled

Turn off Windows Update, from https://blog.csdn.net/milaoshu1020/article/details/115062811

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
' switch_win_update_v3.vbs
Const usosvc_reg = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usosvc"
Set fso = createobject("scripting.filesystemobject")
Set shell = createobject("wscript.shell")
curdir = fso.getparentfoldername(wscript.scriptfullname)
 
If wscript.arguments.count = 0 Then
	Set sh = createobject("shell.application")
	sh.shellexecute wscript.fullname,"""" & wscript.scriptfullname & """ -admin",,"runas"
ElseIf wscript.arguments.count = 1 And wscript.arguments(0) = "-admin" Then
	run
Else
	msgbox "Argument error!"
End If
 
Sub Run()
	Do
		ret = inputbox("0: Turn off Win10 Update;" & vbcrlf & _
						"1: Turn on Win10 Update;" & vbcrlf & _
						vbcrlf & _
						"Input:", "Switch Win10 Update v3","0")
		Select Case ret
		Case "0"
			retnum = shell.run("sc.exe stop usosvc",0,True)
			shell.regwrite usosvc_reg & "\WOW64",&H14c,"REG_DWORD"
			msgbox "Turned Win10 Update off!",vbexclamation
			Exit Do
		Case "1"
			shell.regdelete usosvc_reg & "\WOW64"
			retnum = shell.run("sc.exe start usosvc",0,True)
			msgbox "Turned Win10 Update on!",vbexclamation
			Exit Do
		Case ""
			Exit Do
		Case Else
			msgbox "Input mismatch!",vbcritical
		End Select
	Loop
End Sub

After doing those things, in a machine with 8G memory and an SSD, we can play a 4G memory allocated Win10 LTSC 2019 vmware guest and a 2G ubuntu20 one in a silky manner.

refer to:
http://www.xitongcheng.com/jiaocheng/win10_article_42055.html
https://www.bilibili.com/read/cv4183745