Archive for the ‘mac’ Category

mac: copy an image to sdcard

December 26, 2016

This post discusses how to copy an image to sdcard. My motivation is to boot q device with the image in sdcard.

testing environment
OS X El Capitan 10.11.4

list all disk and partition
In my case, the sdcard is exported a block device, /dev/disk2, which is mounted at /Volumes/NO NAME with file system fat32.

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            250.1 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macintosh HD           +249.8 GB   disk1
                                 Logical Volume on disk0s2
                                 1043D3CE-3F0E-4966-BC11-8D76D427A94A
                                 Unencrypted
/dev/disk2 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.5 GB    disk2
   1:             Windows_FAT_32 NO NAME                 15.5 GB    disk2s1
$ mount
/dev/disk1 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk2s1 on /Volumes/NO NAME (msdos, local, nodev, nosuid, noowners)

unmount sdcard
After the sdcard is unmounted, it’s not managed by file system. Now it’s safe to read/write the block device of sdcard directly.

$ diskutil unmountDisk /dev/disk2
$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            250.1 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macintosh HD           +249.8 GB   disk1
                                 Logical Volume on disk0s2
                                 1043D3CE-3F0E-4966-BC11-8D76D427A94A
                                 Unencrypted
/dev/disk2 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.5 GB    disk2
   1:             Windows_FAT_32 NO NAME                 15.5 GB    disk2s1
$ mount
/dev/disk1 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)

copy boot image to sdcard
Use dd command to copy image to the block device of sdcard directly.

$ dd bs=512 if=image_file of=/dev/disk2

eject sdcard
Finally, eject sdcard. The block device of sdcard will be released by kernel. Now it’s safe to remove the sdcard.

$ diskutil eject /dev/disk2s1
$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            250.1 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macintosh HD           +249.8 GB   disk1
                                 Logical Volume on disk0s2
                                 1043D3CE-3F0E-4966-BC11-8D76D427A94A
                                 Unencrypted

conclusion
The post discusses commands to copy an image to sdcard.

Advertisements

Install GNU Compiler Collection in OS X

August 4, 2016

This post discusses how to install gcc(GNU Compiler Collection) in OS X.

environment

  • OS X El Capitan, version 10.11.5
  • Xcode Version 7.3.1

Xcode, Xcode Command Line Tools and gcc
Xcode is a suite of software development tools with which we could develop applications running on OS X and iOS. Xcode Command Line Tools is a subset of Xcode. It contains many unix-like command line tools such as gcc. However the gcc in Xcode version 7 is actually clang whose backend is llvm. What I need is GNU Compiler Collection rather than clang/llvm.

$ ls -al /usr/bin
lrwxr-xr-x     1 root   wheel         7 Jul  9 03:13 c++ -> clang++
lrwxr-xr-x     1 root   wheel         5 Jul  9 03:13 cc -> clang

install gcc with brew
At first, search formulae related to gcc. It appears that the repository homebrew/versions has formulae of different gcc version.

$ brew search gcc
gcc                               homebrew/versions/gcc44           homebrew/versions/gcc46           homebrew/versions/gcc48           homebrew/versions/gcc5            homebrew/versions/llvm-gcc28    
homebrew/versions/gcc43           homebrew/versions/gcc45           homebrew/versions/gcc47           homebrew/versions/gcc49           homebrew/versions/gcc6   

Then, install the gcc of the version satisfy our needs. In my case, I want to install the latest gcc. So I install the formula homebrew/versions/gcc6. This formula then download gcc source code, make, and make install gcc-6. The build time is about 40 minutes.

$ brew install homebrew/versions/gcc6
==> Tapping homebrew/versions
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-versions'...
remote: Counting objects: 219, done.
remote: Compressing objects: 100% (207/207), done.
remote: Total 219 (delta 20), reused 56 (delta 12), pack-reused 0
Receiving objects: 100% (219/219), 263.71 KiB | 0 bytes/s, done.
Resolving deltas: 100% (20/20), done.
Checking connectivity... done.
Tapped 212 formulae (239 files, 969.8K)
==> Installing gcc6 from homebrew/versions
==> Installing dependencies for homebrew/versions/gcc6: gmp, mpfr, libmpc, isl014
==> Installing homebrew/versions/gcc6 dependency: gmp
==> Downloading https://homebrew.bintray.com/bottles/gmp-6.1.1.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gmp-6.1.1.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/gmp/6.1.1: 17 files, 3.2M
==> Installing homebrew/versions/gcc6 dependency: mpfr
==> Downloading https://homebrew.bintray.com/bottles/mpfr-3.1.4.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mpfr-3.1.4.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/mpfr/3.1.4: 25 files, 3.6M
==> Installing homebrew/versions/gcc6 dependency: libmpc
==> Downloading https://homebrew.bintray.com/bottles/libmpc-1.0.3.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libmpc-1.0.3.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/libmpc/1.0.3: 11 files, 350.1K
==> Installing homebrew/versions/gcc6 dependency: isl014
==> Downloading http://isl.gforge.inria.fr/isl-0.14.tar.bz2
######################################################################## 100.0%
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/isl014/0.14 --with-gmp=system --with-gmp-prefix=/usr/local/opt/gmp
==> make
==> make install
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

Conflicts with isl in main repository.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/isl014/lib
    CPPFLAGS: -I/usr/local/opt/isl014/include

==> Summary
🍺  /usr/local/Cellar/isl014/0.14: 69 files, 3.2M, built in 29 seconds
==> Installing homebrew/versions/gcc6
==> Downloading https://ftpmirror.gnu.org/gcc/gcc-6.1.0/gcc-6.1.0.tar.bz2
==> Downloading from http://mirror.hust.edu.cn/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.bz2
######################################################################## 100.0%
==> Patching
patching file gcc/jit/Make-lang.in
==> ../configure --build=x86_64-apple-darwin15.5.0 --prefix=/usr/local/Cellar/gcc6/6.1.0 --libdir=/usr/local/Cellar/gcc6/6.1.0/lib/gcc/6 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-6
==> make bootstrap
==> make install
🍺  /usr/local/Cellar/gcc6/6.1.0: 1,434 files, 282.3M, built in 39 minutes 45 seconds

verify gcc-6 is GNU Compiler Collection
man page of gcc-6 shows that it is GNU project C and C++ compiler.

$ man gcc-6

GCC(1)                                                                                   GNU                                                                                  

NAME
       gcc - GNU project C and C++ compiler

conclusion
The gcc in Xcode Command Line Tools is not GNU Compiler Collection. We need to install GNU Compiler Collection by ourself.

macbook: resize dock

February 6, 2016

This post discusses how to resize dock in macbook.

OS version
Screen Shot 2016-02-06 at 5.47.00 PM

open System Preference
Click Apple icon, and then Click System Preference.
Screen Shot 2016-02-06 at 5.50.24 PM

open Dock setting
Screen Shot 2016-02-06 at 5.51.56 PM

adjust Dock size
Screen Shot 2016-02-06 at 5.53.24 PM


%d bloggers like this: