Month: March 2013

Testing VSPROG with Freedom board

I’m testing Freedom board with OpenOCD and VSProg following the instruction from this message:
http://tech.groups.yahoo.com/group/versaloon/message/347

# vsprog -skinetis -ms -I main.elf -o w
VSProg 1.0 svn:
CopyRight(c) 2008-2010 by SimonQian <SimonQian@SimonQian.com>

URL: http://www.SimonQian.com/en/Versaloon
mail: SimonQian@SimonQian.com

Info:   Chip name undefined, try auto-detecting.
Info:   Versaloon(0x33)by Simon(compiled on Oct 25 2011)
Info:   USB_TO_XXX abilities: 0x00000008:0x00000040:0xC0000006
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Info:   CORTEX-M0(+) r0p0 processor detected
Info:   CPUID = 0x410CC600
Info:   KINETIS series: KL family
Info:   KINETIS chip: KL25
Info:   KINETIS device die number: 09
Info:   KINETIS device revision number: 01
Info:   KINETIS sram size: 16384
Info:   KINETIS flash size: 128K
Info:   KINETIS pin number: 80
Info:   Chip-id read is 0x25151486.
Info:   Auto-detect signature is 0x25151486
Error:  kinetis auto-detect failed.
Error:  Fail to initialize target.
Error:  Fail to run command: prepare.

To fix this first issue just add this config to kinetis.xml:

<chip name="kl25z128frdm">
<chip_id>0x25151486</chip_id>
<program_mode>js</program_mode>
<app_default>0xFF</app_default>
<app_addr>0x00000000</app_addr>
<app_seg>0</app_seg>
<app_page_size>1024</app_page_size>
<sram_addr>0x20000000</sram_addr>
<uid init="0xFF" bytesize="12" mask="0xFFFFFFFF:0xFFFFFFFF:0xFFFFFFFF" format="%4x%4x%4x"></uid>
</chip>

Now it will report flash error:

# vsprog -skinetis -ms -I main.elf -o w
VSProg 1.0 svn:
CopyRight(c) 2008-2010 by SimonQian 

URL: http://www.SimonQian.com/en/Versaloon
mail: SimonQian@SimonQian.com

Info:   Chip name undefined, try auto-detecting.
Info:   Versaloon(0x33)by Simon(compiled on Oct 25 2011)
Info:   USB_TO_XXX abilities: 0x00000008:0x00000040:0xC0000006
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Info:   CORTEX-M0(+) r0p0 processor detected
Info:   CPUID = 0x410CC600
Info:   KINETIS series: KL family
Info:   KINETIS chip: KL25
Info:   KINETIS device die number: 09
Info:   KINETIS device revision number: 01
Info:   KINETIS sram size: 16384
Info:   KINETIS flash size: 128K
Info:   KINETIS pin number: 80
Info:   Chip-id read is 0x25151486.
Info:   Auto-detect signature is 0x25151486
Info:   kl25z128frdm found
Error:  flash is not defined, please define first.
Error:  Fail to check target defined content.
Error:  Fail to run command: prepare.

This error message “Error: flash is not defined, please define first.” is because I was using ELF instead of binary.
Just convert this ELF to Binary:

$ arm-none-eabi-objcopy -O binary main.elf main.bin

Let us to try again:

# vsprog -skinetis -ms -I main.bin -o w
VSProg 1.0 svn:
CopyRight(c) 2008-2010 by SimonQian 

URL: http://www.SimonQian.com/en/Versaloon
mail: SimonQian@SimonQian.com

Info:   Chip name undefined, try auto-detecting.
Info:   Versaloon(0x33)by Simon(compiled on Oct 25 2011)
Info:   USB_TO_XXX abilities: 0x00000008:0x00000040:0xC0000006
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Info:   CORTEX-M0(+) r0p0 processor detected
Info:   CPUID = 0x410CC600
Info:   KINETIS series: KL family
Info:   KINETIS chip: KL25
Info:   KINETIS device die number: 09
Info:   KINETIS device revision number: 01
Info:   KINETIS sram size: 16384
Info:   KINETIS flash size: 128K
Info:   KINETIS pin number: 80
Info:   Chip-id read is 0x25151486.
Info:   Auto-detect signature is 0x25151486
Info:   kl25z128frdm found
Error:  fuse is not defined, please define first.
Error:  Fail to check target defined content.
Error:  Fail to run command: prepare.

Hmm, now it says the fuse is not defined…

Let us to try to erase the chip:

# vsprog -skinetis -ms -I main.bin -o e
VSProg 1.0 svn:
CopyRight(c) 2008-2010 by SimonQian 

URL: http://www.SimonQian.com/en/Versaloon
mail: SimonQian@SimonQian.com

