Orage Pi Zero H2/H3 - Bookworm Port - Impossible to make SD card Image

Hi everyone,
I really have a need to get H3 based old OrangePi zero boards working with most up to date python. I’ve been using DietPiStrech for ages but there is no more support for anything that is python based. I’ve tried my best to find a way to get bookworm working, obvioulsy Dietpi will never get this going, so doing my best, all I could get was some pre built image by someone else. Based on this I’ve tried the DietPi installation commands and they seem to work ish.

My problem is, I’ve tried every single tool available (dd, balena, win32, rufus, etc ) to make an SD card image BUT no image can ever be successfully burned such that it simply works. Only ever the original card can work, never a image copied.

Any ideas how to copy this card to a working image?
Much appreciated in advance

I understood that you have a working DietPi Stretch system running.
Could then be the first step to go to Buster via this blog post

and then go on to Bookworm via these blog posts

and

Would you like to create a backup of your current system or what is your goal?

Thank you StephanStS
I did try to do this step by step as suggested. I did end up with a fully working module BUT, apparently can’t go beyond Bullseye.
In any case, I can have up to date tools which was the biggest motivation.

With this said, the problem is still the same, I can’t make a working image of this card. The card it self works great, but no linux of windows tool, can do this. I even tried both balena and DD straight from card to card copy… Nothing. It always gives this.

Loading, please wait...
starting version 232
[    6.943470] sunxi-mmc 1c10000.mmc: allocated mmc-pwrseq
[    7.220558] sunxi-mmc 1c10000.mmc: base:0xe0c22000 irq:24
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... Scanning for Btrfs filesystems
[    7.267364] mmc1: new high speed SDIO card at address 0001
done.
Begin: Will now check root file system ... fsck from util-linux 2.29.2
[/sbin/fsck.ext4 (1) -- /dev/mmcblk0p1] fsck.ext4 -a -C0 /dev/mmcblk0p1
/dev/mmcblk0p1: clean, 67365/462720 files, 516841/1936384 blocks
done.
[    7.937587] EXT4-fs (mmcblk0p1): mounted filesystem with writeback data mode. Opts: (null)
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... done.
/sbin/init: error while loading shared libraries: /lib/systemd/libsystemd-shared-247.so: invalid ELF header
[    8.200626] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
[    8.200626]
[    8.210123] CPU: 1 PID: 1 Comm: init Not tainted 4.14.13-sunxi #5
[    8.216212] Hardware name: Allwinner sun8i Family
[    8.220946] [<c010db15>] (unwind_backtrace) from [<c010a0d9>] (show_stack+0x11/0x14)
[    8.228695] [<c010a0d9>] (show_stack) from [<c0867ca9>] (dump_stack+0x69/0x78)
[    8.235924] [<c0867ca9>] (dump_stack) from [<c011a3bd>] (panic+0xb9/0x1c8)
[    8.242802] [<c011a3bd>] (panic) from [<c011e2ad>] (complete_and_exit+0x1/0x18)
[    8.250114] [<c011e2ad>] (complete_and_exit) from [<db0f9f6c>] (0xdb0f9f6c)
[    8.257081] CPU3: stopping

Joulinar, It’s not just back up, I need to make this image available for reproduction in multiple boards. Such that a simple etcher can just make more DC cards for more devices.

Could you please post the used dd command line and its output.
Additionally, please post a lsblk of your systenm right before the dd command execution and directly after.

My laptop has a dedicated SD card reader “mmc” unit.
The SDB is just a USB sd card reader.

Direct copy past from shell.

