[<<] [<] Page 1 of 2 [>] [>>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [gnupic] PICDEM FS USB and Linux tools
From: "Xiaofan Chen" ####@####.#### Date: 21 Sep 2007 00:59:34 +0100 Message-Id: <a276da400709201658o1d1db289jc7f5d4901ee70e5a@mail.gmail.com> On 9/21/07, Rick Bronson ####@####.#### wrote: > Hi, > > If someone wanted to use Linux tools for uploading a program via USB > to the PICDEM board what are the suggested tools? Two I've run across > are: > > 1. picdem.pl (or picdem2.pl which is mentioned but I can't find it) > 2. fsusb-0.1.11-2.tar.gz > > picdem.pl seems to requre USB.pm, which I can't seem to find for > debian. Unless it's the one in Zaptel. > > /fsusb-0.1.11-2> lsusb > Bus 002 Device 003: ID 04d8:000c Microchip Technology, Inc. This is the demo mode VID/PID. You need to press the button to get into the bootloader mode. > fsusb gives me: > > /fsusb-0.1.11-2> sudo ./fsusb --program usbhid.hex > Locating USB Microchip(tm) PICDEM-FS USB(tm) (vendor 0x04d8/product 0x000c) > Found USB PICDEM-FS USB as device '003' on USB bus 002 > Communication established. Onboard firmware version is 1.0 > usb PICDEM read: Resource temporarily unavailable > Fatal error> USB read failed Which kernel version are you using? If you are using very very latest kernel, then you might have to patch the source codes to detach the kernel driver to get the demo code working. (the demo code is at http://www.varxec.net/picdem_fs_usb/ ) http://forum.sparkfun.com/viewtopic.php?=&p=24707 PS: some PIC USB open source links: 1. PUF using sdcc : http://vasco.gforge.enseeiht.fr/ 2. PIC18F4550 USB/MSD sourceforge, Apache License V2.0 http://sourceforge.net/projects/pic18fusb 3) GPLed USB stack with SDCC http://forum.microchip.com/tm.aspx?m=170553 http://www.nutsvolts.com/%7Edownloads/USB.zip 4) PICDEM FS USB bootloader for Linux/Windows using libusb http://www.internetking.org/fsusb/ http://forum.microchip.com/tm.aspx?m=106426 5) PICDEM FS USB demo appliation under Linux/Windows using libusb http://www.varxec.net/picdem_fs_usb/ Xiaofan | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [gnupic] PICDEM FS USB and Linux tools
From: "Xiaofan Chen" ####@####.#### Date: 21 Sep 2007 01:00:54 +0100 Message-Id: <a276da400709201659u6ee345d6h818cd26b6475ace3@mail.gmail.com> On 9/21/07, Xiaofan Chen ####@####.#### wrote: > On 9/21/07, Rick Bronson ####@####.#### wrote: > > Hi, > > > > If someone wanted to use Linux tools for uploading a program via USB > > to the PICDEM board what are the suggested tools? Two I've run across > > are: > > > > 1. picdem.pl (or picdem2.pl which is mentioned but I can't find it) > > 2. fsusb-0.1.11-2.tar.gz > > > > picdem.pl seems to requre USB.pm, which I can't seem to find for > > debian. Unless it's the one in Zaptel. > > > > /fsusb-0.1.11-2> lsusb > > Bus 002 Device 003: ID 04d8:000c Microchip Technology, Inc. > > This is the demo mode VID/PID. You need to press the button to > get into the bootloader mode. The bootloader VID/PID is 04d8:000b. > > fsusb gives me: > > > > /fsusb-0.1.11-2> sudo ./fsusb --program usbhid.hex > > Locating USB Microchip(tm) PICDEM-FS USB(tm) (vendor 0x04d8/product 0x000c) > > Found USB PICDEM-FS USB as device '003' on USB bus 002 > > Communication established. Onboard firmware version is 1.0 > > usb PICDEM read: Resource temporarily unavailable > > Fatal error> USB read failed > > Which kernel version are you using? If you are using very very latest > kernel, then you might have to patch the source codes to detach the > kernel driver to get the demo code working. > (the demo code is at http://www.varxec.net/picdem_fs_usb/ ) > http://forum.sparkfun.com/viewtopic.php?=&p=24707 > > PS: some PIC USB open source links: > 1. PUF using sdcc : http://vasco.gforge.enseeiht.fr/ > > 2. PIC18F4550 USB/MSD sourceforge, Apache License V2.0 > http://sourceforge.net/projects/pic18fusb > > 3) GPLed USB stack with SDCC > http://forum.microchip.com/tm.aspx?m=170553 > http://www.nutsvolts.com/%7Edownloads/USB.zip > > 4) PICDEM FS USB bootloader for Linux/Windows using libusb > http://www.internetking.org/fsusb/ > http://forum.microchip.com/tm.aspx?m=106426 > > 5) PICDEM FS USB demo appliation under Linux/Windows using libusb > http://www.varxec.net/picdem_fs_usb/ > > > Xiaofan > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [gnupic] PICDEM FS USB and Linux tools
From: Nicolas ####@####.#### Date: 21 Sep 2007 10:16:22 +0100 Message-Id: <92d8b98a0709210216o8505c69h7f6bc6740b58072f@mail.gmail.com> On 9/20/07, Rick Bronson ####@####.#### wrote: > If someone wanted to use Linux tools for uploading a program via USB > to the PICDEM board what are the suggested tools? Two I've run across Piklab should also support the PICDEM bootloader... Please give me feedback if it does not work. Regards, Nicolas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [gnupic] PICDEM FS USB and Linux tools
From: "Xiaofan Chen" ####@####.#### Date: 21 Sep 2007 15:18:55 +0100 Message-Id: <a276da400709210718w24c87943y8f0b24af0f7bd79c@mail.gmail.com> On 9/21/07, Nicolas ####@####.#### wrote: > On 9/20/07, Rick Bronson ####@####.#### wrote: > > If someone wanted to use Linux tools for uploading a program via USB > > to the PICDEM board what are the suggested tools? Two I've run across > > Piklab should also support the PICDEM bootloader... > Please give me feedback if it does not work. > I was trying to test out this under Ubuntu 6.06 but unfortunately Piklab crashed when I was trying to configure the programmer. The old version is ok but mentioned that it does not support 18F4550. The latest svn version is also not working. fsusb works fine under Ubuntu 6.06. GUI mode prompt from the latest version: Connecting Picdem Bootloader on USB Port with device 18F4550... Bootloader version 1.0.0 detected Set target self powered: true Connected. The selected programmer cannot read device memory Console mode: mcuee@ubuntu:~$ piklab-prog -p picdem_bootloader -c read testcdc.hex piklab-prog: version 0.14.5 (rev. 2209) programmer: picdem_bootloader Error: Device not specified. mcuee@ubuntu:~$ piklab-prog -d 18f4550 -p picdem_bootloader -c read testcdc.hex piklab-prog: version 0.14.5 (rev. 2209) programmer: picdem_bootloader device: 18F4550 Using port from configuration file. Error: The selected programmer cannot read device memory. mcuee@ubuntu:~$ uname -a Linux ubuntu 2.6.15-28-386 #1 PREEMPT Wed Jul 18 22:50:32 UTC 2007 i686 GNU/Linux Crash log when configuring Piklab: Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1". [Thread debugging using libthread_db enabled] [New Thread -1238889600 (LWP 12345)] [KCrash handler] #6 0x081687e0 in Hardware::Config::hardwareNames (this=0x0, type=Port::USBType) at hardware_config.cpp:89 #7 0x0816895e in Hardware::Config::currentHardware (this=0x0, type=Port::USBType) at hardware_config.cpp:38 #8 0x080b57e7 in Programmer::SelectConfigWidget::portChanged (this=0x9c26b18) at prog_config_widget.cpp:131 #9 0x080ca391 in Programmer::SelectConfigWidget::qt_invoke (this=0x9c26b18, _id=50, _o=0xbff2c798) at prog_config_widget.moc.cpp:170 #10 0xb6a8d051 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 #11 0xb6e2025a in QSignal::signal () from /usr/lib/libqt-mt.so.3 #12 0xb6aaa7c8 in QSignal::activate () from /usr/lib/libqt-mt.so.3 #13 0xb6ab22b8 in QSingleShotTimer::event () from /usr/lib/libqt-mt.so.3 #14 0xb6a22f3e in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3 #15 0xb6a2313a in QApplication::notify () from /usr/lib/libqt-mt.so.3 #16 0xb71a7d7d in KApplication::notify () from /usr/lib/libkdecore.so.4 #17 0x081b012b in QApplication::sendEvent (receiver=0x875b110, event=0xbff2cb08) at qapplication.h:520 #18 0xb6a1492b in QEventLoop::activateTimers () from /usr/lib/libqt-mt.so.3 #19 0xb69c7f67 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3 #20 0xb6a3ba2f in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3 #21 0xb6a21a79 in QApplication::enter_loop () from /usr/lib/libqt-mt.so.3 #22 0xb6c4052c in QDialog::exec () from /usr/lib/libqt-mt.so.3 #23 0x080883b2 in MainWindow::configure (this=0x875a028, showType=ConfigCenter::General) at toplevel.cpp:494 #24 0x080cf0eb in MainWindow::qt_invoke (this=0x875a028, _id=79, _o=0xbff2cf3c) at toplevel.moc.cpp:642 #25 0xb6a8d051 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 #26 0xb6a8daec in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 #27 0xb73c28a7 in KAction::activated () from /usr/lib/libkdeui.so.4 #28 0xb73f8674 in KAction::slotActivated () from /usr/lib/libkdeui.so.4 #29 0xb7413d96 in KAction::slotPopupActivated () from /usr/lib/libkdeui.so.4 #30 0xb741404b in KAction::qt_invoke () from /usr/lib/libkdeui.so.4 #31 0xb6a8d051 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 #32 0xb6e2025a in QSignal::signal () from /usr/lib/libqt-mt.so.3 #33 0xb6aaa7c8 in QSignal::activate () from /usr/lib/libqt-mt.so.3 #34 0xb6bb2149 in QPopupMenu::mouseReleaseEvent () from /usr/lib/libqt-mt.so.3 #35 0xb73ce4e7 in KPopupMenu::mouseReleaseEvent () from /usr/lib/libkdeui.so.4 #36 0xb6ac7825 in QWidget::event () from /usr/lib/libqt-mt.so.3 #37 0xb6a22f3e in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3 #38 0xb6a234c8 in QApplication::notify () from /usr/lib/libqt-mt.so.3 #39 0xb71a7d7d in KApplication::notify () from /usr/lib/libkdecore.so.4 #40 0xb69b41c5 in QApplication::sendSpontaneousEvent () from /usr/lib/libqt-mt.so.3 #41 0xb69af5c0 in QETWidget::translateMouseEvent () from /usr/lib/libqt-mt.so.3 #42 0xb69add59 in QApplication::x11ProcessEvent () from /usr/lib/libqt-mt.so.3 #43 0xb69c74db in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3 #44 0xb6a3ba2f in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3 #45 0xb6a3b952 in QEventLoop::exec () from /usr/lib/libqt-mt.so.3 #46 0xb6a21a4d in QApplication::exec () from /usr/lib/libqt-mt.so.3 #47 0x08084773 in main (argc=1, argv=0xbff2dc84) at main.cpp:32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [gnupic] PICDEM FS USB and Linux tools
From: Rick Bronson ####@####.#### Date: 21 Sep 2007 22:15:34 +0100 Message-Id: <E1IYpqg-0003df-00@amazonia.comcast.net> Hi, Thanks very much for the help. I really appreciate it. > The bootloader VID/PID is 04d8:000b. Sorry I missed this little detail. One thing I've noticed both on the PICDEM and the UWB (Sparkfun) board is if I hold the button down for "boot mode" the entry listed in "lsusb" only stays for some time. That is, I get the board in boot mode and then keep doing "lsusb" the listing: Bus 002 Device 027: ID 04d8:000b Microchip Technology, Inc. shows up for about 1-3 seconds then goes away. Any ideas about this? I'm running Debian sid: uname -a Linux amazonia 2.6.19.7 #1 SMP PREEMPT Wed Apr 18 22:22:29 PDT 2007 i686 GNU/Linux If I download during this time it all works fine but once it's gone I can't download (of course). > 3) GPLed USB stack with SDCC > http://forum.microchip.com/tm.aspx?m=170553 > http://www.nutsvolts.com/%7Edownloads/USB.zip I built this up (with sdcc) and ran it but it doesn't seem to give me anything on USB (it does make "lsusb" pause though). Anyone else build it? Here are some files of importance: http://www.efn.org/~rick/work/pic/Makefile http://www.efn.org/~rick/work/pic/rm18f4550.lkr http://www.efn.org/~rick/work/pic/main.c http://www.efn.org/~rick/work/pic/crt0i-rloc.c > Piklab should also support the PICDEM bootloader... > Please give me feedback if it does not work. I tried Piklab but when I select "sdcc" in "settings->configure piklab->toolschains" then save, when I come back in to "settings->configure piklab->toolschains" it's set to "gputils". Thanks again for the help. Rick | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [gnupic] PICDEM FS USB and Linux tools
From: "Xiaofan Chen" ####@####.#### Date: 22 Sep 2007 00:43:02 +0100 Message-Id: <a276da400709211642w64677e8ra9726d84c14d3d36@mail.gmail.com> On 9/22/07, Rick Bronson ####@####.#### wrote: > Hi, > > Thanks very much for the help. I really appreciate it. > > > The bootloader VID/PID is 04d8:000b. > > Sorry I missed this little detail. > > One thing I've noticed both on the PICDEM and the UWB (Sparkfun) > board is if I hold the button down for "boot mode" the entry listed in > "lsusb" only stays for some time. That is, I get the board in boot > mode and then keep doing "lsusb" the listing: > > Bus 002 Device 027: ID 04d8:000b Microchip Technology, Inc. > > shows up for about 1-3 seconds then goes away. Any ideas about > this? I'm running Debian sid: Apparently this is a problem with Debian kernel and people (including me --under Ubuntu 7.04) are having problem with the bootloader and the CDC example (UWB is based on the CDC example). It is said compiling a new vanila kernel will help. I have not done that yet. It has been a while that I need to recompile a kernel... Please also refer to the following threads: http://forum.microchip.com/tm.aspx?m=283378 Under Ubuntu 6.06, the USB examples worked fine. Regards, Xiaofan | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [gnupic] PICDEM FS USB and Linux tools
From: "Xiaofan Chen" ####@####.#### Date: 22 Sep 2007 02:36:29 +0100 Message-Id: <a276da400709211835l6baad8b2na275bf526a28ee25@mail.gmail.com> On 9/21/07, Nicolas ####@####.#### wrote: > On 9/20/07, Rick Bronson ####@####.#### wrote: > > If someone wanted to use Linux tools for uploading a program via USB > > to the PICDEM board what are the suggested tools? Two I've run across > > Piklab should also support the PICDEM bootloader... > Please give me feedback if it does not work. > I tried the released version 0.14.5 and it does not crash like the SVN version but it still does not work. Message: " disconnect hardware connect hardware disconnect hardware Connecting Picdem Bootloader on USB Port with device 18F4550... USB Port: find if there is already an installed driver USB Port: alternate setting is 0 USB Port: USB bcdDevice: 0x0000 USB Port: send: "\00\00\00\00\00" USB Port: write to endpoint 0x01 (bulk - out) 5 chars: "\00\00\00\00\00" USB Port: read from endpoint 0x81 (bulk - in) 4 chars USB Port: received: "\00\00\00\01" Bootloader version 1.0.0 detected Set target self powered: true Connected. disconnect hardware The selected programmer cannot read device memory." Xiaofan | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [gnupic] PICDEM FS USB and Linux tools
From: "Xiaofan Chen" ####@####.#### Date: 22 Sep 2007 02:54:50 +0100 Message-Id: <a276da400709211854r51e53e41u2e0cb80d85a3aef8@mail.gmail.com> On 9/21/07, Rick Bronson ####@####.#### wrote: > Hi, > > If someone wanted to use Linux tools for uploading a program via USB > to the PICDEM board what are the suggested tools? Two I've run across > are: > > 1. picdem.pl (or picdem2.pl which is mentioned but I can't find it) > 2. fsusb-0.1.11-2.tar.gz > > picdem.pl seems to requre USB.pm, which I can't seem to find for > debian. Unless it's the one in Zaptel. > I have not used picdem.pl but I happen to have the archive posted by Ben Dugan before. The author is Alessandro. I have not used it since fsusb works fine for me. USB.pm: is it this one? http://search.cpan.org/~gwadej/Device-USB-0.21/lib/Device/USB.pm picdem.pl: I notice that attachement does not with GNUPIC archive. So I will try to posted it here. I tried to find it in the thread I posted and found the post but the attachement was gone. http://www.linuxhacker.org/cgi-bin/ezmlm-cgi?1:aas:6514:laceapkmfbcildembmhb#b #!/usr/bin/perl -w use USB; use IO::File; #use Data::HexDump (); #use Data::Dumper; use constant READ_VERSION => 0x00; use constant READ_FLASH => 0x01; use constant WRITE_FLASH => 0x02; use constant ERASE_FLASH => 0x03; use constant READ_EEDATA => 0x04; use constant WRITE_EEDATA => 0x05; use constant READ_CONFIG => 0x06; use constant WRITE_CONFIG => 0x07; use constant UPDATE_LED => 0x32; use constant RESET => 0xFF; my $commands = { 'dump' => [ qw ( userid config eeprom program ) ], 'erase' => [ qw ( userid eeprom program ) ], 'compare' => 'file', 'reset' => undef, 'fill' => undef, 'write' => 'file', }; print "picdem.pl 0.4 - 20050329\n"; print "Copyright (c) 2005 Tower Technologies, written by Alessandro Zummo,\n"; print "licensed under the GPL. Feedback to ####@####.#### # show usage when no args help() unless scalar @ARGV; # validate commands my @cmds = @ARGV; while (scalar @cmds) { my $cmd = shift @cmds; # check command help("Unknown command: $cmd\n") unless grep { $cmd eq $_ } keys %$commands; my $what = shift @cmds if defined $commands->{$cmd}; # check command's option (if required) help( "Unknown option for $cmd: $what\n", "Valid options are: ", join(',', @{$commands->{$cmd}}), "\n" ) if ref($commands->{$cmd}) eq 'ARRAY' and not grep { $what eq $_ } @{$commands->{$cmd}}; help("Missing filename\n") if defined $commands->{$cmd} and $commands->{$cmd} eq 'file' and not defined $what; } # the real job # init USB USB::usb_init(); USB::usb_find_busses(); USB::usb_find_devices(); # Search for 0x04D8/0x000B my $device = picdem_find(0x04D8, 0x00B); die "Couldn't find PICDEM FS USB\n" unless defined $device; print "PICDEM FS USB found\n"; # open and setup my $handle = USB::usb_open($device); USB::usb_set_configuration($handle, 1); USB::usb_claim_interface($handle, 0); # led on picdem_update_led($handle, 4, 1); # banner my ($maj, $min) = picdem_version($handle); print "bootloader version $maj.$min\n\n"; my $cmd = ''; while (scalar @ARGV) { $cmd = shift; my $what = shift if defined $commands->{$cmd}; job($handle, $cmd, $what); } # leds off, we have finished. if ($cmd ne 'reset') { picdem_update_led($handle, 3, 0); picdem_update_led($handle, 4, 0); } USB::usb_release_interface($handle, 0); USB::usb_close($handle); print "done.\n"; sub job { my ($handle, $cmd, $what) = @_; # handle commands if ($cmd eq 'dump') { print "dumping $what\n"; picdem_read_userid($handle) if $what eq 'userid'; picdem_read_config($handle) if $what eq 'config'; picdem_read_eeprom($handle) if $what eq 'eeprom'; picdem_read_flash($handle) if $what eq 'program'; } if ($cmd eq 'erase') { print "erasing $what\n"; picdem_erase_eeprom($handle) if $what eq 'eeprom'; picdem_erase_flash($handle) if $what eq 'program'; picdem_erase_block($handle, 0x00200000, 1) if $what eq 'userid'; } if ($cmd eq 'write') { my $data = load_inhx32($what); print "writing\n"; picdem_write_flash($handle, $data); print "comparing\n"; picdem_compare_flash($handle, $data); } picdem_compare_flash($handle, load_inhx32($what)) if $cmd eq 'compare'; picdem_reset($handle) if $cmd eq 'reset'; picdem_fill($handle) if $cmd eq 'fill'; } sub help { print @_; print "\nUsage:\n\n"; foreach (sort keys %$commands) { print "$_\t[", join(',', @{$commands->{$_}}), "]\n" if defined $commands->{$_} and ref($commands->{$_}) eq 'ARRAY'; print "$_\t<inhx32 file name>\n" if defined $commands->{$_} and $commands->{$_} eq 'file'; print "$_\n" if not defined $commands->{$_}; } exit; } sub picdem_find { my ($vid, $pid) = @_; my $bus = &USB::get_usb_busses(); do { my $device = &USB::get_usb_devices($bus); do { my $desc = USB::get_usb_device_descriptor($device); return $device if $desc->{'idVendor'} == $vid and $desc->{'idProduct'} == $pid; } while ($device = USB::get_usb_next_device($device)); } while ($bus = USB::get_usb_next_bus($bus)); return undef; } sub do_cmd { my ($handle, $command, @data) = @_; my ($out, $len) = encode($command, @data); my $in = 0xFF x 64; # print ">>> $len\n"; # dump_buffer($out); my $num = USB::usb_bulk_write($handle, 0x01, $out, $len, 300); die "usb_bulk_write: $!\n" if $num < 0; $num = USB::usb_bulk_read($handle, 0x81, $in, 64, 1000); die "usb_bulk_read: $!\n" if $num < 0; # print "<<< $num\n"; # dump_buffer(substr($in, 0, $num)); @data = unpack('C*', substr($in, 0, $num)); return \@data; } sub encode { my ($command, @data) = @_; my $raw = pack('C*', $command, @data); return ($raw, length($raw)); } sub dump_buffer { my ($buffer) = @_; my ($cmd, $len, $addr1, $addr2, $addr3, $data) = unpack('C C C C C a*', $buffer); # printf "CMD: %02x\n", $cmd; # printf "LEN: %02x\n", $len; print Data::HexDump::HexDump($buffer); print "\n"; } sub picdem_version { my ($handle) = @_; my $data = do_cmd($handle, READ_VERSION); return ($data->[3], $data->[2]); } sub picdem_reset { my ($handle) = @_; do_cmd($handle, RESET); } sub picdem_update_led { my ($handle, $led, $status) = @_; my $data = do_cmd($handle, UPDATE_LED, $led, $status); } sub picdem_read_config { my ($handle) = @_; my $cfg1 = do_cmd($handle, READ_CONFIG, 14, 0x00, 0x00, 0x30); my $cfg2 = do_cmd($handle, READ_CONFIG, 2, 0xFE, 0xFF, 0x3F); $cfg1 = join ' ', map { sprintf "%02X", $_ } splice @$cfg1, 5; print "\n"; printf "300000: %s\n", $cfg1; printf "3000FE: %02X\n", $cfg2->[5]; printf "3000FF: %02X\n", $cfg2->[6]; print "\n"; } sub picdem_read_userid { my ($handle) = @_; my $uid = do_cmd($handle, READ_CONFIG, 8, 0x00, 0x00, 0x20); $uid = join ' ', map { sprintf "%02X", $_ } splice @$uid, 5; print "\n"; print "200000: $uid\n"; print "\n"; } sub picdem_read_eeprom { my ($handle) = @_; print "\n"; for (my $i = 0; $i < 0xFF; $i += 16) { my $mem = do_cmd($handle, READ_EEDATA, 16, 0x00, 0x00, $i); $mem = join ' ', map { sprintf "%02X", $_ } splice @$mem, 5; printf "0000%02X: $mem\n", $i; } print "\n"; } sub picdem_erase_eeprom { my ($handle) = @_; for (my $i = 0; $i < 0xFF; $i += 16) { do_cmd($handle, WRITE_EEDATA, 16, 0x00, 0x00, $i, (0xFF) x 16); } } sub mkpicaddr { my $addr = $_[0]; return ( ($addr & 0x0000FF), (($addr & 0x00FF00) >> 8), (($addr & 0xFF0000) >> 16), ); } sub picdem_read_flash { my ($handle) = @_; print "program:\n"; for (my $i = 0; $i < 0x007FFF; $i += 16) { my @addr = mkpicaddr($i); my $mem = do_cmd($handle, READ_FLASH, 16, @addr); $mem = join ' ', map { sprintf "%02X", $_ } splice @$mem, 5; printf "%02X%02X%02X: $mem\n", $addr[2], $addr[1], $addr[0]; } print "\n"; } # erases $count 64-byte blocks starting @ $addr sub picdem_erase_block { my ($handle, $addr, $count) = @_; do_cmd($handle, ERASE_FLASH, $count, mkpicaddr($addr)); } sub picdem_erase_flash { my ($handle) = @_; # optimized but not working.. (??) # picdem_erase_block($handle, 0x00000800, 0xE0); # picdem_erase_block($handle, 0x00004000, 0xFF); for (my $i = 0x800; $i < 0x7FFF; $i += 64) { picdem_erase_block($handle, $i, 1); } } sub picdem_compare_flash { my ($handle, $data) = @_; my $errors = 0; foreach my $addr (sort keys %{$data->{'addr'}}) { next unless $addr >= 0x800; my @addr = mkpicaddr($addr); my @data = unpack('C*', $data->{'addr'}{$addr}{'data'}); my $len = scalar @data; my $mem = do_cmd($handle, READ_FLASH, scalar @data, @addr); for (my $i = 0; $i < $len; $i++) { printf "mismatch #%d @ %08X: wanted %02X, read %02X\n", ++$errors, $addr + $i, $data[$i], $mem->[5 + $i] if $data[$i] != $mem->[5 + $i]; } } print "comparing succesful\n" unless $errors > 0; } sub picdem_write_flash { my ($handle, $data) = @_; my $i = 0; foreach my $addr (sort keys %{$data->{'addr'}}) { next unless $addr >= 0x800; my @addr = mkpicaddr($addr); my @data = unpack('C*', $data->{'addr'}{$addr}{'data'}); my $len = scalar @data; die "picdem_write_flash: max 16 bytes\n" if $len > 16; # check data is at 16 bytes boundary if ($addr & 0x0000000F) { my $block = $addr & 0xFFFFFFF0; #printf "fixing boundary: %08X %08X %d\n", $addr, $block, $len; @data = ((0xFF) x ($addr - $block), @data); $len = scalar @data; $addr = $block; } # picdem seems to only accept 16 bytes packets. We extend # the packet with 0xFF. It will not hurt. push(@data, (0xFF) x (16 - $len)) if $len < 16; #printf "programming %08X\n", $addr; do_cmd($handle, WRITE_FLASH, 16, mkpicaddr($addr), @data ); $i++; } print "programmed $i locations\n"; } sub picdem_fill { my ($handle) = @_; print "filling program memory with 0x55AA\n"; for (my $i = 0x800; $i < 0x7FFF; $i += 16) { do_cmd($handle, WRITE_FLASH, 16, mkpicaddr($i), ((0x55, 0xAA) x 8) ); } } sub load_inhx32 { my ($file) = @_; my $fh = new IO::File; $fh->open($file, '<:crlf') or die "Couldn't open $file: $!\n"; print "loading $file\n"; my $high = 0x0000; my %data = (); while (<$fh>) { next unless /^:([[:xdigit:]]{2})([[:xdigit:]]{4})([[:xdigit:]]{2})([[:xdigit:]]{0,}?)([[:xdigit:]]{2})$/; my ($count, $addr, $type, $data, $checksum) = ($1, $2, $3, $4, $5); last if $type == 0x01; # EOF # Extended linear address record if ($type == 0x04) { die "Wrong address in type 0x04, must be 0x000, found $addr\n" unless $addr eq '0000'; $high = (hex($data) << 16); next; } # Extended segment address record if ($type == 0x02) { die "Wrong address in type 0x02, must be 0x000, found $addr\n" unless $addr eq '0000'; $high = (hex($data) << 4); next; } # Data record if ($type == 0x00) { $addr = $high || hex($addr); # printf "$count %08X $type $data $checksum\n", $addr; $data{'addr'}{$addr}{'data'} = pack('H*', $data); $data{'addr'}{$addr}{'length'} = length($data{'addr'}{$addr}{'data'}); $data{'addr'}{$addr}{'checksum'} = pack('H', $checksum); next; } die "I'm not able to handle INHX32 record type $type\n"; } $fh->close; # print Data::Dumper->Dump([\%data]); return \%data; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [gnupic] PICDEM FS USB and Linux tools
From: Nicolas ####@####.#### Date: 22 Sep 2007 07:47:11 +0100 Message-Id: <92d8b98a0709212346s7a0b1347ob31786153baddcb3@mail.gmail.com> On 9/22/07, Xiaofan Chen ####@####.#### wrote: > I tried the released version 0.14.5 and it does not crash like the > SVN version but it still does not work. > > Message: > " > disconnect hardware > connect hardware > disconnect hardware > Connecting Picdem Bootloader on USB Port with device 18F4550... > USB Port: find if there is already an installed driver > USB Port: alternate setting is 0 > USB Port: USB bcdDevice: 0x0000 > USB Port: send: "\00\00\00\00\00" > USB Port: write to endpoint 0x01 (bulk - out) 5 chars: "\00\00\00\00\00" > USB Port: read from endpoint 0x81 (bulk - in) 4 chars > USB Port: received: "\00\00\00\01" > Bootloader version 1.0.0 detected > Set target self powered: true > Connected. > disconnect hardware > The selected programmer cannot read device memory." The message may not be clear enough but it just means that this bootloader cannot read the contents of the device memory... You may want to try writing instead. Regards, Nicolas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [gnupic] PICDEM FS USB and Linux tools
From: "Xiaofan Chen" ####@####.#### Date: 22 Sep 2007 10:22:17 +0100 Message-Id: <a276da400709220221x1210a22ay19742e6bb80363f4@mail.gmail.com> On 9/22/07, Nicolas ####@####.#### wrote: > On 9/22/07, Xiaofan Chen ####@####.#### wrote: > > I tried the released version 0.14.5 and it does not crash like the > > SVN version but it still does not work. > > > > Message: > > The selected programmer cannot read device memory." > > The message may not be clear enough but it just means that this > bootloader cannot read the contents of the device memory... You may > want to try writing instead. > Ok now I see what it means even though this is strange. The bootloader should be able to read the program memory. fsusb works fine with reading and writing. So I tried erasing and writing: both did not work. Debug message" disconnect hardware Connecting Picdem Bootloader on USB Port with device 18F4550... USB Port: find if there is already an installed driver USB Port: alternate setting is 0 USB Port: USB bcdDevice: 0x0000 USB Port: send: "\00\00\00\00\00" USB Port: write to endpoint 0x01 (bulk - out) 5 chars: "\00\00\00\00\00" USB Port: read from endpoint 0x81 (bulk - in) 4 chars USB Port: received: "\00\00\00\01" Bootloader version 1.0.0 detected Set target self powered: true Connected. Erasing... USB Port: send: "\01\00\00\30\20" USB Port: write to endpoint 0x01 (bulk - out) 5 chars: "\01\00\00\30\20" USB Port: read from endpoint 0x81 (bulk - in) 37 chars USB Port: Error receiving data (ep=0x81 res=-110) (err=could not get bound driver: No data available). disconnect hardware The selected programmer cannot read device memory. connect hardware disconnect hardware Connecting Picdem Bootloader on USB Port with device 18F4550... USB Port: find if there is already an installed driver USB Port: alternate setting is 0 USB Port: USB bcdDevice: 0x0000 USB Port: send: "\00\00\00\00\00" USB Port: write to endpoint 0x01 (bulk - out) 5 chars: "\00\00\00\00\00" USB Port: read from endpoint 0x81 (bulk - in) 4 chars USB Port: received: "\00\00\00\01" Bootloader version 1.0.0 detected Set target self powered: true Connected. Programming device memory... USB Port: send: "\01\00\00\30\20" USB Port: write to endpoint 0x01 (bulk - out) 5 chars: "\01\00\00\30\20" USB Port: read from endpoint 0x81 (bulk - in) 37 chars USB Port: Error receiving data (ep=0x81 res=-110) (err=could not get bound driver: No data available). disconnect hardware fsusb works fine (I made some minor modifications so that I do not need to run it as root with some udev rules). ####@####.#### ./fsusb --program picdemfsusb.hex Locating USB Microchip(tm) PICDEM-FS USB(tm) (vendor 0x04d8/product 0x000b) Found USB PICDEM-FS USB as device '002' on USB bus 002 Communication established. Onboard firmware version is 1.0 Writing program memory successful Program memory validated ####@####.#### ./fsusb --read test4550.hex Locating USB Microchip(tm) PICDEM-FS USB(tm) (vendor 0x04d8/product 0x000b) Found USB PICDEM-FS USB as device '002' on USB bus 002 Communication established. Onboard firmware version is 1.0 Finished reading Regards, Xiaofan | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[<<] [<] Page 1 of 2 [>] [>>] |