Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various readme edits #3

Merged
merged 4 commits into from
May 11, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 27 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Maintainer: Yatao Li

Origianl Author: Cole Smith
Original Author: Cole Smith

License: LGPL-2.1

Expand All @@ -21,8 +21,7 @@ If you are running advanced filesystems on your host (for example `zfs`), don’
## Quickstart

Pre-built root filesystem(s) are provided in the **Releases** tab. Skip to the **Prepare the SD Card** section if using
a pre-built image. Replace `arch-linux-clockworkpi-a06-root-fs.tar.xz` with your downloaded file name in the guide
steps.
a pre-built image.

**NOTE:** Please note the following defaults for the release filesystem:

Expand Down Expand Up @@ -52,8 +51,7 @@ We will start by creating an ARM chroot environment to build our root filesystem
1. Install the required packages

```
$ yay -S base-devel binfmt-qemu-static qemu-user-static arch-install-scripts

$ yay -S base-devel qemu-user-static qemu-user-binfmt arch-install-scripts
# systemctl restart systemd-binfmt.service
```

Expand Down Expand Up @@ -127,7 +125,7 @@ For this section, **all commands will be run inside the chroot**.
# locale-gen
```

5. Set `fstab`
5. Reference partitions in `/etc/fstab`

```
# echo 'LABEL=ROOT_ARCH / f2fs defaults,noatime 0 0' >> /etc/fstab
Expand Down Expand Up @@ -325,7 +323,7 @@ $ exit
### Unmount The Root Filesystem

```
# umonut root
yatli marked this conversation as resolved.
Show resolved Hide resolved
# umount root
```

# Tar The Root Filesystem
Expand Down Expand Up @@ -358,63 +356,64 @@ but use our tarball in place of theirs.
1. Zero the beginning of the SD card

```
# dd if=/dev/zero of=/dev/sdX bs=1M count=32
yatli marked this conversation as resolved.
Show resolved Hide resolved
# dd if=/dev/zero of=/dev/mmcblkX bs=1M count=32
```

2. Start fdisk to partition the SD card

```
# fdisk /dev/sdX
# fdisk /dev/mmcblkX
```

3. Inside fdisk,

1. Type **o**. This will clear out any partitions on the drive
2. Type **p** to list partitions. There should be no partitions left
3. Type **n**, then **p** for primary, **1** for the first partition on the drive, **32768** for the first sector
4. Type **+2G** to create the boot partition of 2GB.
5. Type **n**, **p**, **2** to create the swap partition. Press ENTER to accept the default first sector.
6. Type **+4G** to create the swap partition of 4GB. (In the hope that we get full hibernation support one day)
5. Type **n**, **p**, **3** to create the root partition. Press ENTER to accept the default first/last sector
6. Write the partition table and exit by typing **w**
3. Type **n**, then **p** for primary, **1** for the first partition on the drive, **32768** for the first sector, then **+2G** for the last sector (boot partition, 2GB)
4. Type **p** and note the end sector number for the partition freshly created.
5. Type **n**, then **p**, **2** for the second partition, **use number from step 4 and add 2** as first sector, then **+4G** for the last sector (swap partition, 4GB)
yatli marked this conversation as resolved.
Show resolved Hide resolved
6. Again, type **p** and note the end sector number for the partition freshly created.
7. Type **n**, then **p**, **3** for the third partition, **use number from step 6 and add 2** as first sector, then leave default for the last sector (root partition, takes all available space)
8. Write the partition table and exit by typing **w**

4. Create the **ext4** filesystem **without a Journal** for boot, and **f2fs** filesystem for root

```
# mkfs.ext4 -L BOOT_ARCH -O ^has_journal /dev/sdX1
# mkswap /dev/sdX2
# mkfs.f2fs -L ROOT_ARCH -O extra_attr,inode_checksum,sb_checksum /dev/sdX3
# blkid /dev/sdX2 # Note down the UUID
# echo 'UUID="<UUID in previous command here>" none swap sw 0 0' >> /etc/fstab
# mkfs.ext4 -L BOOT_ARCH -O ^has_journal /dev/mmcblkX1
# mkswap /dev/mmcblkX2
# mkfs.f2fs -l ROOT_ARCH -O extra_attr,inode_checksum,sb_checksum /dev/mmcblkX3
```

**IMPORTANT** The `mkswap` command will return the swap partition's UUID, which will be needed later. Please write it down.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw if we can make sure fdisk gives us gpt partitions, then systemd will automatically find and use the swap partitions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice, that could be handy!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


**NOTE:** Disabling the journal is helpful for simple flash devices like SD Cards to reduce successive writes.
In rare cases, your filesystem may become corrupted, which may arise as a boot loop.
Running `fsck -y /dev/sdX1` on an external system can fix this issue.
Running `fsck -y /dev/mmcblkX1` on an external system can fix this issue.

5. Mount the filesystem

```
# mount /dev/sdX3 /mnt
# mount /dev/mmcblkX3 /mnt
# mkdir -p /mnt/boot
# mount /dev/sdX1 /mnt/boot
# mount /dev/mmcblkX1 /mnt/boot
```

6. Install the root filesystem (as root not via sudo)

```
# sudo su
# bsdtar -xpf arch-linux-clockworkpi-a06-root-fs.tar.xz -C /mnt
# echo 'UUID="<SWAP PARTITION UUID HERE>" none swap sw 0 0' >> /mnt/etc/fstab
# exit
```

7. Install the bootloader to the SD card

```
# cd /mnt/boot
# dd if=idbloader.img of=/dev/sdX seek=64 conv=notrunc,fsync
# dd if=uboot.img of=/dev/sdX seek=16384 conv=notrunc,fsync
# dd if=trust.img of=/dev/sdX seek=24576 conv=notrunc,fsync
# dd if=idbloader.img of=/dev/mmcblkX seek=64 conv=notrunc,fsync
# dd if=uboot.img of=/dev/mmcblkX seek=16384 conv=notrunc,fsync
# dd if=trust.img of=/dev/mmcblkX seek=24576 conv=notrunc,fsync
```

8. Unmount and eject the SD card
Expand All @@ -423,7 +422,7 @@ Running `fsck -y /dev/sdX1` on an external system can fix this issue.
# cd
# umount /mnt/boot
# umount /mnt
# eject /dev/sdX
# sync
```

## Done!
Expand All @@ -432,8 +431,7 @@ The SD card is now ready to be booted by the DevTerm! Good luck!

## Next Steps

You will want to set up Wi-Fi on first boot. You can do so by
Copy link
Owner

@yatli yatli May 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you also test if wiringpi and the printer works?
also, while I'm not sure if it works, you can test suspend without the mainboard mod like this:

1. sudo systemctl suspend
2. observe that it goes to sleep
3. plug in power
4. observe whether it resumes
5. if we're lucky and it bounces back, use dmesg to verify it's a deep sleep

Copy link
Author

@lonewsk lonewsk May 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the green led be on while sleeping?

After running systemctl suspend, screen turns off, keyboard unresponsive, green light on.

It immediately resume when I plug a power cable in.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the printer to try it sorry.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And fan works 👍

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh then it means we actually have a way to wake up the core without the mainboard hack. this is good.
no worry about the printer.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And fan works

yep that's the handy work of the Manjaro folks.

using [NetworkManager](https://wiki.archlinux.org/title/NetworkManager).
You will want to set up Wi-Fi on first boot. Use the command `nmtui`.

Check out the [post-install suggestions](https://wiki.archlinux.org/title/General_recommendations) from Arch Linux for
further configuration.
Expand Down