HOME
  Security
   Software
    Hardware
  
FPGA
  CPU
   Android
    Raspberry Pi
  
nLite
  Xcode
   etc.
    ALL
  
English Translate 中文翻訳
LINK
BACK
 

2017/05/20

Raspberry Pi 3で Windows用の OpenOCDバイナリをビルドする方法 Raspberry Pi 3で Windows用の OpenOCDバイナリをビルドする方法

(ラズパイで Open On-Chip Debugger OpenOCDの Windowsバイナリをコンパイルして作成する方法)

Tags: [Raspberry Pi], [電子工作]






● Raspberry Pi 3 Model Bを遂に購入

 Raspberry Pi3 Model B RPI2 RPI3

 大人気の CPUボードの Raspberry Piに WiFiと Bluetoothが搭載されたモデルが新発売となりました。
 以前から Raspberry Pi 2を買おうかどうか迷っていましたが、Raspberry Pi 3 Model Bの発売を機に購入を決意してラズベリアンになる事にしました。

 ※ ラズパイの OS Raspbianはバージョンが上がる毎に過去の版と OSの内部の作りが変わり、過去に書かれた製作記事(例えば Raspbian Wheezyの時代の記事)がそのままではエラーが出たりして動かない事が有ります。
 ※ 当方のホームページのラズパイ記事は全て Raspberry Pi 3 Model Bと Raspbian Jessieの組み合わせで動作確認をしております。
(ただし、将来的に新しい Raspbian OSが出た場合に、当方の Raspbian Jessieを基にした内容がそのままでは動かない可能性が有ります。)
 ※ 2017/08/16から Raspbian OSは Raspbian Jessieから Raspbian Stretchに変わりました。

Download Raspbian for Raspberry Pi

ちなみに、歴代のバージョンと名称は
Debianコードネーム年月備考
Debian 9Stretch2017/08/16~
Debian 8Jessie2015~2016/02からラズパイ3対応
Debian 7Wheezy2013~2016
Debian 6.0Squeeze2011~2014
Debian GNU/Linux 5.0Lenny2009~2012


● Raspberry Pi 3で Open On-Chip Debugger

 最初調べたら OpenOCDは FT232R(R系の FTDIチップ)をサポートしないと言う事で FT232Hを買いました。
 ただし、後述する様に FT232Rの BitBang用のパッチが有ります。
 最初は無用なトラブルを避ける為に素直に FT232Hチップの USBアダプタを使用します。
 CJMCU-232H USB FTDI FT232H USB Adapter
 Multifunction CJMCU FT232H USB to JTAG UART/ FIFO SPI/ I2C module High-speed 480Mbit/sec

FTDI UM232H - FTDI FT232H
秋月電子通商 - FT232HL ハイスピードUSBシリアル変換モジュール [AE-FT232HL]

 なお、FTDIの FT232系チップの JTAG機能である MPSSEの解説記事を日本で最初にトランジスタ技術に執筆しました。
 この解説記事以降、FTDIの MPSSEを使用した JTAGの作成が活発になりました。

2005/12/31
FTDI FT2232Cの MPSSE機能の使い方と実力
FTDI FT2232Cの MPSSE機能の使い方と実力

  ジャスト・ワンチップで 4.5Mbpsの USB-シリアル・データ伝送が可能、(トラ技 2006/01掲載)

FT232H - Hi-Speed Single Channel USB UART/FIFO IC

・CJMCU-232H USB FTDI FT232H USB Adapter
CJMCU-232H USB FTDI FT232H USB Adapter


・CJMCU-232H USB FTDI FT232H USB Adapter
CJMCU-232H USB FTDI FT232H USB Adapter


・CJMCU-232H USB FTDI FT232H USB Adapter
CJMCU-232H USB FTDI FT232H USB Adapter


・CJMCU-232H USB FTDI FT232H USB Adapter
CJMCU-232H USB FTDI FT232H USB Adapter




● Raspberry Pi 3で Open On-Chip Debugger

Open On-Chip Debugger
Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing

Open On-Chip Debugger
OpenOCD 0.10.0 release is out
January 22nd, 2017

http://openocd.org/supported-jtag-interfaces/
Supported JTAG interfaces

http://www.besttechnology.co.jp/modules/knowledge/?OpenOCD
OpenOCD_0.10.0+dev-00143-gf6449a7cb

http://nemuisan.blog.bai.ne.jp/openocd.zylin.com/?cid=8657
OpenOCD小ネタ


https://sourceforge.net/p/openocd/mailman/openocd-devel/thread/y2pc09652431005030301md1292cc6lc9fac4568ac10763@mail.gmail.com/
FTDI FT232R用の BitBang版
http://forum.sparkfun.com/viewtopic.php?f=18&t=21411
Support for FT232R in sync bitbang mode implemented
http://vak.ru/doku.php/proj/bitbang/bitbang-jtag
FTDI FT232R Bitbang-JTAG: universal homebrew USB-programmer
openocd-ft232r.pch.gz


 本手順の場合、lusb0_usb.hを usb.hのファイル名のリネームや、gendef libusb0.dll等の手順は不要です。
 が、config.hの編集は必要です。




 ここから

sudo apt-get update
sudo apt-get -y install git-core libtool autoconf automake texinfo cmake pkg-config
sudo apt-get -y install mingw32 mingw32-runtime

cat /usr/x86_64-w64-mingw32/include/usb.h | grep libusb_get_port_numbers
cat /usr/i686-w64-mingw32/include/usb.h | grep libusb_get_port_numbers

# FTDIのライブラリ libftd2xx
cd
wget http://www.ftdichip.com/Drivers/CDM/CDM%20v2.12.26%20WHQL%20Certified.zip
cd
mkdir libftd2xx-win32
cd libftd2xx-win32
unzip ../CDM\ v2.12.26\ WHQL\ Certified.zip

# libusb-win32 libusb-win32 is a port of libusb-0.1 under Windows
# https://sourceforge.net/projects/libusb-win32/
# これは不要
cd
wget -o libusb-win32-bin-1.2.6.0.zip.tmp https://downloads.sourceforge.net/project/libusb-win32/libusb-win32-releases/1.2.6.0/libusb-win32-bin-1.2.6.0.zip
ls -l
unzip libusb-win32-bin-1.2.6.0.zip

cd
cd libusb-win32-bin-1.2.6.0
cd ./bin/x86/

# /home/pi/libusb-win32-bin-1.2.6.0/bin/x86

ls -l

-rw-r--r-- 1 pi pi  1036 May 19 14:24 libusb0.def
-rw-r--r-- 1 pi pi 67680 May 19 14:24 libusb0.dll
-rw-r--r-- 1 pi pi 36422 May 19 17:30 libusb0.dll.a
-rw-r--r-- 1 pi pi 36422 May 19 23:55 libusb0n.dll.a
-rw-r--r-- 1 pi pi 42592 Jan 17  2012 libusb0.sys
-rw-r--r-- 1 pi pi 67680 Jan 17  2012 libusb0_x86.dll
-rw-r--r-- 1 pi pi 36422 May 19 23:56 libusb.a

# libusb A cross-platform user library to access USB devices
# http://libusb.info/
# これは不要
sudo apt-get -y install p7zip
cd
mkdir libusb-1.0
cd libusb-1.0
wget https://jaist.dl.sourceforge.net/project/libusb/libusb-1.0/libusb-1.0.21/libusb-1.0.21.7z
p7zip -d libusb-1.0.21.7z

/home/pi/libusb-1.0/include
/home/pi/libusb-1.0/MS32

# libusb-1.0
# git://git.libusb.org/libusb.git
cd
git clone git://git.libusb.org/libusb.git

cd
cd libusb
./autogen.sh
# ./configure –prefix=/usr/i686-w64-mingw32/sys-root/mingw –host=i686-w64-mingw32
./configure --help

/*
What do you need to download?
Packages are named as follows:

    [Target]-gcc-[Version]-release-[OS]-rubenvb.*
    [Target]-clang-[Version]-release-[OS]-rubenvb.*

Target:  GCC triplet for the system this toolchain builds code for:
         x86_64-w64-mingw32: 64-bit Windows
         i686-w64-mingw32: 32-bit Windows
Version: GCC version
OS:      OS the toolchain is built for:
         linux64: 64-bit linux
         win64: 64-bit Windows
         win32: 32-bit Windows (also work on 64-bit Windows)
         cygwin: Cygwin (www.cygwin.com)
*/

# 64bit mingw64
OPENOCD_TARGET=x86_64-w64-mingw32

# 32bit mingw64
OPENOCD_TARGET=i686-w64-mingw32

# 32bit mingw32
OPENOCD_TARGET=i586-mingw32msvc

cd
cd libusb

LIBUSB_HOST=$OPENOCD_TARGET
LIBUSB_PREFIX=/usr/$LIBUSB_HOST/sys-root/mingw
echo $LIBUSB_HOST
echo $LIBUSB_PREFIX

# -staticは指定しない。
# CFLAGS="-static-libgcc -static-libstdc++" \
# CPPFLAGS="-static-libgcc -static-libstdc++" \
# CXXFLAGS="-static-libgcc -static-libstdc++" \
# LDFLAGS="-static-libgcc -static-libstdc++" \

./configure \
  --build=arm-linux \
  --host=$LIBUSB_HOST \
  --prefix=$LIBUSB_PREFIX

make clean

make

sudo make install
ls -l $LIBUSB_PREFIX


