Annotation of wikisrc/ports/evbarm/odroid-c1.mdwn, revision 1.28

1.22      wiki        1: [[!meta title="NetBSD/evbarm on Hardkernel ODROID-C1 and ODROID-C1+"]]
1.1       wiki        2: 
1.19      wiki        3: [ODROID-C1](http://www.hardkernel.com/main/products/prdt_info.php?g_code=G141578608433&tab_idx=1) was a $35 quad-core SBC from Hardkernel. ODROID-C1 support was introduced in NetBSD 7.0.  It has been succeeded by the [ODROID-C1+](http://www.hardkernel.com/main/products/prdt_info.php?g_code=G143703355573), which is supported by the same NetBSD kernel.
1.13      wiki        4: 
1.1       wiki        5: [[!toc levels=2]]
                      6: 
1.2       wiki        7: # Supported hardware
1.6       wiki        8:  - CPU: Cortex-A5: Amlogic S805 (4-core) at 1.5GHz
1.2       wiki        9:    - CPU frequency scaling is supported with machdep.cpu sysctl tree
                     10:    - SMP supported
                     11:    - PL310 L2 cache controller
                     12:  - GIC
                     13:  - A5 global timer
1.23      wiki       14:  - Watchdog timer
1.16      wiki       15:  - "SDHC" and "SDIO" SD/MMC controllers (DMA)
1.2       wiki       16:  - Serial console
1.7       wiki       17:  - Framebuffer console
1.2       wiki       18:  - USB host (OTG)
                     19:  - Gigabit Ethernet (GMAC)
                     20:    - RTL8211F PHY
                     21:  - Hardware random number generator
1.11      wiki       22:  - RTC
1.15      wiki       23:  - GPIO
1.2       wiki       24: 
                     25: # TODO
                     26:  - USB device mode
                     27:  - IR receiver
                     28:  - I2C
1.7       wiki       29:  - Audio
1.2       wiki       30: 
1.28    ! jmcneill   31: # Installation (NetBSD -current after 20170412)
        !            32: 
        !            33: * Start with an ARMv7 image from *evbarm-earmv7hf/binary/gzimg/* such as *armv7.img*
        !            34: * Build U-Boot for ODROID-C1 <https://github.com/hardkernel/u-boot/tree/odroidc-v2011.03>
        !            35:   * Pre-built binaries here: <http://ftp.netbsd.org/pub/NetBSD/misc/jmcneill/odroidc1/u-boot-odroidc-v2011.03-20150308.tar.gz>
        !            36: * Write the bootloader to the empty space at the start of the base image:
        !            37: [[!template  id=programlisting text="""
        !            38: # dd if=bl1.bin.hardkernel of=armv7.img bs=1 count=442 conv=notrunc
        !            39: # dd if=bl1.bin.hardkernel of=armv7.img bs=512 skip=1 seek=1 conv=notrunc
        !            40: # dd if=u-boot.bin of=armv7.img bs=512 seek=64 conv=notrunc
        !            41: """]]
        !            42: * Write the image to an SD card.
        !            43: * Edit *boot.ini* on the MS-DOS partition. Note that the default boot.ini has `console=fb` in `bootargs`, which you should remove if you want serial console:
        !            44: [[!template  id=programlisting text="""
        !            45: ODROIDC-UBOOT-CONFIG
        !            46: 
        !            47: setenv bootargs "root=ld0a awge0.mac-address=${ethaddr} console=fb"
        !            48: setenv bootcmd "fatload mmc 0:1 0x21000000 netbsd-ODROID-C1.ub; bootm 0x21000000"
        !            49: run bootcmd
        !            50: """]] 
        !            51: 
        !            52: # Installation (NetBSD 7.0/7.1)
1.2       wiki       53: 
1.20      wiki       54: * Start with an ARMv7 image from *evbarm-earmv7hf/binary/gzimg/* such as *armv7.img*
1.2       wiki       55: * Build U-Boot for ODROID-C1 <https://github.com/hardkernel/u-boot/tree/odroidc-v2011.03>
1.3       wiki       56:   * Pre-built binaries here: <http://ftp.netbsd.org/pub/NetBSD/misc/jmcneill/odroidc1/u-boot-odroidc-v2011.03-20150308.tar.gz>
1.27      sevan      57: * Note the location and size of the FFS partition in the *armv7.img* disklabel:
1.4       wiki       58: [[!template  id=programlisting text="""
1.20      wiki       59: # $TOOLDIR/bin/nbdisklabel -M evbarm -B le armv7.img
1.4       wiki       60: ...
                     61: 8 partitions:
                     62: #        size    offset     fstype [fsize bsize cpg/sgs]
                     63:  a:   1359312    385024     4.2BSD      0     0     0  # (Cyl.    188 -    851*)
                     64:  b:    262144    122880       swap                     # (Cyl.     60 -    187)
                     65:  c:   1744336         0     unused      0     0        # (Cyl.      0 -    851*)
                     66:  d:   1744336         0     unused      0     0        # (Cyl.      0 -    851*)
                     67:  e:    114688      8192      MSDOS                     # (Cyl.      4 -     59)
                     68: """]]
1.2       wiki       69: * Write the bootloader to the empty space at the start of the base image:
                     70: [[!template  id=programlisting text="""
1.20      wiki       71: # dd if=bl1.bin.hardkernel of=armv7.img bs=1 count=442 conv=notrunc
                     72: # dd if=bl1.bin.hardkernel of=armv7.img bs=512 skip=1 seek=1 conv=notrunc
                     73: # dd if=u-boot.bin of=armv7.img bs=512 seek=64 conv=notrunc
1.2       wiki       74: """]]
1.4       wiki       75: * Since the bootloader has overwritten the disklabel, we need to re-add partition "a" from the disklabel to the MBR partition table:
                     76: [[!template  id=programlisting text="""
1.20      wiki       77: # $TOOLDIR/bin/armv7--netbsdelf-eabihf-fdisk -u armv7.img
1.4       wiki       78: ...
                     79: Which partition do you want to change?: [none] 1
                     80: The data for partition 1 is:
                     81: <UNUSED>
                     82: sysid: [0..255 default: 169] 
                     83: start: [0..109cyl default: 63, 0cyl, 0MB] 385024
                     84: size: [0..85cyl default: 1359312, 85cyl, 664MB] 1359312
                     85: ...
                     86: Which partition do you want to change?: [none] 
                     87: ...
                     88: Should we write new partition table? [n] y
                     89: """]]
1.2       wiki       90: * Write the image to an SD card.
1.21      wiki       91: * Edit *boot.ini* on the MS-DOS partition. Note that the default boot.ini has `console=fb` in `bootargs`, which you should remove if you want serial console:
1.2       wiki       92: [[!template  id=programlisting text="""
                     93: ODROIDC-UBOOT-CONFIG
                     94: 
1.21      wiki       95: setenv bootargs "root=ld0f awge0.mac-address=${ethaddr} console=fb"
1.2       wiki       96: setenv bootcmd "fatload mmc 0:1 0x21000000 netbsd.ub; bootm 0x21000000"
                     97: run bootcmd
1.21      wiki       98: """]] 
                     99: 
1.5       wiki      100: * On first boot, it will stop because of the wrong device in /etc/fstab. Take this opportunity to grow the root file-system:
1.4       wiki      101: [[!template  id=programlisting text="""
                    102: # fdisk -u ld0
                    103: ...
                    104: Which partition do you want to change?: [none] 1
                    105: The data for partition 1 is:
                    106: NetBSD (sysid 169)
                    107:     start 385024, size 1359312 (664 MB, Cyls 23/246/32-108/147/55)
                    108:         PBR is not bootable: All bytes are identical (0x00)
                    109: sysid: [0..255 default: 169]
                    110: start: [0..966cyl default: 385024, 24cyl, 188MB]
                    111: size: [0..942cyl default: 1359312, 85cyl, 664MB] $
                    112: ...
                    113: Which partition do you want to change?: [none]
                    114: ...
                    115: Should we write new partition table? [n] y
                    116: # resize_ffs -y /dev/rld0f
                    117: # reboot
                    118: """]]
                    119: * Next boot, create a new /etc/fstab:
                    120: [[!template  id=programlisting text="""
                    121: # mount -u -o rw /dev/ld0f /
                    122: # cat > /etc/fstab << EOF
                    123: /dev/ld0f       /               ffs     rw      1 1
                    124: /dev/ld0e       /boot           msdos   rw      1 1
                    125: kernfs          /kern           kernfs  rw
                    126: ptyfs           /dev/pts        ptyfs   rw
                    127: procfs          /proc           procfs  rw
                    128: tmpfs           /var/shm        tmpfs   rw,-m1777,-sram%25
                    129: EOF
                    130: # reboot
                    131: """]]
1.2       wiki      132: 
1.9       wiki      133: # HDMI
                    134: 
1.10      wiki      135: ## Framebuffer console
                    136: 
                    137: Simply add **console=fb** to the *bootargs* variable in *boot.ini*.
                    138: 
1.9       wiki      139: ## Video mode
                    140: 
                    141: HDMI video mode can be selected in U-Boot with the *video* command, e.g.:
                    142: 
                    143: [[!template  id=programlisting text="""
                    144: odroidc#video dev open 1080P
                    145: """]]
                    146: 
                    147: To make this change permanent, add it to the *bootcmd* variable in *boot.ini*:
                    148: 
                    149: [[!template  id=programlisting text="""
                    150: setenv bootcmd "video dev open 1080P; fatload mmc 0:1 0x21000000 netbsd.ub; bootm 0x21000000"
                    151: """]]
                    152: 
1.14      wiki      153: ## 16 or 24 bpp?
                    154: 
                    155: 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>.
                    156: 
1.9       wiki      157: ## Overscan compensation
1.8       wiki      158: 
                    159: 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.:
                    160: 
                    161: [[!template  id=programlisting text="""
                    162: # sysctl -w hw.genfb0.scale=95
                    163: """]]
                    164: 
                    165: Setting *scale* to 100 disables scaling, any other value enables the scaler. Values between 10 and 100 are allowed.
                    166: 
                    167: To set this value at boot, you can add **fb.scale=95** to the kernel cmdline options in *boot.ini*.
                    168: 
1.15      wiki      169: # SYS_LED
                    170: 
                    171: 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*:
                    172: 
                    173: [[!template  id=programlisting text="""
                    174: gpio4 13 set out sys_led
                    175: """]]
                    176: 
                    177: After rebooting, the LED state can be controlled with [[!template id=man name="gpioctl" section="8"]].
                    178: 
                    179: [[!template  id=programlisting text="""
                    180: # turn the light on
                    181: gpioctl gpio4 sys_led on
                    182: 
                    183: # turn the light off
                    184: gpioctl gpio4 sys_led off
                    185: 
                    186: # toggle the light state
                    187: gpioctl gpio4 sys_led toggle
                    188: """]]
                    189: 
1.24      wiki      190: # U-Boot Environment
                    191: 
                    192: To read/write U-Boot environment variables from NetBSD, download and compile the following program: <http://ftp.netbsd.org/pub/NetBSD/misc/jmcneill/odroidc1/uenv.c>
                    193: 
1.25      wiki      194: # Automatically booting a backup kernel
                    195: 
                    196: *These instructions assume the kernels live on eMMC. Adjust devices accordingly for SD card setup.*
                    197: 
                    198: To setup an ODROID-C1 to fall back to a recovery kernel in the event of a boot failure, install the recovery kernel as /boot/onetbsd.ub.
                    199: 
                    200: Create /boot/boot.ini as follows:
                    201: [[!template  id=programlisting text="""
                    202: ODROIDC-UBOOT-CONFIG
                    203: setenv bootargs "root=ld0f awge0.mac-address=${ethaddr}"
                    204: fatload mmc 0:1 0x22000000 boot.scr
                    205: source 0x22000000
                    206: """]]
                    207: 
                    208: Create /boot/boot.txt:
                    209: [[!template  id=programlisting text="""
                    210: # regenerate with:
                    211: #  mkubootimage -A arm -C none -O netbsd -T script -a 0 -n "NetBSD/odroidc1 boot" boot.txt boot.scr
                    212: 
                    213: setenv rescue_kernel "onetbsd.ub"
                    214: setenv kernel "netbsd.ub"
                    215: 
                    216: if test ${boot_rescue} = false; then
                    217:   setenv boot_rescue true
                    218:   saveenv
                    219:   fatload mmc 0:1 0x21000000 ${kernel}
                    220:   mw.l c1109900 0f08ffff        # arm watchdog
                    221:   bootm 0x21000000
                    222: else
                    223:   fatload mmc 0:1 0x21000000 ${rescue_kernel}
                    224:   bootm 0x21000000
                    225: fi
                    226: """]]
                    227: 
                    228: Generate boot.scr from boot.txt:
                    229: [[!template  id=programlisting text="""
                    230: mkubootimage -A arm -C none -O netbsd -T script -a 0 -n "NetBSD/odroidc1 boot" /boot/boot.txt /boot/boot.scr
                    231: """]]
                    232: 
                    233: Install the **uenv** tool from above and add the following to root's crontab:
                    234: [[!template  id=programlisting text="""
                    235: @reboot                                 /usr/local/sbin/uenv ld0 boot_rescue false
                    236: """]]
                    237: 
1.12      wiki      238: # Documentation
                    239: 
                    240: Amlogic S805 datasheet: <http://dn.odroid.com/S805/Datasheet/S805_Datasheet%20V0.8%2020150126.pdf>
                    241: 
1.1       wiki      242: # ODROID-C1 UART pins
                    243: 
                    244: From [ODROID Forum](http://forum.odroid.com/viewtopic.php?f=115&t=7684):
                    245: 
                    246: [[!template  id=programlisting text="""
                    247:  ___UART____
                    248: |Pin 4 - GND|
                    249: |Pin 3 - RXD|
                    250: |Pin 2 - TXD|
                    251: |Pin 1 - VCC|
                    252: \___________|
                    253: 
                    254: 3.3V LVTTL
                    255: """]]
1.26      leot      256: 

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