sudo dd if=/dev/mmcblk0 of=sd-card.img bs=1024 conv=notrunc status=progress
[sudo] password for ubuntu: 
7928796160 bytes (7.9 GB, 7.4 GiB) copied, 500 s, 15.9 MB/s
7749632+0 records in
7749632+0 records out
7935623168 bytes (7.9 GB, 7.4 GiB) copied, 500.388 s, 15.9 MB/s
sda           8:0    0 119.2G  0 disk 
├─sda1        8:1    0     1M  0 part 
├─sda2        8:2    0    52G  0 part 
└─sda3        8:3    0  67.3G  0 part /
sdb           8:16   1   7.6G  0 disk 
└─sdb1        8:17   1   7.4G  0 part /media/ubuntu/add9824a-575d-4c79-9839-90e9d565400f1
sr0          11:0    1  1024M  0 rom  
mmcblk0     179:0    0   7.4G  1 disk 
└─mmcblk0p1 179:1    0   7.4G  1 part /media/ubuntu/add9824a-575d-4c79-9839-90e9d565400f
sudo dd of=/dev/sdb if=sd-card.img bs=1024 conv=notrunc status=progress
[sudo] password for ubuntu: 
7932544000 bytes (7.9 GB, 7.4 GiB) copied, 2702 s, 2.9 MB/s
7749632+0 records in
7749632+0 records out
7935623168 bytes (7.9 GB, 7.4 GiB) copied, 2702.85 s, 2.9 MB/s
sda           8:0    0 119.2G  0 disk 
├─sda1        8:1    0     1M  0 part 
├─sda2        8:2    0    52G  0 part 
└─sda3        8:3    0  67.3G  0 part /
sdb           8:16   1   7.6G  0 disk 
└─sdb1        8:17   1   7.4G  0 part /media/ubuntu/add9824a-575d-4c79-9839-90e9d565400f1
sr0          11:0    1  1024M  0 rom  
mmcblk0     179:0    0   7.4G  1 disk 
└─mmcblk0p1 179:1    0   7.4G  1 part /media/ubuntu/add9824a-575d-4c79-9839-90e9d565400f

So, I’ve tried to do this again but at every step, make an image and try it.
First image made after update to Duster. Try shell output:

/dev/mmcblk0p1: clean, 64700/462720 files, 492017/1936384 blocks
done.
[    7.669014] EXT4-fs (mmcblk0p1): mounted filesystem with writeback data mode. Opts: (null)
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... done.
[    7.939559] request_module: kmod_concurrent_max (0) close to 0 (max_modprobes: 50), for module binfmt-60d4, throttling...
run-init: /sbin/init: Exec format error
[   12.970690] request_module: modprobe binfmt-60d4 cannot be processed, kmod busy with 50 threads for more than 5 seconds now
[   13.021049] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
[   13.021049]
[   13.042126] CPU: 2 PID: 1 Comm: run-init Not tainted 4.14.13-sunxi #5
[   13.048562] Hardware name: Allwinner sun8i Family
[   13.053296] [<c010db15>] (unwind_backtrace) from [<c010a0d9>] (show_stack+0x11/0x14)
[   13.061044] [<c010a0d9>] (show_stack) from [<c0867ca9>] (dump_stack+0x69/0x78)

Seems like it was doomed right at the start.

Looks like you are mixing different architectures? What devices are you using?

The device is always he same. OrangePi Zero with H3 allwinner.
If this was an architecture issue, the original card wouldn’t work after the update, but it does.

I’ve been hinted by a friend that this could have something to do with a “secure boot” option “somewhere” ?..
Ideas? comments?..

(I really appreciate everyone comments, any help is a great help)

Would it be possible to do the dd procedure directly from card to card, i.e. without the temporary sd-card.img file (-> dd if=/dev/mmcblk0 of=/dev/sdb bs=1M status=progress)?
If this works, a test with the sd-card.img, but without the conv=notrunc option would be a test. This option I never used yet.
I also always use a block size of 1M, I hope that this speeds things up. It could also be a test to use a larger block size: dd if=/dev/mmcblk0 of=sd-card.img bs=1M status=progress

I’ve done just this if several new cards off the carton.
Same problem. Some how, only the original card works.
I’ve reinstalled the whole thing from original image and upgraded everything again step by step.
Then done this suggestion.

[  193.316784] DietPi-PreBoot[12523]: /usr/bin/mawk: line 1329: 1EEB5: command not found
[  193.317650] DietPi-PreBoot[12524]: /usr/bin/mawk: line 1330: 1EEB6: command not found
[  193.318332] DietPi-PreBoot[12525]: /usr/bin/mawk: line 1331: 1EEB7: command not found
[  193.318987] DietPi-PreBoot[12526]: /usr/bin/mawk: line 1332: 1EEB8: command not found

