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, 1 month ago) by wiki
Branches: MAIN
CVS tags: HEAD
web commit by jmcneill: GPIO, SYS_LED info

[[!meta title="NetBSD/evbarm on Hardkernel ODROID-C1"]]

[ODROID-C1]( is a $35 quad-core SBC from Hardkernel. ODROID-C1 support was introduced in NetBSD 7.0.

[[!toc levels=2]]

# Supported hardware
 - CPU: Cortex-A5: Amlogic S805 (4-core) at 1.5GHz
   - CPU frequency scaling is supported with machdep.cpu sysctl tree
   - SMP supported
   - PL310 L2 cache controller
 - GIC
 - A5 watchdog timer
 - A5 global timer
 - SD/MMC controller (DMA)
 - Serial console
 - Framebuffer console
 - USB host (OTG)
 - Gigabit Ethernet (GMAC)
   - RTL8211F PHY
 - Hardware random number generator
 - RTC

 - USB device mode
 - Simultaneous SD card and eMMC usage
 - SD/MMC UHS-I support (needs sdmmc(4) changes)
 - IR receiver
 - I2C
 - Audio

# Installation

* Start with an ARMv7 image from *evbarm-earmv7hf/binary/gzimg/* such as *beagleboard.img*
* Build U-Boot for ODROID-C1 <>
  * Pre-built binaries here: <>
* Note the location and size of the FFS partition in the *beagleboard.img* disklabel:
[[!template  id=programlisting text="""
# $TOOLDIR/bin/nbdisklabel -M evbarm -B le beagleboard.img
8 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:   1359312    385024     4.2BSD      0     0     0  # (Cyl.    188 -    851*)
 b:    262144    122880       swap                     # (Cyl.     60 -    187)
 c:   1744336         0     unused      0     0        # (Cyl.      0 -    851*)
 d:   1744336         0     unused      0     0        # (Cyl.      0 -    851*)
 e:    114688      8192      MSDOS                     # (Cyl.      4 -     59)
* Write the bootloader to the empty space at the start of the base image:
[[!template  id=programlisting text="""
# dd if=bl1.bin.hardkernel of=beagleboard.img bs=1 count=442 conv=notrunc
# dd if=bl1.bin.hardkernel of=beagleboard.img bs=512 skip=1 seek=1 conv=notrunc
# dd if=u-boot.bin of=beagleboard.img bs=512 seek=64 conv=notrunc
* Since the bootloader has overwritten the disklabel, we need to re-add partition "a" from the disklabel to the MBR partition table:
[[!template  id=programlisting text="""
# $TOOLDIR/bin/armv7--netbsdelf-eabihf-fdisk -u beagleboard.img
Which partition do you want to change?: [none] 1
The data for partition 1 is:
sysid: [0..255 default: 169] 
start: [0..109cyl default: 63, 0cyl, 0MB] 385024
size: [0..85cyl default: 1359312, 85cyl, 664MB] 1359312
Which partition do you want to change?: [none] 
Should we write new partition table? [n] y
* Write the image to an SD card.
* Copy the kernel (netbsd.ub) for your board to the root of the MS-DOS partition on the SD card.
* Create or edit *boot.ini* on the MS-DOS partition:
[[!template  id=programlisting text="""

setenv bootargs "root=ld0f awge0.mac-address=${ethaddr}"
setenv bootcmd "fatload mmc 0:1 0x21000000 netbsd.ub; bootm 0x21000000"
run bootcmd
* On first boot, it will stop because of the wrong device in /etc/fstab. Take this opportunity to grow the root file-system:
[[!template  id=programlisting text="""
# fdisk -u ld0
Which partition do you want to change?: [none] 1
The data for partition 1 is:
NetBSD (sysid 169)
    start 385024, size 1359312 (664 MB, Cyls 23/246/32-108/147/55)
        PBR is not bootable: All bytes are identical (0x00)
sysid: [0..255 default: 169]
start: [0..966cyl default: 385024, 24cyl, 188MB]
size: [0..942cyl default: 1359312, 85cyl, 664MB] $
Which partition do you want to change?: [none]
Should we write new partition table? [n] y
# resize_ffs -y /dev/rld0f
# reboot
* Next boot, create a new /etc/fstab:
[[!template  id=programlisting text="""
# mount -u -o rw /dev/ld0f /
# cat > /etc/fstab << EOF
/dev/ld0f       /               ffs     rw      1 1
/dev/ld0e       /boot           msdos   rw      1 1
kernfs          /kern           kernfs  rw
ptyfs           /dev/pts        ptyfs   rw
procfs          /proc           procfs  rw
tmpfs           /var/shm        tmpfs   rw,-m1777,-sram%25
# reboot


## Framebuffer console

Simply add **console=fb** to the *bootargs* variable in *boot.ini*.

## Video mode

HDMI video mode can be selected in U-Boot with the *video* command, e.g.:

[[!template  id=programlisting text="""
odroidc#video dev open 1080P

To make this change permanent, add it to the *bootcmd* variable in *boot.ini*:

[[!template  id=programlisting text="""
setenv bootcmd "video dev open 1080P; fatload mmc 0:1 0x21000000 netbsd.ub; bootm 0x21000000"

## 16 or 24 bpp?

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 <>.

## Overscan compensation

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.:

[[!template  id=programlisting text="""
# sysctl -w hw.genfb0.scale=95

Setting *scale* to 100 disables scaling, any other value enables the scaler. Values between 10 and 100 are allowed.

To set this value at boot, you can add **fb.scale=95** to the kernel cmdline options in *boot.ini*.


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*:

[[!template  id=programlisting text="""
gpio4 13 set out sys_led

After rebooting, the LED state can be controlled with [[!template id=man name="gpioctl" section="8"]].

[[!template  id=programlisting text="""
# turn the light on
gpioctl gpio4 sys_led on

# turn the light off
gpioctl gpio4 sys_led off

# toggle the light state
gpioctl gpio4 sys_led toggle

# Documentation

Amlogic S805 datasheet: <>


From [ODROID Forum](

[[!template  id=programlisting text="""
|Pin 4 - GND|
|Pin 3 - RXD|
|Pin 2 - TXD|
|Pin 1 - VCC|


CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb