From 79070d8c9561ce105d67257d418847616510721e Mon Sep 17 00:00:00 2001 From: Nascs Fang Date: Mon, 14 Oct 2024 17:58:52 +0800 Subject: [PATCH 01/14] feat: add a way to add a customized logo Signed-off-by: Nascs Fang --- docs/common/dev/_custom_logo.mdx | 74 +++++++++++++++++++ .../current/common/dev/_custom_logo.mdx | 74 +++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 docs/common/dev/_custom_logo.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx diff --git a/docs/common/dev/_custom_logo.mdx b/docs/common/dev/_custom_logo.mdx new file mode 100644 index 000000000..1edc027eb --- /dev/null +++ b/docs/common/dev/_custom_logo.mdx @@ -0,0 +1,74 @@ +## 定制 Logo + +### 确认 U-boot 是否是 rknext + +### 准备一张或者两张图片 + +### 将图片转为 .bmp 格式 + +1. 安装所需要的库 + +```bash +pip install Pillow +``` + +2. 新建一个 convert.py 的文件, 将以下内容保存到 convert.py 中 + +
+ + convert.py + +```py + +from PIL import Image +import sys + +class BMPImageInfo: + def __init__(self, image_path): + self.image_path = image_path + + def get_image_info(self): + with Image.open(self.image_path) as img: + + width, height = img.size + + total_pixels = width * height + return width, height, total_pixels + +def main(image_file): + image_info = BMPImageInfo(image_file) + width, height, total_pixels = image_info.get_image_info() + print(f"Image Width: {width} pixels") + print(f"Image Height: {height} pixels") + print(f"Total Pixels: {total_pixels}") + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("Usage: python3 get_bmp_info.py ") + else: + main(sys.argv[1]) + +``` + +
+ +3. 将图片转为 .bmp 格式 + +```bash +python3 pic1.jpg logo.bmp +python3 pic1.jpg logo_kernel.bmp +``` + +### 将以上两张 bmp 图片保存到 config 分区 + +```bash +sudo mount /dev/mmcblk0p1 /mnt/ +sudo cp logo.bmp /mnt/ +sudo cp logo_kernel.bmp /mnt/ +sudo sync /mnt +sudo umount /mnt +``` + +### 重启系统 + +连接 HDMI 后,系统重新启动,HDMI 将显示刚设定的 logo,直至桌面出现。 diff --git a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx new file mode 100644 index 000000000..2b24bf9c4 --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx @@ -0,0 +1,74 @@ +## Customize Logo + +### Verify that U-boot is rknext + +### Prepare one or two images + +### Convert the image to .bmp format + +1. Install the required libraries + +```bash +pip install Pillow +``` + +2. Create a new convert.py file and save the following to convert.py + +
+ + convert.py + +```py + +from PIL import Image +import sys + +class BMPImageInfo: + def __init__(self, image_path): + self.image_path = image_path + + def get_image_info(self): + with Image.open(self.image_path) as img: + + width, height = img.size + + total_pixels = width * height + return width, height, total_pixels + +def main(image_file): + image_info = BMPImageInfo(image_file) + width, height, total_pixels = image_info.get_image_info() + print(f"Image Width: {width} pixels") + print(f"Image Height: {height} pixels") + print(f"Total Pixels: {total_pixels}") + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("Usage: python3 get_bmp_info.py ") + else: + main(sys.argv[1]) + +``` + +
+ +3. Converting images to .bmp format + +```bash +python3 pic1.jpg logo.bmp +python3 pic1.jpg logo_kernel.bmp +``` + +### Save the above two bmp images to the config partition + +```bash +sudo mount /dev/mmcblk0p1 /mnt/ +sudo cp logo.bmp /mnt/ +sudo cp logo_kernel.bmp /mnt/ +sudo sync /mnt +sudo umount /mnt +``` + +### Reboot System + +After connecting the HDMI, the system will reboot and the HDMI will display the logo you just set until the desktop appears. From b4ed847a2861098b6245487aa4bf19fc55a660d8 Mon Sep 17 00:00:00 2001 From: Nascs Fang Date: Mon, 14 Oct 2024 18:09:57 +0800 Subject: [PATCH 02/14] feat: port customed logo to 3a Signed-off-by: Nascs Fang --- docs/rock3/rock3a/low-level-dev/custom-logo.md | 9 +++++++++ .../current/rock3/rock3a/low-level-dev/custom-logo.md | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 docs/rock3/rock3a/low-level-dev/custom-logo.md create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md diff --git a/docs/rock3/rock3a/low-level-dev/custom-logo.md b/docs/rock3/rock3a/low-level-dev/custom-logo.md new file mode 100644 index 000000000..c946ec96a --- /dev/null +++ b/docs/rock3/rock3a/low-level-dev/custom-logo.md @@ -0,0 +1,9 @@ +--- +sidebar_position: 8 +--- + +import LOGO from '../../../common/dev/\_custom_logo.mdx'; + +# 定制 Logo + + diff --git a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md new file mode 100644 index 000000000..20178dc07 --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md @@ -0,0 +1,9 @@ +--- +sidebar_position: 8 +--- + +import LOGO from '../../../common/dev/\_custom_logo.mdx'; + +# Customized Logo + + From 89512030069230c19b1ec01dbc5ad7a836d2f7dc Mon Sep 17 00:00:00 2001 From: Nascs Fang Date: Mon, 14 Oct 2024 18:12:29 +0800 Subject: [PATCH 03/14] feat: port customed logo to 3b Signed-off-by: Nascs Fang --- docs/rock3/rock3b/low-level-dev/custom-logo.md | 9 +++++++++ .../current/rock3/rock3b/low-level-dev/custom-logo.md | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 docs/rock3/rock3b/low-level-dev/custom-logo.md create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md diff --git a/docs/rock3/rock3b/low-level-dev/custom-logo.md b/docs/rock3/rock3b/low-level-dev/custom-logo.md new file mode 100644 index 000000000..c946ec96a --- /dev/null +++ b/docs/rock3/rock3b/low-level-dev/custom-logo.md @@ -0,0 +1,9 @@ +--- +sidebar_position: 8 +--- + +import LOGO from '../../../common/dev/\_custom_logo.mdx'; + +# 定制 Logo + + diff --git a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md new file mode 100644 index 000000000..20178dc07 --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md @@ -0,0 +1,9 @@ +--- +sidebar_position: 8 +--- + +import LOGO from '../../../common/dev/\_custom_logo.mdx'; + +# Customized Logo + + From efe1c2983c8058b70f34adae9e5a02ac84e106f8 Mon Sep 17 00:00:00 2001 From: Nascs Fang Date: Mon, 14 Oct 2024 18:55:32 +0800 Subject: [PATCH 04/14] fix: fix the output file size Signed-off-by: Nascs Fang --- docs/common/dev/_custom_logo.mdx | 52 ++++++++++++------- .../current/common/dev/_custom_logo.mdx | 52 ++++++++++++------- 2 files changed, 66 insertions(+), 38 deletions(-) diff --git a/docs/common/dev/_custom_logo.mdx b/docs/common/dev/_custom_logo.mdx index 1edc027eb..f02f2e60e 100644 --- a/docs/common/dev/_custom_logo.mdx +++ b/docs/common/dev/_custom_logo.mdx @@ -21,32 +21,46 @@ pip install Pillow ```py from PIL import Image +import os import sys -class BMPImageInfo: - def __init__(self, image_path): - self.image_path = image_path - - def get_image_info(self): - with Image.open(self.image_path) as img: - +class ImageConverter: + def __init__(self, input_path, output_path): + self.input_path = input_path + self.output_path = output_path + self.target_size = 0.5 * 1024 * 1024 # 0.5 MB in bytes (512 KB) + + def convert_to_bmp(self): + with Image.open(self.input_path) as img: + # Convert to RGB since BMP doesn't support transparency + img = img.convert("RGB") + + # Resize the image if the file size exceeds 0.5 MB + img = self.resize_to_fit(img) + + # Save as BMP + img.save(self.output_path, format='BMP') + + def resize_to_fit(self, img): + # Gradually reduce the size of the image until it fits within the target size + while True: + img.save(self.output_path, format='BMP') + if os.path.getsize(self.output_path) <= self.target_size: + break + # Reduce the size by 10% width, height = img.size + img = img.resize((int(width * 0.9), int(height * 0.9)), Image.ANTIALIAS) + return img - total_pixels = width * height - return width, height, total_pixels - -def main(image_file): - image_info = BMPImageInfo(image_file) - width, height, total_pixels = image_info.get_image_info() - print(f"Image Width: {width} pixels") - print(f"Image Height: {height} pixels") - print(f"Total Pixels: {total_pixels}") +def main(input_file, output_file): + converter = ImageConverter(input_file, output_file) + converter.convert_to_bmp() if __name__ == "__main__": - if len(sys.argv) != 2: - print("Usage: python3 get_bmp_info.py ") + if len(sys.argv) != 3: + print("Usage: python3 convert_logo.py ") else: - main(sys.argv[1]) + main(sys.argv[1], sys.argv[2]) ``` diff --git a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx index 2b24bf9c4..ca37e249e 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx @@ -21,32 +21,46 @@ pip install Pillow ```py from PIL import Image +import os import sys -class BMPImageInfo: - def __init__(self, image_path): - self.image_path = image_path - - def get_image_info(self): - with Image.open(self.image_path) as img: - +class ImageConverter: + def __init__(self, input_path, output_path): + self.input_path = input_path + self.output_path = output_path + self.target_size = 0.5 * 1024 * 1024 # 0.5 MB in bytes (512 KB) + + def convert_to_bmp(self): + with Image.open(self.input_path) as img: + # Convert to RGB since BMP doesn't support transparency + img = img.convert("RGB") + + # Resize the image if the file size exceeds 0.5 MB + img = self.resize_to_fit(img) + + # Save as BMP + img.save(self.output_path, format='BMP') + + def resize_to_fit(self, img): + # Gradually reduce the size of the image until it fits within the target size + while True: + img.save(self.output_path, format='BMP') + if os.path.getsize(self.output_path) <= self.target_size: + break + # Reduce the size by 10% width, height = img.size + img = img.resize((int(width * 0.9), int(height * 0.9)), Image.ANTIALIAS) + return img - total_pixels = width * height - return width, height, total_pixels - -def main(image_file): - image_info = BMPImageInfo(image_file) - width, height, total_pixels = image_info.get_image_info() - print(f"Image Width: {width} pixels") - print(f"Image Height: {height} pixels") - print(f"Total Pixels: {total_pixels}") +def main(input_file, output_file): + converter = ImageConverter(input_file, output_file) + converter.convert_to_bmp() if __name__ == "__main__": - if len(sys.argv) != 2: - print("Usage: python3 get_bmp_info.py ") + if len(sys.argv) != 3: + print("Usage: python3 convert_logo.py ") else: - main(sys.argv[1]) + main(sys.argv[1], sys.argv[2]) ``` From 2f31690f2b9c73ef5ac264a367664ea8b36903f3 Mon Sep 17 00:00:00 2001 From: Nascs Fang Date: Wed, 16 Oct 2024 10:22:50 +0800 Subject: [PATCH 05/14] fix: fix the convert cmd Signed-off-by: Nascs Fang --- docs/common/dev/_custom_logo.mdx | 4 ++-- .../current/common/dev/_custom_logo.mdx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/common/dev/_custom_logo.mdx b/docs/common/dev/_custom_logo.mdx index f02f2e60e..5541ebcb2 100644 --- a/docs/common/dev/_custom_logo.mdx +++ b/docs/common/dev/_custom_logo.mdx @@ -69,8 +69,8 @@ if __name__ == "__main__": 3. 将图片转为 .bmp 格式 ```bash -python3 pic1.jpg logo.bmp -python3 pic1.jpg logo_kernel.bmp +python3 convert.py pic1.jpg logo.bmp +python3 convert.py pic1.jpg logo_kernel.bmp ``` ### 将以上两张 bmp 图片保存到 config 分区 diff --git a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx index ca37e249e..14d3d4862 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx @@ -69,8 +69,8 @@ if __name__ == "__main__": 3. Converting images to .bmp format ```bash -python3 pic1.jpg logo.bmp -python3 pic1.jpg logo_kernel.bmp +python3 convert.py pic1.jpg logo.bmp +python3 convert.py pic1.jpg logo_kernel.bmp ``` ### Save the above two bmp images to the config partition From fd2d248b74898ffdce368adfd49a3b8fadb57e71 Mon Sep 17 00:00:00 2001 From: Nascs Fang Date: Wed, 16 Oct 2024 10:47:13 +0800 Subject: [PATCH 06/14] fix: fix the title Signed-off-by: Nascs Fang --- docs/common/dev/_custom_logo.mdx | 2 -- docs/rock3/rock3a/low-level-dev/custom-logo.md | 2 +- docs/rock3/rock3b/low-level-dev/custom-logo.md | 2 +- .../current/common/dev/_custom_logo.mdx | 2 -- .../current/rock3/rock3a/low-level-dev/custom-logo.md | 2 +- .../current/rock3/rock3b/low-level-dev/custom-logo.md | 2 +- 6 files changed, 4 insertions(+), 8 deletions(-) diff --git a/docs/common/dev/_custom_logo.mdx b/docs/common/dev/_custom_logo.mdx index 5541ebcb2..f72b29d39 100644 --- a/docs/common/dev/_custom_logo.mdx +++ b/docs/common/dev/_custom_logo.mdx @@ -1,5 +1,3 @@ -## 定制 Logo - ### 确认 U-boot 是否是 rknext ### 准备一张或者两张图片 diff --git a/docs/rock3/rock3a/low-level-dev/custom-logo.md b/docs/rock3/rock3a/low-level-dev/custom-logo.md index c946ec96a..c8a6fe74b 100644 --- a/docs/rock3/rock3a/low-level-dev/custom-logo.md +++ b/docs/rock3/rock3a/low-level-dev/custom-logo.md @@ -4,6 +4,6 @@ sidebar_position: 8 import LOGO from '../../../common/dev/\_custom_logo.mdx'; -# 定制 Logo +# 定制开机 Logo diff --git a/docs/rock3/rock3b/low-level-dev/custom-logo.md b/docs/rock3/rock3b/low-level-dev/custom-logo.md index c946ec96a..c8a6fe74b 100644 --- a/docs/rock3/rock3b/low-level-dev/custom-logo.md +++ b/docs/rock3/rock3b/low-level-dev/custom-logo.md @@ -4,6 +4,6 @@ sidebar_position: 8 import LOGO from '../../../common/dev/\_custom_logo.mdx'; -# 定制 Logo +# 定制开机 Logo diff --git a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx index 14d3d4862..14d169788 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx @@ -1,5 +1,3 @@ -## Customize Logo - ### Verify that U-boot is rknext ### Prepare one or two images diff --git a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md index 20178dc07..ba4b72915 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md @@ -4,6 +4,6 @@ sidebar_position: 8 import LOGO from '../../../common/dev/\_custom_logo.mdx'; -# Customized Logo +# Customized Boot Logo diff --git a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md index 20178dc07..ba4b72915 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md @@ -4,6 +4,6 @@ sidebar_position: 8 import LOGO from '../../../common/dev/\_custom_logo.mdx'; -# Customized Logo +# Customized Boot Logo From efcf289082eeaf1b70bdf7435a5ea673a403540f Mon Sep 17 00:00:00 2001 From: Nascs Fang Date: Wed, 16 Oct 2024 11:06:31 +0800 Subject: [PATCH 07/14] fix: explain the reason for using rknext Signed-off-by: Nascs Fang --- docs/common/dev/_custom_logo.mdx | 8 ++++++++ .../current/common/dev/_custom_logo.mdx | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/common/dev/_custom_logo.mdx b/docs/common/dev/_custom_logo.mdx index f72b29d39..7897adbaf 100644 --- a/docs/common/dev/_custom_logo.mdx +++ b/docs/common/dev/_custom_logo.mdx @@ -1,5 +1,13 @@ ### 确认 U-boot 是否是 rknext +由于目前我们只在 rknext 中集成了该功能, 所以需要确认手中板子的 U-boot 是否是 2024 年 10 月份之后的版本, + +如: + +```bash +U-Boot SPL latest-2023.07.02-6-4257d241-g4257d241 (Oct 12 2023 - 07:58:46 +0000) +``` + ### 准备一张或者两张图片 ### 将图片转为 .bmp 格式 diff --git a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx index 14d169788..fd790fb51 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx @@ -1,4 +1,12 @@ -### Verify that U-boot is rknext +### Verify that the U-boot is rknext + +Since we have only integrated this feature in rknext, you need to check if the U-boot on your board is from October 2024 onwards. + +For example: + +```bash +U-Boot SPL latest-2023.07.02-6-4257d241-g4257d241 (Oct 12 2023 - 07:58:46 +0000) +``` ### Prepare one or two images From e9700414502ed17ffee9001f760f7f24c903df99 Mon Sep 17 00:00:00 2001 From: Nascs Fang Date: Wed, 16 Oct 2024 20:24:48 +0800 Subject: [PATCH 08/14] fix: fix the u-boot predication Signed-off-by: Nascs Fang --- docs/common/dev/_custom_logo.mdx | 14 ++++++++++++++ .../current/common/dev/_custom_logo.mdx | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/docs/common/dev/_custom_logo.mdx b/docs/common/dev/_custom_logo.mdx index 7897adbaf..abeedbb4a 100644 --- a/docs/common/dev/_custom_logo.mdx +++ b/docs/common/dev/_custom_logo.mdx @@ -2,14 +2,28 @@ 由于目前我们只在 rknext 中集成了该功能, 所以需要确认手中板子的 U-boot 是否是 2024 年 10 月份之后的版本, +可在开机 log 中查看 U-boot 版本 + 如: ```bash U-Boot SPL latest-2023.07.02-6-4257d241-g4257d241 (Oct 12 2023 - 07:58:46 +0000) ``` +:::tip + +该篇文章是以 "U-boot 已经是 2024 年 10 月份之后的 rknext" 为前提条件的 + +::: + ### 准备一张或者两张图片 +:::tip + +图片 width \* height 不能超过 200000 + +::: + ### 将图片转为 .bmp 格式 1. 安装所需要的库 diff --git a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx index fd790fb51..13d7340b9 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx @@ -2,14 +2,28 @@ Since we have only integrated this feature in rknext, you need to check if the U-boot on your board is from October 2024 onwards. +U-boot version can be viewed in the boot log + For example: ```bash U-Boot SPL latest-2023.07.02-6-4257d241-g4257d241 (Oct 12 2023 - 07:58:46 +0000) ``` +:::tip + +The article is predicated on the premise that “U-boot is already rknext after October 2024” + +::: + ### Prepare one or two images +:::tip + +Image width \* height must not exceed 200000 + +::: + ### Convert the image to .bmp format 1. Install the required libraries From 13224eac4ec64df45a9857d50ed91fd68ac42010 Mon Sep 17 00:00:00 2001 From: Nascs Fang Date: Thu, 17 Oct 2024 09:30:39 +0800 Subject: [PATCH 09/14] fix: fix the punctuation mark checked by pre-commit Signed-off-by: Nascs Fang --- .../current/common/dev/_custom_logo.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx index 13d7340b9..c1d4c2242 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx @@ -12,7 +12,7 @@ U-Boot SPL latest-2023.07.02-6-4257d241-g4257d241 (Oct 12 2023 - 07:58:46 +0000) :::tip -The article is predicated on the premise that “U-boot is already rknext after October 2024” +The article is predicated on the premise that "U-boot is already rknext after October 2024" ::: From eefa306a14e2d12783cdf27d54968655ddd3df3b Mon Sep 17 00:00:00 2001 From: Nascs Fang Date: Thu, 17 Oct 2024 11:33:20 +0800 Subject: [PATCH 10/14] feat: add u-boot compilation method in custom logo Signed-off-by: Nascs Fang --- docs/common/dev/_custom_logo.mdx | 31 ++++++++++++++++- .../rock3/rock3a/low-level-dev/custom-logo.md | 2 +- .../rock3/rock3b/low-level-dev/custom-logo.md | 2 +- .../current/common/dev/_custom_logo.mdx | 33 ++++++++++++++++++- .../rock3/rock3a/low-level-dev/custom-logo.md | 2 +- .../rock3/rock3b/low-level-dev/custom-logo.md | 2 +- 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/docs/common/dev/_custom_logo.mdx b/docs/common/dev/_custom_logo.mdx index abeedbb4a..e64c97320 100644 --- a/docs/common/dev/_custom_logo.mdx +++ b/docs/common/dev/_custom_logo.mdx @@ -10,12 +10,41 @@ U-Boot SPL latest-2023.07.02-6-4257d241-g4257d241 (Oct 12 2023 - 07:58:46 +0000) ``` + + + + +- 参考 U-boot 开发, 编译 rknext 的 U-boot + +``` +./bsp u-boot rknext -r 99 +``` + +- 将 {props.product} 的 U-boot 拷贝到板子上 + +
+  scp -r .root/.root/usr/lib/u-boot/{props.product_dir}/ radxa@192.168.xx.xx:~/
+
+ +- 在 {props.product} 上执行以下命令以替换最新的 U-boot + +
+  cd {props.product_dir}
+  sudo bash setup.sh update_bootloader /dev/mmcblk0
+
+ :::tip -该篇文章是以 "U-boot 已经是 2024 年 10 月份之后的 rknext" 为前提条件的 +/dev/mmcblk0 这里是 eMMC, 如果系统安装在 SD 卡上, 那就是 /dev/mmcblk1 +如果系统安装在 nvme 等设备上,那就需要更新 SPI Flash 上的 U-boot ::: +- 重启系统,确认 U-boot 更新到了最新的 rknext + +
+
+ ### 准备一张或者两张图片 :::tip diff --git a/docs/rock3/rock3a/low-level-dev/custom-logo.md b/docs/rock3/rock3a/low-level-dev/custom-logo.md index c8a6fe74b..c3f615a6b 100644 --- a/docs/rock3/rock3a/low-level-dev/custom-logo.md +++ b/docs/rock3/rock3a/low-level-dev/custom-logo.md @@ -6,4 +6,4 @@ import LOGO from '../../../common/dev/\_custom_logo.mdx'; # 定制开机 Logo - + diff --git a/docs/rock3/rock3b/low-level-dev/custom-logo.md b/docs/rock3/rock3b/low-level-dev/custom-logo.md index c8a6fe74b..87cb63759 100644 --- a/docs/rock3/rock3b/low-level-dev/custom-logo.md +++ b/docs/rock3/rock3b/low-level-dev/custom-logo.md @@ -6,4 +6,4 @@ import LOGO from '../../../common/dev/\_custom_logo.mdx'; # 定制开机 Logo - + diff --git a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx index c1d4c2242..8f066461c 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx @@ -10,12 +10,43 @@ For example: U-Boot SPL latest-2023.07.02-6-4257d241-g4257d241 (Oct 12 2023 - 07:58:46 +0000) ``` + + + + +- Refer to U-boot development to compile rknext's U-boot. + +``` +./bsp u-boot rknext -r 99 +``` + +- Copy the U-boot of {props.product} to the board + +
+  scp -r .root/.root/usr/lib/u-boot/{props.product_dir}/ radxa@192.168.xx.xx:~/
+
+ +- Execute the following command on {props.product} to replace the latest U-boot + +
+  cd {props.product_dir}
+  sudo bash setup.sh update_bootloader /dev/mmcblk0
+
+ +sh setup.sh update_bootloader /dev/mmcblk0{" "} + :::tip -The article is predicated on the premise that "U-boot is already rknext after October 2024" +/dev/mmcblk0 is eMMC, or /dev/mmcblk1 if the system is installed on an SD card. +If the system is installed on a device such as nvme, then you need to update the U-boot on the SPI Flash ::: +- Reboot the system and make sure the U-boot is updated to the latest rknext. + +
+
+ ### Prepare one or two images :::tip diff --git a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md index ba4b72915..96128b2f0 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md @@ -6,4 +6,4 @@ import LOGO from '../../../common/dev/\_custom_logo.mdx'; # Customized Boot Logo - + diff --git a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md index ba4b72915..63f1f0564 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md @@ -6,4 +6,4 @@ import LOGO from '../../../common/dev/\_custom_logo.mdx'; # Customized Boot Logo - + From d7e063a35d9236bfe60ac9bcfce3acb90677e922 Mon Sep 17 00:00:00 2001 From: Nascs Fang Date: Thu, 17 Oct 2024 11:34:45 +0800 Subject: [PATCH 11/14] fix: fix the translation issue Signed-off-by: Nascs Fang --- .../current/common/dev/_custom_logo.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx index 8f066461c..cc327fc24 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/common/dev/_custom_logo.mdx @@ -11,9 +11,9 @@ U-Boot SPL latest-2023.07.02-6-4257d241-g4257d241 (Oct 12 2023 - 07:58:46 +0000) ``` - + - + - Refer to U-boot development to compile rknext's U-boot. ``` From a3ace4f134b020af5bcb988fdbaff73b5cca26b5 Mon Sep 17 00:00:00 2001 From: William Norman <105425502+nascs@users.noreply.github.com> Date: Mon, 27 Jan 2025 11:53:01 +0800 Subject: [PATCH 12/14] fix: apply suggestions from code review Co-authored-by: ZHANG Yuntian --- docs/common/dev/_custom_logo.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/common/dev/_custom_logo.mdx b/docs/common/dev/_custom_logo.mdx index e64c97320..1e1e16af7 100644 --- a/docs/common/dev/_custom_logo.mdx +++ b/docs/common/dev/_custom_logo.mdx @@ -2,7 +2,7 @@ 由于目前我们只在 rknext 中集成了该功能, 所以需要确认手中板子的 U-boot 是否是 2024 年 10 月份之后的版本, -可在开机 log 中查看 U-boot 版本 +可在开机日志中查看 U-Boot 版本 如: @@ -47,9 +47,9 @@ U-Boot SPL latest-2023.07.02-6-4257d241-g4257d241 (Oct 12 2023 - 07:58:46 +0000) ### 准备一张或者两张图片 -:::tip +:::warn -图片 width \* height 不能超过 200000 +图片总像素数不能超过 200000。 ::: From 7c9d835e51d496bce621b865e12146aab0b937ad Mon Sep 17 00:00:00 2001 From: nascs Date: Mon, 27 Jan 2025 14:19:39 +0800 Subject: [PATCH 13/14] fix: fix bugs according to code review Signed-off-by: Nascs Fang --- docs/common/dev/_custom_logo.mdx | 117 ++++-------------- .../rock3/rock3a/low-level-dev/custom-logo.md | 2 +- .../rock3/rock3b/low-level-dev/custom-logo.md | 2 +- .../rock3/rock3a/low-level-dev/custom-logo.md | 2 +- .../rock3/rock3b/low-level-dev/custom-logo.md | 2 +- 5 files changed, 29 insertions(+), 96 deletions(-) diff --git a/docs/common/dev/_custom_logo.mdx b/docs/common/dev/_custom_logo.mdx index 1e1e16af7..92fc00489 100644 --- a/docs/common/dev/_custom_logo.mdx +++ b/docs/common/dev/_custom_logo.mdx @@ -1,128 +1,61 @@ -### 确认 U-boot 是否是 rknext +### 确认 U-boot 是否是 rk2410 -由于目前我们只在 rknext 中集成了该功能, 所以需要确认手中板子的 U-boot 是否是 2024 年 10 月份之后的版本, +由于目前我们只在 rk2410 中集成了该功能, 所以需要确认手中板子的 U-boot 是否是 2024 年 10 月份之后的版本, 可在开机日志中查看 U-Boot 版本 如: ```bash -U-Boot SPL latest-2023.07.02-6-4257d241-g4257d241 (Oct 12 2023 - 07:58:46 +0000) +U-Boot rk2410-2017.09-1-g1a7692f4-dirty #runner (Jan 26 2025 - 10:37:18 +0000) ``` - + + + +可直接替换 logo 图片 + - -- 参考 U-boot 开发, 编译 rknext 的 U-boot + + + +- 参考 U-boot 开发, 编译 rk2410 的 U-boot ``` -./bsp u-boot rknext -r 99 +./bsp u-boot rk2410 -r 99 ``` - 将 {props.product} 的 U-boot 拷贝到板子上
-  scp -r .root/.root/usr/lib/u-boot/{props.product_dir}/ radxa@192.168.xx.xx:~/
-
- -- 在 {props.product} 上执行以下命令以替换最新的 U-boot - -
-  cd {props.product_dir}
-  sudo bash setup.sh update_bootloader /dev/mmcblk0
+  scp -r u-boot-rk2410_2017.09-1_arm64.deb radxa@192.168.xx.xx:~/
 