Info:   Chip name undefined, try auto-detecting.
Info:   Versaloon(0x33)by Simon(compiled on Oct 25 2011)
Info:   USB_TO_XXX abilities: 0x00000008:0x00000040:0xC0000006
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Info:   CORTEX-M0(+) r0p0 processor detected
Info:   CPUID = 0x410CC600
Info:   KINETIS series: KL family
Info:   KINETIS chip: KL25
Info:   KINETIS device die number: 09
Info:   KINETIS device revision number: 01
Info:   KINETIS sram size: 16384
Info:   KINETIS flash size: 128K
Info:   KINETIS pin number: 80
Info:   Chip-id read is 0x25151486.
Info:   Auto-detect signature is 0x25151486
Info:   kl25z128frdm found
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Info:   CORTEX-M0(+) r0p0 processor detected
Info:   CPUID = 0x410CC600
Info:   KINETIS series: KL family
Info:   KINETIS chip: KL25
Info:   KINETIS device die number: 09
Info:   KINETIS device revision number: 01
Info:   KINETIS sram size: 16384
Info:   KINETIS flash size: 128K
Info:   KINETIS pin number: 80
Info:   Chip-id read is 0x25151486.
Info:   erasing flash
erasing flash |========================================%100| 0.00s used
Info:   flash erased

Good, I hope! 🙂

Now, I will try to flash again:

# vsprog -skinetis -ms -I main.bin -o w
VSProg 1.0 svn:
CopyRight(c) 2008-2010 by SimonQian 

URL: http://www.SimonQian.com/en/Versaloon
mail: SimonQian@SimonQian.com

Info:   Chip name undefined, try auto-detecting.
Info:   Versaloon(0x33)by Simon(compiled on Oct 25 2011)
Info:   USB_TO_XXX abilities: 0x00000008:0x00000040:0xC0000006
Info:   SWDID = 0x0BC11477
Info:   AHB-AP_ID = 0x04770031
Info:   ROM_ADDRESS = 0xF0002003
Info:   CFG = 0x00000000, Little-endian
Error:  Stiky Error/Overrun.
Error:  Fail to initialize cm.
Error:  Maybe your last firmware disable the JTAG/SWD port, try using OpenOCD to erase the firmware.
Error:  Fail to enter program mode.
Error:  kinetis auto-detect failed.
Error:  Fail to initialize target.
Error:  Fail to run command: prepare.

Hmm, I think it is necessary to disable some protection before to try writing something.

Let to test OpenOCD-CMSIS-DAP:

# ./src/openocd -f ./tcl/interface/vsllink.cfg
Open On-Chip Debugger 0.7.0-dev-g1d8f0c1 (2013-03-18-19:24)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.sourceforge.net/doc/doxygen/bugs.html
Error: The specified debug interface was not found (vsllink)
The following debug interfaces are available:
1: cmsis-dap
Runtime Error: ./tcl/interface/vsllink.cfg:7: 
in procedure 'script' 
at file "embedded:startup.tcl", line 58
in procedure 'interface' called at file "./tcl/interface/vsllink.cfg", line 7
root@bob:/comum/Projetos/Freedom/openocd/OpenOCD-CMSIS-DAP# ./src/openocd -f ./tcl/interface/vsllink.cfg^C
root@bob:/comum/Projetos/Freedom/openocd/OpenOCD-CMSIS-DAP# ./src/openocd -c "interface cmsis-dap" -f tcl/target/kl25.cfg
Open On-Chip Debugger 0.7.0-dev-g1d8f0c1 (2013-03-18-19:24)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'cmsis-dap'
Info : CMSIS-ADI: cmsis_dap_select
Info : CMSIS-DAP: cmsis_dap_swd_init
Info : kernel driver active
Info : kernel driver now detached.
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
cortex_m3 reset_config sysresetreq
adapter speed: 50 kHz
Info : CMSIS-DAP: cmsis_dap_init
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Packet Size  = 64
Info : CMSIS-DAP: Packet Count = 32
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0 
Info : CMSIS-DAP: cmsis_dap_reset_link
Info : DAP_SWJ Sequence (reset: 50+ '1' followed by 0)
Info : DAP Read IDCODE
Info : CMSIS-DAP: Interface ready
Info : clock speed 50 kHz
Info : CMSIS-ADI: cmsis_dap_init
Info : CMSIS-ADI: cmsis_dap_queue_idcode_read
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 00
Info :                              0bc11477
Info : IDCODE 0x0bc11477
Info : CMSIS-ADI: cmsis_dap_queue_ap_abort
START...
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              00000040
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 04 00000020
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              00000040
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 04 50000000
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              f0000040
Info : CMSIS-ADI: cmsis_dap_run
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              f0000040
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_read 00
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info :                              03000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_read 04
Info :                              ddfdffff
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 000000f0
Info : CMSIS-ADI: cmsis_dap_queue_ap_read f4
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 000000f0
Info :                              00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_read f8
Info :                              f0002003
Info : CMSIS-ADI: cmsis_dap_queue_ap_read fc
Info :                              04770031
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_write 00 a2000012
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_write 04 e000ed00
Info : CMSIS-ADI: cmsis_dap_queue_ap_read_block 01
Error: CMSIS-DAP: Block Read Error (04)
Info : CMSIS-ADI: cmsis_dap_queue_ap_abort

