File:  [NetBSD Developer Wiki] / wikisrc / ports / evbarm / odroid-c1.mdwn
Revision 1.15: download - view: text, annotated - select for diffs
Sat Apr 25 14:50:13 2015 UTC (6 years, 2 months ago) by wiki
Branches: MAIN
CVS tags: HEAD
web commit by jmcneill: GPIO, SYS_LED info

    1: [[!meta title="NetBSD/evbarm on Hardkernel ODROID-C1"]]
    2: 
    3: [ODROID-C1](http://www.hardkernel.com/main/products/prdt_info.php?g_code=G141578608433&tab_idx=1) is a $35 quad-core SBC from Hardkernel. ODROID-C1 support was introduced in NetBSD 7.0.
    4: 
    5: [[!toc levels=2]]
    6: 
    7: # Supported hardware
    8:  - CPU: Cortex-A5: Amlogic S805 (4-core) at 1.5GHz
    9:    - CPU frequency scaling is supported with machdep.cpu sysctl tree
   10:    - SMP supported
   11:    - PL310 L2 cache controller
   12:  - GIC
   13:  - A5 watchdog timer
   14:  - A5 global timer
   15:  - SD/MMC controller (DMA)
   16:  - Serial console
   17:  - Framebuffer console
   18:  - USB host (OTG)
   19:  - Gigabit Ethernet (GMAC)
   20:    - RTL8211F PHY
   21:  - Hardware random number generator
   22:  - RTC
   23:  - GPIO
   24: 
   25: # TODO
   26:  - USB device mode
   27:  - Simultaneous SD card and eMMC usage
   28:  - SD/MMC UHS-I support (needs sdmmc(4) changes)
   29:  - IR receiver
   30:  - I2C
   31:  - Audio
   32: 
   33: # Installation
   34: 
   35: * Start with an ARMv7 image from *evbarm-earmv7hf/binary/gzimg/* such as *beagleboard.img*
   36: * Build U-Boot for ODROID-C1 <https://github.com/hardkernel/u-boot/tree/odroidc-v2011.03>
   37:   * Pre-built binaries here: <http://ftp.netbsd.org/pub/NetBSD/misc/jmcneill/odroidc1/u-boot-odroidc-v2011.03-20150308.tar.gz>
   38: * Note the location and size of the FFS partition in the *beagleboard.img* disklabel:
   39: [[!template  id=programlisting text="""
   40: # $TOOLDIR/bin/nbdisklabel -M evbarm -B le beagleboard.img
   41: ...
   42: 8 partitions:
   43: #        size    offset     fstype [fsize bsize cpg/sgs]
   44:  a:   1359312    385024     4.2BSD      0     0     0  # (Cyl.    188 -    851*)
   45:  b:    262144    122880       swap                     # (Cyl.     60 -    187)
   46:  c:   1744336         0     unused      0     0        # (Cyl.      0 -    851*)
   47:  d:   1744336         0     unused      0     0        # (Cyl.      0 -    851*)
   48:  e:    114688      8192      MSDOS                     # (Cyl.      4 -     59)
   49: """]]
   50: * Write the bootloader to the empty space at the start of the base image:
   51: [[!template  id=programlisting text="""
   52: # dd if=bl1.bin.hardkernel of=beagleboard.img bs=1 count=442 conv=notrunc
   53: # dd if=bl1.bin.hardkernel of=beagleboard.img bs=512 skip=1 seek=1 conv=notrunc
   54: # dd if=u-boot.bin of=beagleboard.img bs=512 seek=64 conv=notrunc
   55: """]]
   56: * Since the bootloader has overwritten the disklabel, we need to re-add partition "a" from the disklabel to the MBR partition table:
   57: [[!template  id=programlisting text="""
   58: # $TOOLDIR/bin/armv7--netbsdelf-eabihf-fdisk -u beagleboard.img
   59: ...
   60: Which partition do you want to change?: [none] 1
   61: The data for partition 1 is:
   62: <UNUSED>
   63: sysid: [0..255 default: 169] 
   64: start: [0..109cyl default: 63, 0cyl, 0MB] 385024
   65: size: [0..85cyl default: 1359312, 85cyl, 664MB] 1359312
   66: ...
   67: Which partition do you want to change?: [none] 
   68: ...
   69: Should we write new partition table? [n] y
   70: """]]
   71: * Write the image to an SD card.
   72: * Copy the kernel (netbsd.ub) for your board to the root of the MS-DOS partition on the SD card.
   73: * Create or edit *boot.ini* on the MS-DOS partition:
   74: [[!template  id=programlisting text="""
   75: ODROIDC-UBOOT-CONFIG
   76: 
   77: setenv bootargs "root=ld0f awge0.mac-address=${ethaddr}"
   78: setenv bootcmd "fatload mmc 0:1 0x21000000 netbsd.ub; bootm 0x21000000"
   79: run bootcmd
   80: """]]
   81: * On first boot, it will stop because of the wrong device in /etc/fstab. Take this opportunity to grow the root file-system:
   82: [[!template  id=programlisting text="""
   83: # fdisk -u ld0
   84: ...
   85: Which partition do you want to change?: [none] 1
   86: The data for partition 1 is:
   87: NetBSD (sysid 169)
   88:     start 385024, size 1359312 (664 MB, Cyls 23/246/32-108/147/55)
   89:         PBR is not bootable: All bytes are identical (0x00)
   90: sysid: [0..255 default: 169]
   91: start: [0..966cyl default: 385024, 24cyl, 188MB]
   92: size: [0..942cyl default: 1359312, 85cyl, 664MB] $
   93: ...
   94: Which partition do you want to change?: [none]
   95: ...
   96: Should we write new partition table? [n] y
   97: # resize_ffs -y /dev/rld0f
   98: # reboot
   99: """]]
  100: * Next boot, create a new /etc/fstab:
  101: [[!template  id=programlisting text="""
  102: # mount -u -o rw /dev/ld0f /
  103: # cat > /etc/fstab << EOF
  104: /dev/ld0f       /               ffs     rw      1 1
  105: /dev/ld0e       /boot           msdos   rw      1 1
  106: kernfs          /kern           kernfs  rw
  107: ptyfs           /dev/pts        ptyfs   rw
  108: procfs          /proc           procfs  rw
  109: tmpfs           /var/shm        tmpfs   rw,-m1777,-sram%25
  110: EOF
  111: # reboot
  112: """]]
  113: 
  114: # HDMI
  115: 
  116: ## Framebuffer console
  117: 
  118: Simply add **console=fb** to the *bootargs* variable in *boot.ini*.
  119: 
  120: ## Video mode
  121: 
  122: HDMI video mode can be selected in U-Boot with the *video* command, e.g.:
  123: 
  124: [[!template  id=programlisting text="""
  125: odroidc#video dev open 1080P
  126: """]]
  127: 
  128: To make this change permanent, add it to the *bootcmd* variable in *boot.ini*:
  129: 
  130: [[!template  id=programlisting text="""
  131: setenv bootcmd "video dev open 1080P; fatload mmc 0:1 0x21000000 netbsd.ub; bootm 0x21000000"
  132: """]]
  133: 
  134: ## 16 or 24 bpp?
  135: 
  136: ODROID-C1 defaults to 16bpp. If you want to try 24bpp, add **fb.depth=24** to the kernel cmdline options in *boot.ini*. There are some issues with 24bpp mode and Xorg; see <http://gnats.netbsd.org/49812>.
  137: 
  138: ## Overscan compensation
  139: 
  140: If you have ODROID-C1 plugged into a TV, the edges of the screen may not be visible. You can scale down the framebuffer console with the **hw.genfb0.scale** sysctl, e.g.:
  141: 
  142: [[!template  id=programlisting text="""
  143: # sysctl -w hw.genfb0.scale=95
  144: """]]
  145: 
  146: Setting *scale* to 100 disables scaling, any other value enables the scaler. Values between 10 and 100 are allowed.
  147: 
  148: To set this value at boot, you can add **fb.scale=95** to the kernel cmdline options in *boot.ini*.
  149: 
  150: # SYS_LED
  151: 
  152: The blue SYS_LED on the board is wired to GPIOAO_13. To control the LED from userland, set **gpio=YES** in rc.conf and add this to */etc/gpio.conf*:
  153: 
  154: [[!template  id=programlisting text="""
  155: gpio4 13 set out sys_led
  156: """]]
  157: 
  158: After rebooting, the LED state can be controlled with [[!template id=man name="gpioctl" section="8"]].
  159: 
  160: [[!template  id=programlisting text="""
  161: # turn the light on
  162: gpioctl gpio4 sys_led on
  163: 
  164: # turn the light off
  165: gpioctl gpio4 sys_led off
  166: 
  167: # toggle the light state
  168: gpioctl gpio4 sys_led toggle
  169: """]]
  170: 
  171: # Documentation
  172: 
  173: Amlogic S805 datasheet: <http://dn.odroid.com/S805/Datasheet/S805_Datasheet%20V0.8%2020150126.pdf>
  174: 
  175: # ODROID-C1 UART pins
  176: 
  177: From [ODROID Forum](http://forum.odroid.com/viewtopic.php?f=115&t=7684):
  178: 
  179: [[!template  id=programlisting text="""
  180:  ___UART____
  181: |Pin 4 - GND|
  182: |Pin 3 - RXD|
  183: |Pin 2 - TXD|
  184: |Pin 1 - VCC|
  185: \___________|
  186: 
  187: 3.3V LVTTL
  188: """]]

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb