• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/board/freescale/create-boot-sd.sh
Vincent StehléVincent Stehlé committed 3029f6ef14f30 Mar 2015
Raw file
Source viewDiff to previous
xxxxxxxxxx
 
1
#!/bin/sh
2
​
3
set -u
4
set -e
5
​
6
PROGNAME=$(basename $0)
7
​
8
usage()
9
{
10
    echo "Create an SD card that boots on an i.MX53/6 board."
11
    echo
12
    echo "Note: all data on the the card will be completely deleted!"
13
    echo "Use with care!"
14
    echo "Superuser permissions may be required to write to the device."
15
    echo
16
    echo "Usage: ${PROGNAME} <sd_block_device>"
17
    echo "Arguments:"
18
    echo "  <sd_block_device>     The device to be written to"
19
    echo
20
    echo "Example: ${PROGNAME} /dev/mmcblk0"
21
    echo
22
}
23
​
24
if [ $# -ne 1 ]; then
25
    usage
26
    exit 1
27
fi
28
​
29
if [ $(id -u) -ne 0 ]; then
30
    echo "${PROGNAME} must be run as root"
31
    exit 1
32
fi
33
​
34
DEV=${1}
35
​
36
# The partition name prefix depends on the device name:
37
# - /dev/sde -> /dev/sde1
38
# - /dev/mmcblk0 -> /dev/mmcblk0p1
39
if echo ${DEV}|grep -q mmcblk ; then
40
    PART="p"
41
else
42
    PART=""
43
fi
44
​
45
PART1=${DEV}${PART}1
46
PART2=${DEV}${PART}2
47
​
48
# Unmount the partitions if mounted
49
umount ${PART1} || true
50
umount ${PART2} || true
51
​
52
# First, clear the card
53
dd if=/dev/zero of=${DEV} bs=1M count=20
54
​
55
sync
56
​
57
# Partition the card.
58
# SD layout for i.MX6 boot:
59
# - Bootloader at offset 1024
60
# - FAT partition starting at 1MB offset, containing uImage and *.dtb
61
# - ext2/3 partition formatted as ext2 or ext3, containing the root filesystem.
62
sfdisk ${DEV} <<EOF
63
32,480,b
64
512,,L
65
EOF
66
​
67
sync
68
​
69
# Copy the bootloader at offset 1024
70
dd if=output/images/u-boot.imx of=${DEV} obs=512 seek=2
71
​
72
# Prepare a temp dir for mounting partitions
73
TMPDIR=$(mktemp -d)
74
​
75
# FAT partition: kernel and DTBs
76
mkfs.vfat ${PART1}
77
mount ${PART1} ${TMPDIR}
78
cp output/images/*Image ${TMPDIR}/
79
cp output/images/*.dtb  ${TMPDIR}/ || true
80
sync
81
umount ${TMPDIR}
82
​
83
# ext2 partition: root filesystem
84
mkfs.ext2 ${PART2}
85
mount ${PART2} ${TMPDIR}
86
tar -C ${TMPDIR}/ -xf output/images/rootfs.tar
87
sync
88
umount ${TMPDIR}
89
​
90
# Cleanup
91
rmdir ${TMPDIR}
92
sync
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.