|
| 1 | +# How to Create an Official PicoCalc SD Card |
| 2 | + |
| 3 | +The purpose of this wiki is to document the partitioning and creation process of the official PicoCalc SD card. |
| 4 | + |
| 5 | +⚠ Warning: This process involves disk partitioning and formatting, which may result in data loss if performed incorrectly. Do not proceed unless you have sufficient experience with Linux system administration. |
| 6 | + |
| 7 | +We are not responsible for any data loss or damage caused by improper use of these instructions. Proceed at your own risk. |
| 8 | + |
| 9 | + |
| 10 | +## Script |
| 11 | + |
| 12 | +```bash |
| 13 | +#!/bin/bash |
| 14 | + |
| 15 | +DEVICE="/dev/$1" |
| 16 | + |
| 17 | +if [ -z "$DEVICE" ]; then |
| 18 | + echo "No disk" |
| 19 | + exit 1 |
| 20 | +fi |
| 21 | + |
| 22 | +if [ ! -b "$DEVICE" ]; then |
| 23 | + echo "$DEVICE not existed" |
| 24 | + exit 1 |
| 25 | +fi |
| 26 | + |
| 27 | + |
| 28 | +echo "Warn: $DEVICE will be destroyed and all data on this disk will be lost,Do you want to continue?" |
| 29 | +read -p "Confirm?(y/n) " confirm |
| 30 | +if [ "$confirm" != "y" ]; then |
| 31 | + echo "Canceled" |
| 32 | + exit 1 |
| 33 | +fi |
| 34 | + |
| 35 | + |
| 36 | +echo "Begin partition..." |
| 37 | + |
| 38 | +# use parted to create msdos partition table |
| 39 | +echo "Create msdos partition table..." |
| 40 | +parted "$DEVICE" mklabel msdos |
| 41 | + |
| 42 | + |
| 43 | +TOTAL_SIZE=$(lsblk -bno SIZE "$DEVICE") |
| 44 | +SIZE_MB=$(( TOTAL_SIZE / 1024 / 1024 )) |
| 45 | + |
| 46 | + |
| 47 | +PART1_SIZE=$(( SIZE_MB - 32 )) |
| 48 | + |
| 49 | + |
| 50 | +echo "Create first partition in size ${PART1_SIZE}MB, FAT32..." |
| 51 | +parted "$DEVICE" mkpart primary fat32 1MiB ${PART1_SIZE}MiB |
| 52 | + |
| 53 | + |
| 54 | +sleep 2 |
| 55 | + |
| 56 | +echo "Format first partition FAT32..." |
| 57 | +mkfs.fat -F32 -v -I "${DEVICE}1" |
| 58 | + |
| 59 | + |
| 60 | +echo "Create second partition in size 32MB..." |
| 61 | +parted "$DEVICE" mkpart primary ${PART1_SIZE}MiB 100% |
| 62 | + |
| 63 | + |
| 64 | +echo "All done:" |
| 65 | +fdisk -l "$DEVICE" |
| 66 | +``` |
| 67 | + |
| 68 | +## How to Use the Script |
| 69 | + |
| 70 | +- Insert a blank SD card into your computer. |
| 71 | +- Run the script: |
| 72 | +```bash |
| 73 | +sudo ./partition_usb_32mb.sh sdb |
| 74 | +``` |
| 75 | +(Replace "sdb" with the correct device name for your SD card.) |
| 76 | + |
| 77 | +***BE CARFUL ABOUT THIS*** |
| 78 | +***BE CARFUL ABOUT THIS*** |
| 79 | +***BE CARFUL ABOUT THIS*** |
| 80 | + |
| 81 | +If you are not careful, all the original data on the disk will be destroyed. |
| 82 | + |
| 83 | +This script prepares the SD card for PicoMite, uLisp, NES emulators, and other Pico firmware using the fatfs library. |
| 84 | + |
| 85 | +Additionally, FUZIX can use `/dev/sdb2` (32MB partition) as its root filesystem, as FUZIX supports a maximum partition size of 32MB. |
| 86 | + |
| 87 | +## Flashing the FUZIX 32MB Image |
| 88 | +- Download the FUZIX image: |
| 89 | + [PicoCalc_Fuzix_v1.0.img](https://github.com/clockworkpi/PicoCalc/blob/master/Bin/PicoCalc%20SD/firmware/PicoCalc_Fuzix_v1.0.img) |
| 90 | + |
| 91 | +- Flash the image to the second partition: |
| 92 | +```bash |
| 93 | +sudo dd if=filesystem.img of=/dev/sdb2 |
| 94 | +``` |
| 95 | + |
| 96 | +## Example Partition Layout |
| 97 | + |
| 98 | +After running the script, your SD card should have the following partition structure: |
| 99 | + |
| 100 | +``` |
| 101 | +Disk /dev/sdb: 59.48 GiB, 63864569856 bytes, 124735488 sectors |
| 102 | +Disk model: STORAGE DEVICE |
| 103 | +Units: sectors of 1 * 512 = 512 bytes |
| 104 | +Sector size (logical/physical): 512 bytes / 512 bytes |
| 105 | +I/O size (minimum/optimal): 512 bytes / 512 bytes |
| 106 | +Disklabel type: dos |
| 107 | +Disk identifier: 0x66a93eb2 |
| 108 | +
|
| 109 | +Device Boot Start End Sectors Size Id Type |
| 110 | +/dev/sdb1 2048 124669951 124667904 59.4G c W95 FAT32 (LBA) |
| 111 | +/dev/sdb2 124669952 124735487 65536 32M 83 Linux |
| 112 | +``` |
| 113 | + |
| 114 | +Now your SD card is ready for PicoCalc, FUZIX, and other supported firmware! |
| 115 | + |
0 commit comments