Skip to content

Setting up a working developer sdcard

Eric Westphal edited this page May 27, 2018 · 4 revisions

Here are some tips for setting up a sdcard with a nicer working environment for developers:

If your main working environment is Linux or OS X, image the sdcard as follows:

  1. Download the latest .img.zip file from https://github.com/cyoung/stratux/releases
  2. Unzip the file: unzip XXX-dev.img.zip.
  3. Plug your sdcard into your computer.
  4. lsblk to see which device your sdcard mounted as; assume it's /dev/sdX.
  5. Image the card with sudo dd if=XXX-dev.img of=/dev/sdX bs=4M status=progress
  6. Optional: create separate partitions for /var and /root. This will keep you from freezing up your Pi if your logs get too large and is good practice for a dev system:
    1. use fparted /dev/sdX and add partitions 3 (2GB - /root) and 4 (the rest - /var)
    2. mkfs.ext4 /dev/sdX3
    3. mkfs.ext4 /dev/sdX4
    4. sudo mkdir /mnt/base /mnt/root /mnt/var (use whatever mount point you like if /mnt is taken)
    5. sudo mount /dev/sdX2 /mnt/base
    6. sudo mount /dev/sdX3 /mnt/root
    7. sudo mount /dev/sdX4 /mnt/var
    8. rsync -Pavz --remove-source-files /mnt/base/root /mnt/root
    9. rm -rf /mnt/base/root/*
    10. rsync -Pavz --remove-source-files /mnt/base/var /mnt/var
    11. rm -rf /mnt/base/var/*
    12. modify fstab to mount mmcblk0p3 to /root and mmcblk0p4 to /var (last number should be 2).
  7. Add your ssh key: cat ~/.ssh/id_rsa.pub | sudo tee -a /mnt/etc/ssh/authorized_keys/root (assuming your public ssh key is ~/.ssh/id_rsa.pub).
  8. (May not be necessary any more: If you like to have a wired ethernet connection: vi /mnt/etc/network/interfaces and insert allow-hotplug eth0 near allow-hotplug wlan0 if it's not there already.)
  9. Unmount the sdcard: sudo umount /mnt. Remove it from the computer, insert it in the Pi, and boot it up.
  10. Now you should easily be able to ssh into the Pi over your wired lan.
  11. Sync up the Pi's time: systemctl start ntp (enable if always wired).
  12. If you didn't create the /root and /var partitions, expand the filesystem: raspi-config and choose the option to expand the filesystem. When finished, reboot.
  13. Verify that the filesystem is expanded or the other partitions are mounted with df -h.
  14. Install Go from https://golang.org/dl/ (ARMv6 architecture). Use wget to download it and then tar -C /root -xzf go$VERSION.linux-armv6l.tar.gz. If it's not already on your $PATH then add export PATH=$PATH:/root/go/bin to /root/.bashrc.
  15. Install git and vim: apt-get update && apt-get install -y git vim.
  16. Clone the stratux repository from GitHub: mkdir /root/go_path/src/github.com/cyoung && cd /root/go_path/src/github.com/cyoung && git clone https://github.com/cyoung/stratux.
  17. Install WiringPi static libs: cd && git clone https://github.com/WiringPi/WiringPi.git && cd WiringPi/wiringPi && make static && make install-static (see https://github.com/WiringPi/WiringPi/INSTALL)
  18. For faster builds: go get github.com/mattn/go-sqlite3

Now you can easily git pull, modify, build. To build: cd ~/go_path/src/github.com/cyoung/stratux && make && make install. If you only want to build the main stratux binary, gen_gdl90, just make xgen_gdl90 && make install.

Happy coding!