qbolsee / serialupdi

a Python utility for programming various Microchip MCU devices using Microchip CMSIS-DAP based debuggers
MIT License
0 stars 0 forks source link

Merge with microchip latest broke write to non-flash ina major way! #1

Open SpenceKonde opened 3 years ago

SpenceKonde commented 3 years ago

Edit for tone: Merge was unsuccessful, megaTinyCore is reverted (and a new round of fixes added to further improve hardware compatibility), that will need to be merged;

C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/python3/python3 -u C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py -t uart -u COM40 -b 460800 -d attiny1614 --fuses 2:0x02 6:0x04 8:0x00 -fC:\Users\Spence\AppData\Local\Temp\arduino_build_728059/Blink.ino.hex -a write Arduino <---> pymcuprog bridge by Quentin Bolsee and Spence Konde Version 1.1.0 - May 2021 Using serial port COM40 at 460800 baud. Target: attiny1614 Set fuses: ['2:0x02', '6:0x04', '8:0x00'] Action: write File: C:\Users\Spence\AppData\Local\Temp\arduino_build_728059/Blink.ino.hex Pinging device... Ping response: 1E9422 Setting fuse 0x2=0x2 Writing literal values... Traceback (most recent call last): File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 266, in main() File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 121, in main return_code = pymcuprog_basic(args, fuses_dict) File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 217, in pymcuprog_basic filename=None) File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 131, in run_pymcu_action status = func(backend, *args, args_pymcu) File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\pymcuprog_main.py", line 368, in _action_write backend.write_memory(bytearray(args.literal), args.memory, args.offset) File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\backend.py", line 530, in write_memory self.programmer.write_memory(data=data, memory_name=memory_name, offset=offset_byte) File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\programmer.py", line 188, in write_memory self.device_model.write(memory, offset, data) File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\nvmserialupdi.py", line 217, in write self.avr.nvm.write_flash(offset_aligned, chunk, blocksize=2) File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\nvm.py", line 224, in write_flash return self.write_nvm(address, data, use_word_access=True, blocksize=blocksize, bulkwrite=bulkwrite) File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\nvm.py", line 311, in write_nvm self.readwrite.write_data_words(address, data, blocksize) File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\readwrite.py", line 141, in write_data_words return self.datalink.st_ptr_inc16_RSD(data, blocksize) File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\link.py", line 207, in st_ptr_inc16_RSD constants.UPDI_ST | constants.UPDI_PTR_INC | constants.UPDI_DATA_16]) + data TypeError: can only append array (not "bytearray") to array TypeError: can only append array (not "bytearray") to array


I remember this error from when I was working on this, because THIS IS THE ERROR THAT LED ME TO END UP USING THAT UGLY SYNTAX TO APPEND! I need to find a way to get this working ASAP
qbolsee commented 3 years ago

I see, so "data" is sometimes a bytearray, sometimes an array. We didn't test fuse write and that might be the culprit, give me an hour.

qbolsee commented 3 years ago

Should be fixed now, but I still can't get fuses to write, I get an "Error with st", and I have the same with your "ugly" syntax, could be related to my D11C serial adapter. Writing flash works fine

SpenceKonde commented 3 years ago

Looks like we picked up some major changes in behavior...

