[Community News] deepin adapts to Apple M1, what have we experienced? (Part 2)
poster avatar
2023-07-05 18:07

deepin adapts to Apple M1, what have we experienced? (Part 2)

适配apple M1 en.jpg

In the previous article, we introduced the selection and introduction of the deepin adaptation M1 solution, so that everyone can understand some of our ideas before adaptation. In this article, we mainly let everyone understand the problems we encountered during the adaptation process and how we solved them.

Three stages of adaptation

After our exploration and practice, the process of deepin adapting to M1 is roughly divided into the following three stages:

The first stage: the basic environment of deepin must be started on the M1, which is the smallest system without a desktop. In this way, the correctness of the adaptation work can be initially verified, and at the same time, it is convenient to carry out the next step of the adaptation work on the real machine.

The second stage: try to install the desktop environment on this minimal system, and carry out relevant adaptation work, so that it can start the DDE desktop, until finally providing a complete deepin desktop environment.

**The third stage: **Use the previous adaptation experience to adapt the U disk installation image, and realize the installation of the deepin system from the U disk.

So, after going through these three stages, what adaptation problems do we need to solve?

Adapt to the minimal deepin environment (command line only)

First of all, we package the M1 Debian rootfs package script based on m1-debian, first change the source of the debootstrap rootfs environment from debian to deepin, when this step is reached, it can be successfully started, and then try to replace the apt software source with the community source of deepin V23 , It was found that a kernel panic occurred during the system startup phase. After analyzing, searching and debugging, nothing came up.

After further analysis and debugging, finally, the community source was replaced with the CI source and rootfs was generated. At this time, the kernel panic error disappeared, and the deepin system was successfully entered. It is guessed that the relevant library version required by the upstream kernel is relatively high, and the software package of the current Community source cannot meet the requirements. Therefore, it is temporarily necessary to use the CI source for adaptation.

At this stage, except for Asahi-related packages that also need to use the m1-debian project, other debian sources can be replaced with deepin sources, as shown in the figure below, the smallest deepin system environment can already be started.

WeChat Image_20230705100102.jpg

Adapt to the basic DDE desktop environment

At the beginning, when installing the DDE desktop environment in the deepin environment, you will encounter the problem of mesa package dependency. Because the mesa package adapted to m1-debian is based on the Debian bookworm environment, it cannot be used directly in the deepin environment. Therefore, deepin-m1 SIG decided to repackage mesa in the deepin environment and build a warehouse independently. Because they have been independently built, so at this stage, the kernel, m1n1, uboot and other components are also repackaged and added to the warehouse.

After solving this problem, the next process will be smoother. Install the mesa and DDE desktop environments, and after solving some strange missing package dependencies, as shown in the figure below, we can start the familiar desktop environment.

WeChat Image_20230705100210.png

However, neither sound nor GPU hardware acceleration is available on top of the current desktop environment. During debugging, we have tried various kernel parameters and kernel compilation scripts of Asahi Linux distributions to customize and adapt the kernel. Unfortunately, judging from the current debugging results, our self-compiled kernel still cannot solve the above problems.

When using the kernel provided by the m1-debian project, although GPU hardware acceleration can be enabled, there will still be problems with the window management. For example, there are abnormal white blocks, and the dock displays abnormalities. This may require adaptation of the core and the window tube.

WeChat Image_20230705100324.png

This problem needs further analysis, debugging and investigation of the root cause of the problem. Currently, the project has been publicly released on github (https://github.com/deepin-community/deepin-m1), and interested developers can try it out. If you want to install directly on Mac, you can also use https://ci.deepin.com/repo/deepin/deepin-ports/deepin-m1/deepin.install script directly.

Adapt to the U disk installation image

Due to the special system boot structure of the Mac system, it is impossible to directly insert a U disk on the device like a normal computer, and then boot the installation program from the U disk to install the system. However, the m1-debian project provides a way to make a LiveCD on a USB stick, and this solution can be used stably. This provides us with an idea of adapting the U disk installation image and booting and installing the deepin system from the U disk.

First, to enable the installation disk system to be successfully started, we need to replace the common kernel of the installation image with the kernel specially made by the Asahi Linux project. This requires us to modify the image production process and package an image specially designed for Mac M1. Mainly in the kernel production stage, the used kernel repository and kernel package are replaced.

Then, during the adaptation process, I also encountered the problem that the installer failed to install the system. An error was reported that the execution of "05_context-menus_copy.job" failed. After investigation, it was found that this is an installation hook for a temporary solution. The current installation environment does not need it, but it leads to errors. Therefore, it is removed during the mirroring process. After that, the installation process can be completed normally.

We would like to solemnly remind everyone that this installation image is not perfect, and there are some limitations and risks that cannot be ignored. In order not to affect the original boot and system partition of the Mac, you can only use custom installation to install the deepin system in the free disk area. Full disk installation and advanced installation can severely damage the boot or Mac system and cause the machine not to work properly. In this case, the only way to restore it is to perform a wire brush with another Mac device. The installer has not blocked the full installation and advanced installation for the time being, so please choose carefully.

For the installation method, please refer to: https://sourl.cn/FjBRqg

Finally, thanks again to the developers of deepin-related SIGs, and thank you very much for your assistance and support in the Asahi Linux and m1-debian projects. It is precisely because of your contributions to open source and participation in open source that the deepin system will get better and better. thank you all!

deepin-m1 SIG entry:


Written by: Archie Meng

Reviewers: Zeno, dengtongxue, Yuma, JasonZhang

Reply Favorite View the author
All Replies
2023-07-08 17:44


Reply View the author