Ahh… that sucks, although having a more accurate progress bar is useful.
I have been able to make a bit of progress on reducing upload speed, but it still seems slower than it should. When I started, it was taking around 52 seconds to erase/write/verify around 11 kB of flash. After removing or reducing a lot of the delays (in the Arduino sketch), I got it down to around 38 seconds.
I think we are running into a limitation on how fast data can be sent over the debug interface. The program writes a page worth (2 kB) of data to the XDATA memory a (64 byte) packet at a time. Then, it writes a cpu code bundle to XDATA memory that reads the page of data from XDATA and writes it to flash. Then it points the CPU at the program in memory, and starts it up. It will halt at the end of the cpu code, and the program is waiting for the cpu to be halted before continuing with another command.
For each (64 byte) packet, in addition to setting up the address at the beginning of a packet, writing each byte (in a loop) to XDATA memory takes seven 8-bit writes (plus three 8-bit reads). It executes (3) debug/cpu instructions:
- [0x56,0x74,0x(byte)] - MOV A, #byte; // write byte to accumulator
- [0x55,0xF0] - MOVX @DPTR, A; // write accumulator to XDATA based on pointer location
- [0x55,0xA3] - INC DPTR; // increment pointer location
We are bit-banging the debug interface which means we are not transferring data as quickly as we could be, but even still, this doesn’t seem like a very efficient way of programing flash.
There is a faster way of doing this on newer CC25xx devices using DMA, but unfortunately it looks like the CC2430 doesn’t support using the debug interface as a DMA source.