# OpenOCD本体
cd
git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd

cd
cd openocd

./guess-rev.sh
# -00143-gf6449a7

./bootstrap
# ./bootstrap: Error: libtool is required
# Cloning into 'jimtcl'...
# Compile on RPi for make Windows binary

LIBUSB1_CFLAGS=-I$LIBUSB_PREFIX/include/libusb-1.0 \
LIBUSB1_LIBS="-L$LIBUSB_PREFIX/lib -lusb-1.0" \
libusb_CFLAGS=-I$LIBUSB_PREFIX/include/libusb-1.0 \
libusb_LIBS="-L$LIBUSB_PREFIX/lib -pthread" \
./configure \
  --build=arm-linux \
  --host=$OPENOCD_TARGET \
  --enable-maintainer-mode \
  --enable-ft2232_ftd2xx \
  --disable-parport-ppdev \
  --with-ftd2xx-win32-zipdir=../libftd2xx-win32

/*
libjaylink configuration summary:
 - Package version ................ 0.1.0
 - Library version ................ 0:0:0
 - Installation prefix ............ /usr/local
 - Building on .................... arm-unknown-linux-gnu
 - Building for ................... arm-unknown-linux-gnu

OpenOCD configuration summary
--------------------------------------------------
MPSSE mode of FTDI based devices        yes (auto)
ST-Link JTAG Programmer                 yes (auto)
TI ICDI JTAG Programmer                 yes (auto)
Keil ULINK JTAG Programmer              yes (auto)
Altera USB-Blaster II Compatible        yes (auto)
Versaloon-Link JTAG Programmer          yes (auto)
OSBDM (JTAG only) Programmer            yes (auto)
eStick/opendous JTAG Programmer         yes (auto)
Andes JTAG Programmer                   yes (auto)
USBProg JTAG Programmer                 no
Raisonance RLink JTAG Programmer        no
Olimex ARM-JTAG-EW Programmer           no
CMSIS-DAP Compliant Debugger            no
Cypress KitProg Programmer              no
Altera USB-Blaster Compatible           no
ASIX Presto Adapter                     no
OpenJTAG Adapter                        no
SEGGER J-Link Programmer                yes (auto)
*/

# config.hを編集して #define HAVE_LIBUSB_ERROR_NAME 1行を追加
nano config.h

#define HAVE_LIBUSB_ERROR_NAME 1

# OpenOCD本体 make
make clean
make

ls -l ./src/*.exe
# */
# -rwxr-xr-x 1 pi pi 9348557 May 16 13:44 ./src/openocd.exe

cd
cp ./openocd/src/openocd.exe .
cp /home/pi/libusb-win32-bin-1.2.6.0/bin/x86/libusb0.dll .
cp $LIBUSB_PREFIX/bin/libusb-1.0.dll .

cp /usr/lib/gcc/i686-w64-mingw32/4.9-posix/libgcc_s_sjlj-1.dll .
cp /usr/i686-w64-mingw32/lib/libwinpthread-1.dll .

# Windowsで動く様に Intelでコンパイルした場合
> openocd.exe /?
Open On-Chip Debugger 0.10.0+dev-00143-gf6449a7 (2017-05-16-14:07)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Unexpected command line argument: /?

# Raspberry Piで動く様に ARMでコンパイルした場合
$ ./src/openocd --help
Open On-Chip Debugger 0.10.0+dev-00143-gf6449a7 (2017-05-09-04:28)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Open On-Chip Debugger
Licensed under GNU GPL v2
--help       | -h       display this help
--version    | -v       display OpenOCD version
--file       | -f       use configuration file <name>
--search     | -s       dir to search for config files and scripts
--debug      | -d       set debug level to 3
             | -d<n>    set debug level to <level>
--log_output | -l       redirect log output to file <name>
--command    | -c       run <command>





 ラズパイ用 OpenOCD

sudo apt-get update
sudo apt-get -y install git-core libtool autoconf automake texinfo cmake pkg-config
$ find /usr/ -name "usb.*" -ls
# 26382    0 lrwxrwxrwx   1 root     root           25 Jun 24  2013 /usr/share/misc/usb.ids -> /var/lib/usbutils/usb.ids
$ find /usr/ -name "libusb.*" -ls
 なし
http://www.ftdichip.com/Drivers/D2XX.htm
FTDI D2XX Drivers
Linux 2015-08-21 1.3.6 ARMv6 hard-float (suits Raspberry Pi)
http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx-arm-v6-hf-1.3.6.tgz

cd
wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx-arm-v6-hf-1.3.6.tgz

cd
mkdir libftd2xx-arm-v6-hf
cd libftd2xx-arm-v6-hf
tar xvfz ../libftd2xx-arm-v6-hf-1.3.6.tgz

