Maple Mini as ISP

stevestrong
Posts: 1813
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Maple Mini as ISP

Post by stevestrong » Tue Feb 28, 2017 4:42 pm

have you set the correct serial port?

User avatar
Rick Kimball
Posts: 1055
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Maple Mini as ISP

Post by Rick Kimball » Tue Feb 28, 2017 6:06 pm

?
Last edited by Rick Kimball on Tue Feb 28, 2017 6:33 pm, edited 1 time in total.
-rick

User avatar
Rick Kimball
Posts: 1055
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Maple Mini as ISP

Post by Rick Kimball » Tue Feb 28, 2017 6:25 pm

I compiled for native and hardware serial. The native one is /dev/ttyACM0, the hardware one is a pl2303 on /dev/ttyUB0

I created a binary file of 512 bytes that is just 0x0 - 0xff 2 times. I did this because the code files I was uploading came back telling me that the code on my disk and the code on the chip didn't match. The verify failed. I wanted to be able to see exactly where it fell down.

The first 256 bytes upload fine and get burned on the chip without a problem. The second chunk fails because the first 7 bytes have 0xff instead of 01, 02, 03, 04, 05, 06. The remaining 249 bytes get burned properly. I'm sure it is the upload part that is failing. If I upload with the USB native then recompile the code to use the hardware serial, it fails to verify properly. Those bytes are 0xFF on the chip.

I ran the avrdude on the command line 2 times .. once using the one compiled for native, and once compiled for hardware serial. When I diff the two you can see where it falls down:

Code: Select all

10c10
<          Using Port                    : /dev/ttyACM0
---
>          Using Port                    : /dev/ttyUSB0
145c145
< ################################## | 100% 0.00s
---
> ################################## | 100% 0.01s
269c269
< ####### | 100% 0.20s
---
> ####### | 100% 0.35s
282c282
< avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [07] . [08] . [09] . [0a] . [0b] . [0c] . [0d] . [0e] . [0f] . [10] . [11] . [12] . [13] . [14] . [15] . [16] . [17] . [18] . [19] . [1a] . [1b] . [1c] . [1d] . [1e] . [1f]   [20] ! [21] " [22] # [23] $ [24] % [25] & [26] ' [27] ( [28] ) [29] * [2a] + [2b] , [2c] - [2d] . [2e] / [2f] 0 [30] 1 [31] 2 [32] 3 [33] 4 [34] 5 [35] 6 [36] 7 [37] 8 [38] 9 [39] : [3a] ; [3b] < [3c] = [3d] > [3e] ? [3f] 
---
> avrdude: Recv: . [00] . [01] . [02] . [03] . [04] . [05] . [06] . [07] . [08] . [09] . [0a] . [0b] . [0c] . [0d] . [0e] . [0f] . [10] . [11] . [12] . [13] . [14] . [15] . [16] . [17] . [18] . [19] . [1a] . [1b] . [1c] . [1d] . [1e] . [1f]   [20] ! [21] " [22] # [23] $ [24] % [25] & [26] ' [27] ( [28] ) [29] * [2a] + [2b] , [2c] - [2d] . [2e] / [2f] 0 [30] 1 [31] 2 [32] 3 [33] 4 [34] 5 [35] 6 [36] 7 [37] 8 [38] 9 [39] : [3a] ; [3b] < [3c] = [3d] > [3e] ? [3f] 
289c289
I can use the native port to do simple things like query the chip fuse settings. Change fuse settings. It only seems to fail with I start uploading code using the native usb.

I've tried this on 3 different bluepills/redpills with the same results so it isn't specific to a particular board.
-rick

stevestrong
Posts: 1813
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Maple Mini as ISP

Post by stevestrong » Tue Feb 28, 2017 7:37 pm

I see two possible problems:
- line 281 - in case of no data Serial.available() can return -1 which is considered valid reception
- line 286 - writng the buff[] can overflow, no limitation to buff size is coded.

User avatar
Rick Kimball
Posts: 1055
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Maple Mini as ISP

Post by Rick Kimball » Tue Feb 28, 2017 8:47 pm

stevestrong wrote:I see two possible problems:
- line 281 - in case of no data Serial.available() can return -1 which is considered valid reception
- line 286 - writng the buff[] can overflow, no limitation to buff size is coded.
line 281:
I had already modified the code before running the tests above. I saw that code as a problem.

Code: Select all

  /* blocking single character read */
  while ( SERIAL.available() <= 0);
  return SERIAL.read();
line 286
I added code to fill() ...

Code: Select all

  if ( n > 64 ) // check and trap if too big
    while(1);
    
  for (unsigned x = 0; x < n; x++) {
    buff[x] = get_ch();
  }
It never trapped at a max of 64. If I change the max to 48 it actually hangs.

So overflowing the buff[] size doesn't seem to be the problem. Nor does the read of -1
-rick

stevestrong
Posts: 1813
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Maple Mini as ISP

Post by stevestrong » Wed Mar 01, 2017 3:48 pm

It seems that the code posted here it is not the one used, so i cannot follow whatever other changes...

stevestrong
Posts: 1813
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Maple Mini as ISP

Post by stevestrong » Sat Mar 04, 2017 3:55 pm

The first seven bytes being 0xff seem very likely to be -1 returned by Serial.read() if no data is available.

Post Reply