2026年10月2日 星期五

UEFI LL#01 - Setup Build Environment (EDK II/stable202505 on Linux/Ubuntu-22.04 on Window11 x64)

Install WSL2 and Ubuntu-22.04
    > wsl --install -d Ubuntu-22.04




Download Container in guest Ubuntu-22.04
    REF: How to Develop With Containers · tianocore/tianocore.github.io Wiki
    REF: Package containers/ubuntu-22-dev
        $ sudo docker pull ghcr.io/tianocore/containers/ubuntu-22-dev:latest
            (latest is commit 6d71a30)


Download EDK II/stable202505
    $ cd ~
    $ git clone https://github.com/tianocore/edk2.git
    $ cd edk2
    $ git checkout -f edk2-stable202505 -b stable202505
    $ git submodule update --init

Launch Container for EDK II
    $ docker run -it \
       -v "${HOME}":"${HOME}" -e EDK2_DOCKER_USER_HOME="${HOME}" \
       --workdir ${HOME}/edk2 \
       ghcr.io/tianocore/containers/ubuntu-22-dev:latest /bin/bash
    -------------------------------------------------------------------------
    Error: 
        docker: permission denied while trying to connect to the Docker daemon socket         at unix:///var/run/docker.sock: Head "http://%2Fvar%2Frun%2Fdocker.sock/_ping":         dial unix /var/run/docker.sock: connect: permission denied
    Reason:    
        Docker daemon binds to a Unix socket owned by root. By default, other users can         only access it using sudo.

    Solution:
        #Create the docker group if it doesn't already exist 
            $ sudo groupadd docker 
        #Add your current user ($USER) to the docker group 
            $ sudo usermod -aG docker $USER 
        #To apply changes immediately without logging out
            $ newgrp docker

Build BaseTools
    $ source edksetup.sh
    $ make -C BaseTools

Build Module Development Elements of EDK II
    $ build -p MdeModulePkg/MdeModulePkg.dsc -t GCC5 -a X64 -b DEBUG
     (GCC5 is the default toolchain tag defined in container, not version)

Mount a FAT32 USB drive in WSL2
    Identify the drive letter in Windows Explorer (e.g., H:).
    Create a mount point in your WSL2 terminal:
        sudo mkdir /mnt/usb
    Mount the drive using the drvfs type
        sudo mount -t drvfs -o uid=$(id -u),gid=$(id -g),metadata H: /mnt/usb




yulin@DESKTOP-00KBDL6:~/tianocore$ pwd
/home/yulin/tianocore


yulin@DESKTOP-00KBDL6:~/tianocore$ cat ~/env_edk2
#!/bin/bash
docker run -it \
        -v "${HOME}":"${HOME}" -e EDK2_DOCKER_USER_HOME="${HOME}" \
        --workdir ${HOME} \
            ghcr.io/tianocore/containers/ubuntu-22-dev:latest /bin/bash


yulin@DESKTOP-00KBDL6:~/tianocore$ cat ~/.bashrc
...
#Yulin: setup build environment in the container for EDK2.
if [ "edk2" == "$USER" ]; then
    TC="$PWD/tianocore"
    VENDOR="Intel"
    EDK_EDK2="$TC/edk2"
    EDK_PLTF="$TC/edk2-platforms"
    EDK_NOSI="$TC/edk2-non-osi"
#   export PACKAGES_PATH=~/edk2:~/edk2-platforms:~/edk2-non-osi
    #Find name of the only folder inside ~/tianocore/edk2-platforms/Platform
    #Assuming ~/tianocore/edk2-platforms/Platform/Intel, PLATFORM=Intel
    export PACKAGES_PATH=$EDK_EDK2:$EDK_PLTF/Platform/$VENDOR:$EDK_PLTF/Silicon/$VENDOR:$EDK_NOSI
    cd $TC
    source $EDK_EDK2/edksetup.sh
    echo
    echo "Reminder: build -t GCC -a X64 -b DEBUG -p <Module>/<Module>.dsc"
    echo "Vendor: $VENDOR"
    echo
fi


yulin@DESKTOP-00KBDL6:~/tianocore$ ls -l
drwxr-xr-x 39 yulin yulin 4096 Dec 23 15:27 edk2
drwxr-xr-x  7 yulin yulin 4096 Jul 22 18:45 edk2-non-osi
drwxr-xr-x  8 yulin yulin 4096 Dec 23 15:00 edk2-platforms


edk2@5698206cd934:~/tianocore$ build -t GCC -a X64 -b DEBUG -p edk2-platforms/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc


edk2@5698206cd934:~/tianocore$ ls -l
drwxr-xr-x  5 edk2 edk2 4096 Dec 24 07:37 Build
drwxr-xr-x 39 edk2 edk2 4096 Dec 23 07:27 edk2
drwxr-xr-x  7 edk2 edk2 4096 Jul 22 10:45 edk2-non-osi
drwxr-xr-x  8 edk2 edk2 4096 Dec 23 07:00 edk2-platforms


Q: Does the ubuntu-22-dev found in https://github.com/tianocore/containers work in a Ubuntu24 host?

A by GoogleAI: 
Yes, the
ubuntu-22-dev container from the TianoCore repository is compatible with an Ubuntu 24.04 (Noble Numbat) host. 
In 2026, using older development containers on newer Ubuntu hosts is a common practice for maintaining stable EDK2 build environments. However, the TianoCore project has also released a native ubuntu-24-dev image specifically for newer systems. 

Compatibility & Usage
  • Docker/Podman Support: Since containers isolate the user-space, an Ubuntu 22.04-based image runs seamlessly on an Ubuntu 24.04 kernel via Docker or Podman.
  • Recommended Command: To use the Ubuntu 22 dev image while sharing your host's home directory (as intended by the TianoCore entry-point script), use:
      docker run -it \
        -v "${HOME}":"${HOME}" \
        -e EDK2_DOCKER_USER_HOME="${HOME}" \
        ghcr.io/tianocore/containers/ubuntu-22-dev:latest /bin/bash
    
  • KVM Acceleration: If you are using this container for the QEMU testing described in your previous scripts, ensure you pass the KVM device to the container by adding --device /dev/kvm to the run command. 

Why use ubuntu-22-dev vs ubuntu-24-dev?
  • Legacy Projects: If your specific UEFI project requires older versions of gcc or python-edk2-pytool-extensions that were validated on 22.04, stick with ubuntu-22-dev.
  • Newer Native Support: If you are starting a fresh project, the ubuntu-24-dev image (available at ghcr.io/tianocore/containers/ubuntu-24-dev:latest) provides updated toolchains natively matched to your host OS. 
Known Issues on Ubuntu 24.04 Hosts 
  • AppArmor: Ubuntu 24.04 introduced stricter AppArmor restrictions for unprivileged user namespaces. If you encounter permission errors when running the container, you may need to install the apparmor-utils package on your host or run the container with --security-opt apparmor=unconfined.


==========================================================
git clone https://github.com/tianocore/edk2.git
cd edk2
git submodule update --init
setx PYTHON_COMMAND "python"
setx NASM_PREFIX "C:\NASM"  NASM executable must be in system PATH variable

#Spawn a new CMD
call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -arch=x86 -host_arch=x64
edksetup.bat Rebuild

#Spawn a new CMD
chcp 65001
call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -arch=x64 -host_arch=x64 -vcvars_ver=14.29
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
edksetup.bat
build -p MdeModulePkg\MdeModulePkg.dsc -a X64 -b DEBUG -t VS2022 -n 1 -v
build -p MdeModulePkg\MdeModulePkg_CdcAcm.dsc -a X64 -b DEBUG -t VS2022 -n 1 -v
build -p MdeModulePkg\UT_UsbCdcAcm.dsc -a X64 -b DEBUG -t VS2022 -n 1 -v


Create a bootable USB disk of UEFI Shell

rufus-4.11.exe + UEFI-Shell-2.2-25H1-DEBUG.iso + GPT partition + BIOS Boot Device Priority

2026年8月10日 星期一

Install Linux on a Windows 11 laptop with Secure Boot disabled

 To install Linux on a Windows 11 laptop with Secure Boot disabled without corrupting your existing OS, follow these steps in order.

1. Prepare Windows 11

Before beginning, you must ensure Windows is in a state that allows another OS to share the hardware.

  • Backup Your Data: Always back up critical Windows files to an external drive or cloud storage before modifying partitions.
  • Disable Fast Startup: Windows 11's "Fast Startup" locks the hard drive, which can lead to data corruption when Linux tries to access it.
    • Open Control Panel > Hardware and Sound > Power Options > Choose what the power buttons do.
    • Click "Change settings that are currently unavailable" and uncheck Turn on fast startup.
  • Shrink the Windows Partition:
    • Right-click the Start button and select Disk Management.
    • Right-click your main (C:) drive and select Shrink Volume.
    • Enter the amount of space to shrink (at least 20-40 GB is recommended for Linux). This will leave "Unallocated Space" for your Linux installation. 

2. Create Bootable Linux Media 

  • Download the ISO for your chosen Linux distribution (e.g., Oracle Linux, Ubuntu, or Fedora).
  • Use a tool like Rufus to write the ISO to a USB drive (minimum 8GB).
  • Critical Setting: In Rufus, ensure Partition scheme is set to GPT and Target system is UEFI (non-CSM) to match Windows 11's boot mode. 