$ ls -l release
total 72
drwxr-xr-x  4 pi pi  4096 Aug 21  2015 build
drwxr-xr-x 14 pi pi  4096 Aug 21  2015 examples
-rwxr-xr-x  1 pi pi 40547 Aug 21  2015 ftd2xx.h
drwxr-xr-x  3 pi pi  4096 Aug 21  2015 libusb
-rw-r--r--  1 pi pi  3414 Aug 21  2015 ReadMe.txt
-rw-r--r--  1 pi pi  5989 Aug 21  2015 release-notes.txt
-rwxr-xr-x  1 pi pi  4787 Aug 21  2015 WinTypes.h

cd
git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd

cd
cd openocd

./guess-rev.sh
# -00143-gf6449a7

./bootstrap

cd
cd openocd
./configure --help

./configure \
  --build=arm-linux
OpenOCD configuration summary
--------------------------------------------------
MPSSE mode of FTDI based devices        no
ST-Link JTAG Programmer                 no
TI ICDI JTAG Programmer                 no
Keil ULINK JTAG Programmer              no
Altera USB-Blaster II Compatible        no
Versaloon-Link JTAG Programmer          no
OSBDM (JTAG only) Programmer            no
eStick/opendous JTAG Programmer         no
Andes JTAG Programmer                   no
USBProg JTAG Programmer                 no
Raisonance RLink JTAG Programmer        no
Olimex ARM-JTAG-EW Programmer           no
CMSIS-DAP Compliant Debugger            no
Cypress KitProg Programmer              no
Altera USB-Blaster Compatible           no
ASIX Presto Adapter                     no
OpenJTAG Adapter                        no
SEGGER J-Link Programmer                no
make clean
make
$ ls -l ./src/openocd
-rwxr-xr-x 1 pi pi 8049244 May 25 13:20 ./src/openocd

$ ./src/openocd
Open On-Chip Debugger 0.10.0+dev-00143-gf6449a7 (2017-05-25-13:13)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
embedded:startup.tcl:60: Error: Can't find openocd.cfg
in procedure 'script'
at file "embedded:startup.tcl", line 60
Error: Debug Adapter has to be specified, see "interface" command
embedded:startup.tcl:60: Error:
in procedure 'script'
at file "embedded:startup.tcl", line 60

$ ./src/openocd --help
Open On-Chip Debugger 0.10.0+dev-00143-gf6449a7 (2017-05-25-13:13)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Open On-Chip Debugger
Licensed under GNU GPL v2
--help       | -h       display this help
--version    | -v       display OpenOCD version
--file       | -f       use configuration file <name>
--search     | -s       dir to search for config files and scripts
--debug      | -d       set debug level to 3
             | -d<n>    set debug level to <level>
--log_output | -l       redirect log output to file <name>
--command    | -c       run <command>

https://github.com/libusb/libusb
A cross-platform library to access USB devices http://libusb.info/

cd
git clone https://github.com/libusb/libusb.git

# https://github.com/libusb/libusb/wiki
cd
cd libusb
./autogen.sh

# configure: error: udev support requested but libudev header not installed
sudo apt-get -y install udev
sudo apt-get -y install libudev-dev

./autogen.sh

./bootstrap.sh

./configure --help
# `configure' configures libusb 1.0.21 to adapt to many kinds of systems.

make

make --dry-run install

# /usr/local/include/libusb-1.0
sudo make install

ls -l /usr/local/include/libusb-1.0

cat /usr/local/include/libusb-1.0/libusb.h | grep libusb_get_port_numbers
# int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len);
# LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)


cd
cd libusb/tests/

make
CC stress.o
CC testlib.o
CCLD stress

pi@raspberrypi:~/libusb/tests $ ls -l
total 104
-rw-r--r-- 1 pi pi 3009 May 25 13:24 libusb_testlib.h
-rw-r--r-- 1 pi pi 17280 May 25 13:37 Makefile
-rw-r--r-- 1 pi pi 149 May 25 13:24 Makefile.am
-rw-r--r-- 1 pi pi 17676 May 25 13:36 Makefile.in
-rwxr-xr-x 1 pi pi 7626 May 25 14:28 stress
-rw-r--r-- 1 pi pi 4661 May 25 13:24 stress.c
-rw-r--r-- 1 pi pi 12892 May 25 14:28 stress.o
-rw-r--r-- 1 pi pi 7343 May 25 13:24 testlib.c
-rw-r--r-- 1 pi pi 15336 May 25 14:28 testlib.o

pi@raspberrypi:~/libusb/tests $ ./stress
Starting test run: init_and_exit...

Starting test run: init_and_exit...
Success (0)
Starting test run: get_device_list...
Success (0)
Starting test run: many_device_lists...
Success (0)
Starting test run: default_context_change...
Success (0)
---
Ran 4 tests
Passed 4 tests
Failed 0 tests
Error in 0 tests
Skipped 0 tests


