2015年5月12日 星期二

Use J-Link to Program NOR Flash of ARM11 (OpenOCD)

Buy a J-Link debugger first.

Use the official J-Flash can program the NOR flash by JTAG, but the speed is too slow.
If I use the SRAM feature of J-Flash, it can not program with my ARM1176JZF, has some issue at cpu reset.
Switch to use OpenOCD can program the NOR Falsh of ARM1176JZF.

Tools:
OpenOCD (official): http://openocd.org/
OpenOCD (Windows): http://www.freddiechopin.info/en/download/category/4-openocd
OpenOCD (another Windows): http://gnutoolchains.com/arm-eabi/openocd/
Zadig: http://zadig.akeo.ie/

Windows Platform:
1. Download OpenOCD for Windows and extract it.
2. Download Zadig and install the libusb driver for J-Link.
3. Connect PC <-> J-Link <-> CPU JTAG
4. Run "bin/openocd.exe -f interface/jlink.cfg". if the libusb driver and J-Link connect OK, we can see some information of CPU and JTAG.
5. Write a configuration for the CPU.

ARM1176JZF.cfg
# For a ARM1176JZF CPU
# With J-Link

interface jlink
# Set Chip Name
if { [info exists CHIPNAME] } {
   set _CHIPNAME $CHIPNAME
} else {
   set _CHIPNAME ARM1176JZF
}

# Set CPU Endian
if { [info exists ENDIAN] } {
   set _ENDIAN $ENDIAN
} else {
   # this defaults to a little-endian
   set _ENDIAN little
}

# Set The CPUAPID
if { [info exists CPUTAPID] } {
   set _CPUTAPID $CPUTAPID
} else {
   set _CPUTAPID 0x07b76f0f
}

jtag newtap $_CHIPNAME cpu -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id $_CPUTAPID

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME arm11 -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm1176

adapter_nsrst_delay 500
jtag_ntrst_delay 500

# Set Speed
adapter_khz 2000

# reset configuration
reset_config trst_and_srst

# Set Flash Device
# (ex.) Flash is an NOR Flash (CFI)
# (ex.) Flash base address at 0x44000000
# (ex.) Flash size is 0x01000000 (16MB)
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME cfi 0x44000000 0x01000000 2 2 $_TARGETNAME jedec_probe

# Add RAM/SRAM space to Speed Up the program process
# (ex.) Ready initialized RAM base addr: 0xC0000000
# (ex.) Ready initialized RAM size: 0x00010000
$_TARGETNAME configure -work-area-phys 0xC0000000  -work-area-size 0x00010000 -work-area-backup 0

# Remote Connect Port
#telnet_port 4444
#gdb_port 3333

# Run Command
init
reset halt
# Program an Image to NOR Flash # (ex.) Need erase/unlock the NOR Flash first # (ex.) Image file: C:/ROM.BIN flash write_image erase unlock C:/ROM.BIN 0x44000000 bin
reset

shutdown

6. Run "openocd.exe -f ARM1176JZF.cfg" to program NOR Flash of ROM.BIN file.

2015年3月7日 星期六

Install pygtk/pygtk3 with native gtk/gtk3 in OSX

1. Install pygtk and pygobject3:
  $ brew install --build-from-source pygtk pygobject3 --without-x --without-x11 --with-gtk+3


Example for pygtk:
main.py:

#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk

if __name__ == '__main__':
    def destroy(widget, data=None):
        gtk.main_quit()
    window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    window.connect("destroy", destroy)
    window.show()

    print "GTK Ver: " + repr(gtk.gtk_version)
    print "PyGTK Ver: " + repr(gtk.pygtk_version)

    gtk.main()


Example for pyobject3:
main.py:

#!/usr/bin/env python

from gi.repository import Gtk

if __name__ == '__main__':
    window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
    window.connect("destroy", Gtk.main_quit)
    window.show()

    print "GTK Ver: " + repr((Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION, Gtk.MICRO_VERSION))

    Gtk.main()

2015年2月27日 星期五

Install Native GTK+/GTK+3 in OSX

1. Install Homebrew (http://brew.sh/)
2. Install gtk+, gtk+3 with config
  >> brew install gtk+ gtk+3 --without-x --without-x11 --with-gtk+3

If already install gtk+ and gtk+3 in OSX, remove it.
  >> brew deps gtk+ | xargs brew remove --force
  >> brew deps gtk+3 | xargs brew remove --force


Test Program:

main.c
#include <stdio.h>
#include <gtk/gtk.h>

int main (int argc, char *argv[])
{
  GtkWidget *window;
  gtk_init (&argc, &argv);
  printf ("GTK Ver: %d.%d.%d\n", gtk_major_version, gtk_minor_version, gtk_micro_version);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW(window), "GTK");
  g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
  gtk_widget_show (window);
  gtk_main ();
  return 0;
}


Makefile
# Makefile of gtk+-2.0
all:
    gcc `pkg-config --cflags gtk+-2.0` -o main main.c `pkg-config --libs gtk+-2.0`


Makefile
# Makefile of gtk+-3.0
all:
    gcc `pkg-config --cflags gtk+-3.0` -o main main.c `pkg-config --libs gtk+-3.0`


If meet 'xcb-shm' not found issue, please
export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig
or
echo "export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig" >> ~/.profile