No way! I will need to modify MDM-AP Control register before trying to use SWD.

Lambendo a criacao (ou o criador)

Desde criança sempre gostei muito de desenhar (creio que quase toda criança gosta) e sempre tive muita facilidade nisso, mas este talento sempre ficou em segundo plano, talvez o lado cientista/pesquisador ofuscou o outro lado.

Esta semana tive a oportunidade de exercer este lado desenhista novamente. Minha esposa pediu que eu criasse uma logomarca para a loja de roupas e aviamentos dela. O nome da loja é Amor de Moça, o nome surgiu a partir de uma flor homonima (amor-de-moça ou, voltando ao lado cientista, apenas: Cosmos bipinnatus).

Inicialmente comecei a desenhar corações, ou outras figuras das quais eu pudesse formar as letras A e M, que são as iniciais da loja. Mas nenhum dos modelos da logomarca estavam legais. Foi então que tive a ideia de usar a propria morfologia da planta “amor-de-moça” para formar as iniciais da loja.

Não deu outra, ficou muito simples e legal:

amordemoca

Para quem tem dificuldades em enxergar formas (por exemplo não consegue ver o C na logo do Carrefour) vai a dica: as letras A e M estão desenhas nas três pétalas superiores da flor.

Se você quiser desenhar flores parecidas com esta use as dicas deste site: http://www.dragoart.com/tuts/3311/1/1/how-to-draw-a-simple-flower.htm

UPDATE: Para ver o resultado da Arte Final acesse www.amordemoca.com

Dica: como listar arquivos num sistema que nao tem o comando ls

Alguns roteadores e outros aparelhos não possuem o comando “ls”, mas felizmente você consegue resolver este problema com o velho truque do echo:

$ echo *

O fato deles tirarem alguns comandos pode barrar usuários newbies, mas quem conhece mais sabe como contornar os problemas. Outro exemplo é o caso do Android de alguns celulares que não tem o comando “cp”, mas você pode usar o comando “cat” para fazer o mesmo papel, pesquise nos comentarios do blog para saber como fazer.

How to debug Freedom Board (FRDM-KL25Z) using OpenOCD

This is a step-by-step to let you debug your board using OpenOCD:

First of all you need to install CMSIS-DAP firmware:
https://acassis.wordpress.com/2013/03/17/changing-frdm-kl25z-boards-firmware-to-become-cmsis-dap-compatible/

You need to install libusb version 1.0:

$ sudo apt-get install libusb-1.0-0-dev

Download and compile OpenOCD with CMSIS-DAP support:

$ git clone https://github.com/TheShed/OpenOCD-CMSIS-DAP.git
$ cd OpenOCD-CMSIS-DAP
$ git checkout -b cmsis origin/cmsis-dap
$ ./bootstrap
$ ./configure --enable-maintainer-mode --enable-cmsis-dap
$ make
$ sudo make install

Time to run OpenOCD:

# openocd -c "interface cmsis-dap" -f tcl/target/kl25.cfg
Open On-Chip Debugger 0.7.0-dev-g1d8f0c1 (2013-03-18-19:24)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'cmsis-dap'
Info : CMSIS-ADI: cmsis_dap_select
Info : CMSIS-DAP: cmsis_dap_swd_init
Info : kernel driver active
Info : kernel driver now detached.
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
cortex_m3 reset_config sysresetreq
adapter speed: 50 kHz
Info : CMSIS-DAP: cmsis_dap_init
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Packet Size  = 64
Info : CMSIS-DAP: Packet Count = 32
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1 
Info : CMSIS-DAP: cmsis_dap_reset_link
Info : DAP_SWJ Sequence (reset: 50+ '1' followed by 0)
Info : DAP Read IDCODE
Info : CMSIS-DAP: Interface ready
Info : clock speed 50 kHz
Info : CMSIS-ADI: cmsis_dap_init
Info : CMSIS-ADI: cmsis_dap_queue_idcode_read
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 00
Info :                              0bc11477
Info : IDCODE 0x0bc11477
Info : CMSIS-ADI: cmsis_dap_queue_ap_abort
START...
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              00000040
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 04 00000020
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              00000040
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 04 50000000
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              f0000040
Info : CMSIS-ADI: cmsis_dap_run
Info : CMSIS-ADI: cmsis_dap_queue_dp_read 04
Info :                              f0000040
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_read 00
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info :                              03000040
Info : CMSIS-ADI: cmsis_dap_queue_ap_read 04
Info :                              ddfdffff
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 000000f0
Info : CMSIS-ADI: cmsis_dap_queue_ap_read f4
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 000000f0
Info :                              00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_read f8
Info :                              f0002003
Info : CMSIS-ADI: cmsis_dap_queue_ap_read fc
Info :                              04770031
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_write 00 a2000012
Info : CMSIS-ADI: cmsis_dap_queue_dp_write 08 00000000
Info : CMSIS-ADI: cmsis_dap_queue_ap_write 04 e000ed00
Info : CMSIS-ADI: cmsis_dap_queue_ap_read_block 01
Info : CMSIS-ADI: cmsis_dap_run
Info : CMSIS-ADI: cmsis_dap_queue_ap_write 04 e0002000
Info : CMSIS-ADI: cmsis_dap_queue_ap_read_block 01
Info : CMSIS-ADI: cmsis_dap_run
Info : CMSIS-ADI: cmsis_dap_queue_ap_write 04 e0001000
Info : CMSIS-ADI: cmsis_dap_queue_ap_read_block 01
Info : CMSIS-ADI: cmsis_dap_run
Info : kl25.cpu: hardware has 2 breakpoints, 2 watchpoints
END...

Now you can debug the FRDM board with openocd normally and even integrated on Eclipse.

That’s all folks, good luck!

UPDATE: After some more tests I noticed the debugging using GDB is not completely functional, then the best approach will be connecting to OpenOCD over telnet at port 4444 and execute the commands to access registers and memory.

Como controlar ponteiro do mouse num computador sem teclado numerico

Como você deve saber saber é possível emular um mouse (mover o cursor) no modo gráfico do Linux usando o teclado numérico, como explicado aqui anteriormente.

Mas e se seu computador (notebook) não tiver teclado numérico?

Felizmente existe um programa que resolve este problema de forma criativa, chama-se keynav.

Instale o keynav com o comando:

$ sudo apt-get install keynav

Em seguida crie o arquivo .keynavrc no diretório base do seu usuario (no meu caso é /home/alan) e coloque o conteúdo:

Left cut-left
Down cut-down
Up cut-up
Right cut-right
control+Left move-left
control+Down move-down
control+Up move-up
control+Right move-right

Agora você deve executar o keynav (ALT + F2 e digite o comando keynav) e para ativa-lo pressione Ctrl + ; (Control e Ponto e vírgula), você verá uma linha vertical e uma linha horizontal dividindo a tela em quatro áreas, use as teclas direcionais do seu teclado (setinhas) para escolher qual área você quer mover o teclado, vá subdividindo as áreas menores até que o cursamento das linhas fique sobre o local que você deseja mover o mouse, então pressione Enter para clicar.

O bom é que o Linux sempre tem uma solução pra tudo, mas o melhor é nunca esquecer o mouse em casa e nem atualizar o sistema antes de um compromisso importante, pois seu mousepad pode parar de funcionar :-/

Fonte: http://askubuntu.com/questions/88948/control-mouse-pointer-with-keyboard-without-a-number-pad

Changing FRDM-KL25Z board’s firmware to become CMSIS-DAP compatible

So you got a Freescale FRDM board? Nice, but unfortunately it comes with bad firmware which doesn’t work on Linux:

http://articles.factori.se/kinetis-freedom/opensda/linux/2012/11/10/kinetis-freedom-plus-opensda-a-no-go-on-linux/

Fortunately Freescale/P&EMicro fixed the issue, as reported by this user:

http://manuelnaranjo.wordpress.com/

Now you can just drag & drop files to it on Linux to get it running new firmware.

But if you are planning a more advanced/serious work with debugging and something like that, you need to upgrade its bootloader to CMSIS-DAP compatible:

http://www.coocox.org/downloadfile/CoIDE/How%20to%20use%20OpenSDA.pdf

Basically all you need to do is download the firmware (APNT_232.ZIP) from Keil, unplug USB from FRDM board, hold RESET button, plug USB again and when green LED start to blink release RESET button. Your computer will mount a BOOTLOADER label disk, then just copy CMSIS-DAP.S19 file to there, wait a little bit (30s up to 1min is ok), unplug and plug USB again the green LED will turn green and turn off after few seconds.

All done, you have a FRDM with CMSIS-DAP support on Linux, it will be compatible with future OpenOCD version and with Crossworks IDE which has support to Windows, Linux and Mac.