cd
cd openocd
./configure \
--build=arm-linux

./configure \
--build=arm-linux \
--enable-maintainer-mode \
--enable-ft2232_ftd2xx \
--disable-parport-ppdev \
--with-libftd2xx-arm-v6-hfdir=../libftd2xx-arm-v6-hf
# --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]

libjaylink configuration summary:
- Package version ................ 0.1.0
- Library version ................ 0:0:0
- Installation prefix ............ /usr/local
- Building on .................... arm-unknown-linux-gnu
- Building for ................... arm-unknown-linux-gnu

OpenOCD configuration summary
--------------------------------------------------
MPSSE mode of FTDI based devices yes (auto)
ST-Link JTAG Programmer yes (auto)
TI ICDI JTAG Programmer yes (auto)
Keil ULINK JTAG Programmer yes (auto)
Altera USB-Blaster II Compatible yes (auto)
Versaloon-Link JTAG Programmer yes (auto)
OSBDM (JTAG only) Programmer yes (auto)
eStick/opendous JTAG Programmer yes (auto)
Andes JTAG Programmer yes (auto)
USBProg JTAG Programmer no
Raisonance RLink JTAG Programmer no
Olimex ARM-JTAG-EW Programmer no
CMSIS-DAP Compliant Debugger no
Cypress KitProg Programmer no
Altera USB-Blaster Compatible no
ASIX Presto Adapter no
OpenJTAG Adapter no
SEGGER J-Link Programmer yes (auto)

$ cat Makefile | grep USB
am__append_23 = $(LIBUSB1_CFLAGS)
am__append_24 = $(LIBUSB1_LIBS)
#am__append_26 = $(LIBUSB0_CFLAGS)
#am__append_27 = $(LIBUSB0_LIBS)
LIBUSB0_CFLAGS =
LIBUSB0_LIBS =
LIBUSB1_CFLAGS = -isystem /usr/local/include/libusb-1.0
LIBUSB1_LIBS = -L/usr/local/lib -lusb-1.0
src_helper_libhelper_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBUSB1_CFLAGS)
src_jtag_aice_libocdaice_la_CPPFLAGS = -I$(top_srcdir)/src/jtag/drivers $(AM_CPPFLAGS) $(LIBUSB1_CFLAGS) $(LIBUSB0_CFLAGS)
src_jtag_drivers_usb_blaster_libocdusbblaster_la_SOURCES = $(USB_BLASTER_SRC)
src_jtag_drivers_usb_blaster_libocdusbblaster_la_CPPFLAGS = -I$(top_srcdir)/src/jtag/drivers $(AM_CPPFLAGS) $(LIBUSB1_CFLAGS) $(LIBFTDI_CFLAGS)
USB_BLASTER_SRC = src/jtag/drivers/usb_blaster/usb_blaster.c \

make clean
make

$ ls -l ./src/openocd
-rwxr-xr-x 1 pi pi 8934168 May 25 13:57 ./src/openocd

$ ./src/openocd -v
Open On-Chip Debugger 0.10.0+dev-00143-gf6449a7 (2017-05-25-13:50)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html

$ ./src/openocd -c interface_list
Open On-Chip Debugger 0.10.0+dev-00143-gf6449a7 (2017-05-25-13:50)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
The following debug interfaces are available:
1: ftdi
2: usb_blaster
3: jlink
4: vsllink
5: ulink
6: hla
7: osbdm
8: opendous
9: aice
Error: Debug Adapter has to be specified, see "interface" command


# FTDI FT232HQ
$ lsusb
Bus 001 Device 004: ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC

um232h.cfg FTDI FT232H

nano openocd.cfg
#
# FTDI UM232H as a JTAG interface
#
# http://www.ftdichip.com/Products/Modules/DevelopmentModules.htm#UM232H
#
# This should also work with a UM232H-B, but that has not been tested.
# Note that UM232H and UM232H-B are 3.3V only.
#

interface ftdi
#ftdi_device_desc "UM232H"
ftdi_vid_pid 0x0403 0x6014

ftdi_layout_init 0xfff8 0xfffb
ftdi_layout_signal nTRST -data 0x0100 -oe 0x0100
ftdi_layout_signal nSRST -data 0x0200 -oe 0x0200