2015年2月13日 星期五

OpenShift Redmine with private Bitbucket

1. Use redmine_bitbucket plugin
  (git@bitbucket.org:steveqx/redmine_bitbucket.git)
2. In "plugins" directory:
  $ git submodule add -f git@bitbucket.org:steveqx/redmine_bitbucket.git
3. git push
4. Migrate db:
  $ rhc ssh
  $ cd ~/app-root/repo
  $ RAILS_ENV=production rake redmine:plugs NAME=redmine_bitbucket
5. Generate ssh key for private repos (id_rsa, id_rsa.pub)
  $ rhc ssh
  $ ssh-keygen -t rsa -f ~/app-root/data/id_rsa
6. Upload "id_rsa.pub" to Bitbucket private repo's "Deployment keys"
7. Add "~/app-root/data/wrapper.sh" with "chmod a+x ~/app-root/data/wrapper.sh"
  #!/bin/bash
  ssh -i $OPENSHIFT_DATA_DIR/id_rsa -o StrictHostKeyChecking=no $1 $2
8. Modify "plugins/redmine_bitbucket/lib/system_command.rb"
  about line 10:
    success = Kernel.system("#{command} > # {logfile.path} 2>&1")
  to:
    success = Kernel.system("GIT_SSH=$OPENSHIFT_DATA_DIR/wrapper.sh #{command} > #{logfile.path} 2>&1")
9. Restart
  $ rhc ssh
  $ ctl_all restart
10. Setting hook path in Bitbucket:
  http://[redmine_url]/hooks/bitbucket/[project_name]

2015年1月30日 星期五

Uninstall Redmine plugin on OpenShift

1. Log into Redmine from SSH
  $ rhc ssh
2. Remove plugin's configuration. (Plugin's name=plugin_name)
  $ RAILS_ENV=production rake db:migrate_plugins PLUGIN={plugin_name} VERSION=0
3. Log out and back into redmine git repo.
4. Remove plugin from source code
  $ git submodule deinit plugins/{plugin_name}
5. Remove submodule info from .gitsubmodule
  $ vi .gitsubmodule
6. Remove plugin's directory
  $ git rm plugins/{plugin_name}
7. Commit & Push it to OpenShift server.
8. Done...

2015年1月17日 星期六

Install Redmine plugin on OpenShift (ex. TimeSheet)


There are 2 TimeSheet Redmine plugin that I have survey.

1. TimeSheets Application
  (https://github.com/maxrossello/redmine_app_timesheets)
2. TimeSheet
  (https://github.com/arkhitech/redmine_timesheet_plugin)

Install TimeSheets Application plugin into OpenShift:
1. Goto redmine root directory
  $ cd redmine
2. git clone with submodule method. (redmine_app__space is the depend plugin)
  $ git submodule add -f https://github.com/maxrossello/redmine_app__space.git plugins/redmine_app__space
   $ git sub modle add -f https://github.com/maxrossello/redmine_app_timesheets.git plugins/redmine_app_timesheet
3. Commit into local repo.
  $ git commit -m "Add TimeSheets Application Plugin"
4. Push to remote repo.
  $ git push
5. If the database information does not be migrate, please login OpenShift server, and rebuild it.
  $ rhc ssh
  $ cd app-root/repo
  $ RAILS_ENV=production rake redmine:plugins:migrate

Install TimeSheet plugin into Openshift:
1. Goto redmine root directory
  $ cd redmine
2. git clone with submodule method.
  git submodule add -f https://github.com/arkhitech/redmine_timesheet_plugin.git plugins/redmine_timesheet_plugin
3. commit into local repo
  $ git commit -m "Add TimeSheet Plugin"
4. Push to remote repo.
  $ git push
5. If the database information does not be migrate, please login OpenShift server, and rebuild it.
  $ rhc ssh
  $ cd app-root/repo
  $ RAILS_ENV=production rake redmine:plugins:migrate

Notes:
1. After I install TimeSheets Application Plugin then I install TimeSheet Plugin, but the TimeSheet Plugin can NOT work. (I don't know what happened)
2. I don't know the usage of "Order" in TimeSheets Application Plugin. (How to delete Order?)

2015年1月13日 星期二

OpenShift with Redmine application

1. Setup OpenShift environment.
    $ rhc setup
2. Create application "redmine" with "ruby-1.9" and "mysql-5.5"
    $ rhc app create redmine ruby-1.9 mysql-5.5
3. Merge "https://github.com/ikedam/openshift-redmine.git" for any version Redmine
    $ cd redmine
    $ git remote add upstream -m master https://github.com/ikedam/openshift-redmine.git
    $ git pull -s recursive -X theirs upstream master
4. Download "redmine-x.y.z.tar.gz" from "http://www.redmine.org"
5. Decompress "redmine-x.y.z.tar.gz" to "redmine-x.y.z" directory.
    $ tar zxvf redmine-x.y.z.tar.gz
6. Copy all files from "redmine-x.y.z" directory to "redmine" directory
    $ cp -R redmine-x.y.z/ redmine/
7. Add 3 lines into .gitignore:
    /files/*
    /log/*
    /public/plugin_assets/*
8. Use "git" to add all files into local repo.
9.  Push local repo. to remote repo.
    $ git push -u origin master
10. Goto Web Page.