Changes between Version 1 and Version 2 of MakingBootableCard


Ignore:
Timestamp:
Jan 24, 2019, 8:33:48 AM (4 years ago)
Author:
Eric Hazen
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MakingBootableCard

    v1 v2  
    33https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841655/Prepare+Boot+Medium
    44
    5 Copy BOOT.BIN and image.ub to first partition, then boot.
     5My version:
     6
     7Find the device name.  For my Lenovo laptop with built-in card reader, it's {{{/dev/mmcblk0}}}.
     8Partitions are {{{/dev/mmcblk0p1}}} etc.  Unmount the card if mounted.
     9
     10'''Erase the first sector'''
     11
     12{{{
     13  $ dd if=/dev/zero of=/dev/xxxx bs=1024 count=1
     14}}}
     15
     16'''Calculate {{{new_cylinders}}}
     17
     18{{{
     19  $ fdisk -l /dev/xxxx
     20
     21  Disk /dev/sdb: 8068 MB, 8068792320 bytes
     22  249 heads, 62 sectors/track, 1020 cylinders, total 15759360 sectors
     23  Units = sectors of 1 * 512 = 512 bytes
     24  Sector size (logical/physical): 512 bytes / 512 bytes
     25  I/O size (minimum/optimal): 512 bytes / 512 bytes
     26  Disk identifier: 0x00000000
     27 
     28  Disk /dev/sdb doesn't contain a valid partition table
     29}}}
     30
     31Note the size in bytes (i.e. 8068792320).  Calculate:
     32
     33{{{new_cylinders = size_in_bytes/8225280}}}
     34
     35(round down).  For this 8Gb example the result is 980.
     36
     37'''Partition the card'''
     38
     39Creat one 200MB FAT32 partition and the remainder as ext2
     40(ext4 should work too).  First, have to set CHS correctly.
     41
     42{{{
     43  $ fdisk /dev/xxxx
     44}}}
     45
     46(delete any existing partitions; shouldn't be any)
     47
     48{{{
     49  Command (m for help): x
     50  Expert command (m for help): h
     51  Number of heads (1-256, default 30): 255
     52  Expert command (m for help): s
     53  Number of sectors (1-63, default 29): 63
     54  Expert command (m for help): c
     55  Number of cylinders (1-1048576, default 2286): <new_cylinders calculated from above>
     56  Expert command (m for help): r
     57}}}
     58
     59Now create partitions:
     60
     61{{{
     62Command (m for help): n
     63Partition type:
     64 p primary (0 primary, 0 extended, 4 free)
     65 e extended
     66Select (default p): p
     67Partition number (1-4, default 1): 1
     68First sector (2048-15759359, default 2048):
     69Using default value 2048
     70Last sector, +sectors or +size{K,M,G} (2048-15759359, default 15759359): +200M
     71 
     72Command (m for help): n
     73Partition type:
     74 p primary (1 primary, 0 extended, 3 free)
     75 e extended
     76Select (default p): p
     77Partition number (1-4, default 2): 2
     78First sector (411648-15759359, default 411648):
     79Using default value 411648
     80Last sector, +sectors or +size{K,M,G} (411648-15759359, default 15759359):
     81Using default value 15759359
     82}}}
     83
     84Set bootable flag, partition types:
     85
     86{{{
     87Command (m for help): a
     88Partition number (1-4): 1
     89 
     90Command (m for help): t
     91Partition number (1-4): 1
     92Hex code (type L to list codes): c
     93Changed system type of partition 1 to c (W95 FAT32 (LBA))
     94 
     95Command (m for help): t
     96Partition number (1-4): 2
     97Hex code (type L to list codes): 83
     98}}}
     99
     100Check table and write changes:
     101
     102{{{
     103Command (m for help): p
     104 
     105Disk /dev/sdb: 8068 MB, 8068792320 bytes
     106249 heads, 62 sectors/track, 1020 cylinders, total 15759360 sectors
     107Units = sectors of 1 * 512 = 512 bytes
     108Sector size (logical/physical): 512 bytes / 512 bytes
     109I/O size (minimum/optimal): 512 bytes / 512 bytes
     110Disk identifier: 0x920c958b
     111 
     112 Device Boot Start End Blocks Id System
     113/dev/sdb1 * 2048 411647 204800 c W95 FAT32 (LBA)
     114/dev/sdb2 411648 15759359 7673856 83 Linux
     115 
     116Command (m for help): w
     117The partition table has been altered!
     118 
     119Calling ioctl() to re-read partition table.
     120 
     121WARNING: If you have created or modified any DOS 6.x
     122partitions, please see the fdisk manual page for additional
     123information.
     124Syncing disks.
     125}}}
     126
     127'''Create filesystems'''
     128
     129{{{
     130mkfs.vfat -F 32 -n boot /dev/sdX1
     131mkfs.ext4 -L root /dev/sdX2
     132}}}
     133
     134'''Mount boot partition'''
     135
     136{{{
     137mkdir -p /mnt/boot
     138mount /dev/sdX1 /mnt/boot
     139}}}
     140
     141'''Copy required files'''
     142{{{
     143cp BOOT.BIN /mnt/boot
     144cp image.ub /mnt/boot
     145umount /mnt/boot
     146}}}