# UM232H        FT232H    JTAG
# Name  Pin     Name      Func
# AD0   J2-6    ADBUS0    TCK
# AD1   J2-7    ADBUS1    TDI
# AD2   J2-8    ADBUS2    TDO
# AD3   J2-9    ADBUS3    TMS
# AD4   J2-10   ADBUS4    (GPIOL0)
# AD5   J2-11   ADBUS5    (GPIOL1)
# AD6   J2-12   ADBUS6    (GPIOL2)
# AD7   J2-13   ADBUS7    (GPIOL3)
# AD0   J1-14   ACBUS0    /TRST
# AD1   J1-13   ACBUS1    /SRST
# AD2   J1-12   ACBUS2    (GPIOH2)
# AD3   J1-11   ACBUS3    (GPIOH3)
# AD4   J1-10   ACBUS4    (GPIOH4)
# AD5   J1-9    ACBUS5    (GPIOH5)
# AD6   J1-8    ACBUS6    (GPIOH6)
# AD7   J1-7    ACBUS7    (GPIOH7)

$ ./src/openocd
Open On-Chip Debugger 0.10.0+dev-00143-gf6449a7 (2017-05-25-13:50)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6014, description '*', serial '*' at bus location '*'

$ sudo ./src/openocd
Error: An adapter speed is not selected in the init script. Insert a call to adapter_khz or jtag_rclk to proceed.

$ sudo ./src/openocd -c "adapter_khz 1000"
adapter speed: 1000 kHz
Error: Debug Adapter has to be specified, see "interface" command




https://sourceforge.net/p/openocd/code/ci/master/tree/tcl/interface
raspberrypi2-native.cfg

nano openocd.cfg
#
# Config for using Raspberry Pi's expansion header
#
# This is best used with a fast enough buffer but also
# is suitable for direct connection if the target voltage
# matches RPi's 3.3V and the cable is short enough.
#
# Do not forget the GND connection, pin 6 of the expansion header.
#

interface bcm2835gpio

bcm2835gpio_peripheral_base 0x3F000000

# Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
# These depend on system clock, calibrated for stock 700MHz
# bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET
bcm2835gpio_speed_coeffs 146203 36

# Each of the JTAG lines need a gpio number set: tck tms tdi tdo
# Header pin numbers: 23 22 19 21
# bcm2835gpio_jtag_nums 11 25 10 9

# or if you have both connected,
# reset_config trst_and_srst srst_push_pull

# Each of the SWD lines need a gpio number set: swclk swdio
# Header pin numbers: 22 18
bcm2835gpio_swd_nums 25 24

# If you define trst or srst, use appropriate reset_config
# Header pin numbers: TRST - 26, SRST - 18

# bcm2835gpio_trst_num 7
# reset_config trst_only

bcm2835gpio_srst_num 18
reset_config srst_only srst_push_pull

# or if you have both connected,
# reset_config trst_and_srst srst_push_pull

$ ./src/openocd

Error: The specified debug interface was not found (bcm2835gpio)


./configure \
--build=arm-linux \
--disable-parport-ppdev \
--enable-maintainer-mode \
--enable-bcm2835gpio \
--enable-sysfsgpio

$ cat Makefile | grep bcm2835gpio
$ cat Makefile | grep sysfsgpio

make clean
make

$ ls -l ./src/openocd
-rwxr-xr-x 1 pi pi 9020848 May 25 14:47 ./src/openocd

$ ./src/openocd -v
Open On-Chip Debugger 0.10.0+dev-00143-gf6449a7 (2017-05-25-13:50)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html

$ ./src/openocd -c interface_list
Open On-Chip Debugger 0.10.0+dev-00143-gf6449a7 (2017-05-25-14:40)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
The following debug interfaces are available:
1: ftdi
2: usb_blaster
3: jlink
4: vsllink
5: ulink
6: hla
7: osbdm
8: opendous
9: sysfsgpio
10: aice
11: bcm2835gpio

$ ./src/openocd
BCM2835 GPIO nums: swclk = 25, swdio = 24
BCM2835 GPIO config: srst = 18
srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srst
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)
open: Permission denied

$ sudo ./src/openocd
BCM2835 GPIO nums: swclk = 25, swdio = 24
BCM2835 GPIO config: srst = 18
srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srst
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)
Error: An adapter speed is not selected in the init script. Insert a call to adapter_khz or jtag_rclk to proceed.

$ sudo ./src/openocd -c "adapter_khz 1000"

adapter speed: 1000 kHz
Error: Debug Adapter has to be specified, see "interface" command




https://sourceforge.net/p/openocd/code/ci/master/tree/tcl/cpu/arm/cortex_m3.tcl

set CPU_TYPE arm
set CPU_NAME cortex_m3
set CPU_ARCH armv7
set CPU_MAX_ADDRESS 0xFFFFFFFF
set CPU_NBITS 32



Welcome to MinGW.org Home of the MinGW and MSYS Projects

apt-cache search mingw | grep mingw32

mingw32 - Minimalist GNU win32 (cross) compiler (transition package)
mingw32-binutils - Minimalist GNU win32 (cross) binutils (transition package)
mingw32-runtime - Minimalist GNU win32 (cross) runtime