3. Configure UEFI/BIOS Settings 

  • Access BIOS: Restart your laptop and repeatedly press the BIOS key (usually F2, F12, Delete, or Esc depending on the manufacturer).
  • Verify Secure Boot: Confirm it is set to Disabled. On some laptops (like Acer), you may need to set a "Supervisor Password" in the Security tab before you can toggle this setting.
  • Disable Fast Boot: If your BIOS has a "Fast Boot" or "Quick Boot" option, disable it to ensure the USB drive is detected during startup. 

4. Install Linux

  • Boot from the USB drive by selecting it in the Boot Menu (often F12 or F10 during startup).
  • During installation, look for an option like "Install Alongside Windows Boot Manager".
    • Manual Method: If you choose "Something Else" (manual partitioning), select the Unallocated Space you created earlier. Create a Root (/) partition (ext4 format). The installer should automatically detect the existing EFI partition used by Windows and add the Linux bootloader (GRUB) there.
  • Bootloader: Ensure the bootloader is installed on the primary disk (e.g., /dev/nvme0n1 or /dev/sda), not a specific partition. This allows GRUB to show a menu where you can choose between Linux and Windows 11 at every startup. 

Troubleshooting

  • Windows Boots Directly: If the laptop boots straight to Windows after installation, you may need to go back into the BIOS and change the Boot Order to prioritize the "Linux" or "GRUB" entry over "Windows Boot Manager".
BitLocker: If Windows has BitLocker encryption enabled, you may be prompted for your BitLocker Recovery Key after changing BIOS settings. Ensure you have this key handy from your Microsoft Account before starting.

2026年2月26日 星期四

[HowTo] install old version of MS product

Reference : 如何下载MS Visual Studio2022 Community的以往版本 - zs李四 - 博客园

Taking "Visual Studio2022 Community" for example :

1. List revisions
    winget show --versions "Microsoft.VisualStudio.2022.Community"

2. Install a revision
    winget install -v 17.9.1 "Microsoft.VisualStudio.2022.Community"

3. Product-specific
    工具 > 取得工具與功能 > ...

2025年6月22日 星期日

Handbook - docker

FAQ


Q: How to customize a container's hostname?

A:

    docker run -dit -p ${SSH_PORT}:22 \

               -v /build:/work \

               -v /home/:/home/ \

               -v /nas:/HOUSE \

               -v /etc/profile.d:/etc/profile.d \

               -v /etc/group:/etc/group:ro \

               -v /etc/passwd:/etc/passwd:ro \

               -v /etc/shadow:/etc/shadow:ro \

               -h ${CONTAINER_HOSTNAME} \

               --name ${CONTAINER_NAME} ${IMAGE_ID} /bin/bash


Q: How to address 
"docker load --input image.tar.gz in Ubuntu 20.04 fails with no space left on device"
A1: Build docker image on top of host OS, ie. Ubuntu 20.04 in this case.
or
The current best practice is:
docker system prune
Note the output from this command prior to accepting the consequences:
WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all dangling images
  - all dangling build cache
Are you sure you want to continue? [y/N]
In other words, continuing with this command is permanent. Keep in mind that best practice is to treat stopped containers as ephemeral i.e. you should be designing your work with Docker to not keep these stopped containers around. You may want to consider using the --rm flag at runtime if you are not actively debugging your containers.
Make sure you read this answer, re: Volumes

You may also be interested in this answer, if docker system prune does not work for you.


--------------------------------------

# Check all the docker container/images

docker container ls

docker image ls

 

# Docker stop

docker stop <container id>

 

# Docker delete

docker rm <container id>

 

#Docker run

docker run <container id>

 

--------------------------------------

# Load docker image

docker load --input <xxx>.tar.gz

 

# change image name (optional)

docker image tag <docker image id> <image_name>:<version>

ex:

docker image tag b9ffda36b031 build_sa525m_env:latest

 

# run container

./execute.sh -p 1234 -n <container name> -I <container id>

 


2024年8月6日 星期二

ADB

Source Android Debug Bridge (adb)  |  Android Studio  |  Android Developers

  • A daemon (adbd), which runs commands on a device. The daemon runs as a background process on each device.
  • A server, which manages communication between the client and the daemon. The server runs as a background process on your development machine.
  • A client, which sends commands. The client runs on your development machine. You can invoke a client from a command-line terminal by issuing an adb command.

2024年8月4日 星期日

Experience of STM32

STM32MP157A-DK1

ST-LINK v2

    VCOM

        Baud = 115200bps