File:  [NetBSD Developer Wiki] / wikisrc / ports / evbarm / odroid-c1.mdwn
Revision 1.32: download - view: text, annotated - select for diffs
Fri Feb 19 23:06:17 2021 UTC (2 months, 2 weeks ago) by wiki
Branches: MAIN
CVS tags: HEAD
web commit by christos

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

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