mingw-w64 GCC for Windows 64 & 32 bits

apt-cache search mingw | grep w64

binutils-mingw-w64 - Cross-binutils for Win32 and Win64 using MinGW-w64
binutils-mingw-w64-i686 - Cross-binutils for Win32 (x86) using MinGW-w64
binutils-mingw-w64-x86-64 - Cross-binutils for Win64 (x64) using MinGW-w64
g++-mingw-w64 - GNU C++ compiler for MinGW-w64
g++-mingw-w64-i686 - GNU C++ compiler for MinGW-w64 targeting Win32
g++-mingw-w64-x86-64 - GNU C++ compiler for MinGW-w64 targeting Win64
gcc-mingw-w64 - GNU C compiler for MinGW-w64
gcc-mingw-w64-base - GNU Compiler Collection for MinGW-w64 (base package)
gcc-mingw-w64-i686 - GNU C compiler for MinGW-w64 targeting Win32
gcc-mingw-w64-x86-64 - GNU C compiler for MinGW-w64 targeting Win64
gdb-mingw-w64 - Cross-debugger for Win32 and Win64 using MinGW-w64
gdb-mingw-w64-target - Cross-debugger server for Win32 and Win64 using MinGW-w6
gfortran-mingw-w64 - GNU Fortran compiler for MinGW-w64
gfortran-mingw-w64-i686 - GNU Fortran compiler for MinGW-w64 targeting Win32
gfortran-mingw-w64-x86-64 - GNU Fortran compiler for MinGW-w64 targeting Win64
gnat-mingw-w64 - GNU Ada compiler for MinGW-w64
gnat-mingw-w64-base - GNU Ada compiler for MinGW-w64 (base package)
gnat-mingw-w64-i686 - GNU Ada compiler for MinGW-w64 targeting Win32
gnat-mingw-w64-x86-64 - GNU Ada compiler for MinGW-w64 targeting Win64
gobjc++-mingw-w64 - GNU Objective-C++ compiler for MinGW-w64
gobjc++-mingw-w64-i686 - GNU Objective-C++ compiler for MinGW-w64 targeting Win32
gobjc++-mingw-w64-x86-64 - GNU Objective-C++ compiler for MinGW-w64 targeting Win64
gobjc-mingw-w64 - GNU Objective-C compiler for MinGW-w64
gobjc-mingw-w64-i686 - GNU Objective-C compiler for MinGW-w64 targeting Win32
gobjc-mingw-w64-x86-64 - GNU Objective-C compiler for MinGW-w64 targeting Win64
libpthreads-mingw-w64 - POSIX threads library for 32- and 64-bit Windows
mingw-ocaml - ocaml-mingw-w64 transitional dummy package
mingw-w64 - Development environment targeting 32- and 64-bit Windows
mingw-w64-common - Common files for Mingw-w64
mingw-w64-i686-dev - Development files for MinGW-w64 targeting Win32
mingw-w64-tools - Development tools for 32- and 64-bit Windows
mingw-w64-x86-64-dev - Development files for MinGW-w64 targeting Win64

MinGW-w64 - for 32 and 64 bit Windows
 General Usage Instructions
 The prefix
 ・i686 = 32-bit
 ・x86_64 = 64-bit

 Linux mingw64 package
Debian - mingw-w64 (5.0.2-1)
 MinGW-w64 = 32 and 64 bit (x86 and x64) Windows applications using the Windows API and the GNU Compiler Collection (gcc) .

 configureに指定する文字列は?
 最初は訳が分からなかったのでメモで残します。

 64bit = x86_64、amd64
 32bit = i386、i586、x86

Mingw - Gentoo Linux Wiki
 SDL tutorial example

Hello World program using Win32API
 Simple "Hello World" Progam

hello.c
#include <windows.h>

int WINAPI
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPTSTR lpCmdLine, int nShowCmd)
{
  MessageBoxW (NULL, L"Hello World!", L"hello", MB_OK | MB_ICONINFORMATION);
  return 0;
}

Bulding hello.exe
$ i686-pc-mingw32-gcc hello.c -o hello.exe -mwindows
$ file hello.exe
hello.exe: PE32 executable for MS Windows (GUI) Intel 80386 32-bit
$ ./hello.exe &







Tags: [Raspberry Pi], [電子工作]

●関連するコンテンツ(この記事を読んだ人は、次の記事も読んでいます)

Raspberry Pi Zero Wを海外通販の Pimoroni等での購入方法、購入出来る通販ショップ一覧まとめ
Raspberry Pi Zero Wを海外通販の Pimoroni等での購入方法、購入出来る通販ショップ一覧まとめ

  ラズパイゼロW ワイヤレスモデルを海外通販でサクッと簡単に個人輸入で入手。技適通過でも国内販売は常に品切れ

