<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>none of this matters &#187; linux</title>
	<atom:link href="http://blog.nemik.net/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nemik.net</link>
	<description></description>
	<lastBuildDate>Mon, 09 Jan 2012 23:55:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Building Energy Micro EFM32 binaries from OS X</title>
		<link>http://blog.nemik.net/2011/06/building-energy-micro-efm32-binaries-from-os-x/</link>
		<comments>http://blog.nemik.net/2011/06/building-energy-micro-efm32-binaries-from-os-x/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 04:09:40 +0000</pubDate>
		<dc:creator>nemik</dc:creator>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[arm ubuntu energy micro efm32 gdb jtag swd micrcontrollers openocd linux]]></category>

		<guid isPermaLink="false">http://blog.nemik.net/?p=101</guid>
		<description><![CDATA[I&#8217;m currently evaluating the EFM32 Gecko MCU from Energy Micro for a project. I&#8217;m using the Developer&#8217;s Kit with the EFM32G290F128 MCU. I mainly work in OS X and Linux and don&#8217;t much like having to boot up the Windows Virtual Machine to develop and debug firmwares. The tools mostly suck (I &#60;3 the CLI) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently evaluating the EFM32 Gecko MCU from Energy Micro for a project. I&#8217;m using the Developer&#8217;s Kit with the EFM32G290F128 MCU.</p>
<p>I mainly work in OS X and Linux and don&#8217;t much like having to boot up the Windows Virtual Machine to develop and debug firmwares. The tools mostly suck (I &lt;3 the CLI) or are very expensive (often both). So I wanted a way to use open source tools like gcc, gdb and openocd.</p>
<p>First step was getting a binary to compile.</p>
<p>1. visit https://github.com/jsnyder/arm-eabi-toolchain and install as directed, make sure you run the make install-bin-extras after all the make-ing and make install-ing.</p>
<p>2. try a sample EFM32G firmware like the one included in the <a href="http://cdn.energymicro.com/dl/packages/DVK_BSP_1.6.1.zip">DVK_BSP_1.6.1.zip</a> copy the &#8216;blink&#8217; one to some directory of your choosing for this project.</p>
<p>3. Download the <a href="http://cdn.energymicro.com/dl/packages/EFM32_CMSIS_2.0.0.zip">EFM CMSIS Library</a> and copy it to the parent directory of the project directory you chose in step 2. Do the same with the &#8216;bsp&#8217; and &#8216;efm32lib&#8217; directories from the DVK_BSP.</p>
<p>4. Edit the Makefile from the &#8216;codesourcery&#8217; part of the example. Mine looks like this:<br />
<code><br />
####################################################################<br />
# Makefile                                                         #<br />
####################################################################</p>
<p>.SUFFIXES:				# ignore builtin rules<br />
.PHONY: all debug release clean</p>
<p>####################################################################<br />
# Definitions                                                      #<br />
####################################################################</p>
<p>DEVICE = EFM32G290F128<br />
PROJECTNAME = blinkG290</p>
<p>OBJ_DIR = build<br />
EXE_DIR = exe<br />
LST_DIR = lst</p>
<p>####################################################################<br />
# Definitions of toolchain.                                        #<br />
# You might need to do changes to match your system setup          #<br />
####################################################################</p>
<p># Change path to CodeSourcery tools according to your system configuration<br />
WINDOWSCS = CodeSourcery/Sourcery G++ Lite<br />
LINUXCS   = /Users/nemik/code/arm-cs-tools<br />
GCCVERSION = $(shell $(CC) -dumpversion)</p>
<p>ifeq ($(ComSpec),)<br />
  ifeq ($(COMSPEC),)<br />
    # Assume we are making on a linux platform<br />
    TOOLDIR = $(LINUXCS)<br />
    RM = rm -rf<br />
  else<br />
    TOOLDIR = $(PROGRAMFILES)/$(WINDOWSCS)<br />
    RM = "$(TOOLDIR)/bin/cs-rm" -rf<br />
  endif<br />
else<br />
  TOOLDIR = $(ProgramFiles)/$(WINDOWSCS)<br />
  RM = "$(TOOLDIR)/bin/cs-rm" -rf<br />
endif</p>
<p>CC      = "$(TOOLDIR)/bin/arm-none-eabi-gcc"<br />
LD      = "$(TOOLDIR)/bin/arm-none-eabi-ld"<br />
AR      = "$(TOOLDIR)/bin/arm-none-eabi-ar"<br />
OBJCOPY = "$(TOOLDIR)/bin/arm-none-eabi-objcopy"<br />
DUMP    = "$(TOOLDIR)/bin/arm-none-eabi-objdump" --disassemble</p>
<p>####################################################################<br />
# Flags                                                            #<br />
####################################################################</p>
<p># -MMD : Don't generate dependencies on system header files.<br />
# -MP  : Add phony targets, useful when a h-file is removed from a project.<br />
# -MF  : Specify a file to write the dependencies to.<br />
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)<br />
# Add -Wa,-ahlms=$(LST_DIR)/$(@F:.o=.lst) to CFLAGS to produce assembly list files<br />
CFLAGS += -D$(DEVICE) -mcpu=cortex-m3 -mthumb -Wall  $(DEPFLAGS)<br />
ASMFLAGS += -Ttext 0x0<br />
LDFLAGS += -Xlinker -Map=$(LST_DIR)/$(PROJECTNAME).map -mcpu=cortex-m3 -mthumb -T../CMSIS/CM3/DeviceSupport/EnergyMicro/EFM32/startup/cs3/efm32g.ld -L"$(TOOLDIR)/arm-none-eabi/lib/thumb2" \<br />
-L"$(TOOLDIR)/lib/gcc/arm-none-eabi/$(GCCVERSION)/thumb2"<br />
LIBS += -lc -lcs3 -lcs3unhosted</p>
<p>INCLUDEPATHS += \<br />
-I.. \<br />
-I../CMSIS/CM3/CoreSupport \<br />
-I../CMSIS/CM3/DeviceSupport/EnergyMicro/EFM32 \<br />
-I../efm32lib/inc \<br />
-I../bsp \<br />
-I../drivers</p>
<p>####################################################################<br />
# Files                                                            #<br />
####################################################################</p>
<p>C_SRC +=  \<br />
../CMSIS/CM3/CoreSupport/core_cm3.c \<br />
../CMSIS/CM3/DeviceSupport/EnergyMicro/EFM32/system_efm32.c \<br />
../bsp/dvk.c \<br />
../bsp/dvk_boardcontrol.c \<br />
../bsp/dvk_ebi.c \<br />
../bsp/dvk_spi.c \<br />
../efm32lib/src/efm32_assert.c \<br />
../efm32lib/src/efm32_cmu.c \<br />
../efm32lib/src/efm32_gpio.c \<br />
../efm32lib/src/efm32_emu.c \<br />
../efm32lib/src/efm32_ebi.c \<br />
../efm32lib/src/efm32_system.c \<br />
../efm32lib/src/efm32_usart.c \<br />
blink.c</p>
<p>S_SRC +=  \<br />
../CMSIS/CM3/DeviceSupport/EnergyMicro/EFM32/startup/cs3/startup_efm32.s</p>
<p>####################################################################<br />
# Rules                                                            #<br />
####################################################################</p>
<p>C_FILES = $(notdir $(C_SRC) )<br />
S_FILES = $(notdir $(S_SRC) )<br />
#make list of source paths, sort also removes duplicates<br />
C_PATHS = $(sort $(dir $(C_SRC) ) )<br />
S_PATHS = $(sort $(dir $(S_SRC) ) )</p>
<p>C_OBJS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.o))<br />
S_OBJS = $(addprefix $(OBJ_DIR)/, $(S_FILES:.s=.o))<br />
C_DEPS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.d))</p>
<p>vpath %.c $(C_PATHS)<br />
vpath %.s $(S_PATHS)</p>
<p># Default build is debug build<br />
all:      debug</p>
<p>debug:    CFLAGS += -DDEBUG -g3 -O0<br />
debug:    $(OBJ_DIR) $(LST_DIR) $(EXE_DIR) $(EXE_DIR)/$(PROJECTNAME).bin</p>
<p>release:  CFLAGS += -DNDEBUG -O3<br />
release:  $(OBJ_DIR) $(LST_DIR) $(EXE_DIR) $(EXE_DIR)/$(PROJECTNAME).bin</p>
<p># Create directories<br />
$(OBJ_DIR):<br />
	mkdir $(OBJ_DIR)<br />
	@echo "Created build directory."</p>
<p>$(EXE_DIR):<br />
	mkdir $(EXE_DIR)<br />
	@echo "Created executable directory."</p>
<p>$(LST_DIR):<br />
	mkdir $(LST_DIR)<br />
	@echo "Created list directory."</p>
<p># Create objects from C SRC files<br />
$(OBJ_DIR)/%.o: %.c<br />
	@echo "Building file: $<"<br />
	$(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<</p>
<p># Assemble .s files<br />
$(OBJ_DIR)/%.o: %.s<br />
	@echo "Assembling $<"<br />
	$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<</p>
<p># Link<br />
$(EXE_DIR)/$(PROJECTNAME).out: $(C_OBJS) $(S_OBJS)<br />
	@echo "Linking target: $@"<br />
	$(CC) $(LDFLAGS) $(C_OBJS) $(S_OBJS) $(LIBS) -o $(EXE_DIR)/$(PROJECTNAME).out</p>
<p># Create binary file<br />
$(EXE_DIR)/$(PROJECTNAME).bin: $(EXE_DIR)/$(PROJECTNAME).out<br />
	@echo "Creating binary file"<br />
	$(OBJCOPY) -O binary $(EXE_DIR)/$(PROJECTNAME).out $(EXE_DIR)/$(PROJECTNAME).bin<br />
# Uncomment next line to produce assembly listing of entire program<br />
#	$(DUMP) $(EXE_DIR)/$(PROJECTNAME).out>$(EXE_DIR)/$(PROJECTNAME).lst</p>
<p>clean:<br />
	$(RM) $(OBJ_DIR) $(LST_DIR) $(EXE_DIR)</p>
<p># include auto-generated dependency files (explicit rules)<br />
ifneq (clean,$(findstring clean, $(MAKECMDGOALS)))<br />
-include $(C_DEPS)<br />
endif<br />
</code></p>
<p>5. Run the `make` command</p>
<p>6. You should have a &#8216;blinkG290.bin&#8217; in the &#8216;exe&#8217; directory. Seems a bit nuts that my bin is 14kb though&#8230;seems quite high for a blinking program; could that be CodeSourcery&#8217;s libcs3 adding so much?</p>
<p>7. Now you can use the energyAware Commander Windows program to load the firmware onto the board :/. I was not able to get openOCD working with the on-board JLink module and SWD. I&#8217;m now in the process of trying to get my BusPirate board to act as a JTAG interface for using the 20-pin adapter of the EFM32 Development Kit and hoping it does JTAG&#8230;<br />
If not, one could also write a Python script with some XMODEM-CRC library to try to upload code to the built-in bootloader on the EFM32 chips using some FTDI USB-serial cable with something like the DST pin being used to pulse RESET and some other un-used serial pin to hold down DBG_SWCLK. But even then some way to debug is needed&#8230;really hoping JTAG can somehow work.</p>
<p>Has anyone tried to do something similar on Linux or OS X without the official Segger JLink software? They don&#8217;t produce OS X binaries and it&#8217;s closed source. Or has anyone gotten an EFM32 DK with its built-in JLink debugger to work with openOCD? Any suggestions would be awesome.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nemik.net/2011/06/building-energy-micro-efm32-binaries-from-os-x/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Arduinoponics with OpenWRT</title>
		<link>http://blog.nemik.net/2009/12/arduinoponics-with-openwrt/</link>
		<comments>http://blog.nemik.net/2009/12/arduinoponics-with-openwrt/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 05:28:49 +0000</pubDate>
		<dc:creator>nemik</dc:creator>
				<category><![CDATA[hydroponics]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.nemik.net/?p=89</guid>
		<description><![CDATA[I updated my GitHub repo: http://github.com/nemik/arduinoponics with code I wrote for the OpenWRT firmware (version 8.09.1). It provides an AJAXy-updating page to OpenWRT&#8217;s Luci web-interface which displays the analog pin values from the Arduino which the Arduinoponics sketch runs on. Here is a screenshot, notice the extra &#8216;Sensors&#8217; link on the top right to access [...]]]></description>
			<content:encoded><![CDATA[<p>I updated my GitHub repo: <a href="http://github.com/nemik/arduinoponics">http://github.com/nemik/arduinoponics</a> with code I wrote for the OpenWRT firmware (version 8.09.1). It provides an AJAXy-updating page to OpenWRT&#8217;s Luci web-interface which displays the analog pin values from the Arduino which the Arduinoponics sketch runs on.</p>
<p>Here is a screenshot, notice the extra &#8216;Sensors&#8217; link on the top right to access the info, the page does not require login<br />
<a href="http://blog.nemik.net/wp-content/uploads/2009/12/Picture-3.png" rel="lightbox[blog]"><img class="alignnone size-medium wp-image-91" title="Arduinoponics OpenWRT screenshot" src="http://blog.nemik.net/wp-content/uploads/2009/12/Picture-3-300x168.png" alt="Arduinoponics OpenWRT screenshot" width="300" height="168" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nemik.net/2009/12/arduinoponics-with-openwrt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing broken JFFS2 partition</title>
		<link>http://blog.nemik.net/2009/11/fixing-broken-jffs2-partition/</link>
		<comments>http://blog.nemik.net/2009/11/fixing-broken-jffs2-partition/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 04:17:14 +0000</pubDate>
		<dc:creator>nemik</dc:creator>
				<category><![CDATA[hydroponics]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.nemik.net/?p=86</guid>
		<description><![CDATA[Lesson #1 of embedded development: don&#8217;t write all your code to your device and not backup/check-in. I did just that when writing some code for the hydroponics monitoring setup on my Fon2100 router running OpenWRT. After trying to opkg install ntpclient and getting a segfault and NTP not working, I restarted  the network on it [...]]]></description>
			<content:encoded><![CDATA[<p>Lesson #1 of embedded development: don&#8217;t write all your code to your device and not backup/check-in. I did just that when writing some code for the hydroponics monitoring setup on my Fon2100 router running <a href="http://openwrt.org/">OpenWRT</a>. After trying to opkg install ntpclient and getting a segfault and NTP not working, I restarted  the network on it which restarted the router. For whatever reason, the router choked and each restart went into failsafe mode. When I telnet&#8217;d into it, dmesg told me the jffs2 partition had trouble mounting with an error in jffs2_link_node_ref.</p>
<p>I had written a bunch of Lua code to read the serial communications coming from the ATMega168 microcontroller (it was sending its analog input values) and store it into files in /tmp which were then read by some more Lua code in the (awesome) <a href="http://luci.subsignal.org/">LuCI</a> framework to make those sensors all cool and AJAXy on the router&#8217;s web-admin menu. This worked great until the NTP attempt. So I wanted all this code back. So in case anyone is as foolish as I was to lose their code in the router, here are the steps I took to recover it. David Woodhouse (dwmw2) and dedekind at #mtd on irc.ipv6.oftc.net were extremely helpful with all this and pointed me in all the right directions.</p>
<ol>
<li>
<div>backup the jffs2 image from the router using dd. mine was coming up in failsafe mode so i had to telnet into 192.168.1.1 and then run command `dd if=/dev/mtdblock2 | gzip -c | ssh nemik@pillbox &#8216;dd of=/tmp/mtd2.gz&#8217; bs=2048` but make sure you do the right mtdblock2 device. do `cat /proc/mtd` and choose the one that is for “rootfs_data”. pillbox is a Linux box on my network I transferred this all to.</div>
</li>
<li>
<div>`gunzip /tmp/mtd2.gz` on the Linux box and i got my 5.5MB partition.</div>
</li>
<li>
<div>wget <a title="ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-1.2.0.tar.bz2" rel="nofollow" href="ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-1.2.0.tar.bz2">ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-1.2.0.tar.bz2</a>. untar, make, make install</div>
</li>
<li>
<div>`sudo mknod /dev/mtd0 c 90 0`</div>
</li>
<li>
<div>`sudo modprobe mtdblock`</div>
</li>
<li>
<div>`sudo dd if=/tmp/mtd2 of=/dev/mtd0 bs=2048`</div>
</li>
<li>
<div>`sudo mount -t jffs2 mtd0 /tmp/1/` THIS DIDN&#8217;T WORK! (right away). The Fon router and openWRT are big-endian and I was trying to mount this on a little-endian x86 box. I needed to recompile the jffs2 kernel module to be big-endian. David Woodhouse (creator of JFFS2) writes how here: [<a title="http://www.infradead.org/pipermail/linux-mtd/2007-May/018227.html" rel="nofollow" href="http://www.infradead.org/pipermail/linux-mtd/2007-May/018227.html">http://www.infradead.org/pipermail/linux-mtd/2007-May/018227.html</a>] I needed to get the kernel source and recompile the jffs2 module</div>
</li>
<li>
<div>get the kernel source `apt-get source linux-image-$(uname -r)`</div>
</li>
<li>
<div>go into the source and do `make prepare_modules`</div>
</li>
<li>
<div>copy /usr/src/linux-headers-2.6.27-14-generic/Module.symvers to the source. this will be different for you, but the Module.symvers is important otherwise the module won&#8217;t load properly</div>
</li>
<li>Change the native_endian #define in fs/jffs2/nodelist.h to be little_endian as David writes in the infraread link on step 7.</li>
<li>
<div>do `make CONFIG_MODVERSIONS=y M=fs/jffs2`</div>
</li>
<li>
<div>if it compiled correctly, you then have a jffs2.ko module. load it via `sudo insmod /home/nemik/code/jffs2/linux-2.6.27/fs/jffs2/jffs2.ko`</div>
</li>
<li>
<div>now try `sudo mount -t jffs2 /dev/mtdblock0 /tmp/1/` and it worked for me!</div>
</li>
</ol>
<p>I was now able to see all my lost files in /tmp/1/ !!! the whole filesystem was there and worked great. I extracted all the code I wrote and learned my lesson never to do development on a router and always backup and check in. Hopefully this helps someone out.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nemik.net/2009/11/fixing-broken-jffs2-partition/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