Pinging device...
pymcuprog.programmer - INFO - Reading device ID...
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0xe6]
pymcuprog.serialupdi.application - INFO - SIB: 'tinyAVR P:0D:0-3M2 (00.59B15.0)'
pymcuprog.serialupdi.application - INFO - Device family ID: 'tinyAVR'
pymcuprog.serialupdi.application - INFO - NVM interface: 'P:0'
pymcuprog.serialupdi.application - INFO - Debug interface: 'D:0'
pymcuprog.serialupdi.application - INFO - PDI oscillator: '3M2'
pymcuprog.serialupdi.application - INFO - Extra info: '(00.59B15.0)'
pymcuprog.serialupdi.application - INFO - Using 16-bit UPDI
pymcuprog.serialupdi.link - DEBUG - LDCS from 0x00
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x80]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x20]
pymcuprog.serialupdi.application - INFO - PDI revision = 0x02
pymcuprog.serialupdi.link - DEBUG - LDCS from 0x0B
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x8b]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x8]
pymcuprog.serialupdi.readwrite - DEBUG - Reading 3 bytes from 0x1100
pymcuprog.serialupdi.link - INFO - ST to ptr
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x69, 0x0, 0x11]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - Repeat 3
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0xa0, 0x2]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x1e, 0x94, 0x22]
pymcuprog.serialupdi.readwrite - DEBUG - Reading 1 bytes from 0x0F01
pymcuprog.serialupdi.link - INFO - ST to ptr
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x69, 0x1, 0xf]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.application - INFO - Device ID from pyupdi = '1E9422' rev 'A'
pymcuprog.serialupdi.readwrite - DEBUG - Reading 3 bytes from 0x1100
pymcuprog.serialupdi.link - INFO - ST to ptr
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x69, 0x0, 0x11]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - Repeat 3
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0xa0, 0x2]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x1e, 0x94, 0x22]
pymcuprog.nvm - INFO - Device ID: '1E9422'
pymcuprog.serialupdi.readwrite - DEBUG - Reading 1 bytes from 0x0F01
pymcuprog.serialupdi.link - INFO - ST to ptr
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x69, 0x1, 0xf]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.nvm - DEBUG - Device revision: 0x00
pymcuprog.nvm - INFO - Device revision: '0.0'
pymcuprog.serialupdi.readwrite - DEBUG - Reading 10 bytes from 0x1103
pymcuprog.serialupdi.link - INFO - ST to ptr
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x69, 0x3, 0x11]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - Repeat 10
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0xa0, 0x9]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x51, 0x50, 0x50, 0x4b, 0x38, 0x20, 0x8c, 0x1f, 0x1, 0x27]
pymcuprog.nvm - INFO - Device serial number: 'b'5150504b38208c1f0127''
Ping response: 1E9422
Setting fuse 0x2=0x2
Writing literal values...
pymcuprog.programmer - INFO - Write...
pymcuprog.programmer - INFO - Writing 1 bytes of data to fuses...
pymcuprog.nvm - DEBUG - Writing 1 bytes to address 0x001282
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.link - INFO - LD from 0x001002
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.nvm - DEBUG - Load NVM address
pymcuprog.serialupdi.link - INFO - ST to 0x001008
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x44, 0x8, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - send : [0x82]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - INFO - ST to 0x001009
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x44, 0x9, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - send : [0x12]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Load fuse data
pymcuprog.serialupdi.link - INFO - ST to 0x001006
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x44, 0x6, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - send : [0x2]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Execute fuse write
pymcuprog.serialupdi.nvm - DEBUG - NVMCMD 7 executing
pymcuprog.serialupdi.link - INFO - ST to 0x001000
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x44, 0x0, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - send : [0x7]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.link - INFO - LD from 0x001002
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x3]
pymcuprog.serialupdi.link - INFO - LD from 0x001002
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.link - INFO - LD from 0x001002
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.nvm - DEBUG - Clear page buffer
pymcuprog.serialupdi.nvm - DEBUG - NVMCMD 4 executing
pymcuprog.serialupdi.link - INFO - ST to 0x001000
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x44, 0x0, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - send : [0x4]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.link - INFO - LD from 0x001002
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.link - INFO - ST to ptr
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x69, 0x82, 0x12]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - ST16 to *ptr++ with RSD, data length: 0x001 in blocks of:  2
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0xc2, 0xe, 0x55, 0xa0, 0xff]
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x65]
pymcuprog.serialupdi.physical - DEBUG - send : [0x2, 0x55]
pymcuprog.serialupdi.physical - DEBUG - send : [0xc2, 0x6]
pymcuprog.serialupdi.nvm - DEBUG - Committing data
pymcuprog.serialupdi.nvm - DEBUG - NVMCMD 1 executing
pymcuprog.serialupdi.link - INFO - ST to 0x001000
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x44, 0x0, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : []
Traceback (most recent call last):
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 266, in <module>
    main()
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 121, in main
    return_code = pymcuprog_basic(args, fuses_dict)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 217, in pymcuprog_basic
    filename=None)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 131, in run_pymcu_action
    status = func(backend, *args, args_pymcu)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\pymcuprog_main.py", line 368, in _action_write
    backend.write_memory(bytearray(args.literal), args.memory, args.offset)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\backend.py", line 530, in write_memory
    self.programmer.write_memory(data=data, memory_name=memory_name, offset=offset_byte)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\programmer.py", line 188, in write_memory
    self.device_model.write(memory, offset, data)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\nvmserialupdi.py", line 217, in write
    self.avr.nvm.write_flash(offset_aligned, chunk, blocksize=2)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\nvm.py", line 224, in write_flash
    return self.write_nvm(address, data, use_word_access=True, blocksize=blocksize,  bulkwrite=bulkwrite)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\nvm.py", line 318, in write_nvm
    self.execute_nvm_command(nvmcommand)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\nvm.py", line 116, in execute_nvm_command
    return self.readwrite.write_byte(self.device.nvmctrl_address + constants.UPDI_NVMCTRL_CTRLA, command)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\readwrite.py", line 70, in write_byte
    return self.datalink.st(address, value)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\link.py", line 334, in st
    return self._st_data_phase([value & 0xFF])
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\link.py", line 277, in _st_data_phase
    raise PymcuprogError("Error with st")
pymcuprog.pymcuprog_errors.PymcuprogError: Error with st
pymcuprog.serialupdi.physical - INFO - Closing port 'COM9'

instead of;'

Pinging device...
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0xe6]
pymcuprog.serialupdi.link - DEBUG - LDCS from 0x00
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x80]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x20]
pymcuprog.serialupdi.link - DEBUG - LDCS from 0x0B
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x8b]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x8]
pymcuprog.serialupdi.readwrite - DEBUG - Reading 3 bytes from 0x1100
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x69, 0x0, 0x11]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - Repeat 3
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0xa0, 0x2]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x1e, 0x94, 0x22]
pymcuprog.serialupdi.readwrite - DEBUG - Reading 1 bytes from 0x0F01
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x69, 0x1, 0xf]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.readwrite - DEBUG - Reading 3 bytes from 0x1100
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x69, 0x0, 0x11]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - Repeat 3
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0xa0, 0x2]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x1e, 0x94, 0x22]
pymcuprog.serialupdi.readwrite - DEBUG - Reading 1 bytes from 0x0F01
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x69, 0x1, 0xf]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.readwrite - DEBUG - Reading 10 bytes from 0x1103
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x69, 0x3, 0x11]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - Repeat 10
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0xa0, 0x9]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x51, 0x50, 0x50, 0x4b, 0x38, 0x20, 0x8c, 0x1f, 0x1, 0x27]
Ping response: 1E9422
Setting fuse 0x2=0x2
Writing literal values...
pymcuprog.nvm - DEBUG - Writing 1 bytes to address 0x001282
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.nvm - DEBUG - Load NVM address
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x8, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x82]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x9, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x12]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Load fuse data
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x6, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x2]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Execute fuse write
pymcuprog.serialupdi.nvm - DEBUG - NVMCMD 7 executing
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x0, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x7]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x3]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
Verifying literal values...
pymcuprog.nvm - DEBUG - Reading 1 bytes from address 0x001282
pymcuprog.serialupdi.readwrite - DEBUG - Reading 1 bytes from 0x1282
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x69, 0x82, 0x12]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x2]
Action took 0.06s
Setting fuse 0x6=0x4
Writing literal values...
pymcuprog.nvm - DEBUG - Writing 1 bytes to address 0x001286
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.nvm - DEBUG - Load NVM address
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x8, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x86]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x9, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x12]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Load fuse data
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x6, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x4]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Execute fuse write
pymcuprog.serialupdi.nvm - DEBUG - NVMCMD 7 executing
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x0, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x7]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x3]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
Verifying literal values...
pymcuprog.nvm - DEBUG - Reading 1 bytes from address 0x001286
pymcuprog.serialupdi.readwrite - DEBUG - Reading 1 bytes from 0x1286
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x69, 0x86, 0x12]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x4]
Action took 0.05s
Setting fuse 0x8=0x0
Writing literal values...
pymcuprog.nvm - DEBUG - Writing 1 bytes to address 0x001288
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.nvm - DEBUG - Load NVM address
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x8, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x88]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x9, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x12]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Load fuse data
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x6, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x0]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Execute fuse write
pymcuprog.serialupdi.nvm - DEBUG - NVMCMD 7 executing
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x44, 0x0, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x7]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
Verifying literal values...
pymcuprog.nvm - DEBUG - Reading 1 bytes from address 0x001288
pymcuprog.serialupdi.readwrite - DEBUG - Reading 1 bytes from 0x1288
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x69, 0x88, 0x12]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]

those were taken with max verbosity, followed by find/replace INFO lines with "" in the passing one because the old version didn't have INFO logging.

SpenceKonde commented 3 years ago

The successful one does

pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x3]
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
Verifying literal values...
pymcuprog.nvm - DEBUG - Reading 1 bytes from address 0x001282
pymcuprog.serialupdi.readwrite - DEBUG - Reading 1 bytes from 0x1282
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x69, 0x82, 0x12]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - LD8 from ptr++
pymcuprog.serialupdi.physical - DEBUG - data:  : [0x55, 0x24]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x2]
Action took 0.06s
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x3]
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.nvm - DEBUG - Clear page buffer
pymcuprog.serialupdi.nvm - DEBUG - NVMCMD 4 executing
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x44, 0x0, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.physical - DEBUG - send : [0x4]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.nvm - DEBUG - Wait flash ready
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x4, 0x2, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x0]
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x69, 0x82, 0x12]
pymcuprog.serialupdi.physical - DEBUG - receive : [0x40]
pymcuprog.serialupdi.link - DEBUG - ST16 to *ptr++ with RSD, data length: 0x001 in blocks of:  2
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0xc2, 0xe, 0x55, 0xa0, 0xff]
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x65]
pymcuprog.serialupdi.physical - DEBUG - send : [0x2, 0x55]
pymcuprog.serialupdi.physical - DEBUG - send : [0xc2, 0x6]
pymcuprog.serialupdi.nvm - DEBUG - Committing data
pymcuprog.serialupdi.nvm - DEBUG - NVMCMD 1 executing
pymcuprog.serialupdi.physical - DEBUG - send : [0x55, 0x44, 0x0, 0x10]
pymcuprog.serialupdi.physical - DEBUG - receive : []
Traceback (most recent call last):
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 266, in <module>
    main()
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 121, in main
    return_code = pymcuprog_basic(args, fuses_dict)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 217, in pymcuprog_basic
    filename=None)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr/tools/prog.py", line 131, in run_pymcu_action
    status = func(backend, *args, args_pymcu)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\pymcuprog_main.py", line 368, in _action_write
    backend.write_memory(bytearray(args.literal), args.memory, args.offset)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\backend.py", line 530, in write_memory
    self.programmer.write_memory(data=data, memory_name=memory_name, offset=offset_byte)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\programmer.py", line 188, in write_memory
    self.device_model.write(memory, offset, data)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\nvmserialupdi.py", line 217, in write
    self.avr.nvm.write_flash(offset_aligned, chunk, blocksize=2)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\nvm.py", line 224, in write_flash
    return self.write_nvm(address, data, use_word_access=True, blocksize=blocksize,  bulkwrite=bulkwrite)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\nvm.py", line 318, in write_nvm
    self.execute_nvm_command(nvmcommand)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\nvm.py", line 116, in execute_nvm_command
    return self.readwrite.write_byte(self.device.nvmctrl_address + constants.UPDI_NVMCTRL_CTRLA, command)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\readwrite.py", line 70, in write_byte
    return self.datalink.st(address, value)
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\link.py", line 334, in st
    return self._st_data_phase([value & 0xFF])
  File "C:\Users\Spence\Documents\Arduino\hardware\megaTinyCore\megaavr\tools\libs\pymcuprog\serialupdi\link.py", line 277, in _st_data_phase
    raise PymcuprogError("Error with st")
pymcuprog.pymcuprog_errors.PymcuprogError: Error with st

WTF is going on? It's doing something radically different?

SpenceKonde commented 3 years ago

Looks like the changes in the Microchip version were much larger than we realized :-( I just did a diff between the two there is a lot more stuff changed than I realized, for sure.

qbolsee commented 3 years ago

I see. For your megaTinyCore release, you can use the old code while we refactor this one. Should I create a branch?

SpenceKonde commented 3 years ago

I mean I guess we should make a branch, though it's not like we have working code here that we don't want to break or something

There's some new code that I checked into the other one and am using for megaTinyCore release that makes the SAMD11C adapters work at 230400 with what Neil preloaded onto it, which i gather is your code.... I also solved the mystery of why it seemed to work for us over zoom at turbo mode - yet the speed wasn't any higher - my scope said it was running at 115200 baud not the requested 460800, which would explain it working better but more slowly.

I really need like, a step-by-step to add a command line argument to prog.py that gets propagated to a low level - making changes is straightforward, but making those changes optional is a monstrous production. I'm not very happy that I'm releasing something that makes the most popular serial adapter (which doesn't even need that modification) which I use for all my uploads take twice as long to upload. I kept running that test over and over and could not believe how hard it was hitting the speed. But we need it, because there's a whole bunch of adapters that are stuck back at 57600 baud without it. The obvious solution is to make it a command line argument, and I tried for HOURS and eventually came to an error that I couldn;t interpret looked at the clock and said fuck it. This codebase is incredibly frustrating to work with - calls jump between files most of which we have no use for with neither rhyme nor reason. I really want to declare that "THIS SHALT USE ONLY SERIAL ADAPTERS" and start axing everything that's only used for those microchip debuggers-used-as-programmers (I mean, if they're programmers with debugging capability, they're a pretty sorry excuse for a programmer since SerialUPDI runs rings around them.