Raspberry Pi 3で安定して使える相性の無い最適な microSDカードの種類のまとめ
Raspberry Pi 3で安定して使える相性の無い最適な microSDカードの種類のまとめ

  ラズパイ3で安定して使える microSDカードを購入する Teamと SanDiskは絶対に買わない

Raspberry Pi 3 Model Bに専用カメラモジュールを接続する方法
Raspberry Pi 3 Model Bに専用カメラモジュールを接続する方法

  ラズパイに専用カメラモジュールを接続して Raspbianで写真の静止画撮影や動画を録画する方法

Raspberry Pi 3の Linuxコンソール上で使用する各種コマンドまとめ
Raspberry Pi 3の Linuxコンソール上で使用する各種コマンドまとめ

  ラズパイの Raspbian OSのコマンドラインで使用する便利コマンド、負荷試験や CPUシリアル番号の確認方法等も

Raspberry Pi 3公式フォーラムの FAQの内容の日本語訳
Raspberry Pi 3公式フォーラムの FAQの内容の日本語訳

  ラズパイ公式フォーラムの「The Raspberry Pi 3 Model B Q&A thread」の日本語訳

Raspberry Pi 3で GPIO端子の I2C機能を有効化する方法
Raspberry Pi 3で GPIO端子の I2C機能を有効化する方法

  ラズパイ3の GPIO端子の I2C機能を有効にして各種センサーを繋げる方法まとめ

大人気の CPUボード、Raspberry Pi 3 Model Bで作ってみよう
大人気の CPUボード、Raspberry Pi 3 Model Bで作ってみよう

  Raspberry Piの開発環境の構築やタッチパネル付き液晶ディスプレイや各種センサーの使い方まとめ


Raspberry Pi 3、シングルボードコンピュータ ラズパイ3 Raspberry Pi関連はこちらへまとめました
 下記以外にも多数のラズパイ関係の記事が有ります。
 (I2C制御、GPIO制御、1-Wire制御、シリアル通信、日本語音声合成、日本語音声認識、中国語音声合成、MeCab 形態素解析エンジン、赤外線リモコン制御、秋月 I2C液晶モジュール、KeDei 3.5インチ液晶、HDMI 5インチ液晶、NFCカードリーダ、コマンドライン操作方法等)
Raspberry Pi 3に HDMI接続の 800x480 5インチ TFT液晶を接続して使用する方法
Raspbian Jessie 2017-07最終版で LIRCを使って学習リモコン、赤外線リモコンを送受信する方法
Raspberry Pi 3の WiFiを広告ブロック機能付きの無線LANアクセスポイント化 hostapd + dnsmasq編
Raspberry Pi 3の Bluetoothで ブルテザで通信する方法(Bluetooth編)
Raspberry Pi 3で日本語音声を合成して喋らせる方法(OpenJTalk編)
Raspberry Pi 3に USB Micを接続して日本語の音声認識をする方法(Julius編)
Raspberry Pi 3の GPIOに LEDとスイッチを接続して Lチカする方法
Raspberry Pi 3の GPIOに LEDとスイッチを接続してシャットダウンボタンを実装する方法
Raspberry Pi 3で GPIO端子の I2C機能を有効化する方法
Raspberry Pi 3の GPIOに I2C通信方式の気圧計 BMP280を接続する方法
Raspberry Pi 3に I2C通信方式の NFCリーダライタ PN532を接続して NFC FeliCaカードを読む方法
Raspberry Pi 3でネットワーク ライブカメラを構築する方法 Motion編
Raspberry Pi 3でネットワーク ライブカメラを構築する方法 MJPG-streamer編
Raspberry Pi 3 Model Bで動画処理アプリ FFmpegをコンパイルする方法
Raspberry Pi3の X-Window Systemに Windowsのリモートデスクトップから接続する方法
Raspberry Pi3に WebRTCの STUN/TRUNサーバと PeerJSサーバをインストールする方法


Espressif ESP8266 Arduino互換でスケッチが使える ESP-12Eモジュール基板
Espressif ESP8266 Arduino互換でスケッチが使える ESP-12Eモジュール基板

  Espressif ESP8266 ESP-12-E NodeMCU V1 ESP12 CP2102

BangGood通販はドローン以外にも面白い商品がまだまだ有った(電子工作編)
BangGood通販はドローン以外にも面白い商品がまだまだ有った(電子工作編)

  レーザー彫刻機、カラー液晶の DIYオシロ、Arduinoや Raspberry Pi用の小型カラー液晶



[HOME] | [BACK]
リンクフリー(連絡不要、ただしトップページ以外はweb構成の変更で移動する場合があります)
Copyright (c) 2017 FREE WING, Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator

http://www.neko.ne.jp/~freewing/raspberry_pi/raspberry_pi_3_build_openocd_windows/