shumatech / BOSSA

BOSSA is a flash programming utility for Atmel's SAM family of flash-based ARM microcontrollers. The motivation behind BOSSA is to create a simple, easy-to-use, open source utility to replace Atmel's SAM-BA software. BOSSA is an acronym for Basic Open Source SAM-BA Application to reflect that goal.
http://www.shumatech.com/web/products/bossa
BSD 3-Clause "New" or "Revised" License
371 stars 250 forks source link

Security Flag #138

Closed barissacikara closed 4 years ago

barissacikara commented 4 years ago

Hi, I'm trying to protect my code from reading. I set --security flag when flashing firmware but i can still read the flash. If i set the --security flag when flashing, i shouldn't read the flash, am i right ?

Here is the flashing output :

avrdude cmd :./bossac --info --debug --port "ttyACM0" --write --verify --security --reset --erase -U true firmware.bin
Set binary mode
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
version()=v2.0 [Arduino:XYZ] Oct 12 2018 18:20:29
chipId=0x10010005
Connected at 921600 baud
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Atmel SMART device 0x10010005 found
write(addr=0x20004000,size=0x34)
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
Device       : ATSAMD21G18A
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Chip ID      : 10010005
version()=v2.0 [Arduino:XYZ] Oct 12 2018 18:20:29
Version      : v2.0 [Arduino:XYZ] Oct 12 2018 18:20:29
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
none
readWord(addr=0x41004018)=0x100
Security     : true
Boot Flash   : true
readWord(addr=0x40000834)=0x7000a
BOD          : true
readWord(addr=0x40000834)=0x7000a
BOR          : true
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
chipErase(addr=0x2000)
done in 0.814 seconds

Write 42884 bytes to flash (671 pages)
write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)
[==                            ] 9% (64/671 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x3000, size=0x1000)
[=====                         ] 19% (128/671 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x4000, size=0x1000)
[========                      ] 28% (192/671 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x5000, size=0x1000)
[===========                   ] 38% (256/671 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x6000, size=0x1000)
[==============                ] 47% (320/671 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x7000, size=0x1000)
[=================             ] 57% (384/671 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x8000, size=0x1000)
[====================          ] 66% (448/671 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x9000, size=0x1000)
[======================        ] 76% (512/671 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0xa000, size=0x1000)
[=========================     ] 85% (576/671 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0xb000, size=0x1000)
[============================  ] 95% (640/671 pages)write(addr=0x20005000,size=0x7c0)
writeBuffer(scr_addr=0x20005000, dst_addr=0xc000, size=0x7c0)
[==============================] 100% (671/671 pages)
done in 0.420 seconds

Verify 42884 bytes of flash with checksum.
checksumBuffer(start_addr=0x2000, size=0x1000) = 6de5
checksumBuffer(start_addr=0x3000, size=0x1000) = 3644
checksumBuffer(start_addr=0x4000, size=0x1000) = a052
checksumBuffer(start_addr=0x5000, size=0x1000) = 5c55
checksumBuffer(start_addr=0x6000, size=0x1000) = de65
checksumBuffer(start_addr=0x7000, size=0x1000) = eeec
checksumBuffer(start_addr=0x8000, size=0x1000) = 5c55
checksumBuffer(start_addr=0x9000, size=0x1000) = eb54
checksumBuffer(start_addr=0xa000, size=0x1000) = bcfd
checksumBuffer(start_addr=0xb000, size=0x1000) = 378
checksumBuffer(start_addr=0xc000, size=0x784) = 8ab6
Verify successful
done in 0.030 seconds
Set security
readWord(addr=0x41004018)=0x100
CPU reset.
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
writeWord(addr=0xe000ed0c,value=0x5fa0004)
iddq commented 4 years ago

ok, and where is the read?