The result is a GIANT list of these.
Eventually the system gets to a login, but after login, the same massive list is again given, no commands can ever be executed.

/usr/bin/mawk: line 1343: 1F135: command not found
/usr/bin/mawk: line 1344: 1F136: command not found
/usr/bin/mawk: line 1345: 1F137: command not found
/usr/bin/mawk: line 1346: 1F138: command not found
/usr/bin/mawk: line 1347: 1F139: command not found
/usr/bin/mawk: line 1348: 1F13A: command not found
/usr/bin/mawk: line 1349: 1F13B: command not found
/usr/bin/mawk: line 1350: syntax error near unexpected token `('
/usr/bin/mawk: line 1350: `1F13C       ELF(▒4 ▒4        (8k8k444  TTTDkDkHuHuHuh
▒▒`|`|pppDDQ▒tdR▒tdHuHuHu▒'
 Web             : https://dietpi.com | https://twitter.com/DietPi_
 Patreon Legends : Camry2731
 Contribute      : https://dietpi.com/contribute.html
 DietPi Hosting  : Powered by https://myvirtualserver.com

 dietpi-launcher : All the DietPi programs in one place
 dietpi-config   : Feature rich configuration tool for your device
 dietpi-software : Select optimised software for installation
 htop            : Resource monitor
 cpu             : Shows CPU information and stats

PuTTYPuTTYroot@DietPi:~# PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY
-bash: PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY: command not found
root@DietPi:~#
root@DietPi:~#
root@DietPi:~#
root@DietPi:~#
root@DietPi:~# apt update
apt: error while loading shared libraries: /usr/lib/arm-linux-gnueabihf/libapt-private.so.0.0: invalid ELF header
root@DietPi:~# apt-install update
-bash: apt-install: command not found
root@DietPi:~# apt-install
-bash: apt-install: command not found
root@DietPi:~# python3
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python39.zip',
    '/usr/lib/python3.9',
    '/usr/lib/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0xb6f2f520 (most recent call first):
<no Python frame>

I’m totally lost…

I’m up to simply give up on this project and restart a new installation of the whole system in an updated version. But I can’t even do this when there is no updated version of this core…
:expressionless:

Probably my last resort, but if anyone can just point me to a good set of instructions on how to build an updated diet pi distro based on uboot and an old tree blob, I can get the tools and give it a try on that myself.
Otherwise… Guess python 2.5 is the only solution possible without viable alternatives.

Looks like data corruption to me, maybe don’t use a SD card, they die too quickly.

5 cards, 5 full clean installations and 20 images in total.
All the cards work from original installation.
Not a single image works from any of the cards in any of the copies.
I’ve got 25 new cards for this and 3 new USB sd readers from 3 different brands.
No mater how you do it. Only the original card installed and upgraded gets to work.
10 images done from dd/balena in Ubuntu and 10 images done from win32 and balena in windows.

If this is corruption… Then all the 2 pcs and all the new material causes always corruption.

PS.: Once working and installed, all the devices have the mmcblk set to RO mode. The cards from the original devices have been running for 5y now. Not a single one had issues.
That is why I like Dietpi, it’s reliable. It saddens me to see that I’ll most likely will have to give up on it for anything than can get me python3 running.

No I don’t think that everytime it was data corruption, but this output looks like corrupted data to me

/usr/bin/mawk: line 1350: `1F13C       ELF(▒4 ▒4        (8k8k444  TTTDkDkHuHuHuh
▒▒`|`|pppDDQ▒tdR▒tdHuHuHu▒'

Did you also test the diect copy like I mentioned above?
dd if=/dev/mmcblk0 of=/dev/sdb bs=1M status=progress

Yes, card to card with the exact like(which copies the main card that is running from to a card on a usb reader). I’ve also made images of the 2 cards and compared both cards against both images. Content matches 100%. I’m clueless on what could be happening that only ever allows the original upgraded card to ever work. Is there any data anywhere else that serves as signature to decode access to any of the kernel anywhere in the card such that only the original would have this?

Am I the only person in the world to ever face this issue?? My luck… :thinking: