Quick jump:  What's new

 
Go to:
 
Weblog: hardware   
in Dobrica Pavlinušić's random unstructured stuff
Arduino


Nano 3.0 Atmega328P-AU

http://dx.com/p/arduino-nano-v3-0-81877

but it doesn't work without bootloader

http://club.dx.com/forums/forums.dx/threadid.1185512
http://club.dx.com/forums/forums.dx/threadid.1218851

avrdude

dpavlin@blue:~$ avrdude -c buspirate -P /dev/ttyUSB0 -p m328p -v

avrdude: Version 5.11.1, compiled on Mar 24 2013 at 00:54:55
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/dpavlin/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : buspirate
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : BusPirate
         Description     : The Bus Pirate

Detecting BusPirate...
avrdude: buspirate_readline(): #
avrdude: buspirate_readline(): RE
avrdude: buspirate_readline(): Bus Pirate v3.b clone w/different PIC
avrdude: buspirate_readline(): Firmware v6.1 r1676  Bootloader v4.4
avrdude: buspirate_readline(): DEVID:0x044F REVID:0x3003 (24FJ64GA004 A3)
avrdude: buspirate_readline(): http://dangerousprototypes.com
avrdude: buspirate_readline(): HiZ>
**
BusPirate: using BINARY mode
BusPirate binmode version: 1
BusPirate SPI version: 1
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as D9
avrdude: safemode: efuse reads as 7

avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as D9
avrdude: safemode: efuse reads as 7
avrdude: safemode: Fuses OK
BusPirate is back in the text mode

avrdude done.  Thank you.

bootloader update

bus pirate

http://dangerousprototypes.com/docs/Bus_Pirate_AVR_Programming

But which bootloader to use? (hint: not optiboot!)

dpavlin@blue:~$ ard-parse-boards nano328 bootloader.file
ATmegaBOOT_168_atmega328.hex

Ok, now flash it!

dpavlin@blue:~$ avrdude -c buspirate -P /dev/ttyUSB0 -p m328p -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex

Detecting BusPirate...
**
BusPirate: using BINARY mode
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "/usr/share/arduino/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex"
avrdude: input file /usr/share/arduino/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex auto detected as Intel Hex
avrdude: writing flash (32670 bytes):

Writing | ################################################## | 100% 56.84s

avrdude: 32670 bytes of flash written
avrdude: verifying flash memory against /usr/share/arduino/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex:
avrdude: load data flash data from input file /usr/share/arduino/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex:
avrdude: input file /usr/share/arduino/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex auto detected as Intel Hex
avrdude: input file /usr/share/arduino/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex contains 32670 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 55.22s

avrdude: verifying ...
avrdude: 32670 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

After re-flash using bus pirate as ISP from Arduino GUI fuses changed:

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

usbasp bootloader update

Sun Jan 12 11:27:34 2020] usb 8-2: new low-speed USB device number 4 using uhci_hcd
[Sun Jan 12 11:27:34 2020] usb 8-2: New USB device found, idVendor=16c0, idProduct=05dc, bcdDevice= 1.02
[Sun Jan 12 11:27:34 2020] usb 8-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Sun Jan 12 11:27:34 2020] usb 8-2: Product: USBasp
[Sun Jan 12 11:27:34 2020] usb 8-2: Manufacturer: www.fischl.de

dpavlin@x200:~$ avrdude -v -patmega328p -cusbasp

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/dpavlin/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : usbasp
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as FD

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK (E:FD, H:DA, L:FF)

avrdude done.  Thank you.

flash ond nano bootloader

this is old nano bootloader, it doesn't work on 115200 but on 57600 with avrdude

dpavlin@x200:~$ avrdude -v -patmega328p -cusbasp -U flash:w:/tmp/nuc/opt/arduino/hardware/arduino/avr/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex

flash optiboot

dpavlin@x200:~$ avrdude -v -patmega328p -cusbasp -U flash:w:/tmp/nuc/opt/arduino/hardware/arduino/avr/bootloaders/optiboot/optiboot_atmega328.hex

add bus pirate to arduino GUI

http://taylanayken.wordpress.com/2011/05/04/using-bus-pirate-with-arduino-ide/

root@blue:~# grep buspirate /usr/share/arduino/hardware/arduino/programmers.txt
buspirate.name=The Bus Pirate
buspirate.communication=serial
buspirate.protocol=buspirate

Simulators/Emulators

emulino

console output, somewhat large network on github

https://github.com/ghewgill/emulino

simuino

ncurses interface, single stepping, doesn't have source control link, can't compile it

http://code.google.com/p/simuino/

emulare

Requres .net, need to test it with mono

http://emulare.sourceforge.net/

simavr

programming sketches

DebugWire protocol

http://www.ruemohr.org/docs/debugwire.html

Internal ADC reference

https://github.com/SensorsIot/ADC_Test/blob/master/ADC_Test.ino

permalink
CubieBoard
cubieboard-ir-module.png

cubieboard_schematic_2012-08-08.pdf

BreadBoard V1.0 03-25 For CubieBoard.pdf

Contents: [Dobrica Pavlinušić's random unstructured stuff]


A20

Running UBI/UBIFS on MLC NAND

NAND in mainline kernel

Samsung K9GBG08U0A NAND

dpavlin@cubieboard:~$ dmesg | grep -A 5 nand
[    4.395437] nand: Could not find valid JEDEC parameter page; aborting
[    4.401898] nand: device found, Manufacturer ID: 0xec, Chip ID: 0xd7
[    4.408272] nand: Samsung NAND 4GiB 3,3V 8-bit
[    4.412719] nand: 4096 MiB, MLC, erase size: 1024 KiB, page size: 8192, OOB size: 640
[    4.421299] Bad block table found at page 524160, version 0x25
[    4.427987] Bad block table found at page 524032, version 0x25
[    4.434238] nand_read_bbt: bad block at 0x000001000000
[    4.439379] nand_read_bbt: bad block at 0x000001100000
[    4.445411] 6 ofpart partitions found on MTD device 1c03000.nand
[    4.451420] Creating 6 MTD partitions on "1c03000.nand":
[    4.456769] 0x000000a00000-0x0001ffa00000 : "rootfs"
[    4.461737] mtd: partition "rootfs" extends beyond the end of device "1c03000.nand" -- size truncated to 0xff600000
[    4.472910] 0x000001000000-0x000001400000 : "env"
[    4.477926] 0x000000c00000-0x000001000000 : "U-Boot.backup"
[    4.483748] 0x000000800000-0x000000c00000 : "U-Boot"
[    4.488997] 0x000000400000-0x000000800000 : "SPL.backup"
[    4.494580] 0x000000000000-0x000000400000 : "SPL"



dpavlin@cubieboard2:~$ dmesg | grep -A 5 nand
[    4.709427] nand: device found, Manufacturer ID: 0xad, Chip ID: 0xd7
[    4.715876] nand: Hynix H27UBG8T2BTR-BC 32G 3.3V 8-bit
[    4.721021] nand: 4096 MiB, MLC, erase size: 2048 KiB, page size: 8192, OOB size: 640
[    4.728997] Scanning device for bad blocks
[    8.484659] 6 ofpart partitions found on MTD device 1c03000.nand
[    8.490678] Creating 6 MTD partitions on "1c03000.nand":
[    8.496021] 0x000000a00000-0x0001ffa00000 : "rootfs"
[    8.500992] mtd: partition "rootfs" extends beyond the end of device "1c03000.nand" -- size truncated to 0xff600000
[    8.515527] 0x000001000000-0x000001400000 : "env"
[    8.520564] 0x000000c00000-0x000001000000 : "U-Boot.backup"
[    8.526504] 0x000000800000-0x000000c00000 : "U-Boot"
[    8.531755] 0x000000400000-0x000000800000 : "SPL.backup"
[    8.537395] 0x000000000000-0x000000400000 : "SPL"

many bad blocks

http://linux-sunxi.org/Mainline_NAND_Howto#Many_bad_blocks

To fix many bad blocks issue you should:

1. Disable nand-on-flash-bbt in your dts
2. Remove this test: http://lxr.free-electrons.com/source/drivers/mtd/nand/nand_base.c?v=4.7#L2940
3. Boot your new kernel and erase chip with flash_erase /dev/mtd[0-X]
4. Re-introduce the bad block check removed in 2, re-enable nand-on-flash-bbt
   and boot the new kernel

Let's try to do this with armbian.

cubieboard

First, enable nand overlay

dpavlin@cubieboard:~$ cat /boot/armbianEnv.txt
overlays=nand

Then remove nand-om-flash-btt:

dpavlin@cubieboard:/$ cd /boot/dtb-`uname -r`/overlay
dpavlin@cubieboard:/boot/dtb-4.14.23-sunxi/overlay$ 

# backup original
root@cubieboard:/boot/dtb-4.14.23-sunxi/overlay# cp sun4i-a10-nand.dtbo sun4i-a10-nand.dtbo.orig

# remote nand-on-flash-bbt
root@cubieboard:/boot/dtb-4.14.23-sunxi/overlay# dtc -I dtb -O dts sun4i-a10-nand.dtbo | grep -v nand-on-flash-bbt > /tmp/nand.dts
root@cubieboard:/boot/dtb-4.14.23-sunxi/overlay# dtc -I dts -O dtb /tmp/nand.dts > sun4i-a10-nand.dtbo

Compile armbian kernel with this patch applied

dpavlin@armbian:~/build$ cp ./patch/kernel/sunxi-dev/nand-disable-badblock-check-for-migration.patch.disabled \
    ./userpatches/kernel/sunxi-next/nand-disable-badblock-check-for-migration.patch

Reboot and check that nand is available:

dpavlin@cubieboard:~$ dmesg | grep -A 8 MTD
[   13.696198] 6 ofpart partitions found on MTD device 1c03000.nand
[   13.702205] Creating 6 MTD partitions on "1c03000.nand":
[   13.707550] 0x000000a00000-0x0001ffa00000 : "rootfs"
[   13.712517] mtd: partition "rootfs" extends beyond the end of device "1c03000.nand" -- size truncated to 0xff600000
[   13.723693] 0x000001000000-0x000001400000 : "env"
[   13.728713] 0x000000c00000-0x000001000000 : "U-Boot.backup"
[   13.734568] 0x000000800000-0x000000c00000 : "U-Boot"
[   13.739778] 0x000000400000-0x000000800000 : "SPL.backup"
[   13.745368] 0x000000000000-0x000000400000 : "SPL"
[   13.751476] sun4i-mdio 1c0b080.mdio: 1c0b080.mdio supply phy not found, using dummy regulator

Now init nand:

root@cubieboard:~# mtd_debug info /dev/mtd0
mtd.type = MTD_MLCNANDFLASH
mtd.flags = MTD_CAP_NANDFLASH
mtd.size = 4284481536 (3G)
mtd.erasesize = 1048576 (1M)
mtd.writesize = 8192 (8K)
mtd.oobsize = 640 
regions = 0


root@cubieboard2:~# mtd_debug info /dev/mtd0
mtd.type = MTD_MLCNANDFLASH
mtd.flags = MTD_CAP_NANDFLASH
mtd.size = 4284481536 (3G)
mtd.erasesize = 2097152 (2M)
mtd.writesize = 8192 (8K)
mtd.oobsize = 640 
regions = 0

root@cubieboard:/home/dpavlin# flash_erase /dev/mtd0 0 0
Erasing 1024 Kibyte @ 600000 --  0 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 6 (mtd0)
        error 5 (Input/output error)
flash_erase: error!: /dev/mtd0: MTD Erase failure
             error 5 (Input/output error)
Erasing 1024 Kibyte @ 700000 --  0 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 7 (mtd0)
        error 5 (Input/output error)
flash_erase: error!: /dev/mtd0: MTD Erase failure
             error 5 (Input/output error)
Erasing 1024 Kibyte @ ff500000 -- 100 % complete 


root@cubieboard:/home/dpavlin# ubiformat /dev/mtd0
ubiformat: mtd0 (mlc-nand), size 4284481536 bytes (4.0 GiB), 4086 eraseblocks of 1048576 bytes (1024.0 KiB), min. I/O size 8192 bytes
libscan: scanning eraseblock 4085 -- 100 % complete  
ubiformat: 4084 eraseblocks are supposedly empty
ubiformat: warning!: 2 of 4086 eraseblocks contain non-UBI data
ubiformat: continue? (y/N) y
ubiformat: warning!: only 0 of 4086 eraseblocks have valid erase counter
ubiformat: erase counter 0 will be used for all eraseblocks
ubiformat: note, arbitrary erase counter value may be specified using -e option
ubiformat: continue? (y/N) y
ubiformat: use erase counter 0 for all eraseblocks
ubiformat: formatting eraseblock 6 --  0 % complete  libmtd: error!: MEMERASE64 ioctl failed for eraseblock 6 (mtd0)
        error 5 (Input/output error)

ubiformat: error!: failed to erase eraseblock 6
           error 5 (Input/output error)
ubiformat: mark it as bad? (y/N) y
ubiformat: marking block 6 bad
ubiformat: formatting eraseblock 7 --  0 % complete  libmtd: error!: MEMERASE64 ioctl failed for eraseblock 7 (mtd0)
        error 5 (Input/output error)

ubiformat: error!: failed to erase eraseblock 7
           error 5 (Input/output error)
ubiformat: mark it as bad? (y/N) y
ubiformat: marking block 7 bad
ubiformat: formatting eraseblock 4085 -- 100 % complete  




ubiattach -p /dev/mtd0

ubimkvol /dev/ubi0 -s 2GiB -N root

mount /dev/ubi0_0 /mnt/ -t ubifs

root@cubieboard:~# mount /dev/ubi0_0 /mnt/ -t ubifs
[Wed Feb 28 17:49:38 2018] UBIFS error (pid: 4709): cannot open "/dev/ubi0:root", error -22
[Wed Feb 28 17:49:43 2018] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 4722
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "root"
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): LEB size: 1032192 bytes (1008 KiB), min./max. I/O unit sizes: 8192 bytes/8192 bytes
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): FS size: 2137669632 bytes (2038 MiB, 2071 LEBs), journal size 33030144 bytes (31 MiB, 32 LEBs)
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
[Wed Feb 28 17:49:44 2018] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID 8E9A30F0-241F-4013-916F-C0B995F22BB1, small LPT model


cubieboard2

This is mostly redundant from cubieboard, but with attempt to define mtd partitions correctly

root@cubieboard2:/home/dpavlin# ubiformat /dev/mtd0
ubiformat: mtd0 (mlc-nand), size 4273995776 bytes (4.0 GiB), 2038 eraseblocks of 2097152 bytes (2.0 MiB), min. I/O size 8192 bytes
libscan: scanning eraseblock 2037 -- 100 % complete  
ubiformat: 2038 eraseblocks have valid erase counter, mean value is 1
ubiformat: formatting eraseblock 2037 -- 100 % complete  



mount ubifs filesystem

dpavlin@cubieboard:~$ grep ubi /mnt/boot/armbianEnv.txt
rootdev=ubi0:root ubi.mtd=0
rootfstype=ubifs

dpavlin@cubieboard:~$ grep ubi /etc/fstab 
ubi0:root / ubifs defaults,noatime,nodiratime 0 1

u-boot

Original u-boot output

HELLO! BOOT0 is starting!
boot0 version : 1.5.1
dram size =1024
Succeed in opening nand flash.
Succeed in reading Boot1 file head.
The size of Boot1 is 0x0003c000.
The file stored in 0X00000000 of block 2 is perfect.
Check is correct.
Ready to disable icache.
Succeed in loading Boot1.
Jump to Boot1.
[       0.133] boot1 version : 1.4.0
[       0.133] pmu type = 3
[       0.134] bat vol = 0
[       0.161] axi:ahb:apb=3:2:2
[       0.161] set dcdc2=1400, clock=1008 successed
[       0.163] key
[       0.175] no key found
[       0.175] flash init start
[       4.051] flash init finish
[       4.052] fs init ok
[       4.053] fattype FAT16
[       4.053] fs mount ok
[       4.060] script finish
[       4.061] power finish
[       4.069] BootMain start
[       4.069] 13
[       4.089] key value = 0
[       4.089] recovery key high 6, low 4
[       4.090] unable to find fastboot_key key_max value
[       4.098] test for multi os boot with display
[       4.100] show pic finish
[       4.103] load kernel start
[       4.127] load kernel successed
[       4.127] start address = 0x4a00000

U-Boot 2011.09-rc1 (Nov 26 2012 - 14:01:52) Allwinner Technology 

CPU:   SUNXI Family
Board: A10-EVB
DRAM:  512 MiB
NAND:  3776 MiB
In:    serial
Out:   serial
Err:   serial
--------fastboot partitions--------
-total partitions:11-
-name-        -start-       -size-      
bootloader  : 1000000       1000000     
env         : 2000000       1000000     
boot        : 3000000       2000000     
system      : 5000000       14000000    
data        : 19000000      20000000    
misc        : 39000000      1000000     
recovery    : 3a000000      2000000     
cache       : 3c000000      8000000     
private     : 44000000      1000000     
sysrecovery : 45000000      14000000    
UDISK       : 59000000      93000000    
-----------------------------------
Hit any key to stop autoboot:  0 
sunxi#

compile with nand support

On Cubieboard2 with those patches we get:

=> nand info

Device 0: nand0, sector size 2048 KiB
  Page size       8192 b
  OOB size         640 b
  Erase size   2097152 b
  subpagesize     8192 b
  options     0x00001000
  bbt options 0x00070000

# which comparted to booted linux kernel with mtd support....

root@cubieboard2:~# mtd_debug info /dev/mtd0
mtd.type = MTD_MLCNANDFLASH
mtd.flags = MTD_CAP_NANDFLASH
mtd.size = 4284481536 (3G)
mtd.erasesize = 2097152 (2M)
mtd.writesize = 8192 (8K)
mtd.oobsize = 640 
regions = 0

# it looks somewhat OK, but mtdparts doesn't (yet) return anything.

Another day, another try to get mtdparts to display something...

root@armbian:~/build/cache/sources/u-boot/v2017.11# grep -i mtd .config
CONFIG_SPL_MTD_SUPPORT=y
CONFIG_CMD_MTDPARTS=y
CONFIG_MTDIDS_DEFAULT="nand0=sunxi-nand"
CONFIG_MTDPARTS_DEFAULT="mtdparts=sunxi-nand:4m(spl),4m(spl-backup),4m(uboot),4m(uboot-backup),4m(env),-(UBI)"
# CONFIG_CMD_MTDPARTS_SPREAD is not set
# MTD Support
CONFIG_MTD=y
# CONFIG_MTD_NOR_FLASH is not set
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTD_UBI_BEB_LIMIT=20
# CONFIG_MTD_UBI_FASTMAP is not set

=> mtdparts

device nand0 <sunxi-nand>, # parts = 6
 #: name                size            offset          mask_flags
 0: spl                 0x00400000      0x00000000      0
 1: spl-backup          0x00400000      0x00400000      0
 2: uboot               0x00400000      0x00800000      0
 3: uboot-backup        0x00400000      0x00c00000      0
 4: env                 0x00400000      0x01000000      0
 5: UBI                 0xfec00000      0x01400000      0

active partition: nand0,0 - (spl) 0x00400000 @ 0x00000000

defaults:
mtdids  : nand0=sunxi-nand
mtdparts: mtdparts=sunxi-nand:4m(spl),4m(spl-backup),4m(uboot),4m(uboot-backup),4m(env),-(UBI)







Instructions after this are hit-or-miss...

dpavlin@klin:/klin/u-boot$ cp configs/Cubieboard_defconfig .config

# add NAND, MTD options, A10 for cubieboard1

# compile while defining flash:

dpavlin@klin:/klin/u-boot$ cat build-cubieboard.sh 
# parametars are probably wrong for your chip!
make V=1 CONFIG_NAND_SUNXI_SPL_ECC_STRENGTH=40 CONFIG_SYS_NAND_PAGE_SIZE=4036 CONFIG_SYS_NAND_OOBSIZE=640 CONFIG_SYS_NAND_BLOCK_SIZE=0x100000


dpavlin@cubieboard:~$ scp 10.60.0.92:/klin/u-boot/u-boot*spl* .

dpavlin@cubieboard:~$ sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8 
488+1 records in
488+1 records out
500154 bytes (500 kB) copied, 0.0423498 s, 11.8 MB/s


It would be better to define params in u-boot config file like:

CONFIG_SYS_EXTRA_OPTIONS="SYS_NAND_BLOCK_SIZE=0x40000,SYS_NAND_PAGE_SIZE=4096,SYS_NAND_OOBSIZE=256"

(with correct values of course).

pinout

U14 (Next to SATA connector)

  SPI0
48 PI13 (SPI0-MISO/UART6-RX/EINT25) 47 PI11 (SPI0-CLK/UART5-RX/EINT23)
46 PI12 (SPI0-MOSI/UART6-TX/EINT24) 45 PI10 (SPI0-CS/UART5-TX/EINT22)
  LCD
44 3.3V (nc in 2012-08-08) 43 VCC-5V
42 Ground 41 SPDIF
40 PB10 (LCD0-SCK/LCD-PIO1) 39 PB11 (LCD0-SDA/LCD-PIO2)
38 Ground 37 PH7 (LCD0-BL-EN/LCD-PIO0/UART5-RX/EINT7)
36 XN_TP (TP-X2) 35 YN_TP (TP-Y2)
34 XP_TP (TP-X1) 33 YP_TP (TP-Y1)
32 PD25 (LCDDE) 31 PB2 (PWM0)
30 PD26 (LCDHSYNC)-VGA-HSYNC 29 PD24 (LCDCLK)
28 PD23 (LCDD23) 27 PD27 (LCDVSYNC)-VGA-VSYNC
26 PD21 (LCDD21) 25 PD22 (LCDD22)
24 PD19 (LCDD19/LVDS1N3) 23 PD20 (LCDD20)
22 PD17 (LCDD17/LVDS1NC) 21 PD18 (LCDD18/LVDS1P3)
20 Ground 19 PD16 (LCDD16/LVDS1PC)
18 PD14 (LCDD14/LVDS1P2) 17 PD15 (LCDD15/LVDS1N2)
16 PD12 (LCDD12/LVDS1P1) 15 PD13 (LCDD13/LVDS1N1)
14 PD10 (LCDD10/LVDS1P0) 13 PD11 (LCDD11/LVDS1N0)
12 PD8 (LCDD8/LVDS0P3) 11 PD9 (LCDD9/LVDS0N3)
10 PD7 (LCDD7/LVDS0NC) 9 Ground
8 PD5 (LCDD5/LVDS0N2) 7 PD6 (LCDD6/LVDS0PC)
6 PD3 (LCDD3/LVDS0N1) 5 PD4 (LCDD4/LNVS0P2)
4 PD1 (LCDD1/LVDS0N0) 3 PD2 (LCDD2/LVDS0P1)
2 Ground 1 PD0 (LCDD0/LVDSP0)

U15 (Between Ethernet port and USB ports)

  CSI1/TS
1 VCC-5V 2 PH15 (CSI1-PWR/EINT15)
3 CSI1-IO-2V8 4 PH14 (CSI1-RST#/EINT14)
5 PG0 (CSI1-PCLK/SDC1-CMD) 6 PB18 (TWI1-SCK)
7 PB19 (TWI1-SDA) 8 PG3 (CSI1-VSYNC/SDC1-D1)
9 PG2 (CSI1-HSYNC/SDC1-D0) 10 PG1 (CSI1-MCLK/SDC1-CLK)
11 PG4 (CSI1-D0/SDC1-D2) 12 PG5 (CSI1-D1/SDC1-D3)
13 PG6 (CSI1-D2/UART3-TX) 14 PG7 (CSI1-D3/UART3-RX
15 PG8 (CSI1-D4/UART3-RTS) 16 PG9 (CSI1-D5/UART3-CTS)
17 PG10 (CSI1-D6/UART4-TX) 18 PG11 (CSI1-D7/UART4-RX)
19 Ground 20 Ground
  Analog SDIO3
21 FMINL 22 PI4 (SDC3-CMD)
23 FMINR 24 PI5 (SDC3-CLK)
25 Ground 26 PI6 (SDC3-D0)
27 VGA-R 28 PI7 (SDC3-D1)
29 VGA-G 30 PI8 (SDC3-D2)
31 VGA-B 32 PI9 (SDC3-D3)
  CSI0/TS
33 LCD1-VSYNC 34 PE4 (CSI0-D0)
35 LCD1-HSYNC 36 PE5 (CSI0-D1)
37 Ground 38 PE6 (CSI0-D2)
39 AVCC 40 PE7 (CSI0-D3)
41 LRADC0 42 PE8 (CSI0-D4)
43 CVBS 44 PE9 (CSI0-D5)
45 HPL 46 PE10 (CSI0-D6)
47 HPR 48 PE11 (CSI0-D7)


everything below line is for legacy kernel and quite old

disk speed

NAND

root@cubieboard2:/home/dpavlin# uname -a
Linux cubieboard2 3.4.109-sun7i #4 SMP PREEMPT Sun Oct 11 14:32:15 CEST 2015 armv7l GNU/Linux
root@cubieboard2:/home/dpavlin# hdparm -t /dev/nand

/dev/nand:
 Timing buffered disk reads:  32 MB in  3.22 seconds =   9.94 MB/sec

# this is different, faster sdcard
root@cubieboard2:~# uname -a
Linux cubieboard2 4.3.3-sunxi #3 SMP Mon Dec 28 11:27:16 CET 2015 armv7l GNU/Linux
root@cubieboard2:~# hdparm -tT /dev/mmcblk0

/dev/mmcblk0:
 Timing cached reads:   770 MB in  2.00 seconds = 384.59 MB/sec
 Timing buffered disk reads:  60 MB in  3.05 seconds =  19.67 MB/sec



SATA

Powered by 2A Nexus 7 power supply (for SATA)

https://groups.google.com/d/searchin/cubieboard/sata/cubieboard/hKJgJneGVmQ/xme3w4Y7XtsJ?fromplusone=1

root@debian:~/sunxi-tools# ./bin2fex /boot/script.bin script.fex
fexc-bin: /boot/script.bin: version: 0.1.2
fexc-bin: /boot/script.bin: size: 42144 (76 sections)

root@debian:~/sunxi-tools# cp script.fex script+sata.fex

root@debian:~/sunxi-tools# diff -urw script.fex script+sata.fex 
--- script.fex  2013-05-30 10:41:13.979510762 +0000
+++ script+sata.fex     2013-05-30 10:42:36.380244101 +0000
@@ -595,7 +595,7 @@
 
 [sata_para]
 sata_used = 1
-sata_power_en =
+sata_power_en = port:PB08<1><default><default><0>
 
 [mmc0_para]
 sdc_used = 1

root@debian:~/sunxi-tools# ./fex2bin script+sata.fex /boot/script.bin

root@debian:/etc# git diff
diff --git a/modules b/modules
index d8894c3..9e65a80 100644
--- a/modules
+++ b/modules
@@ -4,3 +4,4 @@
 # at boot time, one per line. Lines beginning with "#" are ignored.
 # Parameters can be specified after the module name.
 
+sw_ahci_platform

Reboot to activate changes and test speed (using 80G intel SSD to have sense of maximum performance)

root@debian:~# hdparm -i /dev/sda

/dev/sda:

 Model=INTEL SSDSA2M080G2GC, FwRev=2CV102HD, SerialNo=CVPO035101VN080JGN
 Config={ Fixed }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=1
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=156301488
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
 AdvancedPM=no WriteCache=enabled
 Drive conforms to: ATA/ATAPI-7 T13 1532D revision 1:  ATA/ATAPI-2,3,4,5,6,7

 * signifies the current active mode

root@debian:~# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   784 MB in  2.00 seconds = 392.08 MB/sec
 Timing buffered disk reads: 460 MB in  3.00 seconds = 153.32 MB/sec

And test with disk:

root@debian:~# hdparm -i /dev/sda

/dev/sda:

 Model=ST96812AS, FwRev=7.24, SerialNo=3PJ1GCKE
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
 BuffType=unknown, BuffSize=8192kB, MaxMultSect=16, MultSect=off
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=117231408
 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5 
 AdvancedPM=yes: unknown setting WriteCache=enabled
 Drive conforms to: Unspecified:  ATA/ATAPI-1,2,3,4,5,6,7

 * signifies the current active mode

root@debian:~# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   746 MB in  2.00 seconds = 372.90 MB/sec
 Timing buffered disk reads: 120 MB in  3.03 seconds =  39.56 MB/sec

GPIO

Camera

OV7670 is supported http://linux-sunxi.org/CSI

hardware

pinout: gpio_defination_large.jpg

https://www.olimex.com/wiki/How_to_add_pwm

cat /sys/class/pwm-sunxi/pwm0/pin 
PB2

echo 10khz > /sys/class/pwm-sunxi/pwm0/period

echo 25 > /sys/class/pwm-sunxi/pwm0/duty_percent

echo 1 > /sys/class/pwm-sunxi/pwm0/run

LEDs

dpavlin@cubieboard2:~$ grep . /sys/class/leds/*/trigger 
/sys/class/leds/blue:ph21:led2/trigger:none battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 timer [heartbeat] backlight cpu0 cpu1 default-on 
/sys/class/leds/green:ph20:led1/trigger:[none] battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 timer heartbeat backlight cpu0 cpu1 default-on 

forum

ina219

device tree

dpavlin@cubieboard2:~$ sensors
ina219-i2c-1-40
Adapter: mv64xxx_i2c adapter
in0:          +0.04 V  
in1:          +4.64 V  
power1:       66.88 W  
curr1:       +13.64 A  

iio_hwmon-isa-0000
Adapter: ISA adapter
temp1:        +33.6�C  

root@cubieboard2:~# dmesg | grep ina | tail -1
[ 6597.685287] ina2xx 1-0040: power monitor ina219 (Rshunt = 100 uOhm)

# hum, it should be 10uA, so I changed that in device tree

dpavlin@cubieboard2:~$ dmesg | grep ina219
[   11.594536] ina2xx 1-0040: power monitor ina219 (Rshunt = 10 uOhm)
dpavlin@cubieboard2:~$ sensors
ina219-i2c-1-40
Adapter: mv64xxx_i2c adapter
in0:          +0.02 V  
in1:          +4.75 V  
power1:       85.00 W  
curr1:       +17.97 A  

iio_hwmon-isa-0000
Adapter: ISA adapter
temp1:        +32.5�C  

# still wrong current!


user-land C

User-land implementation which works: https://github.com/ZigFisher/Glutinium/blob/master/i2c-telemetry/src/ina219.c

modified a little to provide full timestamp and fflush: ina219.c

dpavlin@cubieboard2:~$ ./ina219 -b 1 -i 1
2017-10-23T12:40:24 4744mV  262.2mA
2017-10-23T12:40:26 4756mV  249.1mA
2017-10-23T12:40:27 4776mV  223.0mA
2017-10-23T12:40:28 4772mV  223.8mA
2017-10-23T12:40:29 4760mV  224.0mA
2017-10-23T12:40:30 4768mV  223.0mA
2017-10-23T12:40:31 4772mV  223.1mA
2017-10-23T12:40:32 4748mV  224.6mA
2017-10-23T12:40:33 4776mV  223.1mA
2017-10-23T12:40:34 4768mV  223.5mA

SPI flash

flashrom

dpavlin@cubieboard:~$ sudo grep spidev /boot/armbianEnv.txt
overlays=pwm nand uart3 uart4 spi-spidev
#overlays=spi-spidev
param_spidev_spi_bus=0


dpavlin@cubieboard:~$ sudo flashrom -p linux_spi:dev=/dev/spidev0.0
flashrom v0.9.9-2-g51e4303 on Linux 4.14.47-sunxi (armv7l)
flashrom is free software, get the source code at https://flashrom.org

Calibrating delay loop... OK.
Found GigaDevice flash chip "GD25Q80(B)" (1024 kB, SPI) on linux_spi.
No operations were specified.

root@cubieboard:/home/dpavlin# time flashrom -p linux_spi:dev=/dev/spidev0.0 -r /dev/null
flashrom v0.9.9-2-g51e4303 on Linux 4.14.47-sunxi (armv7l)
flashrom is free software, get the source code at https://flashrom.org

Calibrating delay loop... OK.
Found GigaDevice flash chip "GD25Q80(B)" (1024 kB, SPI) on linux_spi.
Reading flash... done.

real    0m11.210s
user    0m0.796s
sys     0m0.381s


build u-boot with SPI support

http://linux-sunxi.org/Bootable_SPI_flash

git clone -b sunxi-spi https://github.com/StephanvanSchaik/u-boot

dpavlin@armbian:~/u-boot$ git diff
diff --git a/configs/Cubieboard_defconfig b/configs/Cubieboard_defconfig
index 0389d4c..cbafac9 100644
--- a/configs/Cubieboard_defconfig
+++ b/configs/Cubieboard_defconfig
@@ -16,3 +16,13 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_USB_EHCI_HCD=y
+
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_DM_SPI=y
+CONFIG_SUNXI_SPI=y
+
dpavlin@armbian:~/u-boot$ make Cubieboard_defconfig




This doesn't actually work for me (since it's missing device tree overlays), but rebasing to current u-boot master doesn't
produce code which compiles.

https://forum.armbian.com/topic/3252-opi-zero-boot-with-spi/

reset

http://linux-sunxi.org/Cubieboard/Reset

external ir receiver

configuration described on lirc page

permalink
FST-01

update vid and pid in compiled binary

since version 1.2.8 you need to insert vid and pid into the binary by running

make build/gnuk-vidpid.elf

and than flash the resulting gnuk-vidpid.bin binary into your FST-01

SWD flashing using ST Link v2

usb 1-1.6.4: new full-speed USB device number 16 using ehci-pci
usb 1-1.6.4: New USB device found, idVendor=0483, idProduct=3748
usb 1-1.6.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.6.4: Product: STM32 STLink
usb 1-1.6.4: Manufacturer: STMicroelectronics
usb 1-1.6.4: SerialNumber: Qÿl^FH<85>PH'Q^C<87>

Problem:

dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk/tool$ ./stlinkv2.py -s
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0002 -> 0001
CORE: 0de01477, CHIP_ID: 00000000
Flash ROM read protection: off
Option bytes: 00000000
Core does not halt, try API V2 halt.
ValueError('Status of core is not halt.', 128)

after several re-runs:

dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk/tool$ ./stlinkv2.py -s
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0002 -> 0001
CORE: 1ba01477, CHIP_ID: a0036410
Flash ROM read protection: off
Option bytes: a0036410
Core does not halt, try API V2 halt.
ValueError('Status of core is not halt.', 128)

after a bit of fiddling with cables (it's always cables, right?)

Lovro contributed that if you are getting continous output like this

ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0002 -> 0001
Core does not halt, try API V2 halt.
ValueError('Status of core is not halt.', 128)

then run this while holding reset active (hold tweezers on both side of C3)
that should hand the uC in a mode that will enable stlinkv2.py script to turn off the flash rom protection and erase the flash while doing that

dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk$ sudo ./tool/stlinkv2.py -s
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0002 -> 0001
CORE: 1ba01477, CHIP_ID: 20036410
Flash ROM read protection: ON
Option bytes: 03fffffe
The MCU is now stopped.
SUCCESS

dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk$ sudo ./tool/stlinkv2.py -u
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0002 -> 0001
Status is 0081
CORE: 1ba01477, CHIP_ID: 20036410
Flash ROM read protection: ON
Option bytes: 03fffffe
Flash ROM read protection disabled.  Reset the board, now.
SUCCESS

# plugin, plugout st-link/v2

dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk$ sudo ./tool/stlinkv2.py -s
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0100 -> 0001
CORE: 1ba01477, CHIP_ID: 20036410
Flash ROM read protection: off
Option bytes: ffff5aa5
Flash ROM blank check: True
SUCCESS

dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk$ sudo ./tool/stlinkv2.py -b ../binaries/gnuk/gnuk.bin 
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0001 -> 0001
CORE: 1ba01477, CHIP_ID: 20036410
Flash ROM read protection: off
Option bytes: ffff5aa5
Flash ROM blank check: True
SPI Flash ROM ID: bf254a
WRITE
VERIFY
PROTECT
Flash ROM read protection enabled.  Reset the board to enable protection.
SUCCESS

# power cycle

dpavlin@blue:/blue-zfs/STM32/FST-01/gnuk$ sudo ./tool/stlinkv2.py -s
ST-Link/V2 version info: 2 17 4
Change ST-Link/V2 mode 0100 -> 0001
CORE: 1ba01477, CHIP_ID: 20036410
Flash ROM read protection: ON
Option bytes: 03fffffe
The MCU is now stopped.
SUCCESS

plugin just FST-01:

[ 9890.019368] usb 1-1.6.4: New USB device found, idVendor=234b, idProduct=0000
[ 9890.019372] usb 1-1.6.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 9890.019374] usb 1-1.6.4: Product: Gnuk Token
[ 9890.019375] usb 1-1.6.4: Manufacturer: Free Software Initiative of Japan
[ 9890.019377] usb 1-1.6.4: SerialNumber: FSIJ-1.0.4-50FF7006
permalink
Samsung ML-2510

It seems that every peace of hardware I have needs a separate page. When I first bought it, I didn't have any problems with it.

Since then, some kernels have problems with USB suspend, but following works:

apt-get install cups splix

And then select ML-2150 in cups.

toner

permalink
OV7670
permalink
eagle

Script to convert eagle sch file to pdf eagle-sch2pdf.sh

dpavlin@t61p:~/t61p/eagle$ wget ftp://ftp.cadsoft.de/eagle/program/6.6/eagle-lin-6.6.0.run

dpavlin@t61p:~/t61p/eagle$ sudo apt-get install libxrandr2:i386

# install
dpavlin@t61p:~/t61p/eagle$ bash eagle-lin-6.6.0.run

# run
dpavlin@t61p:~/t61p/eagle$ /home/dpavlin/eagle-6.6.0/bin/eagle

dpavlin@klin:/klin$ wget http://web.cadsoft.de/ftp/eagle/program/7.2/eagle-lin-7.2.0.run
dpavlin@klin:/klin$ sudo apt-get install libxrandr2:i386 libfontconfig1:i386
dpavlin@klin:/klin$ bash eagle-lin-7.2.0.run
permalink
STM32discovery


STM32F100RBT6B

dpavlin@blue:~$ lsusb | grep ST
Bus 003 Device 006: ID 0483:3744 SGS Thomson Microelectronics STLINK Pseudo disk

Install toolchain

dpkg --add-architecture i386
apt-get install libc6-i386
#wget https://launchpad.net/gcc-arm-embedded/4.7/4.7-2012-q4-major/+download/gcc-arm-none-eabi-4_7-2012q4-20121208-linux.tar.bz2
wget https://sourcery.mentor.com/GNUToolchain/package4463/public/arm-none-eabi/arm-2009q1-161-arm-none-eabi-i686-pc-linux-gnu.tar.bz2


Install openocd

dpavlin@blue:~$ sudo apt-get install openocd
dpavlin@blue:~$ dpkg -l openocd
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                    Version          Architecture     Description
+++-=======================-================-================-====================================================
ii  openocd                 0.6.1-1          amd64            Open on-chip JTAG debug solution for ARM and MIPS sy

start openocd

Disable STLINKv1 SCSI emulation, see https://github.com/texane/stlink

root@blue:~# modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i

root@blue:~# sudo openocd -f /usr/share/openocd/scripts/board/stm32vldiscovery.cfg
Open On-Chip Debugger 0.6.1 (2012-12-05-01:32)
Licensed under GNU GPL v2
For bug reports, read
       http://openocd.sourceforge.net/doc/doxygen/bugs.html
adapter speed: 1000 kHz
Info : clock speed 1000 kHz
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints

Open another window and connect with telnet:

dpavlin@blue:~$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> reset init
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000b4c msp: 0x20000400

summon toolchain

openocd

dpavlin@blue:~/sat$ sudo openocd -f /usr/share/openocd/scripts/board/stm32vldiscovery.cfg
[sudo] password for dpavlin: 
Open On-Chip Debugger 0.6.1 (2012-12-05-01:32)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.sourceforge.net/doc/doxygen/bugs.html
adapter speed: 1000 kHz
Info : clock speed 1000 kHz
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'telnet' connection from 4444
Warn : target was in unknown state when halt was requested
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x21000000 pc: 0x080001ce msp: 0x20001ff0

From different terminal

dpavlin@blue:~/sat$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> halt
target was in unknown state when halt was requested
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x21000000 pc: 0x080001ce msp: 0x20001ff0
> 

> flash write_image erase /virtual/stm32discovery/libopencm3/examples/stm32/f1/stm32vl-discovery/fancyblink/fancyblink.hex
auto erase enabled
device id = 0x10016420
flash size = 128kbytes
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000003a msp: 0x20001ff0
wrote 2048 bytes from file /virtual/stm32discovery/libopencm3/examples/stm32/f1/stm32vl-discovery/fancyblink/fancyblink.hex in 0.192207s (10.405 KiB/s)


Using Arduino IDE

http://forums.leaflabs.com/topic.php?id=630

permalink
Proxmark


Cheap(er) China Proxmark

Mifare sniff/crack

http://code.google.com/p/crapto1/

http://www.youtube.com/watch?v=kTvb7tjbSTI
http://www.fuzzysecurity.com/tutorials/rfid/3.html

Proxmark firmware comparison on emulated Mifare 4k

r command note
590   USB HID
  hf mf rdbl 0 A a0a1a2a3a4a5 OK
  hf mf chk 0 A a0a1a2a3a4a5 Can't select card
617   USB HID
  hf mf rdbl 0 A a0a1a2a3a4a5 OK
  hf mf chk 0 A a0a1a2a3a4a5 Can't select card
  hf mf mifare 2 red, needs power cycle
  hf mf nested o 0 a a0a1a2a3a4a5 4 t Can't select card
672   proxendian.h:22:4: error: #error Define BYTE_ORDER
756   USB CCID
  hf mf rdbl 0 A a0a1a2a3a4a5 Auth error
  hf mf chk 0 A a0a1a2a3a4a5 Can't select card
  hf mf mifare red, yellow, red, needs power cycle
  hf mf nested o 0 a a0a1a2a3a4a5 4 t Can't select card
840   latest
  hf mf rdbl 0 A a0a1a2a3a4a5 Can't select card
  hf mf chk 0 A a0a1a2a3a4a5 Can't select card
  hf mf mifare Can't select card
  hf mf nested o 0 a a0a1a2a3a4a5 4 t Can't select card

Usage

proxmark3> hw version
#db# Prox/RFID mark3 RFID instrument                 
#db# bootrom: svn 816 2013-10-11 22:09:42                 
#db# os: svn 816 2013-10-11 22:09:43                 
#db# FPGA image built on 2012/ 1/ 6 at 15:27:56                 
uC: AT91SAM7S256 Rev B          
Embedded Processor: ARM7TDMI          
Nonvolatile Program Memory Size: 256K bytes          
Second Nonvolatile Program Memory Size: None          
Internal SRAM Size: 64K bytes          
Architecture Identifier: AT91SAM7Sxx Series          
Nonvolatile Program Memory Type: Embedded Flash Memory          

proxmark3> hw tune
#db# Measuring antenna characteristics, please wait...                 
#db# Measuring complete, sending report back to host                 
          
# LF antenna:  0.00 V @   125.00 kHz          
# LF antenna:  0.00 V @   134.00 kHz          
# LF optimal:  0.00 V @ 12000.00 kHz          
# HF antenna:  7.28 V @    13.56 MHz          
# Your LF antenna is unusable.          

proxmark3> hf 14a read
ATQA : 02 00          
 UID : ?? ?? ?? ??
 SAK : 38 [1]          
TYPE : Nokia 6212 or 6131 MIFARE CLASSIC 4K          
 ATS : 0d 78 f7 b1 02 4a 43 4f 50 76 32 34 31 27 cc           
       -  TL : length is 13 bytes          
       -  T0 : TA1 is present, TB1 is present, TC1 is present, FSCI is 8          
       - TA1 : different divisors are NOT supported, DR: [2, 4, 8], DS: [2, 4, 8]          
       - TB1 : SFGI = 0, FWI = 8          
       - TC1 : NAD is NOT supported, CID is supported          
       -  HB : 4a 43 4f 50 76 32 34 31           



brute force 26-bit proxcard

firmware version

According to http://wiki.radiowar.org/Proxmark3%E5%9B%BA%E4%BB%B6%E5%88%97%E8%A1%A8
firmwares newer than 617 have problems.

Google translated version

Please do not upgrade your firmware to the CDC Proxmark3 version r617 ~ r830 driver's! We found that because the problem will lead to Proxmark3 code appears unable to identify high-frequency card, and 816 will appear after Nested number of keys for 000000000000.

flashing update

dpavlin@blue:/blue-zfs/FPGA/proxmark/proxmark3$ make flash-all


Compile new version of firmware

All instructions below this are for old version of software see http://www.proxmark.org/forum/viewtopic.php?id=1668

http://code.google.com/p/proxmark3/wiki/Compiling je strgan http://www.proxmark.org/forum/post/3244/#p3244

sudo apt-get install build-essential libreadline5 libreadline-dev libusb-0.1-4 libusb-dev libqt4-dev perl pkg-config

dpavlin@t61p:/tank/proxmark3$ svn co http://proxmark3.googlecode.com/svn/trunk proxmark3

Boot loader

dpavlin@t61p:/tank/proxmark3/proxmark3$ ./client/flasher -b ./bootrom/obj/bootrom.elf 
Loading ELF file './bootrom/obj/bootrom.elf'...
Loading usable ELF segments:
0: V 0x00100000 P 0x00100000 (0x00000200->0x00000200) [R X] @0x94
1: V 0x00200000 P 0x00100200 (0x000017a8->0x000017a8) [R X] @0x294

Waiting for Proxmark to appear on USB...
Connected units:
        1. SN: ? [004/013]
 Found.
Entering bootloader...
(Press and release the button only to abort)
Waiting for Proxmark to reappear on USB....
Connected units:
        1. SN: ? [004/014]
 Found.

Flashing...
Writing segments for file: ./bootrom/obj/bootrom.elf
 0x00100000..0x001001ff [0x200 / 2 blocks].. OK
 0x00100200..0x001019a7 [0x17a8 / 24 blocks]........................ OK

Resetting hardware...
All done.

Have a nice day!

^
dpavlin@t61p:/tank/proxmark3/proxmark3$ ./client/flasher ./armsrc/obj/fullimage.elf 
Loading ELF file './armsrc/obj/fullimage.elf'...
Loading usable ELF segments:
0: V 0x00102000 P 0x00102000 (0x0000a4bc->0x0000a4bc) [R  ] @0xb4
1: V 0x00110000 P 0x00110000 (0x0000ba8c->0x0000ba8c) [R X] @0xa570
2: V 0x00200000 P 0x0011ba8c (0x00000004->0x00000004) [RW ] @0x15ffc
Note: Extending previous segment from 0xba8c to 0xba90 bytes

Waiting for Proxmark to appear on USB...
Connected units:
        1. SN: ? [004/015]
 Found.
Entering bootloader...
(Press and release the button only to abort)
Waiting for Proxmark to reappear on USB....
Connected units:
        1. SN: ChangeMe [004/016]
 Found.

Flashing...
Writing segments for file: ./armsrc/obj/fullimage.elf
 0x00102000..0x0010c4bb [0xa4bc / 165 blocks]..................................................................................................................................................................... OK
 0x00110000..0x0011ba8f [0xba90 / 187 blocks]........................................................................................................................................................................................... OK

Resetting hardware...
All done.

Have a nice day!
permalink
MSP430 Chronos

Open the watch

https://www.youtube.com/watch?v=kOKDaPp8oiY

Mailing list

https://groups.google.com/forum/#!forum/ti-chronos-development-

Watch

OpenChronos

https://github.com/poelzi/OpenChronos/

dpavlin@blue:/blue-raidz1/MSP430/Chronos$ git clone git@github.com:poelzi/OpenChronos.git
Cloning into 'OpenChronos'...
remote: Counting objects: 1639, done.
remote: Compressing objects: 100% (907/907), done.
remote: Total 1639 (delta 921), reused 1321 (delta 671)
Receiving objects: 100% (1639/1639), 1.02 MiB | 330.00 KiB/s, done.
Resolving deltas: 100% (921/921), done.
Checking connectivity... done
dpavlin@blue:/blue-raidz1/MSP430/Chronos$ cd OpenChronos/
dpavlin@blue:/blue-raidz1/MSP430/Chronos/OpenChronos$ 


outdated

openchronos-ng

http://sourceforge.net/p/openchronos-ng/

dpavlin@blue:/blue-raidz1/MSP430/Chronos$ git clone git://git.code.sf.net/p/openchronos-ng/code openchronos-ng-code
Cloning into 'openchronos-ng-code'...
remote: Counting objects: 4088, done.
remote: Compressing objects: 100% (1961/1961), done.
remote: Total 4088 (delta 2930), reused 2831 (delta 2036)
Receiving objects: 100% (4088/4088), 1.31 MiB | 627.00 KiB/s, done.
Resolving deltas: 100% (2930/2930), done.
Checking connectivity... done
dpavlin@blue:/blue-raidz1/MSP430/Chronos$ ls
OpenChronos  openchronos-ng-code
dpavlin@blue:/blue-raidz1/MSP430/Chronos$ cd openchronos-ng-code/
dpavlin@blue:/blue-raidz1/MSP430/Chronos/openchronos-ng-code$ sudo apt-get install python-urwid
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  python-urwid
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 731 kB of archives.
After this operation, 2,697 kB of additional disk space will be used.
Get:1 http://ftp.hr.debian.org/debian/ sid/main python-urwid amd64 1.1.1-1+b1 [731 kB]
Fetched 731 kB in 0s (848 kB/s)      
Selecting previously unselected package python-urwid.
(Reading database ... 274572 files and directories currently installed.)
Unpacking python-urwid (from .../python-urwid_1.1.1-1+b1_amd64.deb) ...
Setting up python-urwid (1.1.1-1+b1) ...


# turn off acleration module which breaks build

dpavlin@blue:/blue-raidz1/MSP430/Chronos/openchronos-ng-code$ make config
grep: config.h: No such file or directory
/usr/bin/python2 tools/config.py

/usr/bin/python2 tools/make_modinit.py


# build

dpavlin@blue:/blue-raidz1/MSP430/Chronos/openchronos-ng-code$ make
Generating dependencies..
/bin/sh: 1: makedepend: not found
CC modinit.c
-e 
>> Building openchronos.elf as target RELEASE
/usr/bin/python2 tools/memory.py -i openchronos.elf -o openchronos.txt
ELF section .text at 0x8000 14972 bytes
ELF section .rodata at 0xba7c 512 bytes
ELF section .data at 0xbc7c 216 bytes
ELF section .vectors at 0xff80 128 bytes
convert to TI Hex




Links

http://processors.wiki.ti.com/index.php/EZ430-Chronos

AP dongle BM-USBD4-V1.1

New, white one with M430F5509 and CC1101

http://www.ti.com/product/msp430f5509

[33569.199972] usb 3-1.2.3: USB disconnect, device number 7
[38564.358606] usb 3-1.1: new full-speed USB device number 8 using ehci-pci
[38564.453766] usb 3-1.1: New USB device found, idVendor=2047, idProduct=0340
[38564.453780] usb 3-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[38564.453783] usb 3-1.1: Product: eZ430-ChronosAP
[38564.453785] usb 3-1.1: Manufacturer: Texas Instruments
[38564.453787] usb 3-1.1: SerialNumber: F5BF93460A000B00
[38564.466959] cdc_acm 3-1.1:1.0: This device cannot do calls on its own. It is not a modem.
[38564.466984] cdc_acm 3-1.1:1.0: ttyACM0: USB ACM device
[38564.467400] usbcore: registered new interface driver cdc_acm
[38564.467402] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

Debugger MSP-eZ430U

[47106.422402] usb 3-1.1: new full-speed USB device number 10 using ehci-pci
[47106.537358] usb 3-1.1: New USB device found, idVendor=0451, idProduct=f432
[47106.537363] usb 3-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[47106.537366] usb 3-1.1: Product: Texas Instruments MSP-FET430UIF
[47106.537369] usb 3-1.1: Manufacturer: Texas Instruments
[47106.537371] usb 3-1.1: SerialNumber: EDFF41CE960B3D18
[47106.543217] cdc_acm 3-1.1:1.0: This device cannot do calls on its own. It is not a modem.
[47106.543222] cdc_acm 3-1.1:1.0: No union descriptor, testing for castrated device
[47106.543241] cdc_acm 3-1.1:1.0: ttyACM0: USB ACM device
[47109.197929] hid-generic 0003:0451:F432.0004: hiddev0,hidraw3: USB HID v1.01 Device [Texas Instruments Texas Instruments MSP-FET430UIF] on usb-0000:00:1a.0-1.1/input1
[47109.548548] usb 3-1.1: USB disconnect, device number 10
[47110.260115] usb 3-1.1: new full-speed USB device number 11 using ehci-pci
[47110.375589] usb 3-1.1: New USB device found, idVendor=0451, idProduct=f432
[47110.375594] usb 3-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[47110.375597] usb 3-1.1: Product: Texas Instruments MSP-FET430UIF
[47110.375599] usb 3-1.1: Manufacturer: Texas Instruments
[47110.375601] usb 3-1.1: SerialNumber: EDFF41CE960B3D18
[47110.381368] cdc_acm 3-1.1:1.0: This device cannot do calls on its own. It is not a modem.
[47110.381373] cdc_acm 3-1.1:1.0: No union descriptor, testing for castrated device
[47110.381399] cdc_acm 3-1.1:1.0: ttyACM0: USB ACM device
[47120.132638] hid-generic 0003:0451:F432.0005: hiddev0,hidraw3: USB HID v1.01 Device [Texas Instruments Texas Instruments MSP-FET430UIF] on usb-0000:00:1a.0-1.1/input1
[47303.482869] usb 3-1.1: USB disconnect, device number 11
[47304.191698] usb 3-1.1: new full-speed USB device number 12 using ehci-pci
[47304.306763] usb 3-1.1: New USB device found, idVendor=0451, idProduct=f432
[47304.306767] usb 3-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[47304.306770] usb 3-1.1: Product: Texas Instruments MSP-FET430UIF
[47304.306772] usb 3-1.1: Manufacturer: Texas Instruments
[47304.306774] usb 3-1.1: SerialNumber: EDFF41CE960B3D18
[47304.312539] cdc_acm 3-1.1:1.0: This device cannot do calls on its own. It is not a modem.
[47304.312554] cdc_acm 3-1.1:1.0: No union descriptor, testing for castrated device
[47304.312575] cdc_acm 3-1.1:1.0: ttyACM0: USB ACM device
[47314.353996] hid-generic 0003:0451:F432.0006: usb_submit_urb(ctrl) failed: -1
[47314.354020] hid-generic 0003:0451:F432.0006: timeout initializing reports
[47314.354185] hid-generic 0003:0451:F432.0006: hiddev0,hidraw3: USB HID v1.01 Device [Texas Instruments Texas Instruments MSP-FET430UIF] on usb-0000:00:1a.0-1.1/input1

sending data

https://github.com/ApertureLabsLtd/ChronIC

permalink
Chicony KG-0609

Disconnect receiver dongle and move finger on touchpad

dpavlin@blue:/blue-zfs/MSP430/goodfet/client$ ./goodfet.nrf sniffmacs | tee /dev/shm/keyboard
Holding autotune on 2402 MHz
sync,mac,r5,r6
'aa,bffffdea01,02,0f' looks valid       1       0.00094
'aa,bffffdea01,02,0f' looks valid       2       0.00187
'aa,bffffdea01,02,0f' looks valid       3       0.00143
'55,5ffffef500,02,0f' looks valid       1       0.00047
'55,5ffffef500,02,0f' looks valid       2       0.00084
'aa,bffffdea01,02,0f' looks valid       4       0.00154
'aa,bffffdea01,02,0f' looks valid       5       0.00182
'aa,bffffdea01,02,0f' looks valid       6       0.00202
'55,5ffffef500,02,0f' looks valid       3       0.00094

dpavlin@x200:/rest/cvs/goodfet/client$ ./goodfet.nrf tune aa,bffffdea01,02,0f

dpavlin@blue:/blue-zfs/MSP430/goodfet/client$ ./goodfet.nrf sniff
Listening as bffffdea01 on 2402 MHz           
 cc af f7 bf ff 1f e0 19 54 3b 9f 2d 2d c4 d4 1d 6a 96 d5 16 93 2a 95 b6 2b 74 d4 aa 85 72 91 41
 cc ef f7 bc fe 7f e0 19 46 c2 5e b0 c2 5a 54 a5 48 cd 42 2c d8 99 dd 19 7a aa a5 85 4a 84 55 15
 cc 2f f7 bd 42 5f e0 19 4c bf be dc d5 69 ab 19 55 8e 95 4f 8f 66 ed ac a7 d2 b6 8d d1 1b 8b 2a
 cc 6f f7 a2 62 ff e0 19 58 26 9e 32 25 20 82 0b 56 d5 12 54 3a a6 bd 5f 7d 75 ed fd 14 b2 4b 48
 cc af f7 a2 7f 9f e0 19 5b 61 5d bf 1a 62 50 b6 a9 14 b8 d9 d2 1a 52 11 0a 25 4d aa a8 dc 85 1a
 cc ef f7 bf 1d 9f e0 19 53 1f 14 a5 14 54 c3 a2 14 d1 84 59 25 56 09 08 77 55 4a 22 ce ad 56 91
permalink
Weblog Navigation
Loading...
Weblog Archives
  • Loading...