Received my MC HCK prototype boards

My first MC HCK
Overview
About
The MC HCK (pronounced: “McHack” [mæk hæk]) is a small, cheap, and versatile microcontroller platform that supports USB for easy programming, and can be built at home for $5. The MC HCK enables everybody to build big and small projects, because spending >$20 for other microcontroller boards is just too much.
Quick Specs
I’ve already ordered a MC HCK prototype kit in July (https://mchck.org/blog/2013-07-27-prototype_kit_funding_succesful/), they were ready for dispatch on 30th September and now I have received them.
Soldering my first MC HCK
I really like that the kits are unassembled, so that I can do a bit SMD soldering.
Prototype Kit 1 Hackers Guide:
Schematics and board layout:
Tools that you may need
- A soldering iron with a fine tip (there is nothing better than a JBC soldering station ;))
- 0.5 mm tin-solder https://en.wikipedia.org/wiki/Solder
- Tweezers
- Magnifying glass
- Solder wick https://en.wikipedia.org/wiki/Desoldering
- Flux https://en.wikipedia.org/wiki/Flux_%28metallurgy%29
- Newspaper
- http://store.curiousinventor.com/guides/Surface_Mount_Soldering/Tools/
- SMD Soldering Guide: http://www.infidigm.net/articles/solder/
Soldering the microcontroller
I will start with soldering the microcontroller because I think its the most complicated to solder component, its in the center of the PCB and heat should be no problem when soldering the other components.
Take your tweezers, position the microcontroller correctly on the PCB then press a bit on the middle of the µC and solder up two pins first.
Then start on another side of the IC, put a bit flux on the pins and solder them up like shown in the video below (http://dangerousprototypes.com/2012/02/03/drag-soldering-a-ft232-ic-with-a-weller-gullwing-tip/):
Soldering ICs works best with a hollowed-out soldering tip.
Soldering the passives
Now the passives, put solder on one pad, hold the component with the tweezers and solder up one side first and then the other.
I will start with the population of C3, C4, C5 and C6.
Next: C1, C2, they should be in the stripe with 10 capacitors (https://github.com/mchck/mchck/wiki/Prototype-Kit-1-Hackers-Guide).
Then R3 which is a 1kR resistor in a white strip with 5 other resistors and labeled 01B.
Now the LED D1. The dot on the SMD LED marks the cathode, it should be pointing away from the uC and USB end, towards the pushbutton.
And finally the push button, now the basic build should be finished.
Blinking LED example
The microcontrollers in the kit have already been flashed with a bootloader and the blink example firmware. After successful assembly, the MC HCK will blink when inserted into a USB port. You can switch the MC HCK into programming mode by pressing the program button - it will then attach as USB DFU device.
To compile our own program we will follow https://github.com/mchck/mchck/wiki/Getting-Started.
Clone the MC HCK git repo:
[chris@thinkpad MCHCK]$ git clone git://github.com/mchck/mchck.git
Cloning into 'mchck'...
remote: Counting objects: 6625, done.
remote: Compressing objects: 100% (2886/2886), done.
remote: Total 6625 (delta 3788), reused 6464 (delta 3644)
Receiving objects: 100% (6625/6625), 42.06 MiB | 842.00 KiB/s, done.
Resolving deltas: 100% (3788/3788), done.
[chris@thinkpad MCHCK]$
Install Ruby:
[chris@thinkpad ~]$ sudo yum install ruby
Loaded plugins: auto-update-debuginfo, fastestmirror, langpacks, refresh-packagekit
Loading mirror speeds from cached hostfile
* fedora: fedora.tu-chemnitz.de
* rpmfusion-free: mirror.us.leaseweb.net
* rpmfusion-free-updates: mirror.us.leaseweb.net
* rpmfusion-nonfree: mirror.us.leaseweb.net
* rpmfusion-nonfree-updates: mirror.us.leaseweb.net
* updates: fedora.tu-chemnitz.de
Package ruby-2.0.0.247-15.fc19.x86_64 already installed and latest version
Nothing to do
[chris@thinkpad ~]$
Building the toolchain
Compile the ARM toolchain for barebone ARM devices (old blog entry):
[chris@thinkpad local]$ sudo yum install mpfr-devel flex gmp-devel libmpc-devel autoconf texinfo bison ncurses-libs ncurses-devel expat expat-devel make gcc gcc-c++ libftdi-devel
[chris@thinkpad local]$ git clone https://github.com/mchck/summon-arm-toolchain.git
[chris@thinkpad local]$ cd summon-arm-toolchain/
[chris@thinkpad local]$ # change install location to ${HOME}/local/sat
[chris@thinkpad summon-arm-toolchain]$ sed -i 's/PREFIX=${HOME}\/sat/PREFIX=${HOME}\/local\/sat/g' summon-arm-toolchain
[chris@thinkpad summon-arm-toolchain]$ # execute the build script
[chris@thinkpad summon-arm-toolchain]$ ./summon-arm-toolchain
... get a cup of coffee ...
[chris@thinkpad summon-arm-toolchain]$
Now you need to export the path of your new toolchain:
[chris@thinkpad ~]$ which arm-none-eabi-gcc
~/local/gcc-arm-none-eabi-4_7-2013q3/bin/arm-none-eabi-gcc
[chris@thinkpad ~]$ export PATH=${HOME}/local/sat/bin:$PATH
[chris@thinkpad ~]$ which arm-none-eabi-gcc
~/local/sat/bin/arm-none-eabi-gcc
[chris@thinkpad ~]$
I’m using normally the toolchain from https://launchpad.net/gcc-arm-embedded/+download to compile my kernels that’s why I’ve added only an alias to my .bashrc:
[chris@thinkpad ~]$ vim .bashrc
[chris@thinkpad ~]$ grep sat .bashrc
alias satexport='export PATH=${HOME}/local/sat/bin:$PATH'
[chris@thinkpad ~]$ source .bashrc
[chris@thinkpad ~]$ which arm-none-eabi-gcc
~/local/gcc-arm-none-eabi-4_7-2013q3/bin/arm-none-eabi-gcc
[chris@thinkpad ~]$ satexport
[chris@thinkpad ~]$ which arm-none-eabi-gcc
~/local/sat/bin/arm-none-eabi-gcc
[chris@thinkpad ~]$
Now I can run satexport when I want to use the summon-arm-toolchain.
You could also add it to your path by adding the following line to your .bashrc:
export PATH=$PATH:${HOME}/local/sat/bin
Compiling and flashing the blink example
[chris@thinkpad MCHCK]$ cd mchck/examples/blink
[chris@thinkpad blink]$ satexport
[chris@thinkpad blink]$ make
...
arm-none-eabi-objcopy -O binary blink.elf blink.bin.tmp
ls -l blink.bin.tmp | awk '{ s=$5; as=29696; printf "%d bytes available\n", (as - s); if (s > as) { exit 1; }}'
28668 bytes available
mv blink.bin.tmp blink.bin
[chris@thinkpad blink]$ make flash
dfu-util -D blink.bin
make: dfu-util: Command not found
make: *** [flash] Error 127
[chris@thinkpad blink]$
To flash the blink example you will need to install dfu-util:
[chris@thinkpad ~]$ sudo yum install dfu-util
Now try again to flash your MC HCK:
[chris@thinkpad blink]$ make flash
dfu-util -D blink.bin
dfu-util 0.7
Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org
Cannot open device
Opening DFU capable USB device... make: *** [flash] Error 1
[chris@thinkpad blink]$
OK, we actually need to plug our MC HCK into the USB port and press the push button (;
[chris@thinkpad blink]$ make flash
dfu-util --device 2323:0001 -D blink.bin
dfu-util 0.7
Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org
Filter on vendor = 0x2323 product = 0x0001
Cannot open device
Opening DFU capable USB device... make: *** [flash] Error 1
[chris@thinkpad blink]$ sudo make flash
dfu-util --device 2323:0001 -D blink.bin
dfu-util 0.7
Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org
Filter on vendor = 0x2323 product = 0x0001
Opening DFU capable USB device... ID 2323:0001
Run-time device DFU version 0110
Found DFU: [2323:0001] devnum=0, cfg=1, intf=0, alt=0, name="UNDEFINED"
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
No valid DFU suffix signature
Warning: File has no DFU suffix
bytes_per_hash=20
Copying data from PC to DFU device
Starting download: [###################################################] finished!
unable to read DFU status
[chris@thinkpad blink]$
Currently I have to use sudo to flash the MC HCK, that can be changed by adding a new udev rule:
[chris@thinkpad blink]$ sudo vim /etc/udev/rules.d/10-local.rules
[chris@thinkpad blink]$ cat /etc/udev/rules.d/10-local.rules
ATTR{idVendor}=="15ba", ATTR{idProduct}=="0004", GROUP="plugdev", MODE="0660" # Olimex Ltd. OpenOCD JTAG TINY
ATTR{idVendor}=="1366", ATTR{idProduct}=="0101", GROUP="plugdev", MODE="0660" # SEGGER J-Link ARM
ATTR{idVendor}=="2323", ATTR{idProduct}=="0001", GROUP="plugdev", MODE="0660" # MC HCK
[chris@thinkpad blink]$
And finally flashing works how it should:
[chris@thinkpad blink]$ make flash
dfu-util --device 2323:0001 -D blink.bin
dfu-util 0.7
Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org
Filter on vendor = 0x2323 product = 0x0001
Opening DFU capable USB device... ID 2323:0001
Run-time device DFU version 0110
Found DFU: [2323:0001] devnum=0, cfg=1, intf=0, alt=0, name="UNDEFINED"
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
No valid DFU suffix signature
Warning: File has no DFU suffix
bytes_per_hash=20
Copying data from PC to DFU device
Starting download: [###################################################] finished!
unable to read DFU status
[chris@thinkpad blink]$
Change the blinking frequency
To see whether it flashes really a new program we can change the blinking frequency:
[chris@thinkpad blink]$ sed -i 's/500/100/g' blink.c
[chris@thinkpad blink]$ cat blink.c
#include <mchck.h>
static struct timeout_ctx t;
static void
blink(void *data)
{
onboard_led(ONBOARD_LED_TOGGLE);
timeout_add(&t, 100, blink, NULL);
}
int
main(void)
{
timeout_init();
/* blink will also setup a timer to itself */
blink(NULL);
sys_yield_for_frogs();
}
[chris@thinkpad blink]$ make
arm-none-eabi-gcc -MM -I../../toolchain//include -I../../toolchain//lib -std=gnu11 -I../../toolchain//CMSIS/Include -I. -include ../../toolchain//include/mchck_internal.h -MT blink.d -MT blink.o -MP -MF blink.d blink.c
arm-none-eabi-gcc -fplan9-extensions -ggdb3 -Os -Wall -Wno-main -mcpu=cortex-m4 -msoft-float -mthumb -ffunction-sections -fdata-sections -fno-builtin -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -I../../toolchain//include -I../../toolchain//lib -std=gnu11 -I../../toolchain//CMSIS/Include -I. -include ../../toolchain//include/mchck_internal.h -c -o blink.o blink.c
../../toolchain//scripts/linkdep -o blink.linkdep blink.o
arm-none-eabi-gcc -o blink.elf -fplan9-extensions -ggdb3 -Os -Wall -Wno-main -mcpu=cortex-m4 -msoft-float -mthumb -ffunction-sections -fdata-sections -fno-builtin -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -Wl,--gc-sections -fwhole-program -T blink.ld-template -nostartfiles -Wl,-Map=blink.map -Wl,-output-linker-script=blink.ld blink.o mchck-lib-builtins.o mchck-lib-gpio.o mchck-lib-onboard-led.o mchck-lib-pin.o mchck-lib-startup_k20.o mchck-lib-system.o mchck-lib-timeout.o
arm-none-eabi-ld: warning: cannot find entry symbol Reset_Handler; defaulting to 0000000000000c00
arm-none-eabi-ld: warning: cannot find entry symbol Reset_Handler; defaulting to 0000000000000c00
arm-none-eabi-objcopy -O binary blink.elf blink.bin.tmp
ls -l blink.bin.tmp | awk '{ s=$5; as=29696; printf "%d bytes available\n", (as - s); if (s > as) { exit 1; }}'
28672 bytes available
mv blink.bin.tmp blink.bin
[chris@thinkpad blink]$ make flash
dfu-util --device 2323:0001 -D blink.bin
dfu-util 0.7
Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org
Filter on vendor = 0x2323 product = 0x0001
Opening DFU capable USB device... ID 2323:0001
Run-time device DFU version 0110
Found DFU: [2323:0001] devnum=0, cfg=1, intf=0, alt=0, name="UNDEFINED"
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
No valid DFU suffix signature
Warning: File has no DFU suffix
bytes_per_hash=20
Copying data from PC to DFU device
Starting download: [###################################################] finished!
unable to read DFU status
[chris@thinkpad blink]$
GCC ARM Embedded toolchain
The GCC ARM Embedded toolchain from https://launchpad.net/gcc-arm-embedded/+download seems to work too:
[chris@thinkpad blink]$ which arm-none-eabi-gcc
~/local/gcc-arm-none-eabi-4_7-2013q3/bin/arm-none-eabi-gcc
[chris@thinkpad blink]$ make
arm-none-eabi-gcc -MM -I../../toolchain//include -I../../toolchain//lib -std=gnu11 -I../../toolchain//CMSIS/Include -I. -include ../../toolchain//include/mchck_internal.h -MT mchck-lib-startup_k20.d -MT mchck-lib-startup_k20.o -MP -MF mchck-lib-startup_k20.d ../../toolchain//lib/mchck/startup_k20.c
...
arm-none-eabi-objcopy -O binary blink.elf blink.bin.tmp
ls -l blink.bin.tmp | awk '{ s=$5; as=29696; printf "%d bytes available\n", (as - s); if (s > as) { exit 1; }}'
28568 bytes available
mv blink.bin.tmp blink.bin
[chris@thinkpad blink]$ make flash
dfu-util --device 2323:0001 -D blink.bin
dfu-util 0.7
Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org
Filter on vendor = 0x2323 product = 0x0001
Opening DFU capable USB device... ID 2323:0001
Run-time device DFU version 0110
Found DFU: [2323:0001] devnum=0, cfg=1, intf=0, alt=0, name="UNDEFINED"
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
No valid DFU suffix signature
Warning: File has no DFU suffix
bytes_per_hash=22
Copying data from PC to DFU device
Starting download: [###################################################] finished!
unable to read DFU status
[chris@thinkpad blink]$
Windows setup
I’m fine with Linux but I know people who may prefer Windows. So lets see how that works.
See here: Embedded development with open source tools on Windows.
What’s next
- Build a second and a third one with a fellow student and then a wireless Atari controller or a notification system for the letter box.
- Use the MC HCK to test the I2C and SPI interface of my OLinuXino