Connected the DHT11 sensor to TM4C123. The sensor is not that accurate, but simple to use. Result displayed on Nokia 5110 LCD.
Programs written with Energia. There are libraries for the sensor and LCD display, but both require slight modification.
Code available on github.
Updates 2016-05-14:
Here is the wiring. Note that my Nokia 5110 board support input of 3v to 5v. Your mileage may vary.
TM4C123 - LCD 5110 Comment
==================================
VBUS - Vcc My version of 5110 supports 3v to 5v
VBUS - BL Backlight
GND - GND
PB_5 - RST Reset
PB_4 - Clk SCK(2) to Clock
PB_7 - Din MOSI(2) to Serial data in
PA_7 - CE Chip Select
PA_2 - DC Select between data or command
TM4C123 - DHT11 Comment
==================================
PD_7 - Data
VBUS - Vcc
GND - GND
Sunday, August 9, 2015
Saturday, August 8, 2015
Nokia 5110 LCD connected to Raspberry Pi
Following sample wiring method as shown on Adafruit:
Source code available on github:
https://github.com/kitsook/lcd5110
Wednesday, August 5, 2015
JMH result on UDOO
Just for fun. As a follow-up on Java 8 on UDOO. Here are the result of running JMH on UDOO.
OpenJDK 1.8.0_51 (Zero VM in interpreted mode only. No Cacao for the default build):
Oracle JVM 1.8.0_51:
That is 18x improvement on the througput.
OpenJDK 1.8.0_51 (Zero VM in interpreted mode only. No Cacao for the default build):
Benchmark Mode Cnt Score Error Units MyBenchmark.testMethod thrpt 200 2593688.336 ? 4998.196 ops/s
Oracle JVM 1.8.0_51:
Benchmark Mode Cnt Score Error Units MyBenchmark.testMethod thrpt 200 47042989.345 ? 97733.584 ops/s
That is 18x improvement on the througput.
Java 8 on UDOO
The performance of OpenJDK 8 on UDOO (Archlinux) is not that great when compared with Beaglebone Black:
Time to download the Oracle JDK 8 for ARM. Same as the case with BBB and Raspberry Pi, the result is much better:
$ uname -a Linux maggie 4.1.3-1-ARCH #1 SMP Wed Jul 22 18:44:39 MDT 2015 armv7l GNU/Linux $ java -version openjdk version "1.8.0_51" OpenJDK Runtime Environment (build 1.8.0_51-b16) OpenJDK Zero VM (build 25.51-b03, interpreted mode) $ time java -XX:+TieredCompilation -XX:+AggressiveOpts fastaredux 25000000 > /dev/null 2>&1 real 6m52.692s user 6m52.095s sys 0m0.480s
Time to download the Oracle JDK 8 for ARM. Same as the case with BBB and Raspberry Pi, the result is much better:
$ java -version java version "1.8.0_51" Java(TM) SE Runtime Environment (build 1.8.0_51-b07) Java HotSpot(TM) Client VM (build 25.51-b07, mixed mode) $ time java -XX:+TieredCompilation -XX:+AggressiveOpts fastaredux 25000000 > /dev/null 2>&1 real 0m20.618s user 0m20.355s sys 0m0.290s
Wednesday, July 29, 2015
Java converting bytes to integers
Saw this Java method on github for converting Little Endian bytes to an integer:
The implementation above is incorrect. In Java, bytes are signed. So the signed bit will got extended when a byte is casted as integer. The correct way to do it should be:
private static int U8TO32_LE(byte[] x, int i) {
return x[i] | (x[i + 1] << 8) | (x[i + 2] << 16) | (x[i + 3] << 24);
}
The implementation above is incorrect. In Java, bytes are signed. So the signed bit will got extended when a byte is casted as integer. The correct way to do it should be:
private static int U8TO32_LE(byte[] x, int i) {
return (x[i] & 0xff) | ((x[i + 1] & 0xff) << 8) | ((x[i + 2] & 0xff) << 16) | ((x[i + 3] & 0xff) << 24);
}
ChaCha20 Java implementation
Thursday, July 16, 2015
Netwon's method with Java lambda expression
Here is a quick-and-dirty implementation of the Newton's method using Java Lambda Expression.
And here are some use/test cases:
Friday, June 12, 2015
Dual band wireless router as bridge with DD-WRT
Many people configure old wireless routers as repeaters to extend range of their networks:
However, with a dual band (2.4GHz and 5GHz) router, it can be used to boost wifi performance. The idea is that, at location where wifi is weak, the secondary router can be configured as bridge to connect to primary router using 2.4GHz (as it has better penetration through walls than 5GHz). Not to mention that with DD-WRT, the TX power can be configured to be much higher than your portable devices.
At the same time, the 5GHz channel of the secondary router can provide a strong and non-interfered signal to local devices. Internet traffic will be bridged to primary router via the 2.4GHz channel.
I recently moved back to Canada and now living in a house sharing the existing Telus internet connection with others :(. There are some tricks that can be done on the crappy V1000H router provided by Telus, but that will be another story.
Since the internet router is located in another floor, the wifi connection is not optimal for me. So I reconfigured my DD-WRT-ed Asus RT-N66U as the diagram shown above. Steps are clearly stated on DD-WRT web site on how to setup router as bridge. The only different is that since my router is dual band, the 5GHz channel can be used to serve my devices while 2.4GHz is used as bridge.
Here are some speed tests ran on my Dell Inspiron 13 (Intel AC7265):
2.4GHz directly to the primary router:
5GHz to secondary router, bridged to primary router via 2.4GHz:
As expected:
- latency is higher when there is one more hop
- improvement on both download and upload speed is significant
(figure from dd-wrt web site)
However, with a dual band (2.4GHz and 5GHz) router, it can be used to boost wifi performance. The idea is that, at location where wifi is weak, the secondary router can be configured as bridge to connect to primary router using 2.4GHz (as it has better penetration through walls than 5GHz). Not to mention that with DD-WRT, the TX power can be configured to be much higher than your portable devices.
At the same time, the 5GHz channel of the secondary router can provide a strong and non-interfered signal to local devices. Internet traffic will be bridged to primary router via the 2.4GHz channel.
I recently moved back to Canada and now living in a house sharing the existing Telus internet connection with others :(. There are some tricks that can be done on the crappy V1000H router provided by Telus, but that will be another story.
Since the internet router is located in another floor, the wifi connection is not optimal for me. So I reconfigured my DD-WRT-ed Asus RT-N66U as the diagram shown above. Steps are clearly stated on DD-WRT web site on how to setup router as bridge. The only different is that since my router is dual band, the 5GHz channel can be used to serve my devices while 2.4GHz is used as bridge.
Here are some speed tests ran on my Dell Inspiron 13 (Intel AC7265):
2.4GHz directly to the primary router:
5GHz to secondary router, bridged to primary router via 2.4GHz:
As expected:
- latency is higher when there is one more hop
- improvement on both download and upload speed is significant
Wednesday, April 29, 2015
Tuesday, March 10, 2015
Cross-compile kernel modules for Raspberry Pi
This is a quick note on how to cross-compile third party kernel modules for Raspberry Pi. The aim is to keep the stock kernel while compiling a module with matching version.
On Raspberry Pi
Update software on the Raspberry Pi
Also, install rpi-update to upgrade the firmware and kernel. Then reboot.
Check the version of kernel
Also, we need to know the configuration used to compile the kernel. Execute the following command to save it to .config. Transfer the file to the cross-compile machine. We will use it later when compiling the kernel.
Here the kernel version is 3.18.9. We can now work on a desktop computer for cross-compiling. First we need to compile the kernel source in order to generate the Module.symvers file. We need this file when compiling third-party modules. For the following example, I will be using a Ubuntu x64 machine.
On the cross-compile machine
Create a folder and download the Rapberry Pi kernel source.
Check the Makefile and make sure the version is same as the kernel running on your Raspberry Pi.
Create another folder and download the compiler and tools
Set an environment variable KERNEL_SRC to point to the location of the source, e.g.
Set an environment variable CCPREFIX to the prefix of the path of tools, e.g.
Change directory to the kernel source and clean the tree
Copy the .config file we created earlier on Raspberry Pi to the kernel source directory, e.g.
We can start to compile the kernel now. In theory we only needed to build the modules. However, here we build the whole kernel and modules just for fun
Once it is done, we can go ahead to build our third party modules, e.g.
Note that you may need to modify the module's Makefile, e.g.
Here, the "-C" path is pointing to the root of the kernel source we just built.
On Raspberry Pi
Update software on the Raspberry Pi
$ sudo apt-get update
$ sudo apt-get upgradeAlso, install rpi-update to upgrade the firmware and kernel. Then reboot.
$ sudo apt-get install rpi-update
$ sudo rpi-update
$ sudo sh -c “sync; sync; shutdown -r now”Check the version of kernel
$ uname -a
Linux fax1 3.18.9+ #767 PREEMPT Sat Mar 7 21:41:13 GMT 2015 armv6l GNU/LinuxAlso, we need to know the configuration used to compile the kernel. Execute the following command to save it to .config. Transfer the file to the cross-compile machine. We will use it later when compiling the kernel.
$ zcat /proc/config.gz > .configHere the kernel version is 3.18.9. We can now work on a desktop computer for cross-compiling. First we need to compile the kernel source in order to generate the Module.symvers file. We need this file when compiling third-party modules. For the following example, I will be using a Ubuntu x64 machine.
On the cross-compile machine
Create a folder and download the Rapberry Pi kernel source.
$ git clone https://github.com/raspberrypi/linux.gitCheck the Makefile and make sure the version is same as the kernel running on your Raspberry Pi.
Create another folder and download the compiler and tools
$ git clone https://github.com/raspberrypi/toolsSet an environment variable KERNEL_SRC to point to the location of the source, e.g.
$ KERNEL_SRC=/home/cho/work/rpi/linuxSet an environment variable CCPREFIX to the prefix of the path of tools, e.g.
$ CCPREFIX=/home/cho/work/rpi-tools/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-Change directory to the kernel source and clean the tree
$ cd /home/cho/work/rpi/linux
$ make mrproperCopy the .config file we created earlier on Raspberry Pi to the kernel source directory, e.g.
$ cp ~/download/.config /home/cho/work/rpi/linuxWe can start to compile the kernel now. In theory we only needed to build the modules. However, here we build the whole kernel and modules just for fun
$ cd /home/cho/work/rpi/linux
$ ARCH=arm CROSS_COMPILE=${CCPREFIX} make oldconfigOnce it is done, we can go ahead to build our third party modules, e.g.
$ cd /home/cho/work/tsc2007/raspi/tsc2007
$ ARCH=arm CROSS_COMPILE=${CCPREFIX} makeNote that you may need to modify the module's Makefile, e.g.
obj-m += tsc2007.o
obj-m += tsc_raspi.o
all:
make -C /home/cho/work/rpi/linux M=$(PWD) modules
clean:
make -C /home/cho/work/rpi/linux M=$(PWD) clean
Here, the "-C" path is pointing to the root of the kernel source we just built.
Subscribe to:
Posts (Atom)




