picprojects.net Forum

picprojects.net Forum
It is currently Tue Oct 16, 2018 12:02 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: picpgm 2.9.2.3 Linux COM LVP mode reliability troubles
PostPosted: Sat Feb 11, 2017 9:27 pm 
Offline

Joined: Sat Feb 11, 2017 8:28 pm
Posts: 3
Dear reader,

here is a somewhat long problem description, trying to include all relevant details of what I am trying to do and how. The short story is, that picpgm does detect my PIC, but often hangs, often quite early, so it is more or less not useable to do real programming yet. Ideas to improve this would be great! Thanks :-)

At the moment I am trying to use picpgm 2.9.2.3 in Linux with an old Samsung phone data cable, using the following:

Code:
    <PgmIf name="Samsung" typ="LVP" connection="COM" jdm_charge_pump="enable">
        <PinCfg name="MCLR" pin="7" invert="1" />
        <PinCfg name="PGM" pin="0" invert="1" />
        <PinCfg name="CLK" pin="4" invert="1" />
        <PinCfg name="DOUT" pin="3" invert="1" />
        <PinCfg name="DIN" pin="1" invert="1" />
    </PgmIf>


The data cable has a RS232 to/from TTL level converter chip for 3 to 5 Volts, now connected to 5 Volts, like the PIC itself. The pin assignment is inspired by 5PIP, but thanks to the chip, everything is "inverted" as is normal on RS232, I think: sending "high" sends -12 Volts which the chip translates to +5 Volts, while "low" is +12 Volts on RS232 and 0 Volts on TTL.

I think that the "invert" settings are correct, because the following works SOMETIMES:

Code:
$ ./picpgm -port /dev/ttyS0 -if Samsung

==================================================================
PICPgm 2.9.2.3
PIC Development Programmer, http://picpgm.picprojects.net
Copyright 2002-2016 Christian Stadler (picpgm@picprojects.net)
built on Dec 17 2016, 21:10:55
==================================================================

Checking connection of programmer "Samsung" ...
Programmer: Samsung
            at /dev/ttyS0

Autodetecting PIC ...

PIC name:    PIC16F1459
Device ID:   0x3023
Flash:       16 kByte
EEPROM:      0 Byte
CalWord1:    0x3CC6
CalWord2:    0x1D33


finished in 4.0 seconds!


As the config file tells, DCD and TxD are used for ICSP DAT, DTR is used for ICSP CLK and RTS is used for MCLR. Not sure what PGM would be, but "pin 0" probably means "not connected" anyway.

The problem is that picpgm hangs very often. Sometimes in "Autodetecting", sometimes in trying to read one of the "CalWord" values. Trying to read the config space or even the program memory hangs even more often. Only once, I was lucky enough to read the whole contents:

Code:
:020000040000FA
:10000000FF3FFF3FFF3FFF3FFF3FFF3FFF3FFF3F00
:10001000FF3FFF3FFF3FFF3FFF3FFF3FFF3FFF3FF0
...
:103FF000FF3FFF3FFF3FFF3FFF3FFF3FFF3FFF3FD1
:020000040001F9
:08000000FFFFFFFFFFFFFFFF00
:020000040001F9
:10000000FF3FFF3FFF3FFF3FFF3F0310FF3FFF3F2B
:02001000FF3FB0
:00000001FF


Reading config memory tells me that addr 0x0000000A is 0x1003, while the rest of the config space is 0x3FFF. None of that sounds very unusual for me, so I would guess that the wiring is okay, for LOW VOLTAGE PROGRAMMING (LVP) mode. Only power (with 1 uF blocking cap) and the 3 ICSP related signals are connected, so the rest of the "circuit" should not cause distractions either. In some cases, I get the impression that picpgm hangs while sending a "break", but there are no messages about what and why gets stuck. Using a normal Linux (3.13 kernel) here. The -delay options do not seem to make much difference either.

Does anybody have ideas how to improve stability of the programmer connection? Given that even reading flash rarely works, I do not dare to use picpgm to write flash yet in the current state.

If that helps, I can try to add some circuit for "if the data cable sends 0 / 5 Volt, set MCLR to VPP / 0 Volt" to compare high voltage programming, but for ICSP, I would really prefer low voltage mode.

With some LED connected between data and ground, I see that picpgm pulls MCLR low and sends short data bursts on the ICSP data and clock wires while doing the autodetect, so I would say the high / low polarities are just fine. Also, the magic "MCHP" bit string to activate LVP is probably sent correctly - otherwise the autodetect would not work either, or am I thinking in the wrong direction here?

As said, and recommendations would be welcome! Thanks! :-)


Top
 Profile  
 
 
 Post subject: Re: picpgm 2.9.2.3 Linux COM LVP mode reliability troubles
PostPosted: Sun Feb 12, 2017 12:24 am 
Offline

Joined: Sat Feb 11, 2017 8:28 pm
Posts: 3
Update: picpgm for Linux seems to often stall in calls to ioctl(3, TIOCSBRK) on a Linux 3.13 kernel.

Connecting MCLR to TXD and connecting the programming data to DTR made things a bit better: In other words, by swapping the usage of pin 3 and 7 on the serial port helped a bit. The idea is that MCLR has to be toggled less often than the ICSP data and clock lines, so connecting the "easier" MCLR line to TXD means TIOCSBRK is needed less often...

Now picpgm is able to upload a tiny (120 code words) hello world program to the PIC once every several attempts without getting stuck - at least a bit of improvement :-)


Top
 Profile  
 
 Post subject: Re: picpgm 2.9.2.3 Linux COM LVP mode reliability troubles
PostPosted: Tue Feb 14, 2017 11:07 pm 
Offline

Joined: Sat Feb 11, 2017 8:28 pm
Posts: 3
On the plus side, when picpgm does work, it flashes 3k-words within 22 seconds for the whole process - it seems that picpgm always does the full 8k-words anyway. Not sure whether it would make sense to support partial flashing?

Flashing sometimes even works on the first attempt now and I never need more than a handful attempts. Maybe related to the PIC now being configured to 4, 8 or 16 MHz internal oscillator after most of my compiles? Or is that unrelated?

When picpgm gets stuck, which still happens quite a bit, stracing picpgm and/or aborting strace sometimes magically gets it out of the stuck "send break" IOCTL call. No idea why, but it helps to complete the flashing process more often :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group