Xbus converterにfirmwareを書き込む

##xbus converterにfirmwareを書き込む。

###まずは、以下のサイトを参考にNucleo経由でopenOCDでSTM32F446REを接続できるか試す。
https://ryochack.hatenablog.com/entry/2017/11/03/234216

とりあえず、nucleo-64経由でSTM34F446REに接続はできた。

###次は、LPC812と接続する。
**/usr/shre/openocd/script/targetのlpc812.cfgとlpc8xx.cfgを探すのに一苦労。
ここがとても参考になった、https://gist.github.com/RickKimball/9009480
/home/miyamoto/git/openocd/tcl/targetのlpc8xx.cfgを使って成功。
Nucleoを使う場合は、　-f -f interface/stlink-v2-1.cfgを指定する。**

LPCのデータシート　http://www.keil.com/dd/docs/datashts/nxp/lpc8xx/lpc81xm.pdf
配線はここ　https://www.sevenwatt.com/main/picos-arm/picos-arm-lpc810-swd-jtag-with-nucleo-stm32/

    $openocd -f interface/stlink-v2-1.cfg -f target/lpc812.cfg
     Open On-Chip Debugger 0.9.0 (2018-01-24-01:05)
     Licensed under GNU GPL v2
     For bug reports, read
         http://openocd.org/doc/doxygen/bugs.html
     Info : auto-selecting first available session transport "hla_swd". To override 
     use 'transport select <transport>'.
     Info : The selected transport took over low-level target control. The results 
     might differ compared to plain JTAG/SWD
     adapter speed: 10 kHz
     adapter_nsrst_delay: 200
     Info : Unable to match requested speed 10 kHz, using 5 kHz
     Info : Unable to match requested speed 10 kHz, using 5 kHz
     Info : clock speed 5 kHz
     Info : STLINK v2 JTAG v28 API v2 SWIM v17 VID 0x0483 PID 0x374B
     Info : using stlink api v2
     Info : Target voltage: 3.251613
     Info : lpc812.cpu: hardware has 4 breakpoints, 2 watchpoints

    $telent localhost 4444
    >reset halt
    >flash write_image erase /home/miyamoto/git/rcinput-converter/build/rcconv.elf
     auto erase enabled
     target state: halted
     target halted due to breakpoint, current mode: Thread 
     xPSR: 0x61000000 pc: 0x10000004 msp: 0x10000104
     Verification will fail since checksum in image (0x0000030d) to be written to 
     flash is different from calculated vector checksum (0xefffe9be).
     To remove this warning modify build tools on developer PC to inject correct LPC vector checksum. 
     wrote 3072 bytes from file /home/miyamoto/git/rcinput-
     converter/build/rcconv.elf in 79.712662s (0.038 KiB/s)

チェックサムが違うっていわれたが、とりあえず書き込みはできた。


openOCDのメッセージ

    Info : accepting 'telnet' connection on tcp/4444
    target state: halted
    target halted due to debug-request, current mode: Thread 
    xPSR: 0xf1000000 pc: 0x1fff0008 msp: 0x10000ffc
    auto erase enabled 
    target state: halted
    target halted due to breakpoint, current mode: Thread 
    xPSR: 0x61000000 pc: 0x10000004 msp: 0x10000104
    Warn : Verification will fail since checksum in image (0x0000030d) to be written to flash is different from calculated vector checksum (0xefffe9be).
    Warn : To remove this warning modify build tools on developer PC to inject 
    correct LPC vector checksum.
    wrote 3072 bytes from file /home/miyamoto/git/rcinput-
    converter/build/rcconv.elf in 79.712662s (0.038 KiB/s)
    Info : dropped 'telnet' connection


![wiring.jpg](https://qiita-image-store.s3.amazonaws.com/0/148248/b670d516-7bd4-780e-ea3d-917b9bf74861.jpeg)

![conperter.jpg](https://qiita-image-store.s3.amazonaws.com/0/148248/a6b29b1f-917e-4465-ad0f-ca9966d7c9f9.jpeg)

![Nucleo.jpg](https://qiita-image-store.s3.amazonaws.com/0/148248/444b8bc7-4977-0d7d-5a7b-de4b02a46706.jpeg)

## checksum errorの原因を調べる
    Warn : Verification will fail since checksum in image (0x0000030d) to be written to flash is 
    different from calculated vector checksum (0xefffe9be).
    Warn : To remove this warning modify build tools on developer PC to inject correct LPC vector checksum.
以下ここからの引用　https://forum.sparkfun.com/viewtopic.php?t=16417

どうやら無視して良いようだ。 
   
    gnore that.

    The 6th interrupt vector for LPC2000 holds a checksum that validates user code. This checksum is 
    injected by OpenOCD, not the compiler, so genrally the image you'd download from the core would be 
    different than the one you had from the compiler.
     
    ---------------------------------------------------------------------------------------------------
   
    Yes i know that, but this checksum must be a valid checksum or my programm doesn´t work. It´s weird 
    because the prgram works fine.

    So i ignore that for now but why OpenOCD change this checksum?