-:::tip +- 在 {props.product} 上使用 rsetup 更新 U-boot -/dev/mmcblk0 这里是 eMMC, 如果系统安装在 SD 卡上, 那就是 /dev/mmcblk1 -如果系统安装在 nvme 等设备上,那就需要更新 SPI Flash 上的 U-boot - -::: - -- 重启系统,确认 U-boot 更新到了最新的 rknext +- 重启系统,确认 U-boot 更新到了最新的 rk2410
-### 准备一张或者两张图片 - -:::warn - -图片总像素数不能超过 200000。 - -::: - -### 将图片转为 .bmp 格式 +### 准备 Logo 图片 -1. 安装所需要的库 +- 将 logo 图片转换为 bmp 格式 -```bash -pip install Pillow -``` - -2. 新建一个 convert.py 的文件, 将以下内容保存到 convert.py 中 - -
- - convert.py - -```py - -from PIL import Image -import os -import sys - -class ImageConverter: - def __init__(self, input_path, output_path): - self.input_path = input_path - self.output_path = output_path - self.target_size = 0.5 * 1024 * 1024 # 0.5 MB in bytes (512 KB) - - def convert_to_bmp(self): - with Image.open(self.input_path) as img: - # Convert to RGB since BMP doesn't support transparency - img = img.convert("RGB") + - 启动 logo 分为两个阶段,第一阶段是 U-boot 阶段,第二阶段是 kernel 阶段。两个阶段的 logo 图片分别为 logo.bmp 和 logo_kernel.bmp。 - # Resize the image if the file size exceeds 0.5 MB - img = self.resize_to_fit(img) + - 若只有一张图片,则 logo 显示时间会比较短。 - # Save as BMP - img.save(self.output_path, format='BMP') + - 两张图片可以是同一张,也可以是不同的。 - def resize_to_fit(self, img): - # Gradually reduce the size of the image until it fits within the target size - while True: - img.save(self.output_path, format='BMP') - if os.path.getsize(self.output_path) <= self.target_size: - break - # Reduce the size by 10% - width, height = img.size - img = img.resize((int(width * 0.9), int(height * 0.9)), Image.ANTIALIAS) - return img +:::warning -def main(input_file, output_file): - converter = ImageConverter(input_file, output_file) - converter.convert_to_bmp() - -if __name__ == "__main__": - if len(sys.argv) != 3: - print("Usage: python3 convert_logo.py ") - else: - main(sys.argv[1], sys.argv[2]) - -``` - -
- -3. 将图片转为 .bmp 格式 +图片总像素数不能超过 200000。 -```bash -python3 convert.py pic1.jpg logo.bmp -python3 convert.py pic1.jpg logo_kernel.bmp -``` +::: -### 将以上两张 bmp 图片保存到 config 分区 +- 将以上两张 bmp 图片保存到 config 分区 ```bash sudo mount /dev/mmcblk0p1 /mnt/ diff --git a/docs/rock3/rock3a/low-level-dev/custom-logo.md b/docs/rock3/rock3a/low-level-dev/custom-logo.md index c3f615a6b..b8f9e9685 100644 --- a/docs/rock3/rock3a/low-level-dev/custom-logo.md +++ b/docs/rock3/rock3a/low-level-dev/custom-logo.md @@ -6,4 +6,4 @@ import LOGO from '../../../common/dev/\_custom_logo.mdx'; # 定制开机 Logo - + diff --git a/docs/rock3/rock3b/low-level-dev/custom-logo.md b/docs/rock3/rock3b/low-level-dev/custom-logo.md index 87cb63759..d3ba01add 100644 --- a/docs/rock3/rock3b/low-level-dev/custom-logo.md +++ b/docs/rock3/rock3b/low-level-dev/custom-logo.md @@ -6,4 +6,4 @@ import LOGO from '../../../common/dev/\_custom_logo.mdx'; # 定制开机 Logo - + diff --git a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md index 96128b2f0..878f20d4a 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md @@ -6,4 +6,4 @@ import LOGO from '../../../common/dev/\_custom_logo.mdx'; # Customized Boot Logo - + diff --git a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md index 63f1f0564..d20d6f487 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md @@ -6,4 +6,4 @@ import LOGO from '../../../common/dev/\_custom_logo.mdx'; # Customized Boot Logo - + From 49eef9e1463ae74ee7b9b47d1de8329f55d155e6 Mon Sep 17 00:00:00 2001 From: nascs Date: Mon, 27 Jan 2025 14:31:32 +0800 Subject: [PATCH 14/14] fix: hide 3a/3b Since the u-boot pr for 3b has not been merged yet, this document is hidden for the time being Signed-off-by: Nascs Fang --- docs/rock3/rock3a/low-level-dev/custom-logo.md | 1 + docs/rock3/rock3b/low-level-dev/custom-logo.md | 1 + .../current/rock3/rock3a/low-level-dev/custom-logo.md | 1 + .../current/rock3/rock3b/low-level-dev/custom-logo.md | 1 + 4 files changed, 4 insertions(+) diff --git a/docs/rock3/rock3a/low-level-dev/custom-logo.md b/docs/rock3/rock3a/low-level-dev/custom-logo.md index b8f9e9685..03a5fa45e 100644 --- a/docs/rock3/rock3a/low-level-dev/custom-logo.md +++ b/docs/rock3/rock3a/low-level-dev/custom-logo.md @@ -1,4 +1,5 @@ --- +sidebar_class_name: hidden sidebar_position: 8 --- diff --git a/docs/rock3/rock3b/low-level-dev/custom-logo.md b/docs/rock3/rock3b/low-level-dev/custom-logo.md index d3ba01add..557d08e9a 100644 --- a/docs/rock3/rock3b/low-level-dev/custom-logo.md +++ b/docs/rock3/rock3b/low-level-dev/custom-logo.md @@ -1,4 +1,5 @@ --- +sidebar_class_name: hidden sidebar_position: 8 --- diff --git a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md index 878f20d4a..c4feca3e4 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3a/low-level-dev/custom-logo.md @@ -1,4 +1,5 @@ --- +sidebar_class_name: hidden sidebar_position: 8 --- diff --git a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md index d20d6f487..5408612d1 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md +++ b/i18n/en/docusaurus-plugin-content-docs/current/rock3/rock3b/low-level-dev/custom-logo.md @@ -1,4 +1,5 @@ --- +sidebar_class_name: hidden sidebar_position: 8 ---